OpenCascade.js
PackageApiModeling dataTkb repB rep graph

BRepGraph (page 2 of 2)

OCCT package BRepGraph: BRepGraph, BRepGraph_Builder, BRepGraph_CacheKind, BRepGraph_CacheKindRegistry, and 180 more bound classes.

BRepGraph_RefsIterator_CoEdgeOfWireTraits

Constructors(1)

Static methods(4)

BRepGraph_RefsIterator_FaceOfShellTraits

Constructors(1)

Static methods(4)

BRepGraph_RefsIterator_OccurrenceOfProductTraits

Constructors(1)

Static methods(4)

BRepGraph_RefsIterator_ShellOfSolidTraits

Constructors(1)

Static methods(4)

BRepGraph_RefsIterator_SolidOfCompSolidTraits

Constructors(1)

Static methods(4)

BRepGraph_RefsIterator_VertexOfFaceTraits

Constructors(1)

Static methods(4)

BRepGraph_RefsIterator_WireOfFaceTraits

Constructors(1)

Static methods(4)

BRepGraph_RefsView

Instance methods(13)

BRepGraph_RefTransientCache

Centralized transient cache for algorithm-computed per-reference values.
Symmetric counterpart of BRepGraph_TransientCache, keyed by BRepGraph_RefId instead of BRepGraph_NodeId. Freshness is tracked via BaseRef::OwnGen rather than BaseDef::SubtreeGen, because references do not own subtrees.
Shares the same BRepGraph_CacheKind descriptors and BRepGraph_CacheKindRegistry as the node cache; the same kind GUID can address values in both caches.
OwnGen-based freshness
Each stored slot records OwnGen at write time. On read, if the stored OwnGen differs from the reference's current OwnGen the cached value is considered stale.
Lifecycle
NOT a Layer. Cleared on BRepGraph_Builder::Add() and Compact(). No explicit removal callback

  • stale data is auto-detected by OwnGen mismatch.
    Thread safety
    After Reserve(), Get() and Set() for in-range indices bypass the mutex entirely. Out-of-range access falls back to mutex-protected vector growth.

Constructors(1)

Instance methods(10)

  • Set(theRef: BRepGraph_RefId, theKind: BRepGraph_CacheKind, theValue: BRepGraph_CacheValue, theCurrentOwnGen: number): void

    Store a cached value for a reference and cache kind.

    Parameters (4)
    • theRef
    • theKind
    • theValue
    • theCurrentOwnGen
  • Set(theRef: BRepGraph_RefId, theKindSlot: number, theValue: BRepGraph_CacheValue, theCurrentOwnGen: number): void

    Store a cached value using a pre-resolved kind slot index. Bypasses BRepGraph_CacheKindRegistry lookup - use in hot parallel paths.

    Parameters (4)
    • theRef
    • theKindSlot
      slot from BRepGraph_CacheKindRegistry::Register()
    • theValue
    • theCurrentOwnGen
  • Get(theRef: BRepGraph_RefId, theKind: BRepGraph_CacheKind, theCurrentOwnGen: number): BRepGraph_CacheValue

    Retrieve a cached value for a reference and cache kind. Returns null handle if no value is stored or if OwnGen has changed.

    Parameters (3)
    • theRef
    • theKind
    • theCurrentOwnGen
  • Get(theRef: BRepGraph_RefId, theKindSlot: number, theCurrentOwnGen: number): BRepGraph_CacheValue

    Retrieve a cached value using a pre-resolved kind slot index.

    Parameters (3)
    • theRef
    • theKindSlot
    • theCurrentOwnGen
  • Remove(theRef: BRepGraph_RefId, theKind: BRepGraph_CacheKind): boolean

    Remove a cached value for a reference and cache kind.

    Parameters (2)
    • theRef
    • theKind
  • Remove(theRef: BRepGraph_RefId, theKindSlot: number): boolean

    Remove a cached value using a pre-resolved cache-kind slot.

    Parameters (2)
    • theRef
    • theKindSlot
  • CollectCacheKindSlots(theRef: BRepGraph_RefId, theCurrentOwnGen: number, theSlots: number[]): number

    Collect fresh cache-kind slot indices for a reference (zero heap allocation). Used internally by CacheView::CacheKindIterator.

    Parameters (3)
    • theRef
      reference to query
    • theCurrentOwnGen
      freshness stamp to match
    • theSlots
      output array (caller-allocated, must hold THE_DEFAULT_RESERVED_KIND_COUNT)
    Returns

    number of populated slots written to theSlots

  • Reserve(theKindCount: number, theCounts: [number, number, number, number, number, number, number, number]): void

    Pre-allocate storage for lock-free parallel access.

    Parameters (2)
    • theKindCount
    • theCounts
  • IsReserved(): boolean

    True if Reserve() has been called and storage is pre-allocated.

  • Clear(): void

    Clear all cached data. Called on BRepGraph_Builder::Add() and Compact().

