XCAF Module
Assembly hierarchy and shape attributes.
LightOcct::LDocument
XCAF document wrapper for hierarchical CAD assembly management.
provides a Light OCCT interface to OpenCASCADE's XCAF (Extended CAF) framework for managing complex hierarchical assemblies with attributes like colors, layers, and custom metadata. Uses the enum + Handle pattern for type-safe storage. LDocument Key features: Assembly hierarchy traversal with depth tags Shape attribute management (colors, layers, metadata) Cross-language POD structures for data exchange Integration with Light OCCT topology classes Architecture: Internally uses Handle(TDocStd_Document) with XCAF tools POD structures for cross-language compatibility Assembly tree represented as flat list with depth tags No OCCT types exposed in public interface
#include <light-occt/xcaf/LDocument.hxx>Quick Reference
Fields: myType
Factory Methods: CreateXcafDocument()
Methods: LDocument(), ~LDocument(), LDocument(), operator=(), GetType(), IsValid(), IsXcaf(), GetAssemblyHierarchy(), GetRootAssemblyEntries(), GetAssemblyNode(), GetChildAssemblyEntries(), GetAssemblyShapeEntries(), AddRootShape(), AddChildShape(), GetShapeByEntry(), GetOneShape(), UpdateShape(), SetShapeAttributes(), GetShapeAttributes(), SetShapeColor(), GetShapeColor(), SetShapeLayer(), SetShapeVisibility(), SetShapeName(), AddShapeMetadata(), GetShapeMetadata(), GetAllLayers(), GetAllUsedColors(), CreateLayer(), CreateAssemblyInstance(), GetComponentInstances(), Clear(), ValidateDocument()
Enums: DocumentType
Types: TypeEnum
Fields
myType
DocumentType myType;Methods
Factory Methods
CreateXcafDocument
Create new empty XCAF document.
static LDocument CreateXcafDocument();Initialized XCAF document ready for use.
Instance Methods
LDocument
Default constructor - creates empty document.
LDocument() const;~LDocument
Destructor.
~LDocument() const;LDocument
Copy constructor.
LDocument(const & LDocument other) const;operator=
Assignment operator.
& LDocument operator=(const & LDocument other) const;GetType
Get document type.
DocumentType GetType() const;Document type enumeration value.
IsValid
Check if document is valid and ready for operations.
bool IsValid() const;True if document is properly initialized.
IsXcaf
Check if document is XCAF type.
bool IsXcaf() const;True if document type is DOCUMENT_XCAF.
GetAssemblyHierarchy
Get complete assembly hierarchy organized by nodes and levels.
AssemblyHierarchyData GetAssemblyHierarchy() const;Assembly hierarchy data with nodes organized by assembly tags.
GetRootAssemblyEntries
Get all root-level assembly entries (assembly tag 0).
std::vector< std::string > GetRootAssemblyEntries() const;of root assembly entry strings. Vector
GetAssemblyNode
Get assembly node data by XCAF entry string.
AssemblyNodeData GetAssemblyNode(const std::string & entry) const;entry XCAF label entry string (e.g., "0:1:2:1"). Assembly node data for the specified entry.
Parameters:
entry- XCAF label entry string (e.
GetChildAssemblyEntries
Get child assembly entries of a specific assembly node.
std::vector< std::string > GetChildAssemblyEntries(const std::string & parentEntry) const;parentEntry XCAF entry string of parent assembly. of child assembly entry strings. Vector
Parameters:
parentEntry- XCAF entry string of parent assembly.
GetAssemblyShapeEntries
Get all shape entries for a specific assembly node.
std::vector< std::string > GetAssemblyShapeEntries(const std::string & assemblyEntry) const;assemblyEntry XCAF entry string of assembly node. of shape entry strings belonging to this assembly. Vector
Parameters:
assemblyEntry- XCAF entry string of assembly node.
AddRootShape
Add new root shape to the assembly.
std::string AddRootShape(const & LShape shape, const & AssemblyNodeData assemblyData, const & ShapeAttributeData attributeData) const;shape Light OCCT shape to add (transformations handled by shape). assemblyData Assembly node data for hierarchy organization. attributeData Shape attribute data (colors, layers, metadata). Entry string of the newly created root node.
Parameters:
shape- Light OCCT shape to add (transformations handled by shape).assemblyData- Assembly node data for hierarchy organization.attributeData- Shape attribute data (colors, layers, metadata).
AddChildShape
Add child shape to an existing assembly node.
std::string AddChildShape(const std::string & parentEntry, const & LShape shape, const & AssemblyNodeData assemblyData, const & ShapeAttributeData attributeData) const;parentEntry Entry string of parent assembly. shape Light OCCT shape to add (transformations handled by shape). assemblyData Assembly node data for hierarchy organization. attributeData Shape attribute data (colors, layers, metadata). Entry string of the newly created child node.
Parameters:
parentEntry- Entry string of parent assembly.shape- Light OCCT shape to add (transformations handled by shape).assemblyData- Assembly node data for hierarchy organization.attributeData- Shape attribute data (colors, layers, metadata).
GetShapeByEntry
Get Light OCCT shape by XCAF entry string.
LShape GetShapeByEntry(const std::string & entry) const;entry XCAF label entry string. Light OCCT shape associated with the entry.
Parameters:
entry- XCAF label entry string.
GetOneShape
Get a single shape representing the entire document.
LShape GetOneShape() const;This method returns a compound containing all root shapes in the document, or a single root shape if there's only one, or an empty shape if the document is empty. This is useful for operations that need to work with the entire document content as a single shape (e.g., meshing, bounding box calculation). containing: LShape Compound of all root shapes if multiple roots exist Single root shape if only one root exists Empty/invalid shape if document has no shapes
UpdateShape
Update shape associated with an entry.
bool UpdateShape(const std::string & entry, const & LShape shape) const;entry XCAF label entry string. shape New Light OCCT shape to associate. True if update was successful.
Parameters:
entry- XCAF label entry string.shape- New Light OCCT shape to associate.
SetShapeAttributes
Set complete shape attributes for a shape.
bool SetShapeAttributes(const std::string & entry, const & ShapeAttributeData attributeData) const;entry XCAF label entry string. attributeData Complete shape attribute data. True if attributes were set successfully.
Parameters:
entry- XCAF label entry string.attributeData- Complete shape attribute data.
GetShapeAttributes
Get complete shape attributes for a shape.
ShapeAttributeData GetShapeAttributes(const std::string & entry) const;entry XCAF label entry string. Shape attribute data with all attributes.
Parameters:
entry- XCAF label entry string.
SetShapeColor
Set color attribute for a shape.
bool SetShapeColor(const std::string & entry, const & ColorData color) const;entry XCAF label entry string. color data with RGBA components. Color True if color was set successfully.
Parameters:
entry- XCAF label entry string.color- data with RGBA components.
GetShapeColor
Get color attribute of a shape.
ColorData GetShapeColor(const std::string & entry) const;entry XCAF label entry string. data, check HasColor in returned . Color ShapeAttributeData
Parameters:
entry- XCAF label entry string.
SetShapeLayer
Set layer assignment for a shape.
bool SetShapeLayer(const std::string & entry, const std::string & layerName) const;entry XCAF label entry string. layerName Name of the layer. True if layer was set successfully.
Parameters:
entry- XCAF label entry string.layerName- Name of the layer.
SetShapeVisibility
Set visibility flag for a shape.
bool SetShapeVisibility(const std::string & entry, bool visible) const;entry XCAF label entry string. visible Visibility flag. True if visibility was set successfully.
Parameters:
entry- XCAF label entry string.visible- Visibility flag.
SetShapeName
Set name/label for a shape.
bool SetShapeName(const std::string & entry, const std::string & name) const;entry XCAF label entry string. name Shape name. True if name was set successfully.
Parameters:
entry- XCAF label entry string.name- Shape name.
AddShapeMetadata
Add metadata entry to a shape node.
bool AddShapeMetadata(const std::string & entry, const & MetadataEntry metadata) const;entry XCAF label entry string. metadata Metadata entry with key-value pair. True if metadata was added successfully.
Parameters:
entry- XCAF label entry string.metadata- Metadata entry with key-value pair.
GetShapeMetadata
Get all metadata for a shape node.
std::vector< > MetadataEntry GetShapeMetadata(const std::string & entry) const;entry XCAF label entry string. of metadata entries. Vector
Parameters:
entry- XCAF label entry string.
GetAllLayers
Get all layer names used in the document.
std::vector< std::string > GetAllLayers() const;of layer names. Vector
GetAllUsedColors
Get all colors used in the document.
std::vector< > ColorData GetAllUsedColors() const;of unique colors found in all shapes. Vector
CreateLayer
Create new layer in the document.
bool CreateLayer(const std::string & layerName) const;layerName Name of the new layer. True if layer was created successfully.
Parameters:
layerName- Name of the new layer.
CreateAssemblyInstance
Create assembly instance (shape transformation handled by ). LShape
std::string CreateAssemblyInstance(const std::string & componentEntry, const std::string & parentEntry, const & AssemblyNodeData assemblyData, const & ShapeAttributeData attributeData) const;componentEntry Entry of component to instantiate. parentEntry Entry of parent assembly. assemblyData Assembly node data for the instance. attributeData Shape attribute data for the instance. Entry string of the new assembly instance.
Parameters:
componentEntry- Entry of component to instantiate.parentEntry- Entry of parent assembly.assemblyData- Assembly node data for the instance.attributeData- Shape attribute data for the instance.
GetComponentInstances
Get all instances that reference a specific component.
std::vector< std::string > GetComponentInstances(const std::string & componentEntry) const;componentEntry Entry of the component. of instance entry strings that reference this component. Vector
Parameters:
componentEntry- Entry of the component.
Clear
Clear all data from the document.
void Clear() const;ValidateDocument
Validate document structure and consistency.
bool ValidateDocument() const;True if document structure is valid.
Enumerations
DocumentType
Document type enumeration for type-safe storage.
enum DocumentType {
DOCUMENT_XCAF, // XCAF document with assembly support.
DOCUMENT_UNDEFINED, // Invalid/uninitialized document.
};Type Definitions
TypeEnum
DocumentType TypeEnum;