OCCT3D About OCCT
Open CASCADE Technology Reference Manual 8.0.1
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions
BRepGraph_Layer Class Referenceabstract

Abstract base class for named attribute layers. More...

#include <BRepGraph_Layer.hxx>

Inheritance diagram for BRepGraph_Layer:
Inheritance graph
[legend]

Public Member Functions

virtual const Standard_GUIDID () const =0
 Layer type identity (unique within a graph).
 
virtual const TCollection_AsciiStringName () const =0
 Layer identity (unique within a graph).
 
virtual void OnNodeRemoved (const BRepGraph_NodeId theNode) noexcept
 Called when a node is soft-removed without a replacement.
 
void OnItemRemoved (const BRepGraph_ItemId theItem) noexcept
 Dispatch a generic item removal to the matching typed removal callback. This is a non-virtual convenience entry point; typed callbacks remain the extension points for derived layers.
 
virtual void OnNodeReplaced (const BRepGraph_NodeId theOldNode, const BRepGraph_NodeId theNewNode) noexcept
 Called when a node is soft-removed and replaced by another node.
 
virtual void CopyTo (const BRepGraph_CopyRemap &theCopy) const =0
 Copy this source layer data into another graph. The source graph is the graph this layer is attached to (Graph()).
 
virtual void InvalidateAll () noexcept=0
 Mark all cached values dirty (bulk invalidation).
 
virtual void Clear () noexcept=0
 Clear all stored data.
 
virtual int SubscribedKinds () const
 Return a bitmask of BRepGraph_NodeId::Kind values this layer subscribes to. Only modification events matching subscribed kinds are dispatched. Default: 0 (no subscription - no modification events received). Override to receive OnNodeModified/OnNodesModified callbacks. The returned value must be constant for the lifetime of the layer.
 
virtual void OnNodeModified (const BRepGraph_NodeId theNode) noexcept
 Called in immediate (non-deferred) mode after a single node is modified. Only dispatched if the node's kind matches SubscribedKinds(). Default: no-op.
 
void OnItemModified (const BRepGraph_ItemId theItem) noexcept
 Dispatch a generic item modification to the matching typed modification callback. This is a non-virtual convenience entry point; typed callbacks remain the extension points for derived layers.
 
virtual void OnNodesModified (const NCollection_Array1< BRepGraph_NodeId > &theModifiedNodes) noexcept
 Called after EndDeferredInvalidation() with all nodes modified during the deferred scope. Only dispatched if at least one modified node's kind matches SubscribedKinds(). The array may contain nodes of kinds not subscribed to - layers should filter internally if needed. Default: no-op.
 
virtual int SubscribedRefKinds () const
 Return a bitmask of BRepGraph_RefId::Kind values this layer subscribes to. Only modification events matching subscribed ref kinds are dispatched. Default: 0 (no subscription). Must be constant for the layer's lifetime.
 
virtual void OnRefRemoved (const BRepGraph_RefId theRef) noexcept
 Called when a reference is soft-deleted via RemoveRef(). No replacement concept - refs are simply removed (unlike nodes which can have a replacement during sewing or deduplication). Dispatched to all layers regardless of SubscribedRefKinds(). Default: no-op.
 
virtual void OnRefModified (const BRepGraph_RefId theRef) noexcept
 Called in immediate (non-deferred) mode after a single ref is mutated. Only dispatched if the ref's kind matches SubscribedRefKinds(). Default: no-op.
 
virtual void OnRefsModified (const NCollection_Array1< BRepGraph_RefId > &theModifiedRefs) noexcept
 Called after EndDeferredInvalidation() with all refs modified during the deferred scope. Only dispatched if at least one modified ref's kind matches SubscribedRefKinds(). The array may contain refs of kinds not subscribed to - layers should filter internally if needed. Default: no-op.
 
uint64_t Revision () const noexcept
 Monotonic revision counter incremented by touch() on every observable state change. Consumers compare stored revisions to detect staleness in O(1). Derived layers MUST call touch() from their mutators.
 
- Public Member Functions inherited from Standard_Transient
 Standard_Transient ()
 Empty constructor.
 
 Standard_Transient (const Standard_Transient &)
 Copy constructor – does nothing.
 
Standard_Transientoperator= (const Standard_Transient &)
 Assignment operator, needed to avoid copying reference counter.
 
virtual ~Standard_Transient ()=default
 Destructor must be virtual.
 
virtual const opencascade::handle< Standard_Type > & DynamicType () const
 Returns a type descriptor about this object.
 
bool IsInstance (const opencascade::handle< Standard_Type > &theType) const
 Returns a true value if this is an instance of Type.
 