BRepGraph_RefUID

Unique reference identifier within a BRepGraph.
Identity = (RefKind, Counter). Generation is excluded from equality/hash. Counter 0 is an invalid sentinel.
Serialization Contract
Entity UIDs (BRepGraph_UID) and reference UIDs (BRepGraph_RefUID) share a single monotonic counter (BRepGraph_Data::myNextUIDCounter). To persist a BRepGraph across sessions:

  1. Write: for each reference entry, serialize (RefKind, Counter, OwnGen).
  2. Read: reconstruct reference entries, populate RefUID vectors with deserialized (RefKind, Counter) values, set myNextUIDCounter to max(all_entity_counters, all_ref_counters) + 1.
  3. myGeneration resets to 0 on load (session-scoped).
  4. VersionStamps from a previous session will correctly detect staleness via Generation mismatch.

Constructors(2)

Static methods(1)

Instance methods(5)

BRepGraph_RelatedIterator

Single-level iterator over semantically related topology nodes.
The iterator yields immediate related nodes for one source node together with the relation kind explaining why each node is returned. Results are not deduplicated; callers that need uniqueness should filter on top.

Constructors(1)

Instance methods(5)

BRepGraph_RepId

Lightweight typed index into a per-kind representation vector inside BRepGraph.
The pair (Kind, Index) forms a unique representation identifier within one graph instance. Default-constructed RepId has Index = UINT32_MAX (invalid).
Representations are NOT topology nodes - they hold geometry or mesh data referenced by topology entities. They do not participate in BFS traversal, reverse index, or parent-child relationships.
RepId is a value type: cheap to copy, compare, hash.

Constructors(2)

Static methods(4)

  • IsGeometryKind(theKind: BRepGraph_RepId_Kind): boolean

    True if the kind is a geometry kind (Surface, Curve3D, Curve2D).

    Parameters (1)
    • theKind
  • IsMeshKind(theKind: BRepGraph_RepId_Kind): boolean

    True if the kind is a mesh kind (Triangulation, Polygon3D, Polygon2D, PolygonOnTri).

    Parameters (1)
    • theKind
  • Start(theKind: BRepGraph_RepId_Kind): BRepGraph_RepId

    First valid id in a dense sequence for the specified kind.

    Parameters (1)
    • theKind
  • Invalid(theKind?: BRepGraph_RepId_Kind): BRepGraph_RepId

    Invalid sentinel id for the specified kind.

    Parameters (1)
    • theKind

Instance methods(2)

  • IsValid(): boolean

    True if this id points to an allocated representation slot.

  • IsValid(theMaxCount: number): boolean

    True if this id points to an allocated slot within [0, theMaxCount). UINT32_MAX (invalid sentinel) always fails this check for any realistic count.

    Parameters (1)
    • theMaxCount

Properties(2)

BRepGraph_ShapesView

Instance methods(7)

BRepGraph_ShellRefId

Constructors(3)

Static methods(3)

Instance methods(2)

  • IsValid(): boolean
  • IsValid(theMaxCount: number): boolean
    Parameters (1)
    • theMaxCount

Properties(1)

BRepGraph_ShellsOfFace

Constructors(2)

Instance methods(10)

BRepGraph_SolidRefId

Constructors(3)

Static methods(3)

Instance methods(2)

  • IsValid(): boolean
  • IsValid(theMaxCount: number): boolean
    Parameters (1)
    • theMaxCount

Properties(1)

BRepGraph_SolidsOfShell

Constructors(2)

Instance methods(10)

BRepGraph_SurfaceRepId

Constructors(3)

Static methods(3)

