Class Solid
Represents a solid geometry object with display, collision detection, and STL capabilities. Provides thread-safe access to geometry data and caching mechanisms.
public class Solid : IGetTriTree, ICollidable, IGetCollidable, IDisplayee, IExpandToBox3d, IStlSource, IGetStl, IDisposable, IMakeXmlSource, IGetSolid, IUpdateByContent, IClearCache
- Inheritance
-
Solid
- Implements
- Inherited Members
- Extension Methods
Constructors
Solid()
Initializes a new instance of the Solid class.
public Solid()
Solid(IGetStl)
Initializes a new instance of the Solid class with the specified STL geometry source.
public Solid(IGetStl geom)
Parameters
geomIGetStlThe STL geometry source.
Solid(IGetStl, PolarResolution2d)
Initializes a new instance of the Solid class with the specified STL geometry source and the mesh resolution the solid is born with (see PolarResolution2d).
public Solid(IGetStl geom, PolarResolution2d polarResolution2d)
Parameters
geomIGetStlThe STL geometry source.
polarResolution2dPolarResolution2dMesh resolution snapshot; null lets the geometry apply its own default.
Solid(XElement, string, IProgress<IMessage>)
Initializes a new instance of the Solid class from XML.
public Solid(XElement src, string baseDirectory, IProgress<IMessage> progress)
Parameters
srcXElementThe XML source element.
baseDirectorystringThe base directory for resolving relative paths.
progressIProgress<IMessage>The progress reporter.
Fields
XName
Gets the XML element name for serialization.
public static string XName
Field Value
Properties
Geom
Gets or sets the STL geometry source. Setting this property will clear the cached data.
public IGetStl Geom { get; set; }
Property Value
NativeStl
Gets the native STL representation. The data is created from the STL representation when first accessed, and is null once this solid is disposed — a disposed solid never rebuilds.
public NativeStl NativeStl { get; }
Property Value
PolarResolution2d
The mesh resolution this solid's runtime products are generated with — part of the solid's identity, fixed at construction (a defensive copy, so later mutation of the caller's carrier cannot reach it). Null lets a parametric Geom apply its own default. To change the resolution, build a new Solid (and dispose the old one); there is no in-place mutation or invalidation protocol. Never serialized: resolution is runtime data, not authored content.
public PolarResolution2d PolarResolution2d { get; }
Property Value
Prepared
Gets or sets whether the solid geometry is prepared for use. Setting this to true will ensure all necessary data structures are initialized. Setting this to false will clear the cached data.
public bool Prepared { get; set; }
Property Value
Rgb
Optional authored display color (RGB, each channel 0~1). Null means not
authored: display sites fall back to a color seeded from the hosting
anchor's persisted Guid, and Display(Bind) pushes no color
of its own. Collision red from the ambient scene scope
(CollisionRedScope — stamped by the detecting equipment)
always wins over the authored color.
Serialized as the optional Rgb attribute of the
<Solid> element; legacy readers ignore attributes, so the
addition is backward and forward compatible.
public Vec3d Rgb { get; set; }
Property Value
SmoothTopoStl3d
Gets the native smooth topology STL representation. The data is created from the STL representation when first accessed, and is null once this solid is disposed — a disposed solid never rebuilds.
public NativeTopoStl3d SmoothTopoStl3d { get; }
Property Value
Stl
Gets the STL representation of the solid geometry.
The STL data is cached after first access, and null once this solid is
disposed. Note this is normally the geometry model's own instance, not a
private copy: a StlFile source hands back the very
CacheStl it holds for its lifetime, so dropping this field frees
nothing for file-backed geometry. Do not mutate the returned mesh.
public Stl Stl { get; }
Property Value
TriTree
Gets the triangle tree representation for collision detection. The tree is built from the native STL data when first accessed, and is null once this solid is disposed — a disposed solid never rebuilds, and CollisionUtil reads a null collidee as “no collision” rather than raising, so a disposed solid silently stops participating in detection.
public TriTree TriTree { get; }
Property Value
Methods
ClearCache()
Manually clears the cached data if the content of Geom has changed. The cache determines the behavior of the Solid.
public void ClearCache()
Display(Bind)
Display function called in DispEngine rendering loop.
public void Display(Bind bind)
Parameters
bindBindBind with DispEngine. See Bind.
Display(Bind, RenderingModeEnum)
Displays the solid according to the specified rendering mode.
public void Display(Bind bind, Solid.RenderingModeEnum renderingMode)
Parameters
bindBindDisplay binding context.
renderingModeSolid.RenderingModeEnumRendering mode.
DisplayFeatureEdges(Bind)
Displays the feature edges of the solid.
public void DisplayFeatureEdges(Bind bind)
Parameters
bindBindDisplay binding context.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
Releases the unmanaged resources and optionally releases the managed resources.
protected virtual void Dispose(bool disposing)
Parameters
disposingbooltrue to release both managed and unmanaged resources; false to release only unmanaged resources.
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
GetCollidable()
Get ICollidable.
public ICollidable GetCollidable()
Returns
- ICollidable
The collidable object.
GetCollidee()
Get ICollidee.
public ICollidee GetCollidee()
Returns
GetSolid()
Gets the solid geometry object.
public Solid GetSolid()
Returns
- Solid
The solid geometry object.
GetSourceGeom()
Gets the source geometry object.
public IGetStl GetSourceGeom()
Returns
- IGetStl
The source geometry object.
GetStl()
Gets the STL geometry data.
public Stl GetStl()
Returns
- Stl
The STL geometry object
GetTriTree()
Get TriTree.
public TriTree GetTriTree()
Returns
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
baseDirectorystringThe base directory for resolving relative paths
relFilestringThe relative file path for the XML source
exhibitionOnlyboolif 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
and chains Reg(factory) on dependents. Idempotent.
public static void Reg(XFactory factory = null)
Parameters
factoryXFactory
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
UpdateByContent()
Updates the object based on its current content.
public void UpdateByContent()