bool IsInstance (const char *const theTypeName) const
 Returns a true value if this is an instance of TypeName.
 
bool IsKind (const opencascade::handle< Standard_Type > &theType) const
 Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism.
 
bool IsKind (const char *const theTypeName) const
 Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism.
 
Standard_TransientThis () const
 Returns non-const pointer to this object (like const_cast). For protection against creating handle to objects allocated in stack or call from constructor, it will raise exception Standard_ProgramError if reference counter is zero.
 
int GetRefCount () const noexcept
 Get the reference counter of this object.
 
void IncrementRefCounter () noexcept
 Increments the reference counter of this object. Uses relaxed memory ordering since incrementing only requires atomicity, not synchronization with other memory operations.
 
int DecrementRefCounter () noexcept
 Decrements the reference counter of this object; returns the decremented value. Uses release ordering for the decrement to ensure all writes to the object are visible before the count reaches zero. An acquire fence is added only when the count reaches zero, ensuring proper synchronization before deletion. This is more efficient than using acq_rel for every decrement.
 
virtual void Delete () const
 Memory deallocator for transient classes.
 

Static Public Member Functions

static int KindBit (const BRepGraph_NodeId::Kind theKind)
 Convenience: return bitmask bit for a given Kind.
 
static int RefKindBit (const BRepGraph_RefId::Kind theKind)
 Convenience: return bitmask bit for a given RefId::Kind.
 
- Static Public Member Functions inherited from Standard_Transient
static constexpr const charget_type_name ()
 Returns a type descriptor about this object.
 
static const opencascade::handle< Standard_Type > & get_type_descriptor ()
 Returns type descriptor of Standard_Transient class.
 

Protected Member Functions

 BRepGraph_Layer ()
 
void touch () noexcept
 Bump the revision counter.
 
bool IsAttached () const noexcept
 True while this layer is registered in a live graph registry.
 
const BRepGraphGraph () const
 Attached graph for read-only layer services. Raises Standard_ProgramError if detached.
 
BRepGraphAttachedGraph () const noexcept
 Attached mutable graph for graph-owned service layers. Returns null if detached.
 
virtual void OnAttached () noexcept
 Called after the layer is attached to a graph registry.
 
virtual void OnDetached () noexcept
 Called before the layer is detached from a graph registry.
 

Static Protected Member Functions

template<BRepGraph_NodeId::Kind TheKind>
static BRepGraph_NodeId::Typed< TheKindRemappedItem (const BRepGraph_CopyRemap &theCopy, const BRepGraph_NodeId::Typed< TheKind > theId)
 
template<BRepGraph_RefId::Kind TheKind>
static BRepGraph_RefId::Typed< TheKindRemappedItem (const BRepGraph_CopyRemap &theCopy, const BRepGraph_RefId::Typed< TheKind > theId)
 

Additional Inherited Members

- Public Types inherited from Standard_Transient
typedef void base_type
 Returns a type descriptor about this object.
 

Detailed Description

Abstract base class for named attribute layers.

A layer groups per-node and per-reference metadata under a unique name with lifecycle callbacks. Layers are registered on BRepGraph and automatically notified when nodes or references are removed, remapped (compact), or modified.

Derived layers store domain-specific data (names, colors, materials, etc.) in internal maps keyed by BRepGraph_NodeId or BRepGraph_RefId. The lifecycle callbacks ensure data consistency across all graph mutations.

Node Modification Events

Layers subscribe to node modification events by overriding SubscribedKinds() to return a non-zero bitmask of Kind values. When a subscribed node kind is modified, OnNodeModified() (immediate mode) or OnNodesModified() (deferred batch mode) is called. Layers with SubscribedKinds() == 0 (default) incur zero dispatch overhead.

Reference Modification Events

Layers subscribe to reference modification events by overriding SubscribedRefKinds() to return a non-zero bitmask of BRepGraph_RefId::Kind values. When a subscribed ref kind is mutated, OnRefModified() (immediate mode) or OnRefsModified() (deferred batch mode) is called. Removal is always dispatched via OnRefRemoved() regardless of subscription.

Thread safety

Callback dispatch is single-threaded (called from mutation paths). Layers that only provide read access can skip internal locking.

Warning
All lifecycle callbacks are declared noexcept. Derived implementations that throw will cause std::terminate. This is enforced by C++ language semantics for noexcept virtual overrides.

Constructor & Destructor Documentation

◆ BRepGraph_Layer()

BRepGraph_Layer::BRepGraph_Layer ( )
protected

Member Function Documentation

◆ AttachedGraph()

