BRepGraphInc is the incidence-table backend used by BRepGraph. It is also an intentional low-level API for callers that need direct storage, load, or reconstruction control.
Use the BRepGraph views (Shapes(), Topo(), Refs(), Editor(), Mesh()) for ordinary graph workflows. Use BRepGraphInc directly when the caller owns the backend invariants: typed-id bounds, soft-removal flags, relation tables, UID vectors, generation counters, and cache invalidation.
Direct storage mutation is valid only if the caller also maintains the matching side effects:
ValidateRelations() and, for public boundaries, BRepGraph_ValidateThe facade does these things automatically; backend users get performance and control in exchange for maintaining the contract explicitly.
Derived TopoDS semantics that are not core graph state are available through algorithm runtime services:
BRepGraphAlgo_ParametersBRepGraphAlgo_RegularityBRepGraph_LayerTopoSupplementThese services do not make derived data part of backend storage. Core reconstruction does not replay parameter or regularity cache values. persisted core incidence model.
Notes:
OccurrenceRefIdsParentProductId, ChildOccurrenceId, LocalLocationChildNodeId (topology root for parts, Product for assemblies)Reference entries are typed incidence edges connecting parent entities to child definitions. Each ref kind has its own entry table and RefId space, managed by RefStore<T> in Storage.
Common header for all reference entries:
OwnGen: generation counter for change tracking (incremented on ref mutation)Removal state is stored in the owning storage bit vectors. Ref parent and child endpoints live on the ref record itself.
Concrete ref entry types extend BaseRef with endpoint and context data:
ShellRef, FaceRef, WireRef, VertexRef, SolidRef, ChildRef, OccurrenceRefOrientation.ChildRef and OccurrenceRef additionally carry LocalLocation.Ordered parent-to-child lists are stored in storage-owned relation tables, not inside definition structs:
ShellRefIds[]FaceRefIds[]WireRefIds[]CoEdgeIds[]CoEdgeIds[]EdgeIds[]ChildRefIds[]SolidRefIds[]OccurrenceRefIds[]ParentOccurrenceRefIds[]Incoming parent traversal reads derived incoming lists on relation structs or sparse node-keyed maps (myNodeToCompounds, myNodeToOccurrences).
RefStore<T> in Storage groups per-kind ref entry vector + UID vector + active count. Provides Get(), Change(), Append(), DecrementActive() -- same pattern as DefStore<T>. Soft-delete state is tracked via RefStore::RemovedFlags bit planes in Storage, not on the BaseRef struct.
The current backend grows all entity/ref/rep stores through Append(). That is correct for graph construction and editing, but it is the main blocker for single-file indexed loading and parallel persistence read paths.
For ODE-style indexed load, the backend needs an internal preparation phase before any record representations are written:
DefStore<T> owns only the outer entity vector and per-kind UID vector. Definition structs do not own child relation lists. Indexed load prepares the definition/ref/rep ranges first, then prepares relation arrays and fills the canonical ordered relation lists from serialized relation sections.
RefStore<T> currently has no inner vector members, so preparation is simpler:
RepStore<T> should also be prepared to final size up front, but representation loading should be split into two sub-phases:
OwnGen, IsRemoved, and rep cross-links such as PolygonOnTriRep.TriangulationRepIdThat split is important for ODE read because geometry and mesh representation decode is the expensive part and is the best parallelization target.
Derived incoming relation lists, sparse maps, and edge caches are maintained at whole-load granularity. Indexed loaders fill definitions, refs, coedges, and ordered relation lists first, then perform one final storage relation rebuild.
Editor and builder mutation paths must not call whole relation rebuilds as repair. They update affected relation entries incrementally with targeted attach/detach/rebind operations.
| Phase | Mode | What happens |
|---|---|---|
| Phase 1 | Sequential | Traverse hierarchy. Create container entities (Compound, CompSolid, Solid, Shell). Collect face contexts. |
| Phase 2 | Parallel | Extract per-face geometry: surface, PCurves, triangulations, vertices, edges. |
| Phase 3 | Sequential | Register faces, wires, edges, CoEdges with TShape deduplication. Link faces to shells. |
| Phase 3a | Sequential | Synthesize wire boundaries for faces with natural restrictions (no explicit wire). Creates vertices, edges, wires, and coedges for surface boundary curves. |
Backend entry point: BRepGraphInc_Populate::Perform().
BRepGraphInc_Populate::Options only controls backend extraction passes. Graph-level assembly policy such as root Product creation is owned by BRepGraph::ShapesView::Options in the facade layer.
BRepGraphInc_Populate::Append() supports incremental addition to an already-populated storage, with TShape dedup against existing entities. Used by BRepGraph::ShapesView::Add() for full-hierarchy ingestion; flattened ingestion uses BRepGraphInc_Populate::AppendFlattened().
For normal graph construction, use BRepGraph::ShapesView::Add() instead. The facade owns the public lifecycle, view initialization, mutation boundary behavior, and cache coordination on top of this backend pipeline.
All geometry is stored in definition frame - the TShape-internal location is baked into the geometry, while instance locations are preserved separately in Ref structures.
Surface: S_merged = S0.Transformed(TFace.Location()) 3D Curve: C_merged = C0.Transformed(TEdge.Location()) Vertex Point: BRep_TVertex::Pnt() (raw, no Location applied)
Formula: repLoc = theShapeLoc⁻¹ × theCombinedLoc; if repLoc ≠ Identity: theGeom.Transformed(repLoc)
PCurves are extracted directly from BRep_TEdge::Curves(), bypassing BRep_Tool::CurveOnSurface which can generate phantom computed PCurves via CurveOnPlane and has TopLoc_Location structural equality issues.
Multi-pass matching in extractStoredPCurves():
IsCurveOnSurface(S, L)| Ref Type | What it stores |
|---|---|
ChildRef.LocalLocation | child shape placement inside a compound |
OccurrenceRef.LocalLocation | product occurrence placement |
Normal topology refs (ShellRef, FaceRef, WireRef, VertexRef, SolidRef) and CoEdgeDef do not store placement. TopoDS locations from normal topology are baked into definitions while populating the graph.
TopoDS_TShape* maps to one graph entityRepDedup mapsPrimary API:
Node(storage, nodeId) - independent, local cacheNode(storage, nodeId, cache) - shared cache for vertex/edge reuseFaceWithCache(storage, faceIdx, cache) - specialized face reconstructionAll geometry restored with TopLoc_Location() = Identity (TShape location already baked):
aBB.MakeFace(aNewFace, S_merged, TopLoc_Location(), tol); aBB.MakeEdge(aNewEdge, C_merged, TopLoc_Location(), tol); aBB.MakeVertex(aNewVtx, rawPoint, tol);
Edge temporarily carries composed wire+edge location for correct BRep_Builder::UpdateEdge storage key:
anEdge.Location(aEdgeInFaceLoc); // Temporarily apply aBB.UpdateEdge(anEdge, aPC, aSurf, Identity); // Stores CR with loc⁻¹ anEdge.Location(Identity); // Reset after attachment
MakeEdge() + Degenerated(true), no 3D curve.| Map | Purpose |
|---|---|
| edge -> wires | Wire membership |
| edge -> faces | Face adjacency from CoEdgeDef::FaceId |
| edge -> coedges | CoEdge lookup by parent edge |
| edge face count | Cached O(1) face count per edge |
| vertex -> edges | Vertex incidence |
| wire -> faces | Wire-to-face membership |
| face -> shells | Face-to-shell membership |
| shell -> solids | Shell-to-solid membership |
| solid -> compounds | Compound parents of a solid |
| solid -> compsolids | CompSolid parents of a solid |
| shell -> compounds | Compound parents of a shell |
| face -> compounds | Compound parents of a face |
| compound -> compounds | Compound parents of a compound |
| compsolid -> compounds | Compound parents of a compsolid |
| product -> occurrences | Assembly references |
Id.Index == i and Id.Kind matches vector kindAll public Storage accessors use strongly-typed ids (BRepGraph_VertexId, BRepGraph_EdgeId, BRepGraph_FaceId, etc.) instead of raw int for compile-time safety. Internally, Storage uses two template patterns:
DefStore<T>: groups entity vector + per-kind UID vector + active count. Provides Get(), Change(), Append(), DecrementActive().RepStore<T>: groups representation vector + active count. Same accessor pattern, no UID vector.Storage containers use the graph's NCollection_IncAllocator where the container type supports allocator propagation:
NCollection_LinearVector lists grow compactly and are updated incrementally by storage helpersAppend() allocates UIDs incrementally (O(M) instead of O(N+M))BRepGraphInc_Populate::OptionsEdgeRelations stores only CoEdgeIds; edge wire/face adjacency is derived from active coedges.| Item | Count | GraphInc Storage |
|---|---|---|
| Solid | 1 | SolidDef table |
| Shell | 1 | ShellDef table |
| Face | 6 | FaceDef table |
| Wire | 6 | WireDef table |
| Edge | 12 | EdgeDef table |
| CoEdge | 24 | CoEdgeDef table |
| Vertex | 8 | VertexDef table |
| Product | 1 (auto root) | ProductDef table |
Key difference: TopoDS expresses context through shape occurrences. GraphInc keeps canonical entities and stores context on refs.
| File | Purpose |
|---|---|
BRepGraphInc_Definition.hxx | Entity struct definitions |
BRepGraphInc_Reference.hxx | Context reference definitions |
BRepGraphInc_Relations.hxx | Relation structs and list helpers |
BRepGraphInc_Storage.hxx/.cxx | Typed storage and ownership |
BRepGraphInc_Populate.hxx/.cxx | TopoDS -> incidence build and append |
BRepGraphInc_Reconstruct.hxx/.cxx | Incidence -> TopoDS reconstruction |
BRepGraphInc_Storage.lxx | Late-include implementation: TypedStorePlanes specializations and template method definitions |
BRepGraphInc_BitFlags.hxx | Bit-plane storage for per-entity boolean flags |
BRepGraphInc_BoundaryBuilder.pxx | Boundary construction helpers (.pxx late-include extension) |
BRepGraphInc_Instance.hxx | Instance location handling |
BRepGraphInc_Load.hxx | Indexed load preparation |
BRepGraphInc_ParityOrientation.hxx | Orientation and parity logic |
BRepGraphInc_RepId.hxx | Strongly-typed representation ID types |
BRepGraphInc_Representation.hxx | Geometry representation records |