Class Stl
STL (stereolithography). Composed by Triangles. Provide Stl File R/W.
public class Stl : IGetStl, IExpandToBox3d
- Inheritance
-
Stl
- Implements
- Inherited Members
- Extension Methods
Constructors
Stl(Box3d)
Ctor by box.
public Stl(Box3d box)
Parameters
boxBox3dbox
Stl(Stl)
Copy ctor.
public Stl(Stl stl)
Parameters
stlStlsrc stl
Stl(params Stl[])
Ctor. Copy triangles from stls.
public Stl(params Stl[] stls)
Parameters
stlsStl[]source stls
Stl(IEnumerable<Tri3d>)
Ctor.
The content of tris is copied by this.tris = new List(tris).
public Stl(IEnumerable<Tri3d> tris)
Parameters
trisIEnumerable<Tri3d>triangles
Stl(Stream, StlType)
Ctor by stream.
public Stl(Stream stream, Stl.StlType stlType = StlType.UNKNOWN)
Parameters
Stl(Stream, StlType, CancellationToken)
Ctor by stream with cooperative cancellation. The reading loops observe
cancel periodically.
public Stl(Stream stream, Stl.StlType stlType, CancellationToken cancel)
Parameters
streamStreamstl data stream
stlTypeStl.StlTypestl data format
cancelCancellationTokenToken to cancel the read; cancelling throws OperationCanceledException and leaves this instance unusable.
Stl(int)
Ctor with preserved triangle grid capacity.
public Stl(int cap = 16)
Parameters
capintPreserved triangle grid capacity
Stl(string, StlType)
ctor by file.
public Stl(string file, Stl.StlType stlType = StlType.UNKNOWN)
Parameters
Stl(string, StlType, CancellationToken)
Ctor by file with cooperative cancellation. The reading loops observe
cancel periodically, so aborting a large file load
(hundreds of MB) takes effect promptly instead of running to completion.
public Stl(string file, Stl.StlType stlType, CancellationToken cancel)
Parameters
filestringstl file
stlTypeStl.StlTypestl file format
cancelCancellationTokenToken to cancel the read; cancelling throws OperationCanceledException and leaves this instance unusable.
Fields
DegenerateCrossTolerance
Cross-product length below which a triangle counts as degenerate for RemoveDegenerateTris(double) (1e-12 mm², i.e. two edges collinear or a vertex pair coincident to ~1e-6 mm).
public const double DegenerateCrossTolerance = 1E-12
Field Value
Properties
Area
Gets the total surface area of the STL model
public double Area { get; }
Property Value
Tris
public List<Tri3d> Tris { get; set; }
Property Value
Methods
ExpandToBox3d(Box3d)
Expands the destination box. This function is usually used to compute the bounding box of elements.
public void ExpandToBox3d(Box3d dst)
Parameters
dstBox3dDestination box
GetStl()
Gets the STL geometry data.
public Stl GetStl()
Returns
- Stl
The STL geometry object
IsAscii(Stream)
Is the stream ascii format stl.
public static bool IsAscii(Stream stream)
Parameters
streamStreamstream
Returns
- bool
true if the stream is ascii format stl; otherwise, return false.
IsAscii(string)
Is the file ascii format stl.
public static bool IsAscii(string file)
Parameters
filestringfile
Returns
- bool
true if the file is ascii format stl; otherwise, return false.
ReBuildNormal()
Re-build normal for all triangles.
public void ReBuildNormal()
RemoveDegenerateTris(double)
Drops triangles whose cross product is (numerically) the zero vector. A mesh consumer that orients triangles exactly — the native sweep — aborts on such a triangle, and it contributes no surface anyway.
public int RemoveDegenerateTris(double crossTolerance = 1E-12)
Parameters
crossTolerancedouble
Returns
- int
The number of triangles removed.
Transform(Mat4d)
Trasnform all the triangles by the given matrix.
public Stl Transform(Mat4d mat)
Parameters
matMat4dmatrix
Returns
- Stl
this
WriteBin(BinaryWriter)
Write this to the writer with binary format.
public void WriteBin(BinaryWriter writer)
Parameters
writerBinaryWriterwriter
WriteBin(string)
Write this to the file with binary format.
public void WriteBin(string file)
Parameters
filestringdst file