Instance methods(2)

  • IsValid(): boolean
  • IsValid(theMaxCount: number): boolean
    Parameters (1)
    • theMaxCount

Properties(1)

BRepGraph_Tool

Centralized geometry access for BRepGraph - analogue of BRep_Tool.
Geometry in BRepGraph is stored in the definition frame (representation Location baked via applyRepresentationLocation). Instance Locations live on topology Instance/Ref structs (VertexInstance, CoEdgeInstance, WireInstance, FaceInstance, ShellInstance, SolidInstance, OccurrenceInstance). This class applies ref Locations automatically when accessing 3D geometry.
Instance structs are lightweight read-only projections produced during traversal, while Ref structs are stored reference entries from RefsView; this API accepts whichever form naturally carries the required context for the queried property.
Methods are grouped by topology kind via nested classes: BRepGraph_Tool::Vertex, Edge, CoEdge, Face, Wire.

BRepGraph_Tool_CoEdge

Constructors(1)

Static methods(15)

BRepGraph_Tool_Edge

Constructors(1)

Static methods(26)

BRepGraph_Tool_Face

Constructors(1)

Static methods(12)

BRepGraph_Tool_Mesh

Constructors(1)

Static methods(10)

BRepGraph_Tool_Vertex

Constructors(1)

Static methods(7)

BRepGraph_Tool_Wire

Constructors(1)

Static methods(5)

BRepGraph_TopoView

Instance methods(13)

BRepGraph_TopoView_CoEdgeOps

Instance methods(10)

BRepGraph_TopoView_EdgeOps

Instance methods(17)

BRepGraph_TopoView_FaceOps

Instance methods(13)

BRepGraph_TopoView_OccurrenceOps

Instance methods(8)

BRepGraph_TopoView_ProductOps

Instance methods(12)

BRepGraph_Transform

Graph-to-graph transformation.
Produces a new BRepGraph by copying and then applying a geometric transformation to vertex points and geometry node locations.
Two geometry modes (matching BRepBuilderAPI_Transform semantics):

  • theCopyGeom = true (geometry-level): deep-copy geometry, transform handles in-place via Geom_Surface::Transform() etc., reset locations to identity.
  • theCopyGeom = false (root-level): light-copy with shared geometry, apply transform via location modification only.
    Mesh handling (theCopyMesh parameter):
  • theCopyMesh = false (default): triangulations and polygons are discarded after a geometry-level transform and must be recomputed.
  • theCopyMesh = true: all mesh data (Poly_Triangulation on FaceDefs and the MeshLayer cache, Poly_Polygon3D on edges, Poly_PolygonOnTriangulation on coedges) is copied and transformed in sync with the geometry. In location-only mode the mesh data is copied as-is (nodes stay in the graph coordinate system, which is unaffected by a pure location compose).
    Typical usage
BRepGraphaGraph; BRepGraph_Builder::Add(aGraph,myShape); gp_TrsfaTrsf; aTrsf.SetTranslation(gp_Vec(10.0,0.0,0.0)); BRepGraphaTransformed=BRepGraph_Transform::Perform(aGraph,aTrsf); TopoDS_ShapeaShape=aTransformed.Shapes().Shape();

