Class CarveStl
A triangle mesh that can be carved: an exact-fraction topology graph with an incrementally maintained spatial index, mutated in place by exact boolean steps (SubstractVolume(Stl, double) / AddVolume(Stl, double)). Unlike NativeTopoStl3wfr (build-once sweeping input), this object is long-lived and accumulates cut geometry step after step; sharp edges and exact planar faces survive the booleans exactly. Not thread-safe.
public class CarveStl : IDisposable, IDisplayee, IExpandToBox3d
- Inheritance
-
CarveStl
- Implements
- Inherited Members
- Extension Methods
Remarks
Conversion loss, by source:
- NativeTopoStl3wfr and another CarveStl are already exact fractions, so those overloads copy coordinates verbatim and take no tolerance — the only lossless inbound paths.
- Stl and NativeTopoStl3d hold
doubles, which have no small-denominator exact form, so those overloads
convert at
fractionTolerance. The loss is inherent to the source type, not to the route: converting such a mesh by any other path costs the same. - Outbound, GenStl() evaluates to double, so a carved result round-tripped through it loses the compound coordinates the booleans produced. Keep the CarveStl itself, or pass it directly as a tool, when the exact surface is the deliverable.
Constructors
CarveStl(Stl, double)
Initializes the container from an STL model. The triangles are
converted to exact fractions at fractionTolerance.
public CarveStl(Stl stl, double fractionTolerance)
Parameters
stlStlThe initial workpiece mesh (a closed shell).
fractionTolerancedoubleThe tolerance for fraction conversion.
CarveStl(CarveStl)
Initializes the container as an exact copy of another CarveStl — a snapshot that later boolean steps on either object leave untouched. Lossless.
public CarveStl(CarveStl src)
Parameters
srcCarveStlThe container to copy.
CarveStl(NativeTopoStl3d, double)
Initializes the container from a double-precision topology graph. The
triangles are converted to exact fractions at
fractionTolerance — the source holds doubles, so
this is inherently the lossy path.
public CarveStl(NativeTopoStl3d src, double fractionTolerance)
Parameters
srcNativeTopoStl3dThe source mesh (a closed shell).
fractionTolerancedoubleThe tolerance for fraction conversion.
CarveStl(NativeTopoStl3wfr)
Initializes the container from an exact-fraction topology graph, copying every coordinate verbatim. Lossless, hence no tolerance: the source is already the same numeric type. The source is only read.
public CarveStl(NativeTopoStl3wfr src)
Parameters
srcNativeTopoStl3wfrThe source mesh (a closed shell).
Properties
CarvePtr
Gets the pointer to the native container.
public nint CarvePtr { get; }
Property Value
IsSeamless
Gets whether every directed edge is paired with an owned reverse (the manifold invariant the booleans maintain).
public bool IsSeamless { get; }
Property Value
Size
Gets the number of triangles currently in the container.
public int Size { get; }
Property Value
Methods
AddVolume(Stl, double)
Exact in-place union: merges the tool volume into the container. Same calling contract as SubstractVolume(Stl, double).
public CarveBooleanResult AddVolume(Stl tool, double fractionTolerance)
Parameters
toolStlThe tool mesh (a closed shell).
fractionTolerancedoubleThe tolerance for the tool's fraction conversion.
Returns
- CarveBooleanResult
The step result; on failure the container is untouched.
AddVolume(CarveStl)
Exact in-place union with another container's current state.
Lossless; tool is only read.
public CarveBooleanResult AddVolume(CarveStl tool)
Parameters
toolCarveStlThe container whose volume is merged in.
Returns
- CarveBooleanResult
The step result; on failure this container is untouched.
AddVolume(NativeTopoStl3wfr)
Exact in-place union with an exact-fraction tool — the lossless tool
path, hence no tolerance. The tool mesh is copied natively before the
surgery consumes it, so tool survives the call.
public CarveBooleanResult AddVolume(NativeTopoStl3wfr tool)
Parameters
toolNativeTopoStl3wfrThe tool mesh (a closed shell).
Returns
- CarveBooleanResult
The step result; on failure the container is untouched.
Display(Bind)
Display function called in DispEngine rendering loop.
public void Display(Bind bind)
Parameters
bindBindBind with DispEngine. See Bind.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
protected virtual void Dispose(bool disposing)
Parameters
disposingbool
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
~CarveStl()
protected ~CarveStl()
GenStl()
Generates an STL model from the container's current state.
public Stl GenStl()
Returns
- Stl
A new STL model.
SubstractVolume(Stl, double)
Exact in-place difference: carves the tool volume out of the container. The tool triangles are consumed natively per call, so the same Stl may be reused for further steps.
public CarveBooleanResult SubstractVolume(Stl tool, double fractionTolerance)
Parameters
toolStlThe tool mesh (a closed shell).
fractionTolerancedoubleThe tolerance for the tool's fraction conversion.
Returns
- CarveBooleanResult
The step result; on failure the container is untouched.
SubstractVolume(CarveStl)
Exact in-place difference using another container's current state as
the tool. Lossless; tool is only read.
public CarveBooleanResult SubstractVolume(CarveStl tool)
Parameters
toolCarveStlThe container whose volume is carved away.
Returns
- CarveBooleanResult
The step result; on failure this container is untouched.
SubstractVolume(NativeTopoStl3wfr)
Exact in-place difference with an exact-fraction tool — the lossless
tool path, hence no tolerance. The tool mesh is copied natively before
the surgery consumes it, so tool survives the call
and may be reused for further steps.
public CarveBooleanResult SubstractVolume(NativeTopoStl3wfr tool)
Parameters
toolNativeTopoStl3wfrThe tool mesh (a closed shell).
Returns
- CarveBooleanResult
The step result; on failure the container is untouched.