Table of Contents

Class CubeTree

Namespace
HiCbtr.Cbtr
Assembly
HiCbtr.dll

Cube-based data structure. CubeTree has high performance for free-form geometry manipulation include volume removal and addition.

public class CubeTree : IDisposable, IDisplayee, ICollidee, ICollidable, IExpandToBox3d, IGetCollidable
Inheritance
CubeTree
Implements
Inherited Members
Extension Methods

Remarks

DispCacheMb and TrisCacheMb are initialized by the configuration file using Config. The initailize xpaths are /CubeTree/DispCacheMb and /CubeTree/TrisCacheMb from the root element.

Constructors

CubeTree(NativeStl, double, CancellationToken, IProgress<IProgressReport>)

public CubeTree(NativeStl stl, double preferredGridWidth, CancellationToken token, IProgress<IProgressReport> progress)

Parameters

stl NativeStl

Triangle Grid. The triangles must be manifold geometry.

preferredGridWidth double

The expected resolution.

token CancellationToken
progress IProgress<IProgressReport>

Remarks

The applied resolution is equal or smaller than the expected resolution. The applied resolution is c*(2^i). Where c is a constant; i is a integer to make the closest value of the formula. 與輸入幾何的誤差分布在菱角及曲面處。

CubeTree(Stl, double, CancellationToken, IProgress<IProgressReport>)

可使用Stl或NativeStl物件初始化,使用NativeStl的速度較快。輸入的三角網格必須是流形幾何(manifold geometry),即三角形的頂點對齊其他三角形的頂點,且為封閉幾何。

public CubeTree(Stl stl, double expectedResolution, CancellationToken token, IProgress<IProgressReport> progress)

Parameters

stl Stl
expectedResolution double

設定裕度,實際裕度會小於等於設定裕度,大約以2的指數作為級距。 與輸入幾何的誤差分布在菱角及曲面處。

token CancellationToken
progress IProgress<IProgressReport>

CubeTree(string)

public CubeTree(string file)

Parameters

file string

Fields

defaultPreferredGridWidth

The default grid_width for the constructor.

public const double defaultPreferredGridWidth = 0.0625

Field Value

double

Properties

CollisionFlag

public CollisionFlag CollisionFlag { get; set; }

Property Value

CollisionFlag

CubetreePtr

Private element.

public nint CubetreePtr { get; }

Property Value

nint

DispCacheMb

Display cache size in Mb. The cahce cost from graphic card and RAM.

public static long DispCacheMb { get; set; }

Property Value

long

Resolution

Get initialized resolution.

public double Resolution { get; }

Property Value

double

TotalCacheMb

Cache size used by CubeTree. Sum of TrisCacheMb and DispCacheMb. TotalCacheMb Setter distributes (2/5 of the setting value) for DispCacheMb.

public static long TotalCacheMb { get; set; }

Property Value

long

TrisCacheMb

Triangles cache size in Mb. The cache costs from RAM.

public static long TrisCacheMb { get; set; }

Property Value

long

Methods

CleanCache()

Call HiCbtr.Cbtr.CubeTree.CleanTrisCache() and HiCbtr.Cbtr.CubeTree.CleanDispCache_().

public static void CleanCache()

CleanDispCachee()

Clean display cache of this.

public void CleanDispCachee()

Diff(NativeStl, double, RangeColorRule, IProgress<IProgressReport>)

public ConcurrentBag<DiffAttachment> Diff(NativeStl idealGeom, double diffRadius, RangeColorRule diffRangeColorRule, IProgress<IProgressReport> progress = null)

Parameters

idealGeom NativeStl
diffRadius double
diffRangeColorRule RangeColorRule
progress IProgress<IProgressReport>

Returns

ConcurrentBag<DiffAttachment>

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)

Expand the destinate box. This function is ususally used to compute the bounding box of elements.

public void ExpandToBox3d(Box3d dst)

Parameters

dst Box3d

destinate box

~CubeTree()

dtor

protected ~CubeTree()

GetCollidable()