Static methods(3)

  • Perform(theGraph: BRepGraph, theTrsf: gp_Trsf, theCopyGeom: boolean, theCopyMesh: boolean): BRepGraph

    Transform the entire graph.

    Parameters (4)
    • theGraph
      a pre-built BRepGraph (must have IsDone() == true)
    • theTrsf
      the transformation to apply
    • theCopyGeom
      if true, geometry is deep-copied before transforming; if false, light-copy then transform locations/points only
    • theCopyMesh
      if true, mesh data (triangulations, polygons) is copied and transformed; if false, meshes are discarded after transform
    Returns

    a new BRepGraph with the transformation applied

  • TransformNode(theGraph: BRepGraph, theNodeId: BRepGraph_NodeId, theTrsf: gp_Trsf, theCopyGeom: boolean, theCopyMesh: boolean): BRepGraph

    Transform a single node sub-graph of any kind (Face, Shell, Solid, Wire, Edge, Vertex). Produces a new BRepGraph containing only the specified node and its referenced sub-graph. The transform is applied to all copied geometry (same rules as Perform()).

    Parameters (5)
    • theGraph
      a pre-built BRepGraph
    • theNodeId
      node identifier (any kind: Face, Shell, Solid, Wire, Edge, Vertex, Compound, CompSolid, Product, Occurrence)
    • theTrsf
      the transformation to apply
    • theCopyGeom
      if true, geometry is deep-copied before transforming
    • theCopyMesh
      if true, mesh data is copied and transformed
    Returns

    a new BRepGraph containing only the specified sub-graph, transformed

  • MoveRef(theGraph: BRepGraph, theRefId: BRepGraph_RefId, theTrsf: gp_Trsf): boolean

    Apply an in-place location-only transform to a single reference. Composes theTrsf into the reference's LocalLocation field without copying any geometry. This is O(1) and equivalent to TopoDS_Shape::Moved(trsf). Cached mesh data on entities downstream of the moved ref is stored in the entity's local frame and is unaffected; callers that bake a world transform into a cache key own the invalidation responsibility.

    Parameters (3)
    • theGraph
      the graph containing the reference
    • theRefId
      reference to move (any ref kind)
    • theTrsf
      the transformation to compose into the location
    Returns

    true on success; false if theTrsf has a non-unit scale factor

    Remarks

    Note: Only pure rotation/translation transforms (scale == 1) are supported. The method is a no-op and returns false if |scaleFactor| != 1.

BRepGraph_TransientCache

Centralized transient cache for algorithm-computed per-node values.
Stores short-lived cached data (BndBox, UVBounds, etc.) in dense per-cache-kind vectors indexed by entity index. O(1) access by direct indexing - no hashing.
SubtreeGen-based freshness
Each stored slot records SubtreeGen at write time. On read, if stored SubtreeGen differs from entity's current SubtreeGen the cached value is considered stale - the caller decides how to handle it.
Lifecycle
NOT a Layer. Cleared on BRepGraph_Builder::Add() and Compact(). No OnNodeRemoved handling - stale data is auto-detected by SubtreeGen mismatch.
Thread safety
After Reserve(), Get() and Set() for in-range indices bypass the mutex entirely - safe because parallel algorithms access different entity slots. Out-of-range access (entities added after construction) falls back to mutex.

Constructors(1)

Instance methods(10)

  • Set(theNode: BRepGraph_NodeId, theKind: BRepGraph_CacheKind, theValue: BRepGraph_CacheValue, theCurrentSubtreeGen: number): void

    Store a cached value for a node and cache kind.

    Parameters (4)
    • theNode
    • theKind
    • theValue
    • theCurrentSubtreeGen
  • Set(theNode: BRepGraph_NodeId, theKindSlot: number, theValue: BRepGraph_CacheValue, theCurrentSubtreeGen: number): void

    Store a cached value using a pre-resolved kind slot index. Bypasses BRepGraph_CacheKindRegistry lookup - use in hot parallel paths.

    Parameters (4)
    • theNode
    • theKindSlot
      slot from BRepGraph_CacheKindRegistry::Register()
    • theValue
    • theCurrentSubtreeGen
  • Get(theNode: BRepGraph_NodeId, theKind: BRepGraph_CacheKind, theCurrentSubtreeGen: number): BRepGraph_CacheValue

    Retrieve a cached value for a node and cache kind.

    Parameters (3)
    • theNode
    • theKind
    • theCurrentSubtreeGen
  • Get(theNode: BRepGraph_NodeId, theKindSlot: number, theCurrentSubtreeGen: number): BRepGraph_CacheValue

    Retrieve a cached value using a pre-resolved kind slot index. Bypasses BRepGraph_CacheKindRegistry lookup - use in hot parallel paths.

    Parameters (3)
    • theNode
    • theKindSlot
      slot from BRepGraph_CacheKindRegistry::Register()
    • theCurrentSubtreeGen
  • Remove(theNode: BRepGraph_NodeId, theKind: BRepGraph_CacheKind): boolean

    Remove a cached value for a node and cache kind.

    Parameters (2)
    • theNode
    • theKind
  • Remove(theNode: BRepGraph_NodeId, theKindSlot: number): boolean

    Remove a cached value using a pre-resolved cache-kind slot.

    Parameters (2)
    • theNode
    • theKindSlot
  • CollectCacheKindSlots(theNode: BRepGraph_NodeId, theCurrentSubtreeGen: number, theSlots: number[]): number

    Collect fresh cache-kind slot indices for a node (zero heap allocation). Used internally by CacheView::CacheKindIterator.

    Parameters (3)
    • theNode
      node to query
    • theCurrentSubtreeGen
      freshness stamp to match
    • theSlots
      output array (caller-allocated, must hold THE_DEFAULT_RESERVED_KIND_COUNT)
    Returns

    number of populated slots written to theSlots

  • Reserve(theKindCount: number, theCounts: [number, number, number, number, number, number, number, number, number, number, number, number]): void

    Pre-allocate storage for lock-free parallel access.

    Parameters (2)
    • theKindCount
    • theCounts
  • IsReserved(): boolean

    True if Reserve() has been called and storage is pre-allocated.

  • Clear(): void

    Clear all cached data. Called on BRepGraph_Builder::Add() and Compact().

