Table of Contents

Class CarveStl

Namespace
Hi.Geom.Topo
Assembly
HiDisp.dll

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

stl Stl

The initial workpiece mesh (a closed shell).

fractionTolerance double

The 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

src CarveStl

The 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

src NativeTopoStl3d

The source mesh (a closed shell).

fractionTolerance double

The 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

src NativeTopoStl3wfr

The source mesh (a closed shell).

Properties

CarvePtr

Gets the pointer to the native container.

public nint CarvePtr { get; }

Property Value

nint

IsSeamless

Gets whether every directed edge is paired with an owned reverse (the manifold invariant the booleans maintain).

public bool IsSeamless { get; }

Property Value

bool

Size

Gets the number of triangles currently in the container.

public int Size { get; }

Property Value

int

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

tool Stl

The tool mesh (a closed shell).

fractionTolerance double

The 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

tool CarveStl

The 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

tool NativeTopoStl3wfr

The 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

bind Bind

Bind 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

disposing bool

ExpandToBox3d(Box3d)

Expands the destination box. This function is usually used to compute the bounding box of elements.

public void ExpandToBox3d(Box3d dst)

Parameters

dst Box3d

Destination 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

tool Stl

The tool mesh (a closed shell).

fractionTolerance double

The 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

tool CarveStl

The 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

tool NativeTopoStl3wfr

The tool mesh (a closed shell).

Returns

CarveBooleanResult

The step result; on failure the container is untouched.