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(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(box3d_t)
Ctor by box.
public Stl(box3d_t box)
Parameters
boxbox3d_tbox
Stl(IEnumerable<tri3d_t>)
Ctor.
The content of tris is copied by this.tris = new List(tris).
public Stl(IEnumerable<tri3d_t> tris)
Parameters
trisIEnumerable<tri3d_t>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_t> Tris { get; set; }
Property Value
Methods
ExpandToBox3d(ref box3d_t)
Expands the destination box.
This function is usually used to compute the bounding box of elements.
box3d_t is a value type, so the destination is passed by reference
(the C++ expand_to_box3d(box3&) shape); an implementation writes
dst = dst.Expanded(...) or forwards ref dst to its parts.
public void ExpandToBox3d(ref box3d_t dst)
Parameters
dstbox3d_tDestination box, expanded in place
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_t)
Trasnform all the triangles by the given matrix.
public Stl Transform(mat4d_t mat)
Parameters
matmat4d_tmatrix
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