BRepGraph_TriangulationRepId

Constructors(3)

Static methods(3)

Instance methods(2)

  • IsValid(): boolean
  • IsValid(theMaxCount: number): boolean
    Parameters (1)
    • theMaxCount

Properties(1)

BRepGraph_UID

Unique node identifier within a BRepGraph.
Identity = (Kind, Counter). Two nodes of different kinds may share a counter value but their UIDs are distinct. Within one kind, counter values never repeat (monotonic, never resets).
Generation is NOT part of identity; it indicates which BRepGraph::Clear() cycle produced this UID (for stale-reference detection).
Trivially copyable, cheap to pass by value.
Serialization Contract
Entity UIDs (BRepGraph_UID) and reference UIDs (BRepGraph_RefUID) share a single monotonic counter (BRepGraph_Data::myNextUIDCounter). To persist a BRepGraph across sessions:

  1. Write: for each entity, serialize (Kind, Counter, OwnGen).
  2. Read: reconstruct entities, populate UID vectors with deserialized (Kind, Counter) values, set myNextUIDCounter to max(all_entity_counters, all_ref_counters) + 1.
  3. myGeneration resets to 0 on load (session-scoped).
  4. VersionStamps from a previous session will correctly detect staleness via Generation mismatch.

Constructors(2)

  • Default: invalid UID (counter = 0 is the invalid sentinel).

  • constructor(theKind: BRepGraph_NodeId_Kind, theCounter: number, theGeneration: number): BRepGraph_UID

    Construct a valid UID. Called internally by BRepGraph::allocateUID().

    Parameters (3)
    • theKind
    • theCounter
    • theGeneration

Static methods(1)

Instance methods(7)

BRepGraph_UIDsView

Instance methods(11)

BRepGraph_Validate

Structural invariant checker for BRepGraph.
Read-only algorithm that verifies the graph's internal consistency: cross-reference bounds, reverse index symmetry, incidence ref consistency, geometry reference validity, removed-node isolation, and wire connectivity.
Distinct from BRepGraphCheck (geometric shape validity). This class checks the graph data structure itself.
Validation Mode Check Matrix
CheckLightweightAudit Active entity count boundaryYESYES Cross-reference bounds-YES Reverse-index consistency-YES Face-count cache consistency-YES Incidence ref consistency-YES Geometry representation refs-YES Removed-node isolation-YES Wire edge connectivity-YES Entity ID positional integrity-YES UID round-trip integrity-YES Assembly DAG cycle detection-YES
Mode Guidance
ModeWhat it checksCostRecommended use LightweightActive entity count boundary onlyLowHot-path release builds when the graph structure is already trustedAuditFull structural audit from cross-reference bounds through assembly DAG cycle detection | Higher | Default validation mode for production pipelines, test gates, and API-boundary verification |
For production pipelines, prefer Mode::Audit; Mode::Lightweight is intended for hot-path release builds where the graph structure is already trusted.

Static methods(3)

  • Run default lightweight structural checks on a built graph. Uses Mode::Lightweight; for full structural audit use Perform(theGraph, Mode::Audit).

    Parameters (1)
    • theGraph
      graph to validate (const, read-only)
    Returns

    validation result with all detected issues

  • Perform(theGraph: BRepGraph, theMode: BRepGraph_Validate_Mode): BRepGraph_Validate_Result

    Run structural checks on a built graph with explicit mode.

    Parameters (2)
    • theGraph
      graph to validate (const, read-only)
    • theMode
      validation mode
    Returns

    validation result with all detected issues

  • Run structural checks on a built graph with explicit options.

    Parameters (2)
    • theGraph
      graph to validate (const, read-only)
    • theOptions
      validation profile/options
    Returns

    validation result with all detected issues