BRepGraph * BRepGraph_Layer::AttachedGraph ( ) const
inlineprotectednoexcept

Attached mutable graph for graph-owned service layers. Returns null if detached.

◆ Clear()

virtual void BRepGraph_Layer::Clear ( )
pure virtualnoexcept

◆ CopyTo()

virtual void BRepGraph_Layer::CopyTo ( const BRepGraph_CopyRemap & theCopy) const
pure virtual

Copy this source layer data into another graph. The source graph is the graph this layer is attached to (Graph()).

Parameters
[in]theCopysource graph, target graph, and source item id -> target item id remap
Note
Missing source items were not copied; persistent layers should skip dependent records.
For BRepGraph_CopyRemap::Mode::Compact, the layer is being migrated in-place after structural compaction. UID/ItemUID records and ref/rep entries should be remapped through the item map. Stale entries (absent from the remap) should be dropped.
Warning
This callback may allocate and is intentionally not noexcept.

Implemented in BRepGraph_LayerDeferred, BRepGraph_LayerHistory, BRepGraph_LayerLock, and BRepGraph_LayerTopoSupplement.

◆ Graph()

const BRepGraph & BRepGraph_Layer::Graph ( ) const
protected

Attached graph for read-only layer services. Raises Standard_ProgramError if detached.

◆ ID()

virtual const Standard_GUID & BRepGraph_Layer::ID ( ) const
pure virtual

Layer type identity (unique within a graph).

Implemented in BRepGraph_LayerDeferred, BRepGraph_LayerHistory, BRepGraph_LayerLock, and BRepGraph_LayerTopoSupplement.

◆ InvalidateAll()

virtual void BRepGraph_Layer::InvalidateAll ( )
pure virtualnoexcept

Mark all cached values dirty (bulk invalidation).

Implemented in BRepGraph_LayerDeferred, BRepGraph_LayerHistory, BRepGraph_LayerLock, and BRepGraph_LayerTopoSupplement.

◆ IsAttached()

bool BRepGraph_Layer::IsAttached ( ) const
inlineprotectednoexcept

True while this layer is registered in a live graph registry.

◆ KindBit()

static int BRepGraph_Layer::KindBit ( const BRepGraph_NodeId::Kind theKind)
inlinestatic

Convenience: return bitmask bit for a given Kind.

◆ Name()

virtual const TCollection_AsciiString & BRepGraph_Layer::Name ( ) const
pure virtual

Layer identity (unique within a graph).

Implemented in BRepGraph_LayerDeferred, BRepGraph_LayerHistory, BRepGraph_LayerLock, and BRepGraph_LayerTopoSupplement.

◆ OnAttached()

virtual void BRepGraph_Layer::OnAttached ( )
protectedvirtualnoexcept

Called after the layer is attached to a graph registry.

◆ OnDetached()

virtual void BRepGraph_Layer::OnDetached ( )
protectedvirtualnoexcept

Called before the layer is detached from a graph registry.

◆ OnItemModified()

void BRepGraph_Layer::OnItemModified ( const BRepGraph_ItemId theItem)
noexcept

Dispatch a generic item modification to the matching typed modification callback. This is a non-virtual convenience entry point; typed callbacks remain the extension points for derived layers.

Parameters
[in]theItemthe modified definition or reference

◆ OnItemRemoved()

void BRepGraph_Layer::OnItemRemoved ( const BRepGraph_ItemId theItem)
noexcept

Dispatch a generic item removal to the matching typed removal callback. This is a non-virtual convenience entry point; typed callbacks remain the extension points for derived layers.

Parameters
[in]theItemthe removed definition or reference

◆ OnNodeModified()

virtual void BRepGraph_Layer::OnNodeModified ( const BRepGraph_NodeId theNode)
virtualnoexcept

Called in immediate (non-deferred) mode after a single node is modified. Only dispatched if the node's kind matches SubscribedKinds(). Default: no-op.

Parameters
[in]theNodethe modified node

◆ OnNodeRemoved()

virtual void BRepGraph_Layer::OnNodeRemoved ( const BRepGraph_NodeId theNode)
virtualnoexcept

Called when a node is soft-removed without a replacement.

Parameters
[in]theNodethe removed node Layers should discard or archive data associated with it.
Warning
Layer callbacks must not throw. They are called from noexcept notification paths (MutGuard destructors, deferred invalidation flush).

Reimplemented in BRepGraph_LayerDeferred, BRepGraph_LayerHistory, BRepGraph_LayerLock, and BRepGraph_LayerTopoSupplement.

◆ OnNodeReplaced()