public ICollidable GetCollidable()

Returns

ICollidable

GetCollidee()

Get ICollidee.

public ICollidee GetCollidee()

Returns

ICollidee

ICollidee

GetRgbTrisNativeArray(double)

Get triangles in type of double array. The returned triangles is non-manifold. It may not be closed model and the apexes of triangle grid may not be overlapped.

public double[] GetRgbTrisNativeArray(double resolution = 0)

Parameters

resolution double

The preferred resolution. The real resolution may be smaller or equal the prefered resolution. The real resolution is discrete. The resolution value is at 2^i. The geometric error mainly locate at corner.

Returns

double[]

rgb traingle grid. In sequence of r,g,b,n.x,n.y,n.z,p0.x,p0.y,p0.z,p1.x,p1.y,p1.z,p2.x,p2.y,p2.z, repetitively. A triangle take 15 double.

GetTris(double)

Get triangles. The returned triangles is non-manifold. It may not be closed model and the apexes of triangle grid may not be overlapped.

public List<Tri3d> GetTris(double resolution = 0)

Parameters

resolution double

設定裕度,實際裕度會小於等於設定裕度,大約以2的指數作為級距。與輸入幾何的誤差分布在菱角及曲面處。裕度越大,三角網格數量越少,運算也較迅速。

Returns

List<Tri3d>

三角網格

RebuildAttach(CbtrPickable)

Every node in CubeTree can contain one CbtrPickable object. This function put or replace the contained data of all nodes to src. 使用UpdateAttach(CbtrPickable)會將尚未儲存資料(CbtrPickable為null)的節點放入src。

public void RebuildAttach(CbtrPickable src)

Parameters

src CbtrPickable

RemoveFlyPiece()

public void RemoveFlyPiece()

Substract(CachedTris, double, bool, bool)

使用BufferedTris效率比NativeStl好。 若差集區域的裕度與本體的裕度不同,則該部位採用較低的裕度。

public UnmanagedSubstraction Substract(CachedTris cutterBufferedTris, double preferredCubeWidth, bool isBuildContactContours = false, bool isAggressiveCut = false)

Parameters

cutterBufferedTris CachedTris

差集幾何

preferredCubeWidth double
isBuildContactContours bool

為真,則回傳的Substraction中含有差集幾何與工件幾何相交處的圍線群,該圍線群可做後續分析使用。

isAggressiveCut bool

Returns

UnmanagedSubstraction

Substract(GeomBoolCache, bool, bool)

public UnmanagedSubstraction Substract(GeomBoolCache geomBoolCache, bool isBuildContactContours = false, bool isAggressiveCut = false)

Parameters

geomBoolCache GeomBoolCache
isBuildContactContours bool
isAggressiveCut bool

Returns

UnmanagedSubstraction

Substract(InitStickConvex, Mat4d, double, bool, bool)

public UnmanagedSubstraction Substract(InitStickConvex initStickConvex, Mat4d mat, double preferredCubeWidth, bool isBuildContactContours = false, bool isAggressiveCut = false)

Parameters

initStickConvex InitStickConvex
mat Mat4d
preferredCubeWidth double
isBuildContactContours bool
isAggressiveCut bool

Returns

UnmanagedSubstraction

Substract(NativeStl, double, bool, bool)

與Substract(BufferedTris,...)同功能。效率較差,多了一個轉換CachedTris的步驟。

public UnmanagedSubstraction Substract(NativeStl cutterStl, double preferredCubeWidth = 0, bool isBuildContactContours = false, bool isAggressiveCut = false)

Parameters

cutterStl NativeStl
preferredCubeWidth double
isBuildContactContours bool
isAggressiveCut bool

Returns

UnmanagedSubstraction

UpdateAttach(CbtrPickable)

Every node in CubeTree can contain one CbtrPickable object. This function put src to the nodes that contain null.

public void UpdateAttach(CbtrPickable src)

Parameters

src CbtrPickable

WriteFile(string)

public void WriteFile(string file)

Parameters

file string