BRepGraph_VersionStamp

Snapshot of an entity/ref identity and version at a point in time.
Combines a persistent UID (entity or reference entry) with OwnGen (own-data version counter) and graph Generation (BRepGraph::Clear() cycle). Computed on demand via BRepGraph::UIDs().StampOf().
Usage pattern:

BRepGraph_VersionStampaStamp=aGraph.UIDs().StampOf(aFaceId); //...later,aftermutations... if(aGraph.UIDs().IsStale(aStamp)) recomputeDerivedData();

Constructors(3)

  • Default constructor. Creates an invalid stamp (invalid UID, zero counters).

  • constructor(theUID: BRepGraph_UID, theMutationGen: number, theGeneration: number): BRepGraph_VersionStamp

    Construct an entity-domain stamp from components.

    Parameters (3)
    • theUID
      persistent entity identity
    • theMutationGen
      OwnGen counter (own-data mutation counter)
    • theGeneration
      graph BRepGraph::Clear() generation
  • constructor(theRefUID: BRepGraph_RefUID, theMutationGen: number, theGeneration: number): BRepGraph_VersionStamp

    Construct a reference-domain stamp from components.

    Parameters (3)
    • theRefUID
      persistent reference identity
    • theMutationGen
      OwnGen counter (own-data mutation counter)
    • theGeneration
      graph BRepGraph::Clear() generation

Instance methods(6)

  • IsValid(): boolean

    Check if the stamp has a valid identity in its domain.

  • IsEntityStamp(): boolean

    True when this is an entity-domain stamp.

  • IsRefStamp(): boolean

    True when this is a reference-domain stamp.

  • Check if two stamps refer to the same entity/reference regardless of version. Compares active UID only, ignoring OwnGen and Generation.

    Parameters (1)
    • theOther
      stamp to compare with
    Returns

    true if both stamps have the same domain and UID

  • Derive a deterministic Standard_GUID from this stamp. The graph GUID is incorporated into the hash, making per-node GUIDs globally unique across different graph instances. One-way: cannot reconstruct stamp fields from the resulting GUID.

    Parameters (1)
    • theGraphGUID
      the owning graph's identity GUID
    Returns

    deterministic Standard_GUID derived from stamp + graph GUID

  • HashValue(): number

    Compute hash value consistent with operator==.

    Returns

    hash combining active UID, domain, OwnGen, and Generation

Properties(7)

BRepGraph_VertexRefId

Constructors(3)

Static methods(3)

Instance methods(2)

  • IsValid(): boolean
  • IsValid(theMaxCount: number): boolean
    Parameters (1)
    • theMaxCount

Properties(1)

BRepGraph_WireExplorer

Iterator for traversing wire edges in connection order using graph data.
Reorders wire coedges by vertex adjacency: the end vertex of each edge matches the start vertex of the next. This is the graph equivalent of BRepTools_WireExplorer, operating on pre-built BRepGraph data.
The coedges are reordered on construction (O(N^2) worst case for N coedges). For most wires this is fast since N is small (4-8 edges typically).
Internal storage uses NCollection_LocalArray with stack allocation for wires with up to 16 edges (the common case), falling back to heap for larger wires.
Usage:

BRepGraph_WireExploreranExp(aGraph,aWireId); for(;anExp.More();anExp.Next()) { constBRepGraph_CoEdgeIdaCoEdgeId=anExp.CurrentCoEdgeId(); constBRepGraphInc::CoEdgeDef&aDef=aGraph.Topo().CoEdges().Definition(aCoEdgeId); //...useaDef... }

Constructors(1)

Instance methods(7)

BRepGraph_WireRefId

Constructors(3)

Static methods(3)

Instance methods(2)

  • IsValid(): boolean
  • IsValid(theMaxCount: number): boolean
    Parameters (1)
    • theMaxCount

Properties(1)

BRepGraph_WiresOfCoEdge

Constructors(2)

Instance methods(10)