virtual void BRepGraph_Layer::OnNodeReplaced ( const BRepGraph_NodeId theOldNode,
const BRepGraph_NodeId theNewNode )
virtualnoexcept

Called when a node is soft-removed and replaced by another node.

Parameters
[in]theOldNodethe removed node
[in]theNewNodethe node that replaces theOldNode Layers that store node-keyed data should migrate from theOldNode to theNewNode when the replacement kind is compatible. This is a structural lifecycle event, not an algorithmic history record.
Warning
Layer callbacks must not throw. They are called from noexcept notification paths (MutGuard destructors, deferred invalidation flush).

Reimplemented in BRepGraph_LayerDeferred, BRepGraph_LayerLock, and BRepGraph_LayerTopoSupplement.

◆ OnNodesModified()

virtual void BRepGraph_Layer::OnNodesModified ( const NCollection_Array1< BRepGraph_NodeId > & theModifiedNodes)
virtualnoexcept

Called after EndDeferredInvalidation() with all nodes modified during the deferred scope. Only dispatched if at least one modified node's kind matches SubscribedKinds(). The array may contain nodes of kinds not subscribed to - layers should filter internally if needed. Default: no-op.

Parameters
[in]theModifiedNodesall modified, non-removed nodes

◆ OnRefModified()

virtual void BRepGraph_Layer::OnRefModified ( const BRepGraph_RefId theRef)
virtualnoexcept

Called in immediate (non-deferred) mode after a single ref is mutated. Only dispatched if the ref's kind matches SubscribedRefKinds(). Default: no-op.

Parameters
[in]theRefthe modified reference

◆ OnRefRemoved()

virtual void BRepGraph_Layer::OnRefRemoved ( const BRepGraph_RefId theRef)
virtualnoexcept

Called when a reference is soft-deleted via RemoveRef(). No replacement concept - refs are simply removed (unlike nodes which can have a replacement during sewing or deduplication). Dispatched to all layers regardless of SubscribedRefKinds(). Default: no-op.

Parameters
[in]theRefthe removed reference

Reimplemented in BRepGraph_LayerDeferred, and BRepGraph_LayerLock.

◆ OnRefsModified()

virtual void BRepGraph_Layer::OnRefsModified ( const NCollection_Array1< BRepGraph_RefId > & theModifiedRefs)
virtualnoexcept

Called after EndDeferredInvalidation() with all refs modified during the deferred scope. Only dispatched if at least one modified ref's kind matches SubscribedRefKinds(). The array may contain refs of kinds not subscribed to - layers should filter internally if needed. Default: no-op.

Parameters
[in]theModifiedRefsall modified, non-removed refs

◆ RefKindBit()

static int BRepGraph_Layer::RefKindBit ( const BRepGraph_RefId::Kind theKind)
inlinestatic

Convenience: return bitmask bit for a given RefId::Kind.

◆ RemappedItem() [1/2]

template<BRepGraph_NodeId::Kind TheKind>
static BRepGraph_NodeId::Typed< TheKind > BRepGraph_Layer::RemappedItem ( const BRepGraph_CopyRemap & theCopy,
const BRepGraph_NodeId::Typed< TheKind > theId )
inlinestaticprotected

◆ RemappedItem() [2/2]

template<BRepGraph_RefId::Kind TheKind>
static BRepGraph_RefId::Typed< TheKind > BRepGraph_Layer::RemappedItem ( const BRepGraph_CopyRemap & theCopy,
const BRepGraph_RefId::Typed< TheKind > theId )
inlinestaticprotected

◆ Revision()

uint64_t BRepGraph_Layer::Revision ( ) const
inlinenoexcept

Monotonic revision counter incremented by touch() on every observable state change. Consumers compare stored revisions to detect staleness in O(1). Derived layers MUST call touch() from their mutators.

◆ SubscribedKinds()

virtual int BRepGraph_Layer::SubscribedKinds ( ) const
virtual

Return a bitmask of BRepGraph_NodeId::Kind values this layer subscribes to. Only modification events matching subscribed kinds are dispatched. Default: 0 (no subscription - no modification events received). Override to receive OnNodeModified/OnNodesModified callbacks. The returned value must be constant for the lifetime of the layer.

◆ SubscribedRefKinds()

virtual int BRepGraph_Layer::SubscribedRefKinds ( ) const
virtual

Return a bitmask of BRepGraph_RefId::Kind values this layer subscribes to. Only modification events matching subscribed ref kinds are dispatched. Default: 0 (no subscription). Must be constant for the layer's lifetime.

◆ touch()

void BRepGraph_Layer::touch ( )
inlineprotectednoexcept

Bump the revision counter.


The documentation for this class was generated from the following file: