Table of Contents

Class GeomCombination

Namespace
Hi.Geom
Assembly
HiGeom.dll

A class that manages multiple STL sources as a single source. As one source its mesh is every item's triangles concatenated (GenStl(IPolarResolution2d)), which is not a closed mesh where items overlap; as IGenStlBodies it hands its items out one closed body at a time, for a consumer that unites bodies instead of meshing them together (the workpiece's stock build).

public class GeomCombination : IStlSource, IGetStl, IMakeXmlSource, IGenStl, IGenStlBodies, IExpandToBox3d, IDuplicate, IReleaseStlCache
Inheritance
GeomCombination
Implements
Inherited Members
Extension Methods

Constructors

GeomCombination()

Default constructor that initializes an empty collection of STL sources.

public GeomCombination()

GeomCombination(params IStlSource[])

Initializes a new instance with a set of STL sources.

public GeomCombination(params IStlSource[] stlSources)

Parameters

stlSources IStlSource[]

A set of STL sources

GeomCombination(XElement, string, string, IProgress<IMessage>)

Ctor.

public GeomCombination(XElement src, string baseDirectory, string relFile, IProgress<IMessage> progress)

Parameters

src XElement

XML

baseDirectory string

Base directory path

relFile string

Relative file path

progress IProgress<IMessage>

Optional progress reporter for the XML parsing chain

Properties

StlSources

Collection of STL sources managed by this instance.

public List<IStlSource> StlSources { get; }

Property Value

List<IStlSource>

XName

Name for XML IO.

public static string XName { get; }

Property Value

string

Methods

CleanStlCache()

Clears the cached STL data, forcing it to be regenerated on the next request.

public void CleanStlCache()

Duplicate(params object[])

Creates a deep copy of the object, excluding any source file references.

public object Duplicate(params object[] res)

Parameters

res object[]

Optional parameters that may be needed during the duplication process

Returns

object

A new instance that is a deep copy of the original object

ExpandToBox3d(ref box3d_t)

Expands the given box by the sources' own boxes.

public void ExpandToBox3d(ref box3d_t dst)

Parameters

dst box3d_t

The box to expand.

Remarks

A rough, quick operation: bounds queries never generate a mesh, so a source without IExpandToBox3d support contributes nothing.

GenStl(IPolarResolution2d)

Generates a new STL.

public Stl GenStl(IPolarResolution2d resolution)

Parameters

resolution IPolarResolution2d

Polar resolution

Returns

Stl

A newly created STL.

GenStlBodies(IPolarResolution2d)

The closed bodies this geometry stands for, in the order the geometry lists them, each with a fresh or cached mesh at resolution (null: every source's own default resolution, as GetStl() answers). An item without a mesh contributes nothing. Not cached here: the leaves cache their own meshes.

public IEnumerable<StlBody> GenStlBodies(IPolarResolution2d resolution)

Parameters

resolution IPolarResolution2d

Polar resolution for the meshes that are generated; null for the defaults.

Returns

IEnumerable<StlBody>

The bodies; empty for a geometry without any.

Remarks

The items in list order: an item that is itself IGenStlBodies (a nested combination, a transformed combination) contributes its own bodies, so the bodies answered are always leaves; any other item is one body, its mesh from GenStl(IPolarResolution2d) at resolution or from GetStl(). A null item, or an item without a mesh (a file not found), contributes nothing. Nothing is cached here and GenStl(IPolarResolution2d)'s cache is not read: the items cache their own meshes.

GetStl()

Gets the combined STL mesh with each source at its own default resolution. Resolution-aware callers pass their value through GenStl(IPolarResolution2d) instead.

public Stl GetStl()

Returns

Stl

The combined STL mesh.

MakeXmlSource(string, string, bool)

Creates an XML representation of the object. This method may also generate additional resources such as related files.

public XElement MakeXmlSource(string baseDirectory, string relFile, bool exhibitionOnly)

Parameters

baseDirectory string

The base directory for resolving relative paths

relFile string

The relative file path for the XML source

exhibitionOnly bool

if true, the extended file creation is suppressed.

Returns

XElement

An XML element representing the object's state

Remarks

For the demand of easy moving source folder (especially project folder) without configuration file path corruption, the relative file path is applied. The baseDirectory is typically the folder at the nearest configuration file folder. Since the folder can be moving with the configuration file.

Reg(XFactory)

Registers this type's deserializer with the given XFactory (or Default when factory is null). Idempotent.

public static void Reg(XFactory factory = null)

Parameters

factory XFactory

ReleaseStlCache()

Lets go of the kept mesh when GetStl() produces it again.

public bool ReleaseStlCache()

Returns

bool

True when the kept mesh is gone (or already was) and GetStl() produces it again; false when the mesh has to stay as the only copy there is (a mesh handed in by hand, a file since deleted or overwritten), or when there is nothing to produce.

Remarks

Forwards to every source. When any source let its mesh go, the combined mesh cached here goes too (GenStl(IPolarResolution2d) builds it again from the sources); when none did, the combined mesh stays and the answer is false.