diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph.cxx index 4fc1a00fa6..c19664274f 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph.cxx @@ -21,12 +21,35 @@ #include #include +#include #include #include +#include #include +#include #include +namespace +{ + +static Standard_GUID generateRandomGUID() +{ + std::random_device aRD; + MathUtils::RandomGenerator aRNG(aRD()); + const uint64_t aRand1 = aRNG.NextInt(); + const uint64_t aRand2 = aRNG.NextInt(); + Standard_UUID aUUID; + aUUID.Data1 = static_cast(aRand1); + aUUID.Data2 = static_cast(aRand1 >> 32); + aUUID.Data3 = static_cast(aRand1 >> 48); + for (int i = 0; i < 8; ++i) + aUUID.Data4[i] = static_cast(aRand2 >> (i * 8)); + return Standard_GUID(aUUID); +} + +} // namespace + //================================================================================================= void BRepGraph::initViews() @@ -210,6 +233,34 @@ BRepGraph_RefUID BRepGraph::allocateRefUID(const BRepGraph_RefId theRefId) //================================================================================================= +void BRepGraph::Clear() +{ + myData->myIncStorage.Clear(); + myData->myHistoryLog.Clear(); + myData->myCurrentShapes.Clear(); + myData->myRootProductIds.Clear(); + myTransientCache.Clear(); + { + std::unique_lock aUIDLock(myData->myUIDToNodeIdMutex); + myData->myUIDToNodeId.Clear(); + myData->myUIDToNodeIdDirty = true; + myData->myUIDToNodeIdGeneration = myData->myGeneration.load(); + } + { + std::unique_lock aRefUIDLock(myData->myRefUIDToRefIdMutex); + myData->myRefUIDToRefId.Clear(); + myData->myRefUIDToRefIdDirty = true; + myData->myRefUIDToRefIdGeneration = myData->myGeneration.load(); + } + ++myData->myGeneration; + myData->myGraphGUID = generateRandomGUID(); + myData->myIsDone = false; + + myLayerRegistry.ClearAll(); +} + +//================================================================================================= + bool BRepGraph::IsDone() const { return myData->myIsDone; @@ -849,7 +900,7 @@ void BRepGraph::markRepModified(const BRepGraph_RepId theRepId) noexcept void BRepGraph::SetAllocator(const occ::handle& theAlloc) { Standard_ASSERT_VOID(!myData->myIsDone, - "SetAllocator: must be called before BRepGraph_Builder::Perform() - " + "SetAllocator: must be called before BRepGraph_Builder::Add() - " "existing graph state will be lost"); myData->myAllocator = diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph.hxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph.hxx index 5c07a36128..d1382d72f4 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph.hxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph.hxx @@ -64,7 +64,7 @@ class BRepGraph_History; //! Curve3D, Curve2D, Triangulation, Polygon) decoupled from topology nodes. //! - **CoEdge**: half-edge entity owning PCurve data for each edge-face binding; //! seam edges use paired CoEdges with opposite Orientation (Parasolid convention). -//! - **Lifecycle**: BRepGraph_Builder::Perform() populates from TopoDS_Shape; +//! - **Lifecycle**: BRepGraph_Builder::Add() populates from TopoDS_Shape; //! Editor() is the single mutation entry point for both structural creation/removal //! (Add*, Remove*, Append*) and field-level RAII-scoped mutation (Mut*()) with //! automatic cache invalidation and upward SubtreeGen propagation. @@ -82,11 +82,11 @@ class BRepGraph_History; //! Deferred invalidation (BRepGraph_DeferredScope) batches SubtreeGen propagation; //! concurrent Editor().Mut*() calls during deferred mode still require external //! serialization. -//! BRepGraph_Builder::Perform() is internally parallel when requested. +//! BRepGraph_Builder::Add() is internally parallel when requested. //! //! ## UID persistence //! UIDs use monotonic counters (not vector indices), persisting across Compact() -//! and node removal. Only BRepGraph_Builder::Perform() resets counters (new generation). +//! and node removal. Only BRepGraph::Clear() resets counters (new generation). //! See BRepGraph_UID.hxx for the serialization contract. //! //! ## Extension model @@ -140,6 +140,9 @@ public: //! Move assignment operator. Standard_EXPORT BRepGraph& operator=(BRepGraph&&) noexcept; + //! Reset the graph to an empty state. Increments generation and regenerates the graph GUID. + Standard_EXPORT void Clear(); + //! Return true if the graph was successfully built. [[nodiscard]] Standard_EXPORT bool IsDone() const; diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Builder.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Builder.cxx index fe4981067f..24f0768d96 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Builder.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Builder.cxx @@ -12,47 +12,25 @@ // commercial license or contractual agreement. #include -#include -#include -#include + #include #include +#include +#include #include #include #include +#include #include #include #include #include -#include -#include #include - -#include -#include -#include +#include namespace { -//! Generate a random Standard_GUID using MathUtils::RandomGenerator -//! seeded with std::random_device for platform entropy. -static Standard_GUID generateRandomGUID() -{ - std::random_device aRD; - MathUtils::RandomGenerator aRNG(aRD()); - // Fill 16 bytes with random data, then construct Standard_UUID field by field. - const uint64_t aRand1 = aRNG.NextInt(); - const uint64_t aRand2 = aRNG.NextInt(); - Standard_UUID aUUID; - aUUID.Data1 = static_cast(aRand1); - aUUID.Data2 = static_cast(aRand1 >> 32); - aUUID.Data3 = static_cast(aRand1 >> 48); - for (int i = 0; i < 8; ++i) - aUUID.Data4[i] = static_cast(aRand2 >> (i * 8)); - return Standard_GUID(aUUID); -} - //================================================================================================= static void assertMutationBoundary(BRepGraph& theGraph, const char* theContext) @@ -67,6 +45,68 @@ static void assertMutationBoundary(BRepGraph& theGraph, const char* theContext) //================================================================================================= +uint32_t BRepGraph_Builder::snapshotCountForKind(const BRepGraph& theGraph, + const TopAbs_ShapeEnum theShapeType) +{ + const BRepGraphInc_Storage& aStorage = theGraph.myData->myIncStorage; + switch (theShapeType) + { + case TopAbs_COMPOUND: + return static_cast(aStorage.NbCompounds()); + case TopAbs_COMPSOLID: + return static_cast(aStorage.NbCompSolids()); + case TopAbs_SOLID: + return static_cast(aStorage.NbSolids()); + case TopAbs_SHELL: + return static_cast(aStorage.NbShells()); + case TopAbs_FACE: + return static_cast(aStorage.NbFaces()); + case TopAbs_WIRE: + return static_cast(aStorage.NbWires()); + case TopAbs_EDGE: + return static_cast(aStorage.NbEdges()); + case TopAbs_VERTEX: + return static_cast(aStorage.NbVertices()); + default: + return 0; + } +} + +//================================================================================================= + +BRepGraph_NodeId BRepGraph_Builder::detectTopologyRoot(const BRepGraph& theGraph, + const TopAbs_ShapeEnum theShapeType, + const uint32_t theOldCountOfShapeKind) +{ + const uint32_t aNewCount = snapshotCountForKind(theGraph, theShapeType); + if (aNewCount <= theOldCountOfShapeKind) + return BRepGraph_NodeId(); + + switch (theShapeType) + { + case TopAbs_COMPOUND: + return BRepGraph_CompoundId(theOldCountOfShapeKind); + case TopAbs_COMPSOLID: + return BRepGraph_CompSolidId(theOldCountOfShapeKind); + case TopAbs_SOLID: + return BRepGraph_SolidId(theOldCountOfShapeKind); + case TopAbs_SHELL: + return BRepGraph_ShellId(theOldCountOfShapeKind); + case TopAbs_FACE: + return BRepGraph_FaceId(theOldCountOfShapeKind); + case TopAbs_WIRE: + return BRepGraph_WireId(theOldCountOfShapeKind); + case TopAbs_EDGE: + return BRepGraph_EdgeId(theOldCountOfShapeKind); + case TopAbs_VERTEX: + return BRepGraph_VertexId(theOldCountOfShapeKind); + default: + return BRepGraph_NodeId(); + } +} + +//================================================================================================= + void BRepGraph_Builder::populateUIDs(BRepGraph& theGraph) { BRepGraphInc_Storage& aStorage = theGraph.myData->myIncStorage; @@ -119,146 +159,144 @@ void BRepGraph_Builder::populateUIDs(BRepGraph& theGraph) //================================================================================================= -void BRepGraph_Builder::Perform(BRepGraph& theGraph, - const TopoDS_Shape& theShape, - const bool theParallel) +void BRepGraph_Builder::appendImpl(BRepGraph& theGraph, + const TopoDS_Shape& theShape, + const Options& theOptions, + NCollection_DynamicArray* theOutFlatRoots) { - Perform(theGraph, theShape, theParallel, BuildOptions()); -} + BRepGraphInc_Storage& aStorage = theGraph.myData->myIncStorage; + const int anOldVtx = aStorage.NbVertices(); + const int anOldEdge = aStorage.NbEdges(); + const int anOldCoEdge = aStorage.NbCoEdges(); + const int anOldWire = aStorage.NbWires(); + const int anOldFace = aStorage.NbFaces(); + const int anOldShell = aStorage.NbShells(); + const int anOldSolid = aStorage.NbSolids(); + const int anOldComp = aStorage.NbCompounds(); + const int anOldCS = aStorage.NbCompSolids(); + const int anOldProduct = aStorage.NbProducts(); + const int anOldOccurrence = aStorage.NbOccurrences(); + const int anOldShellRef = aStorage.NbShellRefs(); + const int anOldFaceRef = aStorage.NbFaceRefs(); + const int anOldWireRef = aStorage.NbWireRefs(); + const int anOldCoEdgeRef = aStorage.NbCoEdgeRefs(); + const int anOldVertexRef = aStorage.NbVertexRefs(); + const int anOldSolidRef = aStorage.NbSolidRefs(); + const int anOldChildRef = aStorage.NbChildRefs(); -//================================================================================================= - -void BRepGraph_Builder::Perform(BRepGraph& theGraph, - const TopoDS_Shape& theShape, - const bool theParallel, - const BuildOptions& theOptions) -{ - theGraph.myData->myIncStorage.Clear(); - theGraph.myData->myHistoryLog.Clear(); - theGraph.myData->myCurrentShapes.Clear(); - theGraph.myData->myRootProductIds.Clear(); - theGraph.myTransientCache.Clear(); - { - std::unique_lock aUIDLock(theGraph.myData->myUIDToNodeIdMutex); - theGraph.myData->myUIDToNodeId.Clear(); - theGraph.myData->myUIDToNodeIdDirty = true; - theGraph.myData->myUIDToNodeIdGeneration = theGraph.myData->myGeneration.load(); - } - { - std::unique_lock aRefUIDLock(theGraph.myData->myRefUIDToRefIdMutex); - theGraph.myData->myRefUIDToRefId.Clear(); - theGraph.myData->myRefUIDToRefIdDirty = true; - theGraph.myData->myRefUIDToRefIdGeneration = theGraph.myData->myGeneration.load(); - } - ++theGraph.myData->myGeneration; - theGraph.myData->myGraphGUID = generateRandomGUID(); - theGraph.myData->myIsDone = false; - - // Notify registered layers that graph data is being cleared. - theGraph.myLayerRegistry.ClearAll(); - - if (theShape.IsNull()) - return; - - // Temporary allocator for populate scratch data, discarded after build. occ::handle aTmpAlloc = new NCollection_IncAllocator; const occ::handle aParamLayer = theGraph.LayerRegistry().FindLayer(); const occ::handle aRegularityLayer = theGraph.LayerRegistry().FindLayer(); - BRepGraphInc_Populate::Perform(theGraph.myData->myIncStorage, - theShape, - theParallel, - theOptions.Populate, - aParamLayer.get(), - aRegularityLayer.get(), - aTmpAlloc); - if (!theGraph.myData->myIncStorage.GetIsDone()) + if (theOptions.Flatten) { - theGraph.myData->myIncStorage.Clear(); + NCollection_DynamicArray aAppendedRoots(8, theGraph.Allocator()); + BRepGraphInc_Populate::AppendFlattened(aStorage, + theShape, + theOptions.Parallel, + aAppendedRoots, + theOptions.Populate, + aParamLayer.get(), + aRegularityLayer.get(), + aTmpAlloc); + if (theOutFlatRoots != nullptr) + { + for (const BRepGraph_NodeId& anId : aAppendedRoots) + theOutFlatRoots->Append(anId); + } + } + else + { + BRepGraphInc_Populate::Append(aStorage, + theShape, + theOptions.Parallel, + theOptions.Populate, + aParamLayer.get(), + aRegularityLayer.get(), + aTmpAlloc); + } + + if (!aStorage.GetIsDone()) return; - } - populateUIDs(theGraph); + theGraph.myData->myCurrentShapes.Clear(); - // Determine the top-level topology root node. - { - BRepGraphInc_Storage& aStorage = theGraph.myData->myIncStorage; - BRepGraph_NodeId aTopologyRoot; // default: invalid (Index = -1) - switch (theShape.ShapeType()) - { - case TopAbs_COMPOUND: - if (aStorage.NbCompounds() > 0) - aTopologyRoot = BRepGraph_CompoundId::Start(); - break; - case TopAbs_COMPSOLID: - if (aStorage.NbCompSolids() > 0) - aTopologyRoot = BRepGraph_CompSolidId::Start(); - break; - case TopAbs_SOLID: - if (aStorage.NbSolids() > 0) - aTopologyRoot = BRepGraph_SolidId::Start(); - break; - case TopAbs_SHELL: - if (aStorage.NbShells() > 0) - aTopologyRoot = BRepGraph_ShellId::Start(); - break; - case TopAbs_FACE: - if (aStorage.NbFaces() > 0) - aTopologyRoot = BRepGraph_FaceId::Start(); - break; - case TopAbs_WIRE: - if (aStorage.NbWires() > 0) - aTopologyRoot = BRepGraph_WireId::Start(); - break; - case TopAbs_EDGE: - if (aStorage.NbEdges() > 0) - aTopologyRoot = BRepGraph_EdgeId::Start(); - break; - case TopAbs_VERTEX: - if (aStorage.NbVertices() > 0) - aTopologyRoot = BRepGraph_VertexId::Start(); - break; - default: - break; - } - - // Auto-create a single root Product pointing to the top-level topology node - // via an occurrence. Skipped when CreateAutoProduct is false (e.g. XCAF builder - // manages Products itself). - if (theOptions.CreateAutoProduct) - { - const BRepGraph_ProductId aProductId = aStorage.AppendProduct(); - BRepGraphInc::ProductDef& aProduct = aStorage.ChangeProduct(aProductId); - theGraph.allocateUID(aProductId); - - // Link the product to its shape root via an occurrence + occurrence ref. - if (aTopologyRoot.IsValid()) - { - const BRepGraph_OccurrenceId anOccId = aStorage.AppendOccurrence(); - BRepGraphInc::OccurrenceDef& anOccDef = aStorage.ChangeOccurrence(anOccId); - anOccDef.ChildDefId = aTopologyRoot; - theGraph.allocateUID(anOccId); - - const BRepGraph_OccurrenceRefId anOccRefId = aStorage.AppendOccurrenceRef(); - BRepGraphInc::OccurrenceRef& anOccRef = aStorage.ChangeOccurrenceRef(anOccRefId); - anOccRef.ParentId = BRepGraph_NodeId(aProductId); - anOccRef.OccurrenceDefId = anOccId; - anOccRef.LocalLocation = theShape.Location(); - theGraph.allocateRefUID(anOccRefId); - aProduct.OccurrenceRefIds.Append(anOccRefId); - } - - theGraph.myData->myRootProductIds.Append(aProductId); - } - } + populateUIDsIncremental(theGraph, + anOldVtx, + anOldEdge, + anOldCoEdge, + anOldWire, + anOldFace, + anOldShell, + anOldSolid, + anOldComp, + anOldCS, + anOldProduct, + anOldOccurrence, + anOldShellRef, + anOldFaceRef, + anOldWireRef, + anOldCoEdgeRef, + anOldVertexRef, + anOldSolidRef, + anOldChildRef); theGraph.myData->myIsDone = true; + assertMutationBoundary(theGraph, "BRepGraph_Builder::Add: post-append mutation boundary"); +} + +//================================================================================================= + +BRepGraph_Builder::Result BRepGraph_Builder::Add(BRepGraph& theGraph, const TopoDS_Shape& theShape) +{ + return Add(theGraph, theShape, Options{}); +} + +//================================================================================================= + +BRepGraph_Builder::Result BRepGraph_Builder::Add(BRepGraph& theGraph, + const TopoDS_Shape& theShape, + const Options& theOptions) +{ + Result aResult; + if (theShape.IsNull()) + return aResult; + + const uint32_t anOldCount = snapshotCountForKind(theGraph, theShape.ShapeType()); + + NCollection_DynamicArray aFlatRoots; + appendImpl(theGraph, theShape, theOptions, theOptions.Flatten ? &aFlatRoots : nullptr); + + if (!theGraph.myData->myIncStorage.GetIsDone()) + return aResult; + + if (theOptions.Flatten && !aFlatRoots.IsEmpty()) + aResult.TopologyRoot = aFlatRoots.First(); + else + aResult.TopologyRoot = detectTopologyRoot(theGraph, theShape.ShapeType(), anOldCount); + + if (theOptions.CreateAutoProduct && aResult.TopologyRoot.IsValid()) + { + aResult.Product = + theGraph.Editor().Products().LinkProductToTopology(aResult.TopologyRoot, theShape.Location()); + if (aResult.Product.IsValid()) + { + const BRepGraphInc::ProductDef& aProductDef = + theGraph.myData->myIncStorage.Product(aResult.Product); + if (!aProductDef.OccurrenceRefIds.IsEmpty()) + { + const BRepGraph_OccurrenceRefId anOccRefId = aProductDef.OccurrenceRefIds.First(); + const BRepGraph_OccurrenceId anOccId = + theGraph.myData->myIncStorage.OccurrenceRef(anOccRefId).OccurrenceDefId; + aResult.Occurrence = anOccId; + } + } + } + // Pre-allocate transient cache for lock-free parallel access. - // Entity counts are now final - Reserve() sizes dense vectors so that - // Get()/Set() skip the mutex for in-range indices. { BRepGraphInc_Storage& aStorage = theGraph.myData->myIncStorage; int aCounts[BRepGraph_TransientCache::THE_KIND_COUNT] = {}; @@ -282,156 +320,139 @@ void BRepGraph_Builder::Perform(BRepGraph& theGraph, theGraph.myTransientCache.Reserve(aReservedKindCount, aCounts); } - assertMutationBoundary(theGraph, "Perform: post-build mutation boundary inconsistency"); + aResult.Ok = + aResult.TopologyRoot.IsValid() || (theOptions.CreateAutoProduct && aResult.Product.IsValid()); + return aResult; } //================================================================================================= -void BRepGraph_Builder::AppendFlattened(BRepGraph& theGraph, - const TopoDS_Shape& theShape, - const bool theParallel, - const BRepGraphInc_Populate::Options& theOptions) +BRepGraph_Builder::Result BRepGraph_Builder::Add(BRepGraph& theGraph, + const TopoDS_Shape& theShape, + const BRepGraph_NodeId theParent) { - if (theShape.IsNull()) - return; - - // Snapshot entity counts before append to allocate UIDs only for new entities. - BRepGraphInc_Storage& aStorage = theGraph.myData->myIncStorage; - const int anOldVtx = aStorage.NbVertices(); - const int anOldEdge = aStorage.NbEdges(); - const int anOldCoEdge = aStorage.NbCoEdges(); - const int anOldWire = aStorage.NbWires(); - const int anOldFace = aStorage.NbFaces(); - const int anOldShell = aStorage.NbShells(); - const int anOldSolid = aStorage.NbSolids(); - const int anOldComp = aStorage.NbCompounds(); - const int anOldCS = aStorage.NbCompSolids(); - const int anOldProduct = aStorage.NbProducts(); - const int anOldOccurrence = aStorage.NbOccurrences(); - const int anOldShellRef = aStorage.NbShellRefs(); - const int anOldFaceRef = aStorage.NbFaceRefs(); - const int anOldWireRef = aStorage.NbWireRefs(); - const int anOldCoEdgeRef = aStorage.NbCoEdgeRefs(); - const int anOldVertexRef = aStorage.NbVertexRefs(); - const int anOldSolidRef = aStorage.NbSolidRefs(); - const int anOldChildRef = aStorage.NbChildRefs(); - - occ::handle aTmpAlloc = new NCollection_IncAllocator; - const occ::handle aParamLayer = - theGraph.LayerRegistry().FindLayer(); - const occ::handle aRegularityLayer = - theGraph.LayerRegistry().FindLayer(); - NCollection_DynamicArray aAppendedRoots(8, theGraph.Allocator()); - BRepGraphInc_Populate::AppendFlattened(aStorage, - theShape, - theParallel, - aAppendedRoots, - theOptions, - aParamLayer.get(), - aRegularityLayer.get(), - aTmpAlloc); - - if (!aStorage.GetIsDone()) - return; - - theGraph.myData->myCurrentShapes.Clear(); - - populateUIDsIncremental(theGraph, - anOldVtx, - anOldEdge, - anOldCoEdge, - anOldWire, - anOldFace, - anOldShell, - anOldSolid, - anOldComp, - anOldCS, - anOldProduct, - anOldOccurrence, - anOldShellRef, - anOldFaceRef, - anOldWireRef, - anOldCoEdgeRef, - anOldVertexRef, - anOldSolidRef, - anOldChildRef); - - theGraph.myData->myIsDone = true; - - assertMutationBoundary(theGraph, "AppendFlattened: post-append mutation boundary inconsistency"); + return Add(theGraph, theShape, theParent, Options{}); } //================================================================================================= -void BRepGraph_Builder::AppendFull(BRepGraph& theGraph, - const TopoDS_Shape& theShape, - const bool theParallel, - const BRepGraphInc_Populate::Options& theOptions) +BRepGraph_Builder::Result BRepGraph_Builder::Add(BRepGraph& theGraph, + const TopoDS_Shape& theShape, + const BRepGraph_NodeId theParent, + const Options& theOptions) { - if (theShape.IsNull()) - return; + Result aResult; + if (theShape.IsNull() || !theParent.IsValid()) + return aResult; - BRepGraphInc_Storage& aStorage = theGraph.myData->myIncStorage; - const int anOldVtx = aStorage.NbVertices(); - const int anOldEdge = aStorage.NbEdges(); - const int anOldCoEdge = aStorage.NbCoEdges(); - const int anOldWire = aStorage.NbWires(); - const int anOldFace = aStorage.NbFaces(); - const int anOldShell = aStorage.NbShells(); - const int anOldSolid = aStorage.NbSolids(); - const int anOldComp = aStorage.NbCompounds(); - const int anOldCS = aStorage.NbCompSolids(); - const int anOldProduct = aStorage.NbProducts(); - const int anOldOccurrence = aStorage.NbOccurrences(); - const int anOldShellRef = aStorage.NbShellRefs(); - const int anOldFaceRef = aStorage.NbFaceRefs(); - const int anOldWireRef = aStorage.NbWireRefs(); - const int anOldCoEdgeRef = aStorage.NbCoEdgeRefs(); - const int anOldVertexRef = aStorage.NbVertexRefs(); - const int anOldSolidRef = aStorage.NbSolidRefs(); - const int anOldChildRef = aStorage.NbChildRefs(); + const uint32_t anOldCount = snapshotCountForKind(theGraph, theShape.ShapeType()); - occ::handle aTmpAlloc = new NCollection_IncAllocator; - const occ::handle aParamLayer = - theGraph.LayerRegistry().FindLayer(); - const occ::handle aRegularityLayer = - theGraph.LayerRegistry().FindLayer(); - BRepGraphInc_Populate::Append(aStorage, - theShape, - theParallel, - theOptions, - aParamLayer.get(), - aRegularityLayer.get(), - aTmpAlloc); + Options anInner = theOptions; + anInner.CreateAutoProduct = false; - if (!aStorage.GetIsDone()) - return; + NCollection_DynamicArray aFlatRoots; + appendImpl(theGraph, theShape, anInner, anInner.Flatten ? &aFlatRoots : nullptr); - theGraph.myData->myCurrentShapes.Clear(); + if (!theGraph.myData->myIncStorage.GetIsDone()) + return aResult; - populateUIDsIncremental(theGraph, - anOldVtx, - anOldEdge, - anOldCoEdge, - anOldWire, - anOldFace, - anOldShell, - anOldSolid, - anOldComp, - anOldCS, - anOldProduct, - anOldOccurrence, - anOldShellRef, - anOldFaceRef, - anOldWireRef, - anOldCoEdgeRef, - anOldVertexRef, - anOldSolidRef, - anOldChildRef); + if (anInner.Flatten && !aFlatRoots.IsEmpty()) + aResult.TopologyRoot = aFlatRoots.First(); + else + aResult.TopologyRoot = detectTopologyRoot(theGraph, theShape.ShapeType(), anOldCount); + if (!aResult.TopologyRoot.IsValid()) + return aResult; - theGraph.myData->myIsDone = true; + switch (theParent.NodeKind) + { + case BRepGraph_NodeId::Kind::Product: { + const BRepGraph_ProductId aChildProduct = + theGraph.Editor().Products().LinkProductToTopology(aResult.TopologyRoot, TopLoc_Location()); + if (!aChildProduct.IsValid()) + return aResult; - assertMutationBoundary(theGraph, "AppendFull: post-append mutation boundary inconsistency"); + const BRepGraph_OccurrenceId anOccId = + theGraph.Editor().Products().LinkProducts(BRepGraph_ProductId(theParent), + aChildProduct, + theShape.Location()); + if (!anOccId.IsValid()) + return aResult; + aResult.Product = aChildProduct; + aResult.Occurrence = anOccId; + aResult.Ok = true; + return aResult; + } + case BRepGraph_NodeId::Kind::Compound: { + const BRepGraph_ChildRefId aRid = + theGraph.Editor().Compounds().AddChild(BRepGraph_CompoundId(theParent), + aResult.TopologyRoot, + theShape.Orientation()); + if (!aRid.IsValid()) + return aResult; + aResult.InsertedRef = BRepGraph_RefId(aRid); + aResult.Ok = true; + return aResult; + } + case BRepGraph_NodeId::Kind::Shell: { + const BRepGraph_ShellId aShell(theParent); + if (aResult.TopologyRoot.NodeKind == BRepGraph_NodeId::Kind::Face) + { + const BRepGraph_FaceRefId aRid = + theGraph.Editor().Shells().AddFace(aShell, + BRepGraph_FaceId(aResult.TopologyRoot), + theShape.Orientation()); + if (!aRid.IsValid()) + return aResult; + aResult.InsertedRef = BRepGraph_RefId(aRid); + aResult.Ok = true; + return aResult; + } + const BRepGraph_ChildRefId aRid = + theGraph.Editor().Shells().AddChild(aShell, aResult.TopologyRoot, theShape.Orientation()); + if (!aRid.IsValid()) + return aResult; + aResult.InsertedRef = BRepGraph_RefId(aRid); + aResult.Ok = true; + return aResult; + } + case BRepGraph_NodeId::Kind::Solid: { + const BRepGraph_SolidId aSolid(theParent); + if (aResult.TopologyRoot.NodeKind == BRepGraph_NodeId::Kind::Shell) + { + const BRepGraph_ShellRefId aRid = + theGraph.Editor().Solids().AddShell(aSolid, + BRepGraph_ShellId(aResult.TopologyRoot), + theShape.Orientation()); + if (!aRid.IsValid()) + return aResult; + aResult.InsertedRef = BRepGraph_RefId(aRid); + aResult.Ok = true; + return aResult; + } + const BRepGraph_ChildRefId aRid = + theGraph.Editor().Solids().AddChild(aSolid, aResult.TopologyRoot, theShape.Orientation()); + if (!aRid.IsValid()) + return aResult; + aResult.InsertedRef = BRepGraph_RefId(aRid); + aResult.Ok = true; + return aResult; + } + case BRepGraph_NodeId::Kind::CompSolid: { + if (aResult.TopologyRoot.NodeKind != BRepGraph_NodeId::Kind::Solid) + return aResult; + const BRepGraph_SolidRefId aRid = + theGraph.Editor().CompSolids().AddSolid(BRepGraph_CompSolidId(theParent), + BRepGraph_SolidId(aResult.TopologyRoot), + theShape.Orientation()); + if (!aRid.IsValid()) + return aResult; + aResult.InsertedRef = BRepGraph_RefId(aRid); + aResult.Ok = true; + return aResult; + } + default: + return aResult; + } } //================================================================================================= diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Builder.hxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Builder.hxx index 516f6e816d..a011053a6c 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Builder.hxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Builder.hxx @@ -15,87 +15,98 @@ #define _BRepGraph_Builder_HeaderFile #include +#include +#include +#include #include +#include +#include class BRepGraph; class TopoDS_Shape; -//! @brief Static helper that populates a BRepGraph from a TopoDS_Shape. -//! -//! BRepGraph_Builder extracts the build logic out of BRepGraph itself, -//! keeping the graph class focused on queries and mutation. -//! It is declared as a friend of BRepGraph to access private storage. +//! @brief Static helper that ingests a TopoDS_Shape into a BRepGraph. class BRepGraph_Builder { public: DEFINE_STANDARD_ALLOC - //! Build-time options owned by BRepGraph_Builder. - struct BuildOptions + //! Build-time options. + struct Options { - //! Backend extraction passes executed during shape population. - BRepGraphInc_Populate::Options Populate; - - //! Auto-create a root Product wrapping the imported top-level topology. - //! Disable this when a higher-level builder manages Product creation. - bool CreateAutoProduct; - - BuildOptions() - : Populate(), - CreateAutoProduct(true) - { - } + BRepGraphInc_Populate::Options Populate{}; + bool CreateAutoProduct = true; //!< wrap topology root in a Product (unparented Add only) + bool Flatten = false; //!< drop hierarchy containers, append faces as roots + bool Parallel = false; //!< run face-level construction in parallel }; - //! Build the full graph from a TopoDS_Shape (clears existing data first). + //! Outcome of a single Add() call. + struct Result + { + BRepGraph_NodeId TopologyRoot; + BRepGraph_ProductId Product; + BRepGraph_OccurrenceId Occurrence; + BRepGraph_RefId InsertedRef; + bool Ok = false; + }; + + //! Ingest a TopoDS_Shape as a new root subgraph, wrapping the topology root in a Product. + //! @param[in,out] theGraph graph to populate + //! @param[in] theShape shape to ingest + //! @return Result with TopologyRoot, Product and Occurrence set on success. + [[nodiscard]] static Standard_EXPORT Result Add(BRepGraph& theGraph, + const TopoDS_Shape& theShape); + + //! Ingest a TopoDS_Shape as a new root subgraph with explicit options. //! @param[in,out] theGraph graph to populate - //! @param[in] theShape root shape - //! @param[in] theParallel if true, face-level construction runs in parallel - static Standard_EXPORT void Perform(BRepGraph& theGraph, - const TopoDS_Shape& theShape, - const bool theParallel = false); + //! @param[in] theShape shape to ingest + //! @param[in] theOptions build-time options + //! @return Result with TopologyRoot set on success; Product/Occurrence set + //! when theOptions.CreateAutoProduct is true. + [[nodiscard]] static Standard_EXPORT Result Add(BRepGraph& theGraph, + const TopoDS_Shape& theShape, + const Options& theOptions); - //! Build the full graph with explicit post-pass control. - static Standard_EXPORT void Perform(BRepGraph& theGraph, - const TopoDS_Shape& theShape, - const bool theParallel, - const BuildOptions& theOptions); + //! Ingest a TopoDS_Shape under an existing parent. + //! + //! Parent kind dispatch: + //! - Product: creates a child part-product, links via Occurrence with shape.Location(). + //! - Compound: appends topology root as a child reference. + //! - Shell: appends a Face as a FaceRef; other shapes via AddChild. + //! - Solid: appends a Shell as a ShellRef; other shapes via AddChild. + //! - CompSolid: appends a Solid as a SolidRef. + //! Other parent kinds yield an invalid Result. + //! @param[in,out] theGraph graph to populate + //! @param[in] theShape shape to ingest + //! @param[in] theParent parent node receiving the topology + //! @return Result with TopologyRoot set, plus (Product, Occurrence) for Product parents + //! or InsertedRef for topology container parents. + [[nodiscard]] static Standard_EXPORT Result Add(BRepGraph& theGraph, + const TopoDS_Shape& theShape, + const BRepGraph_NodeId theParent); - //! Append a shape to the existing graph without clearing. - //! Flattens hierarchy containers away. Solid/Shell/Compound/CompSolid inputs - //! append their contained faces as roots instead of adding container nodes. - //! Uses existing deduplication maps to avoid re-registering shared entities. - //! @param[in,out] theGraph graph to extend - //! @param[in] theShape shape to add - //! @param[in] theParallel if true, per-face geometry extraction is parallel - //! @param[in] theOptions backend extraction options - static Standard_EXPORT void AppendFlattened( - BRepGraph& theGraph, - const TopoDS_Shape& theShape, - const bool theParallel, - const BRepGraphInc_Populate::Options& theOptions = BRepGraphInc_Populate::Options()); - - //! Append a shape to the existing graph without clearing. - //! Preserves the full shape hierarchy: Solid/Shell/Compound/CompSolid nodes - //! are created alongside Face/Edge/Vertex nodes. Shapes already present in - //! the graph (same TShape pointer) are deduplicated and not re-added. - //! @param[in,out] theGraph graph to extend - //! @param[in] theShape shape to add - //! @param[in] theParallel if true, per-face geometry extraction is parallel - //! @param[in] theOptions backend extraction options - static Standard_EXPORT void AppendFull( - BRepGraph& theGraph, - const TopoDS_Shape& theShape, - const bool theParallel, - const BRepGraphInc_Populate::Options& theOptions = BRepGraphInc_Populate::Options()); + //! Ingest a shape under an existing parent with explicit options. + //! Options::CreateAutoProduct is ignored. + [[nodiscard]] static Standard_EXPORT Result Add(BRepGraph& theGraph, + const TopoDS_Shape& theShape, + const BRepGraph_NodeId theParent, + const Options& theOptions); private: - //! Allocate UIDs for all incidence entities after BRepGraphInc_Populate - //! has filled the storage. + static void appendImpl(BRepGraph& theGraph, + const TopoDS_Shape& theShape, + const Options& theOptions, + NCollection_DynamicArray* theOutFlatRoots = nullptr); + + static BRepGraph_NodeId detectTopologyRoot(const BRepGraph& theGraph, + const TopAbs_ShapeEnum theShapeType, + const uint32_t theOldCountOfShapeKind); + + static uint32_t snapshotCountForKind(const BRepGraph& theGraph, + const TopAbs_ShapeEnum theShapeType); + static void populateUIDs(BRepGraph& theGraph); - //! Allocate UIDs only for entities in range [theOld, current) per kind. - //! Used by AppendFlattened() to avoid re-walking existing entities. static void populateUIDsIncremental(BRepGraph& theGraph, const int theOldVtx, const int theOldEdge, diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Compact.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Compact.cxx index 9ab6d46aeb..eca0a86750 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Compact.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Compact.cxx @@ -937,13 +937,31 @@ BRepGraph_Compact::Result BRepGraph_Compact::Perform(BRepGraph& theGraph, const const BRepGraph_NodeId aNewShapeRoot = remapId(anOldShapeRoot); if (aNewShapeRoot.IsValid()) { - aNewProductId = aNewGraph.Editor().Products().Add(aNewShapeRoot); + // Find the old part-root occurrence ref to preserve its placement. + TopLoc_Location anOldRootLoc; + for (const BRepGraph_OccurrenceRefId& anOldOccRefId : anOldProduct.OccurrenceRefIds) + { + const BRepGraphInc::OccurrenceRef& anOldOccRef = + theGraph.Refs().Occurrences().Entry(anOldOccRefId); + if (anOldOccRef.IsRemoved) + continue; + const BRepGraphInc::OccurrenceDef& anOldOccDef = + theGraph.Topo().Occurrences().Definition(anOldOccRef.OccurrenceDefId); + if (!anOldOccDef.IsRemoved && anOldOccDef.ChildDefId.IsValid() + && BRepGraph_NodeId::IsTopologyKind(anOldOccDef.ChildDefId.NodeKind)) + { + anOldRootLoc = anOldOccRef.LocalLocation; + break; + } + } + aNewProductId = + aNewGraph.Editor().Products().LinkProductToTopology(aNewShapeRoot, anOldRootLoc); } } if (!aNewProductId.IsValid()) { - aNewProductId = aNewGraph.Editor().Products().AddAssembly(); + aNewProductId = aNewGraph.Editor().Products().CreateEmptyProduct(); } if (!aNewProductId.IsValid()) @@ -1059,9 +1077,9 @@ BRepGraph_Compact::Result BRepGraph_Compact::Perform(BRepGraph& theGraph, const } const BRepGraph_OccurrenceId aNewOccId = - aNewGraph.Editor().Products().AddOccurrence(*aNewParentId, - *aNewChildId, - anOldOccRef.LocalLocation); + aNewGraph.Editor().Products().LinkProducts(*aNewParentId, + *aNewChildId, + anOldOccRef.LocalLocation); if (aNewOccId.IsValid()) { @@ -1222,8 +1240,6 @@ BRepGraph_Compact::Result BRepGraph_Compact::Perform(BRepGraph& theGraph, const aGraphData->myNextUIDCounter.load(std::memory_order_relaxed), std::memory_order_relaxed); // Preserve graph generation so transferred UIDs remain valid after compaction. - // Compact rewrites ids and clears caches explicitly; it is not a new BRepGraph_Builder::Perform() - // cycle. aNewGraphData->myGeneration.store(aGraphData->myGeneration.load(std::memory_order_relaxed), std::memory_order_relaxed); aNewGraphData->myIsDone = true; @@ -1231,11 +1247,7 @@ BRepGraph_Compact::Result BRepGraph_Compact::Perform(BRepGraph& theGraph, const // Save layers before swap (default move would transfer empty layers from aNewGraph). BRepGraph_LayerRegistry aSavedLayerRegistry = std::move(theGraph.layerRegistry()); - // Save TShape-to-NodeId and NodeId-to-OriginalShape bindings before swap. - // These maps are populated by BRepGraphInc_Populate during BRepGraph_Builder::Perform() with - // TopoDS_Shape data. The rebuilt aNewGraph has no TopoDS_Shape bindings, so they must be - // transferred here. We capture into local vectors using the ForEach API, then remap keys/values - // after the swap. + // Transfer TShape-to-NodeId and NodeId-to-OriginalShape bindings: the rebuilt graph has none. NCollection_DynamicArray> aTShapeBindings; NCollection_DynamicArray> aOriginalBindings; aGraphData->myIncStorage.ForEachTShapeBinding( diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Copy.hxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Copy.hxx index 005574b78c..27173afbaf 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Copy.hxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Copy.hxx @@ -36,7 +36,7 @@ //! ## Typical usage //! @code //! BRepGraph aGraph; -//! BRepGraph_Builder::Perform(aGraph, myShape); +//! BRepGraph_Builder::Add(aGraph, myShape); //! BRepGraph aCopy = BRepGraph_Copy::Perform(aGraph); //! TopoDS_Shape aShape = aCopy.Shapes().Shape(); //! @endcode diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Data.hxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Data.hxx index cfef3442f5..c4105fb897 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Data.hxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Data.hxx @@ -61,7 +61,7 @@ struct BRepGraph_Data std::atomic myNextUIDCounter{ 1}; //!< Starts at 1; counter=0 is BRepGraph_UID invalid sentinel. std::atomic myGeneration{0}; - Standard_GUID myGraphGUID; //!< Random graph identity, generated at BRepGraph_Builder::Perform(). + Standard_GUID myGraphGUID; //!< Random graph identity, generated at BRepGraph_Builder::Add(). //! History subsystem. BRepGraph_History myHistoryLog; diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_EditorView.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_EditorView.cxx index a6c4c17206..40b709a0f7 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_EditorView.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_EditorView.cxx @@ -942,6 +942,42 @@ BRepGraph_CompoundId BRepGraph::EditorView::CompoundOps::Add( //================================================================================================= +BRepGraph_ChildRefId BRepGraph::EditorView::CompoundOps::AddChild( + const BRepGraph_CompoundId theCompoundEntity, + const BRepGraph_NodeId theChildEntity, + const TopAbs_Orientation theOri) +{ + BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; + if (!isActiveNode(aStorage, theCompoundEntity) || !isActiveTopologyNode(aStorage, theChildEntity)) + { + return BRepGraph_ChildRefId(); + } + + const uint32_t anOldNbChildRefs = static_cast(aStorage.NbChildRefs()); + const BRepGraph_ChildRefId aChildRefId(aStorage.NbChildRefs()); + aStorage.AppendChildRef(); + BRepGraphInc::ChildRef& aChildRef = aStorage.ChangeChildRef(aChildRefId); + aChildRef.ParentId = theCompoundEntity; + aChildRef.ChildDefId = theChildEntity; + aChildRef.Orientation = theOri; + myGraph->allocateRefUID(aChildRefId); + aStorage.ChangeCompound(theCompoundEntity).ChildRefIds.Append(aChildRefId); + + aStorage.BuildDeltaReverseIndex(static_cast(aStorage.NbEdges()), + static_cast(aStorage.NbWires()), + static_cast(aStorage.NbFaces()), + static_cast(aStorage.NbShells()), + static_cast(aStorage.NbSolids()), + static_cast(aStorage.NbCompounds()), + static_cast(aStorage.NbCompSolids()), + anOldNbChildRefs, + static_cast(aStorage.NbSolidRefs())); + myGraph->markModified(theCompoundEntity); + return aChildRefId; +} + +//================================================================================================= + BRepGraph_CompSolidId BRepGraph::EditorView::CompSolidOps::Add( const NCollection_DynamicArray& theSolidEntities) { @@ -975,7 +1011,45 @@ BRepGraph_CompSolidId BRepGraph::EditorView::CompSolidOps::Add( //================================================================================================= -BRepGraph_ProductId BRepGraph::EditorView::ProductOps::Add(const BRepGraph_NodeId theShapeRoot) +BRepGraph_SolidRefId BRepGraph::EditorView::CompSolidOps::AddSolid( + const BRepGraph_CompSolidId theCompSolidEntity, + const BRepGraph_SolidId theSolidEntity, + const TopAbs_Orientation theOri) +{ + BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; + if (!isActiveNode(aStorage, theCompSolidEntity) || !isActiveNode(aStorage, theSolidEntity)) + { + return BRepGraph_SolidRefId(); + } + + const uint32_t anOldNbSolidRefs = static_cast(aStorage.NbSolidRefs()); + const BRepGraph_SolidRefId aSolidRefId(aStorage.NbSolidRefs()); + aStorage.AppendSolidRef(); + BRepGraphInc::SolidRef& aSREntry = aStorage.ChangeSolidRef(aSolidRefId); + aSREntry.ParentId = theCompSolidEntity; + aSREntry.SolidDefId = theSolidEntity; + aSREntry.Orientation = theOri; + myGraph->allocateRefUID(aSolidRefId); + aStorage.ChangeCompSolid(theCompSolidEntity).SolidRefIds.Append(aSolidRefId); + + aStorage.BuildDeltaReverseIndex(static_cast(aStorage.NbEdges()), + static_cast(aStorage.NbWires()), + static_cast(aStorage.NbFaces()), + static_cast(aStorage.NbShells()), + static_cast(aStorage.NbSolids()), + static_cast(aStorage.NbCompounds()), + static_cast(aStorage.NbCompSolids()), + static_cast(aStorage.NbChildRefs()), + anOldNbSolidRefs); + myGraph->markModified(theCompSolidEntity); + return aSolidRefId; +} + +//================================================================================================= + +BRepGraph_ProductId BRepGraph::EditorView::ProductOps::LinkProductToTopology( + const BRepGraph_NodeId theShapeRoot, + const TopLoc_Location& thePlacement) { BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; if (!isActiveTopologyNode(aStorage, theShapeRoot)) @@ -994,7 +1068,7 @@ BRepGraph_ProductId BRepGraph::EditorView::ProductOps::Add(const BRepGraph_NodeI BRepGraphInc::OccurrenceDef& anOccDef = aStorage.ChangeOccurrence(anOccId); anOccDef.ChildDefId = theShapeRoot; Standard_ASSERT_RETURN(isValidOccurrenceChildKind(anOccDef.ChildDefId.NodeKind), - "ProductOps::Add: invalid occurrence child kind", + "ProductOps::LinkProductToTopology: invalid occurrence child kind", BRepGraph_ProductId()); myGraph->allocateUID(anOccId); @@ -1003,6 +1077,7 @@ BRepGraph_ProductId BRepGraph::EditorView::ProductOps::Add(const BRepGraph_NodeI BRepGraphInc::OccurrenceRef& anOccRef = aStorage.ChangeOccurrenceRef(anOccRefId); anOccRef.ParentId = aProductId; anOccRef.OccurrenceDefId = anOccId; + anOccRef.LocalLocation = thePlacement; myGraph->allocateRefUID(anOccRefId); aProductDef.OccurrenceRefIds.Append(anOccRefId); @@ -1014,7 +1089,7 @@ BRepGraph_ProductId BRepGraph::EditorView::ProductOps::Add(const BRepGraph_NodeI //================================================================================================= -BRepGraph_ProductId BRepGraph::EditorView::ProductOps::AddAssembly() +BRepGraph_ProductId BRepGraph::EditorView::ProductOps::CreateEmptyProduct() { BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; const BRepGraph_ProductId aProductId(aStorage.NbProducts()); @@ -1028,21 +1103,20 @@ BRepGraph_ProductId BRepGraph::EditorView::ProductOps::AddAssembly() //================================================================================================= -BRepGraph_OccurrenceId BRepGraph::EditorView::ProductOps::AddOccurrence( +BRepGraph_OccurrenceId BRepGraph::EditorView::ProductOps::LinkProducts( const BRepGraph_ProductId theParentProduct, const BRepGraph_ProductId theReferencedProduct, const TopLoc_Location& thePlacement) { - // Delegate with no parent occurrence (top-level). - return AddOccurrence(theParentProduct, - theReferencedProduct, - thePlacement, - BRepGraph_OccurrenceId()); + return LinkProducts(theParentProduct, + theReferencedProduct, + thePlacement, + BRepGraph_OccurrenceId()); } //================================================================================================= -BRepGraph_OccurrenceId BRepGraph::EditorView::ProductOps::AddOccurrence( +BRepGraph_OccurrenceId BRepGraph::EditorView::ProductOps::LinkProducts( const BRepGraph_ProductId theParentProduct, const BRepGraph_ProductId theReferencedProduct, const TopLoc_Location& thePlacement, @@ -1072,7 +1146,7 @@ BRepGraph_OccurrenceId BRepGraph::EditorView::ProductOps::AddOccurrence( BRepGraphInc::OccurrenceDef& anOccDef = aStorage.ChangeOccurrence(anOccId); anOccDef.ChildDefId = theReferencedProduct; Standard_ASSERT_RETURN(isValidOccurrenceChildKind(anOccDef.ChildDefId.NodeKind), - "ProductOps::AddOccurrence: invalid occurrence child kind", + "ProductOps::LinkProducts: invalid occurrence child kind", BRepGraph_OccurrenceId()); myGraph->allocateUID(anOccId); @@ -1099,24 +1173,6 @@ BRepGraph_OccurrenceId BRepGraph::EditorView::ProductOps::AddOccurrence( //================================================================================================= -void BRepGraph::EditorView::AppendFlattenedShape(const TopoDS_Shape& theShape, - const bool theParallel, - const BRepGraphInc_Populate::Options& theOptions) -{ - BRepGraph_Builder::AppendFlattened(*myGraph, theShape, theParallel, theOptions); -} - -//================================================================================================= - -void BRepGraph::EditorView::AppendFullShape(const TopoDS_Shape& theShape, - const bool theParallel, - const BRepGraphInc_Populate::Options& theOptions) -{ - BRepGraph_Builder::AppendFull(*myGraph, theShape, theParallel, theOptions); -} - -//================================================================================================= - void BRepGraph::EditorView::GenOps::RemoveNode(const BRepGraph_NodeId theNode) { RemoveNode(theNode, BRepGraph_NodeId()); @@ -2233,8 +2289,6 @@ void BRepGraph::EditorView::WireOps::ReplaceEdge(const BRepGraph_WireId theWireD aRevIdx.BindEdgeToCoEdge(theNewEdgeEntity, aCoEdgeDefId); // Update edge-to-face: bind new edge, unbind old edge for all faces of this wire. - // Wire-to-face mappings are built from FaceDef.WireRefs during BRepGraph_Builder::Perform() - // and are stable across edge mutations - only face-level operations modify them. const NCollection_DynamicArray* aFaces = aRevIdx.FacesOfWire(theWireDefId); if (aFaces != nullptr) { diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_EditorView.hxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_EditorView.hxx index 4e229b4d48..671a3693ab 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_EditorView.hxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_EditorView.hxx @@ -38,8 +38,8 @@ class Geom2d_Curve; //! ProductOps, GenOps) to create topology definition nodes (vertices, edges, wires, //! faces, shells, solids, compounds) and assembly nodes (products, occurrences) //! without an existing TopoDS_Shape. -//! - Field-level RAII-scoped mutation via Mut*() guards (MutEdge, MutFace, MutCoEdge, -//! MutProduct, MutOccurrence, MutSurface, etc.) with automatic cache invalidation +//! - Field-level RAII-scoped mutation via Mut*() guards (Edges().Mut, Faces().Mut, +//! Products().Mut, Occurrences().Mut, Reps().MutSurface, etc.) with automatic cache invalidation //! and upward SubtreeGen propagation on guard destruction. //! - Incremental shape appending, soft-deletion of nodes, and deferred invalidation //! mode for batched structural edit loops under external serialization. @@ -547,6 +547,16 @@ public: [[nodiscard]] Standard_EXPORT BRepGraph_CompoundId Add(const NCollection_DynamicArray& theChildEntities); + //! Append a single child to an existing compound definition. + //! @param[in] theCompoundEntity typed compound definition identifier + //! @param[in] theChildEntity typed child topology definition identifier + //! @param[in] theOri orientation of the child in the compound + //! @return typed child reference identifier, or invalid if inputs are not active + [[nodiscard]] Standard_EXPORT BRepGraph_ChildRefId + AddChild(const BRepGraph_CompoundId theCompoundEntity, + const BRepGraph_NodeId theChildEntity, + const TopAbs_Orientation theOri = TopAbs_FORWARD); + //! Detach one exact child ref from a compound definition. //! Use BRepGraph_RefsChildOfParent::CurrentId() when removing from a compound //! iterator. The method removes the exact ChildRef entry, erases it from the @@ -583,6 +593,16 @@ public: [[nodiscard]] Standard_EXPORT BRepGraph_CompSolidId Add(const NCollection_DynamicArray& theSolidEntities); + //! Append a single solid to an existing compsolid definition. + //! @param[in] theCompSolidEntity typed compsolid definition identifier + //! @param[in] theSolidEntity typed solid definition identifier + //! @param[in] theOri orientation of the solid in the compsolid + //! @return typed solid reference identifier, or invalid if inputs are not active + [[nodiscard]] Standard_EXPORT BRepGraph_SolidRefId + AddSolid(const BRepGraph_CompSolidId theCompSolidEntity, + const BRepGraph_SolidId theSolidEntity, + const TopAbs_Orientation theOri = TopAbs_FORWARD); + //! Detach one exact solid ref from a compsolid definition. //! Use BRepGraph_RefsSolidOfCompSolid::CurrentId() when removing from a //! compsolid iterator. The method removes the exact SolidRef entry, erases it @@ -609,50 +629,47 @@ public: BRepGraph* myGraph; }; - //! @brief Product and assembly creation and editing operations. + //! @brief Product and assembly low-level reconstruction primitives. + //! Wire two existing entities together; for shape ingestion use BRepGraph_Builder::Add(). class ProductOps { public: - //! Add a part product with a root shape node. + //! Create a Product wrapping an existing topology root via an Occurrence. //! @param[in] theShapeRoot root topology NodeId for the part + //! @param[in] thePlacement local placement stored on the root OccurrenceRef //! @return typed product definition identifier, or invalid if the root is //! not an active topology definition node - [[nodiscard]] Standard_EXPORT BRepGraph_ProductId Add(const BRepGraph_NodeId theShapeRoot); + [[nodiscard]] Standard_EXPORT BRepGraph_ProductId + LinkProductToTopology(const BRepGraph_NodeId theShapeRoot, + const TopLoc_Location& thePlacement = TopLoc_Location()); - //! Add a product without a direct shape root. - //! It can later own child occurrences and may itself be referenced by an - //! occurrence like any other product. + //! Create a Product with no direct shape root; can later own child occurrences. //! @return typed product definition identifier - [[nodiscard]] Standard_EXPORT BRepGraph_ProductId AddAssembly(); + [[nodiscard]] Standard_EXPORT BRepGraph_ProductId CreateEmptyProduct(); - //! Add an occurrence linking a parent product to a referenced (child) product. - //! ParentOccurrenceIdx is set to -1 (top-level). + //! Link two existing Products via a fresh top-level Occurrence. //! @param[in] theParentProduct typed parent product identifier //! @param[in] theReferencedProduct typed child product identifier being instantiated //! @param[in] thePlacement local placement relative to parent //! @return typed occurrence definition identifier, or invalid unless the - //! parent is an active product with no direct shape root and the - //! referenced product is active + //! parent and referenced products are both active and not equal [[nodiscard]] Standard_EXPORT BRepGraph_OccurrenceId - AddOccurrence(const BRepGraph_ProductId theParentProduct, - const BRepGraph_ProductId theReferencedProduct, - const TopLoc_Location& thePlacement); + LinkProducts(const BRepGraph_ProductId theParentProduct, + const BRepGraph_ProductId theReferencedProduct, + const TopLoc_Location& thePlacement); - //! Add an occurrence with an explicit parent occurrence for nested assembly chains. - //! This establishes a tree-structured placement path for unambiguous - //! GlobalLocation() / GlobalOrientation() computation even when products are shared (DAG). + //! Link two existing Products via a fresh Occurrence inside an explicit parent occurrence + //! (for nested assembly chains with unambiguous GlobalLocation in DAGs). //! @param[in] theParentProduct typed parent product identifier //! @param[in] theReferencedProduct typed child product identifier being instantiated //! @param[in] thePlacement local placement relative to parent //! @param[in] theParentOccurrence typed occurrence that placed the parent product - //! @return typed occurrence definition identifier, or invalid unless the - //! parent product, referenced product, and explicit parent occurrence - //! form a valid active assembly chain + //! @return typed occurrence definition identifier, or invalid unless the chain is active [[nodiscard]] Standard_EXPORT BRepGraph_OccurrenceId - AddOccurrence(const BRepGraph_ProductId theParentProduct, - const BRepGraph_ProductId theReferencedProduct, - const TopLoc_Location& thePlacement, - const BRepGraph_OccurrenceId theParentOccurrence); + LinkProducts(const BRepGraph_ProductId theParentProduct, + const BRepGraph_ProductId theReferencedProduct, + const TopLoc_Location& thePlacement, + const BRepGraph_OccurrenceId theParentOccurrence); //! Detach one exact occurrence ref from a product definition. //! Use BRepGraph_RefsOccurrenceOfProduct::CurrentId() when removing from a @@ -679,20 +696,33 @@ public: [[nodiscard]] Standard_EXPORT BRepGraph_MutGuard Mut( const BRepGraph_ProductId theProduct); - //! Return scoped mutable occurrence definition guard. (Occurrences live under - //! products and their lifecycle is co-located with `AddOccurrence` / - //! `RemoveOccurrence`, hence the Mut accessor is on ProductOps.) - [[nodiscard]] Standard_EXPORT BRepGraph_MutGuard MutOccurrence( + private: + friend class EditorView; + + explicit ProductOps(BRepGraph* theGraph) + : myGraph(theGraph) + { + } + + BRepGraph* myGraph; + }; + + //! @brief Occurrence mutation operations. + class OccurrenceOps + { + public: + //! Return scoped mutable occurrence definition guard. + [[nodiscard]] Standard_EXPORT BRepGraph_MutGuard Mut( const BRepGraph_OccurrenceId theOccurrence); //! Return scoped mutable occurrence reference guard. - [[nodiscard]] Standard_EXPORT BRepGraph_MutGuard MutOccurrenceRef( + [[nodiscard]] Standard_EXPORT BRepGraph_MutGuard MutRef( const BRepGraph_OccurrenceRefId theOccurrenceRef); private: friend class EditorView; - explicit ProductOps(BRepGraph* theGraph) + explicit OccurrenceOps(BRepGraph* theGraph) : myGraph(theGraph) { } @@ -819,33 +849,15 @@ public: //! Return product and assembly creation and editing operations. [[nodiscard]] ProductOps& Products() { return myProductOps; } + //! Return occurrence mutation operations. + [[nodiscard]] OccurrenceOps& Occurrences() { return myOccurrenceOps; } + //! Return generic node, reference, and representation removal operations. [[nodiscard]] GenOps& Gen() { return myGenOps; } //! Return representation (surface, curve, triangulation, polygon) mutation operations. [[nodiscard]] RepOps& Reps() { return myRepOps; } - //! Append a shape to the existing graph without clearing. - //! Compound/CompSolid/Solid/Shell inputs are flattened to appended face roots. - //! @param[in] theShape shape to add - //! @param[in] theParallel if true, per-face geometry extraction is parallel - //! @param[in] theOptions backend extraction options - Standard_EXPORT void AppendFlattenedShape( - const TopoDS_Shape& theShape, - const bool theParallel = false, - const BRepGraphInc_Populate::Options& theOptions = BRepGraphInc_Populate::Options()); - - //! Append a shape to the graph preserving the full topology hierarchy. - //! Solid/Shell/Compound/CompSolid nodes are created alongside Face/Edge/Vertex nodes. - //! Shapes already in the graph (same TShape pointer) are deduplicated. - //! @param[in] theShape shape to add - //! @param[in] theParallel if true, per-face geometry extraction is parallel - //! @param[in] theOptions backend extraction options - Standard_EXPORT void AppendFullShape( - const TopoDS_Shape& theShape, - const bool theParallel = false, - const BRepGraphInc_Populate::Options& theOptions = BRepGraphInc_Populate::Options()); - //! Begin deferred invalidation mode. //! While active, markModified() only increments OwnGen + SubtreeGen and //! appends to the deferred list - without acquiring the shape-cache mutex @@ -907,24 +919,26 @@ private: myCompoundOps(theGraph), myCompSolidOps(theGraph), myProductOps(theGraph), + myOccurrenceOps(theGraph), myGenOps(theGraph), myRepOps(theGraph) { } - BRepGraph* myGraph; - VertexOps myVertexOps; - EdgeOps myEdgeOps; - CoEdgeOps myCoEdgeOps; - WireOps myWireOps; - FaceOps myFaceOps; - ShellOps myShellOps; - SolidOps mySolidOps; - CompoundOps myCompoundOps; - CompSolidOps myCompSolidOps; - ProductOps myProductOps; - GenOps myGenOps; - RepOps myRepOps; + BRepGraph* myGraph; + VertexOps myVertexOps; + EdgeOps myEdgeOps; + CoEdgeOps myCoEdgeOps; + WireOps myWireOps; + FaceOps myFaceOps; + ShellOps myShellOps; + SolidOps mySolidOps; + CompoundOps myCompoundOps; + CompSolidOps myCompSolidOps; + ProductOps myProductOps; + OccurrenceOps myOccurrenceOps; + GenOps myGenOps; + RepOps myRepOps; }; #endif // _BRepGraph_EditorView_HeaderFile diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_EditorView_Mut.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_EditorView_Mut.cxx index 551d8bdb34..0007874174 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_EditorView_Mut.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_EditorView_Mut.cxx @@ -378,7 +378,7 @@ BRepGraph_MutGuard BRepGraph::EditorView::ProductOps:: //================================================================================================== -BRepGraph_MutGuard BRepGraph::EditorView::ProductOps::MutOccurrence( +BRepGraph_MutGuard BRepGraph::EditorView::OccurrenceOps::Mut( const BRepGraph_OccurrenceId theOccurrence) { BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; @@ -474,7 +474,7 @@ BRepGraph_MutGuard BRepGraph::EditorView::GenOps::MutChi //================================================================================================== -BRepGraph_MutGuard BRepGraph::EditorView::ProductOps::MutOccurrenceRef( +BRepGraph_MutGuard BRepGraph::EditorView::OccurrenceOps::MutRef( const BRepGraph_OccurrenceRefId theOccurrenceRef) { BRepGraphInc_Storage& aStorage = myGraph->myData->myIncStorage; diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_RefTransientCache.hxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_RefTransientCache.hxx index a1112284d6..d887281068 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_RefTransientCache.hxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_RefTransientCache.hxx @@ -36,7 +36,7 @@ //! differs from the reference's current OwnGen the cached value is considered stale. //! //! ## Lifecycle -//! NOT a Layer. Cleared on BRepGraph_Builder::Perform() and Compact(). No explicit removal callback +//! NOT a Layer. Cleared on BRepGraph_Builder::Add() and Compact(). No explicit removal callback //! - stale data is auto-detected by OwnGen mismatch. //! //! ## Thread safety @@ -48,7 +48,7 @@ public: //! Number of BRepGraph_RefId::Kind enum values (Shell..Occurrence = 0..7). static constexpr int THE_REF_KIND_COUNT = 8; - //! Default number of cache-kind slots reserved after BRepGraph_Builder::Perform(). + //! Default number of cache-kind slots reserved after BRepGraph_Builder::Add(). static constexpr int THE_DEFAULT_RESERVED_KIND_COUNT = 16; //! Per-slot storage: cached value handle + OwnGen stamp. @@ -114,7 +114,7 @@ public: return myIsReserved.load(std::memory_order_acquire); } - //! Clear all cached data. Called on BRepGraph_Builder::Perform() and Compact(). + //! Clear all cached data. Called on BRepGraph_Builder::Add() and Compact(). Standard_EXPORT void Clear() noexcept; //! Move constructor: transfers data, creates fresh mutex. diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_ShapesView.hxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_ShapesView.hxx index 67f3cad603..d3af85d964 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_ShapesView.hxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_ShapesView.hxx @@ -26,7 +26,7 @@ //! NodeIds via TShape pointer comparison. Shape() is the stable cached public //! route for repeated access; Reconstruct() forces a fresh rebuild with the //! same node-kind semantics and bypasses the persistent reconstructed-shape cache. -//! BRepGraph_Builder::Perform() and Compact() clear the persistent reconstructed-shape cache. +//! BRepGraph_Builder::Add() and Compact() clear the persistent reconstructed-shape cache. //! Obtained via BRepGraph::Shapes(). class BRepGraph::ShapesView { diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Transform.cxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Transform.cxx index 96552a706f..5caad7908b 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Transform.cxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Transform.cxx @@ -109,7 +109,7 @@ void BRepGraph_Transform::applyLocationTransform(BRepGraph& theGraph, const gp_T if (aOccRef.IsRemoved) continue; BRepGraph_MutGuard aMutRef = - theGraph.Editor().Products().MutOccurrenceRef(aRefId); + theGraph.Editor().Occurrences().MutRef(aRefId); aMutRef->LocalLocation = aLoc * aMutRef->LocalLocation; } }); diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Transform.hxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Transform.hxx index a4bceebbf2..5c3f9d6d14 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Transform.hxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_Transform.hxx @@ -39,7 +39,7 @@ //! ## Typical usage //! @code //! BRepGraph aGraph; -//! BRepGraph_Builder::Perform(aGraph, myShape); +//! BRepGraph_Builder::Add(aGraph, myShape); //! gp_Trsf aTrsf; //! aTrsf.SetTranslation(gp_Vec(10.0, 0.0, 0.0)); //! BRepGraph aTransformed = BRepGraph_Transform::Perform(aGraph, aTrsf); diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_TransientCache.hxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_TransientCache.hxx index 8345deb0b6..122644a5cb 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_TransientCache.hxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_TransientCache.hxx @@ -217,7 +217,7 @@ private: //! considered stale - the caller decides how to handle it. //! //! ## Lifecycle -//! NOT a Layer. Cleared on BRepGraph_Builder::Perform() and Compact(). No OnNodeRemoved handling - +//! NOT a Layer. Cleared on BRepGraph_Builder::Add() and Compact(). No OnNodeRemoved handling - //! stale data is auto-detected by SubtreeGen mismatch. //! //! ## Thread safety @@ -230,7 +230,7 @@ public: //! Number of Kind enum slots to cover (0..11, with gap at 9). static constexpr int THE_KIND_COUNT = BRepGraph_NodeId::THE_KIND_COUNT; - //! Default number of cache-kind slots reserved after BRepGraph_Builder::Perform(). + //! Default number of cache-kind slots reserved after BRepGraph_Builder::Add(). static constexpr int THE_DEFAULT_RESERVED_KIND_COUNT = 16; //! Per-slot storage: cached value handle + SubtreeGen stamp. @@ -299,7 +299,7 @@ public: return myIsReserved.load(std::memory_order_acquire); } - //! Clear all cached data. Called on BRepGraph_Builder::Perform() and Compact(). + //! Clear all cached data. Called on BRepGraph_Builder::Add() and Compact(). Standard_EXPORT void Clear() noexcept; //! Move constructor: transfers data, creates fresh mutex. diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_UID.hxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_UID.hxx index b59f39f8dc..0958b4cf38 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_UID.hxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_UID.hxx @@ -26,7 +26,7 @@ //! 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_Builder::Perform() cycle +//! 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. @@ -108,9 +108,9 @@ struct BRepGraph_UID } private: - size_t myCounter; //!< 0 = invalid sentinel; valid counters start at 1. - BRepGraph_NodeId::Kind myKind; //!< Node kind. - uint32_t myGeneration; //!< BRepGraph_Builder::Perform() cycle that produced this UID. + size_t myCounter; //!< 0 = invalid sentinel; valid counters start at 1. + BRepGraph_NodeId::Kind myKind; //!< Node kind. + uint32_t myGeneration; //!< BRepGraph::Clear() cycle that produced this UID. }; //! std::hash specialization for NCollection_DefaultHasher support. diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_UIDsView.hxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_UIDsView.hxx index 71eb0e7d0b..161a183675 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_UIDsView.hxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_UIDsView.hxx @@ -22,13 +22,10 @@ class Standard_GUID; //! @brief Read-only view for persistent unique identifiers. //! //! UIDs are (Kind, Counter) pairs that persist across graph mutations -//! (Compact, node removal). Each UID is assigned exactly once and never -//! reused. Counters are monotonic and independent of vector indices, -//! so UIDs survive Compact() index remapping. Only BRepGraph_Builder::Perform() resets -//! counters (new generation). The Generation field enables stale-reference -//! detection when a graph is rebuilt. -//! Provides bidirectional NodeId/UID resolution. -//! Obtained via BRepGraph::UIDs(). +//! (Compact, node removal). Counters are monotonic and independent of vector +//! indices. Clear() starts a new graph generation and refreshes the graph +//! GUID, enabling stale-reference detection when a graph is rebuilt. +//! Provides bidirectional NodeId/UID resolution. Obtained via BRepGraph::UIDs(). class BRepGraph::UIDsView { public: @@ -63,12 +60,12 @@ public: //! @return true if the RefUID resolves to an active reference in this graph generation [[nodiscard]] Standard_EXPORT bool Has(const BRepGraph_RefUID& theUID) const; - //! Return the current generation counter (incremented on each BRepGraph_Builder::Perform()). + //! Return the current generation counter (incremented on each BRepGraph::Clear()). //! @return graph generation number [[nodiscard]] Standard_EXPORT uint32_t Generation() const; //! Return the graph-level identity GUID. - //! Generated randomly at BRepGraph_Builder::Perform() time; changes on each rebuild. + //! Generated randomly at BRepGraph::Clear() time; changes on each rebuild. //! @return reference to the graph identity GUID [[nodiscard]] Standard_EXPORT const Standard_GUID& GraphGUID() const; diff --git a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_VersionStamp.hxx b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_VersionStamp.hxx index ffd1f7678d..4e9e71389b 100644 --- a/src/ModelingData/TKBRep/BRepGraph/BRepGraph_VersionStamp.hxx +++ b/src/ModelingData/TKBRep/BRepGraph/BRepGraph_VersionStamp.hxx @@ -23,7 +23,7 @@ //! @brief 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_Builder::Perform() cycle). +//! OwnGen (own-data version counter) and graph Generation (BRepGraph::Clear() cycle). //! Computed on demand via BRepGraph::UIDs().StampOf(). //! //! Usage pattern: @@ -48,7 +48,7 @@ struct BRepGraph_VersionStamp BRepGraph_RefUID myRefUID; //!< Reference identity for ref-domain stamps. uint32_t myMutationGen; //!< OwnGen counter at snapshot time (maps to BaseDef::OwnGen / BaseRef::OwnGen). - uint32_t myGeneration; //!< Graph BRepGraph_Builder::Perform() generation at snapshot time. + uint32_t myGeneration; //!< Graph BRepGraph::Clear() generation at snapshot time. Domain myDomain; //!< Active identity domain. //! Default constructor. Creates an invalid stamp (invalid UID, zero counters). @@ -64,7 +64,7 @@ struct BRepGraph_VersionStamp //! Construct an entity-domain stamp from components. //! @param[in] theUID persistent entity identity //! @param[in] theMutationGen OwnGen counter (own-data mutation counter) - //! @param[in] theGeneration graph BRepGraph_Builder::Perform() generation + //! @param[in] theGeneration graph BRepGraph::Clear() generation BRepGraph_VersionStamp(const BRepGraph_UID& theUID, const uint32_t theMutationGen, const uint32_t theGeneration) @@ -79,7 +79,7 @@ struct BRepGraph_VersionStamp //! Construct a reference-domain stamp from components. //! @param[in] theRefUID persistent reference identity //! @param[in] theMutationGen OwnGen counter (own-data mutation counter) - //! @param[in] theGeneration graph BRepGraph_Builder::Perform() generation + //! @param[in] theGeneration graph BRepGraph::Clear() generation BRepGraph_VersionStamp(const BRepGraph_RefUID& theRefUID, const uint32_t theMutationGen, const uint32_t theGeneration) diff --git a/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_Populate.hxx b/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_Populate.hxx index d4acea2a1e..316025ef01 100644 --- a/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_Populate.hxx +++ b/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_Populate.hxx @@ -29,7 +29,7 @@ class BRepGraph_LayerRegularity; //! //! This class is part of the BRepGraphInc backend and is intended for //! backend maintenance, tests, and low-level infrastructure only. -//! External code should enter through BRepGraph_Builder::Perform(), which owns the +//! External code should enter through BRepGraph_Builder::Add(), which owns the //! public lifecycle, cache invalidation, and layer coordination. //! //! Adapted from BRepGraph_Builder, but writes to incidence-table storage diff --git a/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_Storage.cxx b/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_Storage.cxx index 32b3c2d703..225f07284d 100644 --- a/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_Storage.cxx +++ b/src/ModelingData/TKBRep/BRepGraphInc/BRepGraphInc_Storage.cxx @@ -565,7 +565,7 @@ void BRepGraphInc_Storage::BuildDeltaReverseIndex(const uint32_t theOldNbEdges, // Ensure allocator is set for reverse index inner vectors. // BuildReverseIndex() always calls SetAllocator(), but when // AppendFlattened/AppendFull is the first operation on a fresh - // graph (no prior BRepGraph_Builder::Perform()), the allocator has not been set yet. + // graph (no prior BRepGraph_Builder::Add()), the allocator has not been set yet. myReverseIdx.SetAllocator(myAllocator); myReverseIdx.BuildDelta(myVertices.Entities, myEdges.Entities, diff --git a/src/ModelingData/TKBRep/GTests/BRepGraphInc_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraphInc_Test.cxx index 8ea5e40103..af7f7dc5b0 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraphInc_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraphInc_Test.cxx @@ -85,7 +85,9 @@ TEST(BRepGraphIncTest, Box_EntityCounts_MatchDefCounts) // Build BRepGraph for parity checks. BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); // Build incidence storage. @@ -108,7 +110,9 @@ TEST(BRepGraphIncTest, Cylinder_EntityCounts_MatchDefCounts) const TopoDS_Shape& aCyl = aCylMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCyl); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, aCyl); ASSERT_TRUE(aGraph.IsDone()); BRepGraphInc_Storage aStorage; @@ -129,7 +133,9 @@ TEST(BRepGraphIncTest, Sphere_EntityCounts_MatchDefCounts) const TopoDS_Shape& aSph = aSphMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aSph); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(aGraph, aSph); ASSERT_TRUE(aGraph.IsDone()); BRepGraphInc_Storage aStorage; diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Assembly_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Assembly_Test.cxx index fd01d80378..818f87389d 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Assembly_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Assembly_Test.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -72,11 +73,13 @@ bool hasRootProduct(const NCollection_DynamicArray& theRoot TEST(BRepGraph_AssemblyTest, Build_SingleSolid_AutoCreatesRootProduct) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Products().Nb(), 1); - // BRepGraph_Builder::Perform() creates a shape-root occurrence linking product to its topology + // BRepGraph_Builder::Add() creates a shape-root occurrence linking product to its topology // root. EXPECT_EQ(aGraph.Topo().Occurrences().Nb(), 1); @@ -101,11 +104,13 @@ TEST(BRepGraph_AssemblyTest, Build_Compound_AutoCreatesRootProduct) aBB.Add(aCompound, BRepPrimAPI_MakeSphere(5.0).Shape()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Products().Nb(), 1); - // BRepGraph_Builder::Perform() creates a shape-root occurrence linking product to its topology + // BRepGraph_Builder::Add() creates a shape-root occurrence linking product to its topology // root. EXPECT_EQ(aGraph.Topo().Occurrences().Nb(), 1); @@ -122,12 +127,15 @@ TEST(BRepGraph_AssemblyTest, Build_Compound_AutoCreatesRootProduct) TEST(BRepGraph_AssemblyTest, AddProduct_IsPart) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); // Add a second part product. const BRepGraph_NodeId aShapeRoot = BRepGraph_SolidId::Start(); - const BRepGraph_ProductId aProductId = aGraph.Editor().Products().Add(aShapeRoot); + const BRepGraph_ProductId aProductId = + aGraph.Editor().Products().LinkProductToTopology(aShapeRoot); EXPECT_TRUE(aProductId.IsValid()); EXPECT_TRUE(aGraph.Topo().Products().IsPart(aProductId)); @@ -137,26 +145,32 @@ TEST(BRepGraph_AssemblyTest, AddProduct_IsPart) TEST(BRepGraph_AssemblyTest, AddProduct_InvalidShapeRoot_ReturnsInvalid) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes4 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); - EXPECT_FALSE(aGraph.Editor().Products().Add(BRepGraph_ProductId::Start()).IsValid()); + EXPECT_FALSE( + aGraph.Editor().Products().LinkProductToTopology(BRepGraph_ProductId::Start()).IsValid()); aGraph.Editor().Gen().RemoveNode(BRepGraph_SolidId::Start()); - EXPECT_FALSE(aGraph.Editor().Products().Add(BRepGraph_SolidId::Start()).IsValid()); + EXPECT_FALSE( + aGraph.Editor().Products().LinkProductToTopology(BRepGraph_SolidId::Start()).IsValid()); } // ============================================================================= -// AddAssembly_EmptyIsNotAssemblyYet +// CreateEmptyProduct_EmptyIsNotAssemblyYet // ============================================================================= -TEST(BRepGraph_AssemblyTest, AddAssembly_EmptyIsNotAssemblyYet) +TEST(BRepGraph_AssemblyTest, CreateEmptyProduct_EmptyIsNotAssemblyYet) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes5 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); - const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().CreateEmptyProduct(); EXPECT_TRUE(aAssemblyId.IsValid()); EXPECT_FALSE(aGraph.Topo().Products().IsAssembly(aAssemblyId)); @@ -164,24 +178,26 @@ TEST(BRepGraph_AssemblyTest, AddAssembly_EmptyIsNotAssemblyYet) } // ============================================================================= -// AddOccurrence_LinksCorrectly +// LinkProducts_LinksCorrectly // ============================================================================= -TEST(BRepGraph_AssemblyTest, AddOccurrence_LinksCorrectly) +TEST(BRepGraph_AssemblyTest, LinkProducts_LinksCorrectly) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes6 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); // auto-created root - const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().CreateEmptyProduct(); gp_Trsf aTrsf; aTrsf.SetTranslation(gp_Vec(100.0, 0.0, 0.0)); TopLoc_Location aLoc(aTrsf); const BRepGraph_OccurrenceId anOccId = - aGraph.Editor().Products().AddOccurrence(aAssemblyId, aPartId, aLoc); + aGraph.Editor().Products().LinkProducts(aAssemblyId, aPartId, aLoc); EXPECT_TRUE(anOccId.IsValid()); @@ -200,11 +216,13 @@ TEST(BRepGraph_AssemblyTest, AddOccurrence_LinksCorrectly) TEST(BRepGraph_AssemblyTest, DAGSharing_MultipleOccurrencesSamePart) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes7 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().CreateEmptyProduct(); gp_Trsf aTrsf1; aTrsf1.SetTranslation(gp_Vec(100.0, 0.0, 0.0)); @@ -212,9 +230,9 @@ TEST(BRepGraph_AssemblyTest, DAGSharing_MultipleOccurrencesSamePart) aTrsf2.SetTranslation(gp_Vec(200.0, 0.0, 0.0)); const BRepGraph_OccurrenceId anOcc1 = - aGraph.Editor().Products().AddOccurrence(aAssemblyId, aPartId, TopLoc_Location(aTrsf1)); + aGraph.Editor().Products().LinkProducts(aAssemblyId, aPartId, TopLoc_Location(aTrsf1)); const BRepGraph_OccurrenceId anOcc2 = - aGraph.Editor().Products().AddOccurrence(aAssemblyId, aPartId, TopLoc_Location(aTrsf2)); + aGraph.Editor().Products().LinkProducts(aAssemblyId, aPartId, TopLoc_Location(aTrsf2)); EXPECT_NE(anOcc1, anOcc2); EXPECT_EQ(aGraph.Topo().Occurrences().Product(anOcc1), @@ -223,24 +241,26 @@ TEST(BRepGraph_AssemblyTest, DAGSharing_MultipleOccurrencesSamePart) EXPECT_EQ(aGraph.Topo().Products().NbComponents(aAssemblyId), 2); } -TEST(BRepGraph_AssemblyTest, AddOccurrence_ParentOccurrenceMustMatchParentProduct) +TEST(BRepGraph_AssemblyTest, LinkProducts_ParentOccurrenceMustMatchParentProduct) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes8 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId anAssemblyA = aGraph.Editor().Products().AddAssembly(); - const BRepGraph_ProductId anAssemblyB = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId anAssemblyA = aGraph.Editor().Products().CreateEmptyProduct(); + const BRepGraph_ProductId anAssemblyB = aGraph.Editor().Products().CreateEmptyProduct(); const BRepGraph_OccurrenceId aParentOccId = - aGraph.Editor().Products().AddOccurrence(anAssemblyA, aPartId, TopLoc_Location()); + aGraph.Editor().Products().LinkProducts(anAssemblyA, aPartId, TopLoc_Location()); ASSERT_TRUE(aParentOccId.IsValid()); const BRepGraph_OccurrenceId anInvalidOccId = - aGraph.Editor().Products().AddOccurrence(anAssemblyB, aPartId, TopLoc_Location(), aParentOccId); + aGraph.Editor().Products().LinkProducts(anAssemblyB, aPartId, TopLoc_Location(), aParentOccId); EXPECT_FALSE(anInvalidOccId.IsValid()); - // BRepGraph_Builder::Perform() creates 1 shape-root occ, AddOccurrence creates 1 more = 2 total. + // BRepGraph_Builder::Add() creates 1 shape-root occ, LinkProducts creates 1 more = 2 total. EXPECT_EQ(aGraph.Topo().Occurrences().Nb(), 2); EXPECT_EQ(aGraph.Topo().Products().NbComponents(anAssemblyB), 0); } @@ -252,7 +272,9 @@ TEST(BRepGraph_AssemblyTest, AddOccurrence_ParentOccurrenceMustMatchParentProduc TEST(BRepGraph_AssemblyTest, RootProductIds_Query) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes9 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); // Auto-created root product is the first root. @@ -262,8 +284,8 @@ TEST(BRepGraph_AssemblyTest, RootProductIds_Query) // Add an assembly and make it instantiate the part product via occurrence. const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().AddAssembly(); - (void)aGraph.Editor().Products().AddOccurrence(aAssemblyId, aPartId, TopLoc_Location()); + const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().CreateEmptyProduct(); + (void)aGraph.Editor().Products().LinkProducts(aAssemblyId, aPartId, TopLoc_Location()); // Now only the assembly (which is not referenced by any occurrence) is a root. aRoots = collectRootProducts(aGraph); @@ -278,13 +300,15 @@ TEST(BRepGraph_AssemblyTest, RootProductIds_Query) TEST(BRepGraph_AssemblyTest, RootProductIds_ShapelessRootAssembly_UsesProductId) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes10 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().CreateEmptyProduct(); ASSERT_TRUE( - aGraph.Editor().Products().AddOccurrence(aAssemblyId, aPartId, TopLoc_Location()).IsValid()); + aGraph.Editor().Products().LinkProducts(aAssemblyId, aPartId, TopLoc_Location()).IsValid()); const NCollection_DynamicArray& aRoots = aGraph.RootProductIds(); ASSERT_EQ(aRoots.Length(), 1); @@ -298,17 +322,19 @@ TEST(BRepGraph_AssemblyTest, RootProductIds_ShapelessRootAssembly_UsesProductId) TEST(BRepGraph_AssemblyTest, RootProductIds_ReflectsAssemblyMutation) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes11 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const NCollection_DynamicArray aRootsBefore = collectRootProducts(aGraph); ASSERT_EQ(aRootsBefore.Length(), 1); EXPECT_EQ(aRootsBefore.Value(0), BRepGraph_ProductId::Start()); - const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().AddAssembly(); - (void)aGraph.Editor().Products().AddOccurrence(aAssemblyId, - BRepGraph_ProductId::Start(), - TopLoc_Location()); + const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().CreateEmptyProduct(); + (void)aGraph.Editor().Products().LinkProducts(aAssemblyId, + BRepGraph_ProductId::Start(), + TopLoc_Location()); const NCollection_DynamicArray aRootsAfter = collectRootProducts(aGraph); ASSERT_EQ(aRootsAfter.Length(), 1); @@ -322,13 +348,15 @@ TEST(BRepGraph_AssemblyTest, RootProductIds_ReflectsAssemblyMutation) TEST(BRepGraph_AssemblyTest, RemoveOccurrence_UpdatesParent) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes12 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().CreateEmptyProduct(); const BRepGraph_OccurrenceId anOccId = - aGraph.Editor().Products().AddOccurrence(aAssemblyId, aPartId, TopLoc_Location()); + aGraph.Editor().Products().LinkProducts(aAssemblyId, aPartId, TopLoc_Location()); EXPECT_EQ(aGraph.Topo().Products().NbComponents(aAssemblyId), 1); const NCollection_DynamicArray& aBeforeRefs = @@ -355,15 +383,17 @@ TEST(BRepGraph_AssemblyTest, RemoveOccurrence_UpdatesParent) TEST(BRepGraph_AssemblyTest, RemoveProduct_CascadeOccurrences) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes13 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().CreateEmptyProduct(); const BRepGraph_OccurrenceId anOcc1 = - aGraph.Editor().Products().AddOccurrence(aAssemblyId, aPartId, TopLoc_Location()); + aGraph.Editor().Products().LinkProducts(aAssemblyId, aPartId, TopLoc_Location()); const BRepGraph_OccurrenceId anOcc2 = - aGraph.Editor().Products().AddOccurrence(aAssemblyId, aPartId, TopLoc_Location()); + aGraph.Editor().Products().LinkProducts(aAssemblyId, aPartId, TopLoc_Location()); // Remove the assembly product - cascades to its child occurrences. aGraph.Editor().Gen().RemoveSubgraph(aAssemblyId); @@ -380,15 +410,17 @@ TEST(BRepGraph_AssemblyTest, RemoveProduct_CascadeOccurrences) TEST(BRepGraph_AssemblyTest, RemoveProduct_RemovesProductAndOccurrences) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes14 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); - // Part product created by BRepGraph_Builder::Perform() references topology via + // Part product created by BRepGraph_Builder::Add() references topology via // a shape-root occurrence. const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); EXPECT_TRUE(aGraph.Topo().Products().IsPart(aPartId)); - // BRepGraph_Builder::Perform() creates 1 shape-root occurrence. + // BRepGraph_Builder::Add() creates 1 shape-root occurrence. ASSERT_EQ(aGraph.Topo().Occurrences().Nb(), 1); const BRepGraph_OccurrenceId aShapeRootOcc = BRepGraph_OccurrenceId::Start(); EXPECT_FALSE(aGraph.Topo().Gen().IsRemoved(aShapeRootOcc)); @@ -409,12 +441,14 @@ TEST(BRepGraph_AssemblyTest, RemoveOccurrence_CascadesToNestedChildren) // TopAsm -> MidAsm -> LeafPart, each level via occurrences. // Removing the mid-level occurrence should also remove the leaf occurrence. BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes15 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ProductId aLeafPart = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aMidAsm = aGraph.Editor().Products().AddAssembly(); - const BRepGraph_ProductId aTopAsm = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aMidAsm = aGraph.Editor().Products().CreateEmptyProduct(); + const BRepGraph_ProductId aTopAsm = aGraph.Editor().Products().CreateEmptyProduct(); gp_Trsf aT1, aT2; aT1.SetTranslation(gp_Vec(10.0, 0.0, 0.0)); @@ -422,10 +456,10 @@ TEST(BRepGraph_AssemblyTest, RemoveOccurrence_CascadesToNestedChildren) // TopAsm places MidAsm. const BRepGraph_OccurrenceId anOccMid = - aGraph.Editor().Products().AddOccurrence(aTopAsm, aMidAsm, TopLoc_Location(aT1)); + aGraph.Editor().Products().LinkProducts(aTopAsm, aMidAsm, TopLoc_Location(aT1)); // MidAsm places LeafPart, with parent occurrence = anOccMid. const BRepGraph_OccurrenceId anOccLeaf = - aGraph.Editor().Products().AddOccurrence(aMidAsm, aLeafPart, TopLoc_Location(aT2), anOccMid); + aGraph.Editor().Products().LinkProducts(aMidAsm, aLeafPart, TopLoc_Location(aT2), anOccMid); EXPECT_FALSE(aGraph.Topo().Gen().IsRemoved(anOccMid)); EXPECT_FALSE(aGraph.Topo().Gen().IsRemoved(anOccLeaf)); @@ -455,7 +489,9 @@ TEST(BRepGraph_AssemblyTest, RemoveOccurrence_CascadesToNestedChildren) TEST(BRepGraph_AssemblyTest, MutProduct_RAII) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes16 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); { @@ -475,13 +511,15 @@ TEST(BRepGraph_AssemblyTest, MutProduct_RAII) TEST(BRepGraph_AssemblyTest, MutOccurrenceRef_LocalLocation) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes17 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().CreateEmptyProduct(); const BRepGraph_OccurrenceId anOccId = - aGraph.Editor().Products().AddOccurrence(aAssemblyId, aPartId, TopLoc_Location()); + aGraph.Editor().Products().LinkProducts(aAssemblyId, aPartId, TopLoc_Location()); ASSERT_TRUE(anOccId.IsValid()); // Find the OccurrenceRefId for the occurrence. @@ -495,7 +533,7 @@ TEST(BRepGraph_AssemblyTest, MutOccurrenceRef_LocalLocation) { BRepGraph_MutGuard aMutRef = - aGraph.Editor().Products().MutOccurrenceRef(anOccRefId); + aGraph.Editor().Occurrences().MutRef(anOccRefId); aMutRef->LocalLocation = TopLoc_Location(aTrsf); } // markRefModified fires here @@ -509,7 +547,7 @@ TEST(BRepGraph_AssemblyTest, MutInvalidAssemblyDefs_ThrowProgramError) BRepGraph aGraph; #if !defined(No_Exception) EXPECT_THROW((void)aGraph.Editor().Products().Mut(BRepGraph_ProductId(7)), Standard_ProgramError); - EXPECT_THROW((void)aGraph.Editor().Products().MutOccurrence(BRepGraph_OccurrenceId(7)), + EXPECT_THROW((void)aGraph.Editor().Occurrences().Mut(BRepGraph_OccurrenceId(7)), Standard_ProgramError); #endif } @@ -521,14 +559,16 @@ TEST(BRepGraph_AssemblyTest, MutInvalidAssemblyDefs_ThrowProgramError) TEST(BRepGraph_AssemblyTest, GlobalPlacement_DeepNesting) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes18 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); // Build: RootAssembly -> (OccSubAsm) -> SubAssembly -> (OccPart) -> Part - const BRepGraph_ProductId aSubAsmId = aGraph.Editor().Products().AddAssembly(); - const BRepGraph_ProductId aRootAsmId = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aSubAsmId = aGraph.Editor().Products().CreateEmptyProduct(); + const BRepGraph_ProductId aRootAsmId = aGraph.Editor().Products().CreateEmptyProduct(); gp_Trsf aTrsf1; aTrsf1.SetTranslation(gp_Vec(100.0, 0.0, 0.0)); @@ -537,13 +577,13 @@ TEST(BRepGraph_AssemblyTest, GlobalPlacement_DeepNesting) // RootAssembly places SubAssembly with aTrsf2 (top-level occurrence, no parent occ). const BRepGraph_OccurrenceId anOccSubAsm = - aGraph.Editor().Products().AddOccurrence(aRootAsmId, aSubAsmId, TopLoc_Location(aTrsf2)); + aGraph.Editor().Products().LinkProducts(aRootAsmId, aSubAsmId, TopLoc_Location(aTrsf2)); // SubAssembly places Part with aTrsf1, with parent occurrence = anOccSubAsm. const BRepGraph_OccurrenceId anOccPart = - aGraph.Editor().Products().AddOccurrence(aSubAsmId, - aPartId, - TopLoc_Location(aTrsf1), - anOccSubAsm); + aGraph.Editor().Products().LinkProducts(aSubAsmId, + aPartId, + TopLoc_Location(aTrsf1), + anOccSubAsm); // OccurrenceLocation returns the local location from the OccurrenceRef. // Global placement composition (parent chain walk) is handled by PathView. @@ -565,7 +605,9 @@ TEST(BRepGraph_AssemblyTest, GlobalPlacement_DeepNesting) TEST(BRepGraph_AssemblyTest, NbNodes_IncludesAssembly) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes19 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const size_t aNbNodesAfterBuild = aGraph.Topo().Gen().NbNodes(); @@ -573,10 +615,10 @@ TEST(BRepGraph_AssemblyTest, NbNodes_IncludesAssembly) EXPECT_GE(aNbNodesAfterBuild, 1u); // Add assembly + occurrence. - const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().AddAssembly(); - (void)aGraph.Editor().Products().AddOccurrence(aAssemblyId, - BRepGraph_ProductId::Start(), - TopLoc_Location()); + const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().CreateEmptyProduct(); + (void)aGraph.Editor().Products().LinkProducts(aAssemblyId, + BRepGraph_ProductId::Start(), + TopLoc_Location()); const size_t aNbNodesAfterAssembly = aGraph.Topo().Gen().NbNodes(); EXPECT_EQ(aNbNodesAfterAssembly, aNbNodesAfterBuild + 2); // +1 product, +1 occurrence @@ -589,13 +631,15 @@ TEST(BRepGraph_AssemblyTest, NbNodes_IncludesAssembly) TEST(BRepGraph_AssemblyTest, OccurrencesOfProduct_ReverseIndex) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes20 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().AddAssembly(); - (void)aGraph.Editor().Products().AddOccurrence(aAssemblyId, aPartId, TopLoc_Location()); - (void)aGraph.Editor().Products().AddOccurrence(aAssemblyId, aPartId, TopLoc_Location()); + const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().CreateEmptyProduct(); + (void)aGraph.Editor().Products().LinkProducts(aAssemblyId, aPartId, TopLoc_Location()); + (void)aGraph.Editor().Products().LinkProducts(aAssemblyId, aPartId, TopLoc_Location()); // Build the product-occurrence reverse index manually. BRepGraphInc_ReverseIndex aRevIdx; @@ -612,10 +656,12 @@ TEST(BRepGraph_AssemblyTest, OccurrencesOfProduct_ReverseIndex) TEST(BRepGraph_AssemblyTest, Product_Count) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes21 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); - (void)aGraph.Editor().Products().AddAssembly(); + (void)aGraph.Editor().Products().CreateEmptyProduct(); int aCount = 0; for (BRepGraph_ProductIterator aProductIt(aGraph); aProductIt.More(); aProductIt.Next()) @@ -632,13 +678,15 @@ TEST(BRepGraph_AssemblyTest, Product_Count) TEST(BRepGraph_AssemblyTest, Occurrence_Count) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes22 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().AddAssembly(); - (void)aGraph.Editor().Products().AddOccurrence(aAssemblyId, aPartId, TopLoc_Location()); - (void)aGraph.Editor().Products().AddOccurrence(aAssemblyId, aPartId, TopLoc_Location()); + const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().CreateEmptyProduct(); + (void)aGraph.Editor().Products().LinkProducts(aAssemblyId, aPartId, TopLoc_Location()); + (void)aGraph.Editor().Products().LinkProducts(aAssemblyId, aPartId, TopLoc_Location()); int aCount = 0; for (BRepGraph_OccurrenceIterator anOccIt(aGraph); anOccIt.More(); anOccIt.Next()) @@ -674,7 +722,9 @@ TEST(BRepGraph_AssemblyTest, NodeId_Helpers) TEST(BRepGraph_AssemblyTest, UID_IsAssembly) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes23 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); // The auto-created root product should have a UID with IsAssembly() == false @@ -686,43 +736,47 @@ TEST(BRepGraph_AssemblyTest, UID_IsAssembly) } // ============================================================================= -// AddOccurrence_InvalidParent_ReturnsInvalid +// LinkProducts_InvalidParent_ReturnsInvalid // ============================================================================= -TEST(BRepGraph_AssemblyTest, AddOccurrence_InvalidParent_ReturnsInvalid) +TEST(BRepGraph_AssemblyTest, LinkProducts_InvalidParent_ReturnsInvalid) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes24 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_OccurrenceId aResult = - aGraph.Editor().Products().AddOccurrence(BRepGraph_ProductId(999), - BRepGraph_ProductId::Start(), - TopLoc_Location()); + aGraph.Editor().Products().LinkProducts(BRepGraph_ProductId(999), + BRepGraph_ProductId::Start(), + TopLoc_Location()); EXPECT_FALSE(aResult.IsValid()); // Out-of-bounds referenced product index. - aResult = aGraph.Editor().Products().AddOccurrence(BRepGraph_ProductId::Start(), - BRepGraph_ProductId(999), - TopLoc_Location()); + aResult = aGraph.Editor().Products().LinkProducts(BRepGraph_ProductId::Start(), + BRepGraph_ProductId(999), + TopLoc_Location()); EXPECT_FALSE(aResult.IsValid()); } // ============================================================================= -// AddOccurrence_SelfReference_ReturnsInvalid +// LinkProducts_SelfReference_ReturnsInvalid // ============================================================================= -TEST(BRepGraph_AssemblyTest, AddOccurrence_SelfReference_ReturnsInvalid) +TEST(BRepGraph_AssemblyTest, LinkProducts_SelfReference_ReturnsInvalid) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes25 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); // Self-referencing: a product cannot be an occurrence of itself. const BRepGraph_OccurrenceId aResult = - aGraph.Editor().Products().AddOccurrence(aPartId, aPartId, TopLoc_Location()); + aGraph.Editor().Products().LinkProducts(aPartId, aPartId, TopLoc_Location()); EXPECT_FALSE(aResult.IsValid()); } @@ -733,13 +787,15 @@ TEST(BRepGraph_AssemblyTest, AddOccurrence_SelfReference_ReturnsInvalid) TEST(BRepGraph_AssemblyTest, RootProducts_RemovedOccurrence_DoesNotAffectRoots) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes26 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().CreateEmptyProduct(); const BRepGraph_OccurrenceId anOccId = - aGraph.Editor().Products().AddOccurrence(aAssemblyId, aPartId, TopLoc_Location()); + aGraph.Editor().Products().LinkProducts(aAssemblyId, aPartId, TopLoc_Location()); // Before removal: only assembly is root (part is referenced). NCollection_DynamicArray aRoots = collectRootProducts(aGraph); @@ -764,11 +820,13 @@ TEST(BRepGraph_AssemblyTest, GlobalPlacement_DAGSharing_DistinctPathsGiveDistinc // Shared part placed twice under the same assembly at different locations. // Each occurrence has its own placement chain - no ambiguity. BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes27 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().CreateEmptyProduct(); gp_Trsf aTrsf1; aTrsf1.SetTranslation(gp_Vec(100.0, 0.0, 0.0)); @@ -776,9 +834,9 @@ TEST(BRepGraph_AssemblyTest, GlobalPlacement_DAGSharing_DistinctPathsGiveDistinc aTrsf2.SetTranslation(gp_Vec(0.0, 200.0, 0.0)); const BRepGraph_OccurrenceId anOcc1 = - aGraph.Editor().Products().AddOccurrence(aAssemblyId, aPartId, TopLoc_Location(aTrsf1)); + aGraph.Editor().Products().LinkProducts(aAssemblyId, aPartId, TopLoc_Location(aTrsf1)); const BRepGraph_OccurrenceId anOcc2 = - aGraph.Editor().Products().AddOccurrence(aAssemblyId, aPartId, TopLoc_Location(aTrsf2)); + aGraph.Editor().Products().LinkProducts(aAssemblyId, aPartId, TopLoc_Location(aTrsf2)); // Same part, different occurrences, different global placements. TopLoc_Location aGlobal1 = aGraph.Topo().Occurrences().OccurrenceLocation(anOcc1); @@ -791,33 +849,33 @@ TEST(BRepGraph_AssemblyTest, GlobalPlacement_DAGSharing_DistinctPathsGiveDistinc } // ============================================================================= -// AddOccurrence_RemovedProduct_ReturnsInvalid +// LinkProducts_RemovedProduct_ReturnsInvalid // ============================================================================= -TEST(BRepGraph_AssemblyTest, AddOccurrence_RemovedProduct_ReturnsInvalid) +TEST(BRepGraph_AssemblyTest, LinkProducts_RemovedProduct_ReturnsInvalid) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes28 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); - const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().CreateEmptyProduct(); // Remove the assembly. aGraph.Editor().Gen().RemoveNode(aAssemblyId); // Cannot add occurrence to a removed product. const BRepGraph_OccurrenceId aResult = - aGraph.Editor().Products().AddOccurrence(aAssemblyId, - BRepGraph_ProductId::Start(), - TopLoc_Location()); + aGraph.Editor().Products().LinkProducts(aAssemblyId, + BRepGraph_ProductId::Start(), + TopLoc_Location()); EXPECT_FALSE(aResult.IsValid()); // Cannot reference a removed product either. - const BRepGraph_ProductId aAsm2 = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aAsm2 = aGraph.Editor().Products().CreateEmptyProduct(); aGraph.Editor().Gen().RemoveNode(BRepGraph_ProductId::Start()); const BRepGraph_OccurrenceId aResult2 = - aGraph.Editor().Products().AddOccurrence(aAsm2, - BRepGraph_ProductId::Start(), - TopLoc_Location()); + aGraph.Editor().Products().LinkProducts(aAsm2, BRepGraph_ProductId::Start(), TopLoc_Location()); EXPECT_FALSE(aResult2.IsValid()); } @@ -829,13 +887,15 @@ TEST(BRepGraph_AssemblyTest, GlobalPlacement_ThreeLevelNesting) { // Root -> Mid -> Leaf, each with a distinct translation. BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes29 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ProductId aLeafPart = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aMidAsm = aGraph.Editor().Products().AddAssembly(); - const BRepGraph_ProductId aRootAsm = aGraph.Editor().Products().AddAssembly(); - const BRepGraph_ProductId aTopAsm = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aMidAsm = aGraph.Editor().Products().CreateEmptyProduct(); + const BRepGraph_ProductId aRootAsm = aGraph.Editor().Products().CreateEmptyProduct(); + const BRepGraph_ProductId aTopAsm = aGraph.Editor().Products().CreateEmptyProduct(); gp_Trsf aT1, aT2, aT3; aT1.SetTranslation(gp_Vec(1.0, 0.0, 0.0)); @@ -844,13 +904,13 @@ TEST(BRepGraph_AssemblyTest, GlobalPlacement_ThreeLevelNesting) // TopAsm places RootAsm. const BRepGraph_OccurrenceId anOccRoot = - aGraph.Editor().Products().AddOccurrence(aTopAsm, aRootAsm, TopLoc_Location(aT3)); + aGraph.Editor().Products().LinkProducts(aTopAsm, aRootAsm, TopLoc_Location(aT3)); // RootAsm places MidAsm, parent occ = anOccRoot. const BRepGraph_OccurrenceId anOccMid = - aGraph.Editor().Products().AddOccurrence(aRootAsm, aMidAsm, TopLoc_Location(aT2), anOccRoot); + aGraph.Editor().Products().LinkProducts(aRootAsm, aMidAsm, TopLoc_Location(aT2), anOccRoot); // MidAsm places Leaf, parent occ = anOccMid. const BRepGraph_OccurrenceId anOccLeaf = - aGraph.Editor().Products().AddOccurrence(aMidAsm, aLeafPart, TopLoc_Location(aT1), anOccMid); + aGraph.Editor().Products().LinkProducts(aMidAsm, aLeafPart, TopLoc_Location(aT1), anOccMid); // OccurrenceLocation returns the local location only. // Verify each level has the correct local placement. @@ -876,7 +936,9 @@ TEST(BRepGraph_AssemblyTest, ShapesView_ProductShape_ReconstructsBuiltRootTransf aRootShape.Reverse(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aRootShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes30 = + BRepGraph_Builder::Add(aGraph, aRootShape); ASSERT_TRUE(aGraph.IsDone()); const TopoDS_Shape aProductShape = aGraph.Shapes().Shape(BRepGraph_ProductId::Start()); @@ -897,11 +959,13 @@ TEST(BRepGraph_AssemblyTest, ShapesView_ProductShape_ReconstructsBuiltRootTransf TEST(BRepGraph_AssemblyTest, ShapesView_AssemblyProduct_ReconstructsChildOccurrences) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes31 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().CreateEmptyProduct(); gp_Trsf aTrsf1; aTrsf1.SetTranslation(gp_Vec(100.0, 0.0, 0.0)); @@ -910,11 +974,11 @@ TEST(BRepGraph_AssemblyTest, ShapesView_AssemblyProduct_ReconstructsChildOccurre ASSERT_TRUE(aGraph.Editor() .Products() - .AddOccurrence(aAssemblyId, aPartId, TopLoc_Location(aTrsf1)) + .LinkProducts(aAssemblyId, aPartId, TopLoc_Location(aTrsf1)) .IsValid()); ASSERT_TRUE(aGraph.Editor() .Products() - .AddOccurrence(aAssemblyId, aPartId, TopLoc_Location(aTrsf2)) + .LinkProducts(aAssemblyId, aPartId, TopLoc_Location(aTrsf2)) .IsValid()); const TopoDS_Shape aAssemblyShape = aGraph.Shapes().Shape(aAssemblyId); @@ -943,28 +1007,30 @@ TEST(BRepGraph_AssemblyTest, ShapesView_AssemblyProduct_ReconstructsChildOccurre TEST(BRepGraph_AssemblyTest, ShapesView_OccurrenceShape_UsesGlobalPlacementChain) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes32 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aSubAssembly = aGraph.Editor().Products().AddAssembly(); - const BRepGraph_ProductId aRootAssembly = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aSubAssembly = aGraph.Editor().Products().CreateEmptyProduct(); + const BRepGraph_ProductId aRootAssembly = aGraph.Editor().Products().CreateEmptyProduct(); gp_Trsf aParentTrsf; aParentTrsf.SetTranslation(gp_Vec(10.0, 0.0, 0.0)); const BRepGraph_OccurrenceId aParentOccurrence = - aGraph.Editor().Products().AddOccurrence(aRootAssembly, - aSubAssembly, - TopLoc_Location(aParentTrsf)); + aGraph.Editor().Products().LinkProducts(aRootAssembly, + aSubAssembly, + TopLoc_Location(aParentTrsf)); ASSERT_TRUE(aParentOccurrence.IsValid()); gp_Trsf aChildTrsf; aChildTrsf.SetTranslation(gp_Vec(20.0, 0.0, 0.0)); const BRepGraph_OccurrenceId aChildOccurrence = - aGraph.Editor().Products().AddOccurrence(aSubAssembly, - aPartId, - TopLoc_Location(aChildTrsf), - aParentOccurrence); + aGraph.Editor().Products().LinkProducts(aSubAssembly, + aPartId, + TopLoc_Location(aChildTrsf), + aParentOccurrence); ASSERT_TRUE(aChildOccurrence.IsValid()); const TopoDS_Shape aSubAssemblyShape = aGraph.Shapes().Shape(aSubAssembly); @@ -992,45 +1058,47 @@ TEST(BRepGraph_AssemblyTest, ShapesView_OccurrenceShape_UsesGlobalPlacementChain TEST(BRepGraph_AssemblyTest, ShapesView_OccurrenceShape_FiltersNestedChildrenByParentOccurrence) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes33 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aSubAssembly = aGraph.Editor().Products().AddAssembly(); - const BRepGraph_ProductId aRootAssembly = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aSubAssembly = aGraph.Editor().Products().CreateEmptyProduct(); + const BRepGraph_ProductId aRootAssembly = aGraph.Editor().Products().CreateEmptyProduct(); gp_Trsf aParentTrsf1; aParentTrsf1.SetTranslation(gp_Vec(100.0, 0.0, 0.0)); const BRepGraph_OccurrenceId aParentOccurrence1 = - aGraph.Editor().Products().AddOccurrence(aRootAssembly, - aSubAssembly, - TopLoc_Location(aParentTrsf1)); + aGraph.Editor().Products().LinkProducts(aRootAssembly, + aSubAssembly, + TopLoc_Location(aParentTrsf1)); ASSERT_TRUE(aParentOccurrence1.IsValid()); gp_Trsf aParentTrsf2; aParentTrsf2.SetTranslation(gp_Vec(200.0, 0.0, 0.0)); const BRepGraph_OccurrenceId aParentOccurrence2 = - aGraph.Editor().Products().AddOccurrence(aRootAssembly, - aSubAssembly, - TopLoc_Location(aParentTrsf2)); + aGraph.Editor().Products().LinkProducts(aRootAssembly, + aSubAssembly, + TopLoc_Location(aParentTrsf2)); ASSERT_TRUE(aParentOccurrence2.IsValid()); gp_Trsf aChildTrsf1; aChildTrsf1.SetTranslation(gp_Vec(10.0, 0.0, 0.0)); const BRepGraph_OccurrenceId aChildOccurrence1 = - aGraph.Editor().Products().AddOccurrence(aSubAssembly, - aPartId, - TopLoc_Location(aChildTrsf1), - aParentOccurrence1); + aGraph.Editor().Products().LinkProducts(aSubAssembly, + aPartId, + TopLoc_Location(aChildTrsf1), + aParentOccurrence1); ASSERT_TRUE(aChildOccurrence1.IsValid()); gp_Trsf aChildTrsf2; aChildTrsf2.SetTranslation(gp_Vec(20.0, 0.0, 0.0)); const BRepGraph_OccurrenceId aChildOccurrence2 = - aGraph.Editor().Products().AddOccurrence(aSubAssembly, - aPartId, - TopLoc_Location(aChildTrsf2), - aParentOccurrence2); + aGraph.Editor().Products().LinkProducts(aSubAssembly, + aPartId, + TopLoc_Location(aChildTrsf2), + aParentOccurrence2); ASSERT_TRUE(aChildOccurrence2.IsValid()); // Verify that occurrence shapes are non-null and have children. @@ -1060,53 +1128,55 @@ TEST(BRepGraph_AssemblyTest, ShapesView_OccurrenceShape_KeepsCommonChildrenAndFiltersBranchSpecificOnes) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes34 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aSubAssembly = aGraph.Editor().Products().AddAssembly(); - const BRepGraph_ProductId aRootAssembly = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aSubAssembly = aGraph.Editor().Products().CreateEmptyProduct(); + const BRepGraph_ProductId aRootAssembly = aGraph.Editor().Products().CreateEmptyProduct(); gp_Trsf aParentTrsf1; aParentTrsf1.SetTranslation(gp_Vec(100.0, 0.0, 0.0)); const BRepGraph_OccurrenceId aParentOccurrence1 = - aGraph.Editor().Products().AddOccurrence(aRootAssembly, - aSubAssembly, - TopLoc_Location(aParentTrsf1)); + aGraph.Editor().Products().LinkProducts(aRootAssembly, + aSubAssembly, + TopLoc_Location(aParentTrsf1)); ASSERT_TRUE(aParentOccurrence1.IsValid()); gp_Trsf aParentTrsf2; aParentTrsf2.SetTranslation(gp_Vec(200.0, 0.0, 0.0)); const BRepGraph_OccurrenceId aParentOccurrence2 = - aGraph.Editor().Products().AddOccurrence(aRootAssembly, - aSubAssembly, - TopLoc_Location(aParentTrsf2)); + aGraph.Editor().Products().LinkProducts(aRootAssembly, + aSubAssembly, + TopLoc_Location(aParentTrsf2)); ASSERT_TRUE(aParentOccurrence2.IsValid()); gp_Trsf aCommonChildTrsf; aCommonChildTrsf.SetTranslation(gp_Vec(5.0, 0.0, 0.0)); const BRepGraph_OccurrenceId aCommonChildOccurrence = - aGraph.Editor().Products().AddOccurrence(aSubAssembly, - aPartId, - TopLoc_Location(aCommonChildTrsf)); + aGraph.Editor().Products().LinkProducts(aSubAssembly, + aPartId, + TopLoc_Location(aCommonChildTrsf)); ASSERT_TRUE(aCommonChildOccurrence.IsValid()); gp_Trsf aBranchChildTrsf1; aBranchChildTrsf1.SetTranslation(gp_Vec(10.0, 0.0, 0.0)); const BRepGraph_OccurrenceId aBranchChildOccurrence1 = - aGraph.Editor().Products().AddOccurrence(aSubAssembly, - aPartId, - TopLoc_Location(aBranchChildTrsf1), - aParentOccurrence1); + aGraph.Editor().Products().LinkProducts(aSubAssembly, + aPartId, + TopLoc_Location(aBranchChildTrsf1), + aParentOccurrence1); ASSERT_TRUE(aBranchChildOccurrence1.IsValid()); gp_Trsf aBranchChildTrsf2; aBranchChildTrsf2.SetTranslation(gp_Vec(20.0, 0.0, 0.0)); const BRepGraph_OccurrenceId aBranchChildOccurrence2 = - aGraph.Editor().Products().AddOccurrence(aSubAssembly, - aPartId, - TopLoc_Location(aBranchChildTrsf2), - aParentOccurrence2); + aGraph.Editor().Products().LinkProducts(aSubAssembly, + aPartId, + TopLoc_Location(aBranchChildTrsf2), + aParentOccurrence2); ASSERT_TRUE(aBranchChildOccurrence2.IsValid()); // Verify occurrence shapes are reconstructed and have children. @@ -1128,13 +1198,15 @@ TEST(BRepGraph_AssemblyTest, TEST(BRepGraph_AssemblyTest, OccurrencesOfProduct_ViaReverseIndex) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes35 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aAsmId = aGraph.Editor().Products().AddAssembly(); - (void)aGraph.Editor().Products().AddOccurrence(aAsmId, aPartId, TopLoc_Location()); - (void)aGraph.Editor().Products().AddOccurrence(aAsmId, aPartId, TopLoc_Location()); + const BRepGraph_ProductId aAsmId = aGraph.Editor().Products().CreateEmptyProduct(); + (void)aGraph.Editor().Products().LinkProducts(aAsmId, aPartId, TopLoc_Location()); + (void)aGraph.Editor().Products().LinkProducts(aAsmId, aPartId, TopLoc_Location()); // Rebuild reverse index to populate product->occurrences. // (BuildReverseIndex is called during Build, but not after Builder mutations.) @@ -1154,19 +1226,21 @@ TEST(BRepGraph_AssemblyTest, OccurrenceLocation_AlwaysTerminates) // OccurrenceLocation returns the local location from the OccurrenceRef. // No parent chain walk means no risk of infinite loops. BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes36 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aAsmId = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aAsmId = aGraph.Editor().Products().CreateEmptyProduct(); gp_Trsf aTrsf; aTrsf.SetTranslation(gp_Vec(1.0, 0.0, 0.0)); const BRepGraph_OccurrenceId anOcc1 = - aGraph.Editor().Products().AddOccurrence(aAsmId, aPartId, TopLoc_Location(aTrsf)); + aGraph.Editor().Products().LinkProducts(aAsmId, aPartId, TopLoc_Location(aTrsf)); const BRepGraph_OccurrenceId anOcc2 = - aGraph.Editor().Products().AddOccurrence(aAsmId, aPartId, TopLoc_Location(aTrsf), anOcc1); + aGraph.Editor().Products().LinkProducts(aAsmId, aPartId, TopLoc_Location(aTrsf), anOcc1); // OccurrenceLocation must terminate and return a location (local from the ref). TopLoc_Location aLoc1 = aGraph.Topo().Occurrences().OccurrenceLocation(anOcc1); @@ -1175,3 +1249,132 @@ TEST(BRepGraph_AssemblyTest, OccurrenceLocation_AlwaysTerminates) TopLoc_Location aLoc2 = aGraph.Topo().Occurrences().OccurrenceLocation(anOcc2); (void)aLoc2; // Just verify it doesn't hang. } + +// ============================================================================= +// Add(graph, shape) -- root ingestion +// ============================================================================= + +TEST(BRepGraph_AssemblyTest, Add_RootProduct_PreservesShapeLocation) +{ + BRepGraph aGraph; + TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape(); + gp_Trsf aTrsf; + aTrsf.SetTranslation(gp_Vec(5.0, 6.0, 7.0)); + aBox.Location(TopLoc_Location(aTrsf)); + + const BRepGraph_Builder::Result aResult = BRepGraph_Builder::Add(aGraph, aBox); + ASSERT_TRUE(aResult.Ok); + ASSERT_TRUE(aResult.Product.IsValid()); + ASSERT_TRUE(aResult.TopologyRoot.IsValid()); + ASSERT_TRUE(aResult.Occurrence.IsValid()); + + ASSERT_EQ(aGraph.RootProductIds().Size(), 1u); + EXPECT_EQ(aGraph.RootProductIds().Value(0), aResult.Product); + + const BRepGraph_OccurrenceRefId anOccRefId = + aGraph.Topo().Products().Definition(aResult.Product).OccurrenceRefIds.Value(0); + const TopLoc_Location& aLoc = aGraph.Refs().Occurrences().Entry(anOccRefId).LocalLocation; + EXPECT_NEAR(aLoc.Transformation().TranslationPart().X(), 5.0, Precision::Confusion()); + EXPECT_NEAR(aLoc.Transformation().TranslationPart().Y(), 6.0, Precision::Confusion()); + EXPECT_NEAR(aLoc.Transformation().TranslationPart().Z(), 7.0, Precision::Confusion()); +} + +TEST(BRepGraph_AssemblyTest, Add_NoAutoProduct_TopologyOnly) +{ + BRepGraph aGraph; + BRepGraph_Builder::Options anOpts; + anOpts.CreateAutoProduct = false; + + const BRepGraph_Builder::Result aResult = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape(), anOpts); + ASSERT_TRUE(aResult.Ok); + EXPECT_FALSE(aResult.Product.IsValid()); + EXPECT_FALSE(aResult.Occurrence.IsValid()); + ASSERT_TRUE(aResult.TopologyRoot.IsValid()); + EXPECT_EQ(aGraph.RootProductIds().Size(), 0u); +} + +TEST(BRepGraph_AssemblyTest, Add_NullShape_ReturnsInvalidResult) +{ + BRepGraph aGraph; + TopoDS_Shape aNull; + const BRepGraph_Builder::Result aResult = BRepGraph_Builder::Add(aGraph, aNull); + EXPECT_FALSE(aResult.Ok); + EXPECT_FALSE(aResult.Product.IsValid()); + EXPECT_FALSE(aResult.TopologyRoot.IsValid()); +} + +// ============================================================================= +// Add(graph, shape, parent) -- parented ingestion +// ============================================================================= + +TEST(BRepGraph_AssemblyTest, Add_ProductParent_CreatesChildPartAndOccurrence) +{ + BRepGraph aGraph; + const BRepGraph_ProductId aParent = aGraph.Editor().Products().CreateEmptyProduct(); + ASSERT_TRUE(aParent.IsValid()); + + gp_Trsf aTrsf; + aTrsf.SetTranslation(gp_Vec(2.0, 0.0, 0.0)); + TopoDS_Shape aSphere = BRepPrimAPI_MakeSphere(5.0).Shape(); + aSphere.Location(TopLoc_Location(aTrsf)); + + const BRepGraph_Builder::Result aResult = + BRepGraph_Builder::Add(aGraph, aSphere, BRepGraph_NodeId(aParent)); + ASSERT_TRUE(aResult.Ok); + ASSERT_TRUE(aResult.TopologyRoot.IsValid()); + ASSERT_TRUE(aResult.Product.IsValid()); + ASSERT_TRUE(aResult.Occurrence.IsValid()); + + EXPECT_NE(aResult.Product, aParent); + + const BRepGraphInc::ProductDef& aParentDef = aGraph.Topo().Products().Definition(aParent); + ASSERT_EQ(aParentDef.OccurrenceRefIds.Size(), 1u); + const BRepGraph_OccurrenceRefId anOccRefId = aParentDef.OccurrenceRefIds.Value(0); + const TopLoc_Location& aLoc = aGraph.Refs().Occurrences().Entry(anOccRefId).LocalLocation; + EXPECT_NEAR(aLoc.Transformation().TranslationPart().X(), 2.0, Precision::Confusion()); +} + +TEST(BRepGraph_AssemblyTest, Add_CompoundParent_AppendsAsChild) +{ + BRepGraph aGraph; + TopoDS_Compound aCompound; + BRep_Builder().MakeCompound(aCompound); + TopoDS_Shape aBox = BRepPrimAPI_MakeBox(1.0, 1.0, 1.0).Shape(); + BRep_Builder().Add(aCompound, aBox); + + const BRepGraph_Builder::Result aRoot = BRepGraph_Builder::Add(aGraph, aCompound); + ASSERT_TRUE(aRoot.Ok); + ASSERT_EQ(aRoot.TopologyRoot.NodeKind, BRepGraph_NodeId::Kind::Compound); + + const BRepGraph_CompoundId aCompoundId(aRoot.TopologyRoot); + const uint32_t aRefsBefore = + static_cast(aGraph.Topo().Compounds().Definition(aCompoundId).ChildRefIds.Size()); + + TopoDS_Shape aFace; + for (TopExp_Explorer anExp(BRepPrimAPI_MakeBox(2.0, 2.0, 2.0).Shape(), TopAbs_FACE); anExp.More(); + anExp.Next()) + { + aFace = anExp.Current(); + break; + } + ASSERT_FALSE(aFace.IsNull()); + const BRepGraph_Builder::Result aChild = + BRepGraph_Builder::Add(aGraph, aFace, BRepGraph_NodeId(aCompoundId)); + ASSERT_TRUE(aChild.Ok); + EXPECT_TRUE(aChild.InsertedRef.IsValid()); + + EXPECT_EQ(aGraph.Topo().Compounds().Definition(aCompoundId).ChildRefIds.Size(), aRefsBefore + 1u); +} + +TEST(BRepGraph_AssemblyTest, Add_InvalidParent_ReturnsInvalidResult) +{ + BRepGraph aGraph; + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes37 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(1.0, 1.0, 1.0).Shape()); + + TopoDS_Shape aBox = BRepPrimAPI_MakeBox(2.0, 2.0, 2.0).Shape(); + const BRepGraph_Builder::Result aResult = + BRepGraph_Builder::Add(aGraph, aBox, BRepGraph_NodeId()); + EXPECT_FALSE(aResult.Ok); +} diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Benchmark_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Benchmark_Test.cxx index f568bb9905..a7b54b8625 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Benchmark_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Benchmark_Test.cxx @@ -93,7 +93,9 @@ TEST(BRepGraph_BenchmarkTest, Smoke_BuildReconstructAndAdjacency) const TopoDS_Compound aFaces = makeFaceCloud(120); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aFaces); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, aFaces); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Faces().Nb(), 0); @@ -112,7 +114,9 @@ TEST(BRepGraph_BenchmarkTest, DISABLED_Build_100Faces) const TopoDS_Compound aFaces = makeFaceCloud(100); const double aAvg = runBenchmark("Build 100 faces", [&]() { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aFaces); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, aFaces); EXPECT_TRUE(aGraph.IsDone()); }); EXPECT_GT(aAvg, 0.0); @@ -123,7 +127,9 @@ TEST(BRepGraph_BenchmarkTest, DISABLED_Build_1000Faces) const TopoDS_Compound aFaces = makeFaceCloud(1000); const double aAvg = runBenchmark("Build 1000 faces", [&]() { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aFaces); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(aGraph, aFaces); EXPECT_TRUE(aGraph.IsDone()); }); EXPECT_GT(aAvg, 0.0); @@ -134,7 +140,9 @@ TEST(BRepGraph_BenchmarkTest, DISABLED_Build_10000Faces) const TopoDS_Compound aFaces = makeFaceCloud(10000); const double aAvg = runBenchmark("Build 10000 faces", [&]() { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aFaces); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes4 = + BRepGraph_Builder::Add(aGraph, aFaces); EXPECT_TRUE(aGraph.IsDone()); }); EXPECT_GT(aAvg, 0.0); @@ -145,7 +153,9 @@ TEST(BRepGraph_BenchmarkTest, DISABLED_Build_1000Faces_Parallel) const TopoDS_Compound aFaces = makeFaceCloud(1000); const double aAvg = runBenchmark("Build 1000 faces parallel", [&]() { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aFaces, true); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes5 = + BRepGraph_Builder::Add(aGraph, aFaces, BRepGraph_Builder::Options{{}, true, false, true}); EXPECT_TRUE(aGraph.IsDone()); }); EXPECT_GT(aAvg, 0.0); @@ -156,7 +166,9 @@ TEST(BRepGraph_BenchmarkTest, DISABLED_Build_10000Faces_Parallel) const TopoDS_Compound aFaces = makeFaceCloud(10000); const double aAvg = runBenchmark("Build 10000 faces parallel", [&]() { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aFaces, true); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes6 = + BRepGraph_Builder::Add(aGraph, aFaces, BRepGraph_Builder::Options{{}, true, false, true}); EXPECT_TRUE(aGraph.IsDone()); }); EXPECT_GT(aAvg, 0.0); @@ -166,7 +178,9 @@ TEST(BRepGraph_BenchmarkTest, DISABLED_Reconstruct_RoundTrip) { const TopoDS_Compound aFaces = makeFaceCloud(10000); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aFaces); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes7 = + BRepGraph_Builder::Add(aGraph, aFaces); ASSERT_TRUE(aGraph.IsDone()); const int aNbFaces = aGraph.Topo().Faces().Nb(); @@ -190,7 +204,9 @@ TEST(BRepGraph_BenchmarkTest, DISABLED_SpatialQuery_Throughput) { const TopoDS_Compound aFaces = makeFaceCloud(10000); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aFaces); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes8 = + BRepGraph_Builder::Add(aGraph, aFaces); ASSERT_TRUE(aGraph.IsDone()); const int aNbFaces = aGraph.Topo().Faces().Nb(); diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Build_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Build_Test.cxx index 22d0d8864f..149f820111 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Build_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Build_Test.cxx @@ -91,7 +91,9 @@ TEST(BRepGraph_BuildTest, Sphere_IsDone) ASSERT_TRUE(aMaker.IsDone()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, aShape); EXPECT_TRUE(aGraph.IsDone()); } @@ -101,7 +103,9 @@ TEST(BRepGraph_BuildTest, Sphere_DefCounts_MatchTopExp) const TopoDS_Shape aShape = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, aShape); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Solids().Nb(), countUnique(aShape, TopAbs_SOLID)); @@ -118,7 +122,9 @@ TEST(BRepGraph_BuildTest, Sphere_SurfaceType) const TopoDS_Shape aShape = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(aGraph, aShape); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GE(aGraph.Topo().Faces().Nb(), 1); @@ -141,7 +147,9 @@ TEST(BRepGraph_BuildTest, Sphere_HasDegenerateEdges) const TopoDS_Shape aShape = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes4 = + BRepGraph_Builder::Add(aGraph, aShape); ASSERT_TRUE(aGraph.IsDone()); // A sphere has degenerate edges at poles. @@ -167,7 +175,9 @@ TEST(BRepGraph_BuildTest, Cylinder_IsDone) ASSERT_TRUE(aMaker.IsDone()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes5 = + BRepGraph_Builder::Add(aGraph, aShape); EXPECT_TRUE(aGraph.IsDone()); } @@ -177,7 +187,9 @@ TEST(BRepGraph_BuildTest, Cylinder_DefCounts_MatchTopExp) const TopoDS_Shape aShape = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes6 = + BRepGraph_Builder::Add(aGraph, aShape); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Faces().Nb(), countUnique(aShape, TopAbs_FACE)); @@ -191,7 +203,9 @@ TEST(BRepGraph_BuildTest, Cylinder_SurfaceType) const TopoDS_Shape aShape = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes7 = + BRepGraph_Builder::Add(aGraph, aShape); ASSERT_TRUE(aGraph.IsDone()); bool aHasCylindrical = false; @@ -218,7 +232,9 @@ TEST(BRepGraph_BuildTest, Cone_IsDone) ASSERT_TRUE(aMaker.IsDone()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes8 = + BRepGraph_Builder::Add(aGraph, aShape); EXPECT_TRUE(aGraph.IsDone()); } @@ -228,7 +244,9 @@ TEST(BRepGraph_BuildTest, Cone_DefCounts_MatchTopExp) const TopoDS_Shape aShape = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes9 = + BRepGraph_Builder::Add(aGraph, aShape); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Faces().Nb(), countUnique(aShape, TopAbs_FACE)); @@ -242,7 +260,9 @@ TEST(BRepGraph_BuildTest, Cone_SurfaceType) const TopoDS_Shape aShape = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes10 = + BRepGraph_Builder::Add(aGraph, aShape); ASSERT_TRUE(aGraph.IsDone()); bool aHasConical = false; @@ -265,7 +285,9 @@ TEST(BRepGraph_BuildTest, Cone_HasDegenerateEdge) const TopoDS_Shape aShape = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes11 = + BRepGraph_Builder::Add(aGraph, aShape); ASSERT_TRUE(aGraph.IsDone()); int aDegCount = 0; @@ -290,7 +312,9 @@ TEST(BRepGraph_BuildTest, Torus_IsDone) ASSERT_TRUE(aMaker.IsDone()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes12 = + BRepGraph_Builder::Add(aGraph, aShape); EXPECT_TRUE(aGraph.IsDone()); } @@ -300,7 +324,9 @@ TEST(BRepGraph_BuildTest, Torus_DefCounts_MatchTopExp) const TopoDS_Shape aShape = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes13 = + BRepGraph_Builder::Add(aGraph, aShape); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Faces().Nb(), countUnique(aShape, TopAbs_FACE)); @@ -314,7 +340,9 @@ TEST(BRepGraph_BuildTest, Torus_SurfaceType) const TopoDS_Shape aShape = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes14 = + BRepGraph_Builder::Add(aGraph, aShape); ASSERT_TRUE(aGraph.IsDone()); bool aHasToroidal = false; @@ -341,7 +369,9 @@ TEST(BRepGraph_BuildTest, Wedge_IsDone) ASSERT_TRUE(aMaker.IsDone()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes15 = + BRepGraph_Builder::Add(aGraph, aShape); EXPECT_TRUE(aGraph.IsDone()); } @@ -351,7 +381,9 @@ TEST(BRepGraph_BuildTest, Wedge_DefCounts_MatchTopExp) const TopoDS_Shape aShape = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes16 = + BRepGraph_Builder::Add(aGraph, aShape); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Solids().Nb(), countUnique(aShape, TopAbs_SOLID)); @@ -368,7 +400,9 @@ TEST(BRepGraph_BuildTest, Wedge_AllPlanarSurfaces) const TopoDS_Shape aShape = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes17 = + BRepGraph_Builder::Add(aGraph, aShape); ASSERT_TRUE(aGraph.IsDone()); for (BRepGraph_FaceIterator aFaceIt(aGraph); aFaceIt.More(); aFaceIt.Next()) @@ -400,7 +434,9 @@ TEST(BRepGraph_BuildTest, Compound_TwoPrimitives_IsDone) aBuilder.Add(aCompound, aSphere); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes18 = + BRepGraph_Builder::Add(aGraph, aCompound); EXPECT_TRUE(aGraph.IsDone()); } @@ -419,7 +455,9 @@ TEST(BRepGraph_BuildTest, Compound_TwoPrimitives_DefCountsAddUp) aBuilder.Add(aCompound, aSphere); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes19 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Faces().Nb(), countUnique(aCompound, TopAbs_FACE)); @@ -441,7 +479,9 @@ TEST(BRepGraph_BuildTest, Compound_ThreeBoxes_DefCounts) } BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes20 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Solids().Nb(), countUnique(aCompound, TopAbs_SOLID)); @@ -468,7 +508,9 @@ TEST(BRepGraph_BuildTest, Compound_Nested_DefCounts) aBuilder.Add(anOuter, aCyl); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, anOuter); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes21 = + BRepGraph_Builder::Add(aGraph, anOuter); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Faces().Nb(), countUnique(anOuter, TopAbs_FACE)); @@ -487,7 +529,9 @@ TEST(BRepGraph_BuildTest, SinglePlanarFace_IsDone) const TopoDS_Shape aShape = aFaceMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes22 = + BRepGraph_Builder::Add(aGraph, aShape); EXPECT_TRUE(aGraph.IsDone()); } @@ -498,7 +542,9 @@ TEST(BRepGraph_BuildTest, SinglePlanarFace_Counts) const TopoDS_Shape aShape = aFaceMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes23 = + BRepGraph_Builder::Add(aGraph, aShape); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Faces().Nb(), 1); @@ -521,7 +567,9 @@ TEST(BRepGraph_BuildTest, SingleEdge_HandlesGracefully) const TopoDS_Shape aShape = anEdgeMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes24 = + BRepGraph_Builder::Add(aGraph, aShape); // BRepGraph is face-level; standalone edges may produce zero counts. // Verify it does not crash and returns consistent state. @@ -535,7 +583,9 @@ TEST(BRepGraph_BuildTest, SingleVertex_HandlesGracefully) const TopoDS_Shape aShape = aVertexMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes25 = + BRepGraph_Builder::Add(aGraph, aShape); // BRepGraph is face-level; standalone vertices may produce zero counts. EXPECT_EQ(aGraph.Topo().Faces().Nb(), 0); @@ -552,7 +602,9 @@ TEST(BRepGraph_BuildTest, Box_FaceDefCount_MatchesTopExp) const TopoDS_Shape aBox = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes26 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Faces().Nb(), countUnique(aBox, TopAbs_FACE)); @@ -565,7 +617,9 @@ TEST(BRepGraph_BuildTest, Box_EdgeDefCount_MatchesTopExp) const TopoDS_Shape aBox = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes27 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Edges().Nb(), countUnique(aBox, TopAbs_EDGE)); @@ -578,7 +632,9 @@ TEST(BRepGraph_BuildTest, Box_VertexDefCount_MatchesTopExp) const TopoDS_Shape aBox = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes28 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Vertices().Nb(), countUnique(aBox, TopAbs_VERTEX)); @@ -591,7 +647,9 @@ TEST(BRepGraph_BuildTest, Box_VertexPoints_MatchBRepTool) const TopoDS_Shape aBox = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes29 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); // Collect all vertex points from TopExp. @@ -628,7 +686,9 @@ TEST(BRepGraph_BuildTest, Box_FaceTolerances_MatchBRepTool) const TopoDS_Shape aBox = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes30 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); NCollection_IndexedMap aFaceMap; @@ -661,7 +721,9 @@ TEST(BRepGraph_BuildTest, Box_EdgeTolerances_MatchBRepTool) const TopoDS_Shape aBox = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes31 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); NCollection_IndexedMap anEdgeMap; @@ -693,7 +755,9 @@ TEST(BRepGraph_BuildTest, Box_AllSurfacesArePlanes) const TopoDS_Shape aBox = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes32 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_EQ(aGraph.Topo().Faces().Nb(), 6); @@ -713,7 +777,9 @@ TEST(BRepGraph_BuildTest, Box_NoDegenerateEdges) const TopoDS_Shape aBox = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes33 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); for (BRepGraph_EdgeIterator anEdgeIt(aGraph); anEdgeIt.More(); anEdgeIt.Next()) @@ -729,7 +795,9 @@ TEST(BRepGraph_BuildTest, Box_EdgeVertexDefsAreValid) const TopoDS_Shape aBox = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes34 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); for (BRepGraph_EdgeIterator anEdgeIt(aGraph); anEdgeIt.More(); anEdgeIt.Next()) @@ -753,7 +821,9 @@ TEST(BRepGraph_BuildTest, Box_FaceSurfacesAreValid) const TopoDS_Shape aBox = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes35 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); for (BRepGraph_FaceIterator aFaceIt(aGraph); aFaceIt.More(); aFaceIt.Next()) @@ -769,7 +839,9 @@ TEST(BRepGraph_BuildTest, Box_EdgeParamRange_IsNonDegenerate) const TopoDS_Shape aBox = aMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes36 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); for (BRepGraph_EdgeIterator anEdgeIt(aGraph); anEdgeIt.More(); anEdgeIt.Next()) @@ -782,20 +854,21 @@ TEST(BRepGraph_BuildTest, Box_EdgeParamRange_IsNonDegenerate) } } -TEST(BRepGraph_BuildTest, AppendFlattenedShape_OnEmptyGraph_BuildsFlattenedGraph) +TEST(BRepGraph_BuildTest, AddFlatten_OnEmptyGraph_BuildsFlattenedGraph) { BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); const TopoDS_Shape& aBox = aBoxMaker.Shape(); - BRepGraph aGraph; - aGraph.Editor().AppendFlattenedShape(aBox); + BRepGraph aGraph; + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes37 = + BRepGraph_Builder::Add(aGraph, aBox, BRepGraph_Builder::Options{{}, false, true, false}); EXPECT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Solids().Nb(), 0); EXPECT_EQ(aGraph.Topo().Shells().Nb(), 0); EXPECT_EQ(aGraph.Topo().Faces().Nb(), 6); - // AppendFlattenedShape creates raw topology roots (no product wrapper). + // Flatten Add creates raw topology roots (no product wrapper). // Verify the 6 appended faces directly. const int aNbFaces = aGraph.Topo().Faces().Nb(); for (BRepGraph_FaceId aFaceId(0); aFaceId.IsValid(aNbFaces); ++aFaceId) @@ -811,13 +884,15 @@ TEST(BRepGraph_BuildTest, Build_MutationBoundary_IsValid) BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBoxMaker.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes38 = + BRepGraph_Builder::Add(aGraph, aBoxMaker.Shape()); ASSERT_TRUE(aGraph.IsDone()); EXPECT_TRUE(aGraph.Editor().ValidateMutationBoundary()); } -TEST(BRepGraph_BuildTest, AppendFlattenedShape_SameFaceTwice_DedupsDefinition) +TEST(BRepGraph_BuildTest, AddFlatten_SameFaceTwice_DedupsDefinition) { BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); const TopoDS_Shape& aBox = aBoxMaker.Shape(); @@ -826,53 +901,63 @@ TEST(BRepGraph_BuildTest, AppendFlattenedShape_SameFaceTwice_DedupsDefinition) ASSERT_TRUE(anExp.More()); const TopoDS_Face aFace = TopoDS::Face(anExp.Current()); - BRepGraph aGraph; - aGraph.Editor().AppendFlattenedShape(aFace); - aGraph.Editor().AppendFlattenedShape(aFace); + BRepGraph aGraph; + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes39 = + BRepGraph_Builder::Add(aGraph, aFace, BRepGraph_Builder::Options{{}, false, true, false}); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes40 = + BRepGraph_Builder::Add(aGraph, aFace, BRepGraph_Builder::Options{{}, false, true, false}); ASSERT_TRUE(aGraph.IsDone()); // Same TShape appended twice: definition is deduplicated. ASSERT_EQ(aGraph.Topo().Faces().Nb(), 1); } -TEST(BRepGraph_BuildTest, AppendFlattenedShape_AfterBuild_DoesNotCreateNewSolidDefs) +TEST(BRepGraph_BuildTest, AddFlatten_AfterBuild_DoesNotCreateNewSolidDefs) { BRepPrimAPI_MakeBox aBox1Maker(10.0, 20.0, 30.0); BRepPrimAPI_MakeBox aBox2Maker(15.0, 25.0, 35.0); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox1Maker.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes41 = + BRepGraph_Builder::Add(aGraph, aBox1Maker.Shape()); ASSERT_TRUE(aGraph.IsDone()); const int aNbSolidsBefore = aGraph.Topo().Solids().Nb(); const int aNbFacesBefore = aGraph.Topo().Faces().Nb(); - aGraph.Editor().AppendFlattenedShape(aBox2Maker.Shape()); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes42 = + BRepGraph_Builder::Add(aGraph, + aBox2Maker.Shape(), + BRepGraph_Builder::Options{{}, false, true, false}); EXPECT_EQ(aGraph.Topo().Solids().Nb(), aNbSolidsBefore); EXPECT_EQ(aGraph.Topo().Faces().Nb(), aNbFacesBefore + 6); - // Initial BRepGraph_Builder::Perform() created 1 product; AppendFlattenedShape doesn't create + // Initial BRepGraph_Builder::Add() created 1 product; Flatten Add doesn't create // products. EXPECT_EQ(aGraph.RootProductIds().Length(), 1); EXPECT_TRUE(aGraph.Editor().ValidateMutationBoundary()); } -TEST(BRepGraph_BuildTest, AppendFullShape_MutationBoundary_IsValid) +TEST(BRepGraph_BuildTest, AddFull_MutationBoundary_IsValid) { BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); BRepPrimAPI_MakeSphere aSphereMaker(5.0); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBoxMaker.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes43 = + BRepGraph_Builder::Add(aGraph, aBoxMaker.Shape()); ASSERT_TRUE(aGraph.IsDone()); - aGraph.Editor().AppendFullShape(aSphereMaker.Shape()); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes44 = + BRepGraph_Builder::Add(aGraph, aSphereMaker.Shape()); ASSERT_TRUE(aGraph.IsDone()); EXPECT_TRUE(aGraph.Editor().ValidateMutationBoundary()); } -TEST(BRepGraph_BuildTest, AppendFlattenedShape_AppendedFaceHasNoParentShell) +TEST(BRepGraph_BuildTest, AddFlatten_AppendedFaceHasNoParentShell) { BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); const TopoDS_Shape& aBox = aBoxMaker.Shape(); @@ -881,21 +966,24 @@ TEST(BRepGraph_BuildTest, AppendFlattenedShape_AppendedFaceHasNoParentShell) ASSERT_TRUE(anExp.More()); const TopoDS_Face aFace = TopoDS::Face(anExp.Current()); - BRepGraph aGraph; - aGraph.Editor().AppendFlattenedShape(aFace); + BRepGraph aGraph; + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes45 = + BRepGraph_Builder::Add(aGraph, aFace, BRepGraph_Builder::Options{{}, false, true, false}); ASSERT_EQ(aGraph.Topo().Faces().Nb(), 1); // Appended face should not be part of any shell. EXPECT_EQ(aGraph.Topo().Shells().Nb(), 0); } -TEST(BRepGraph_BuildTest, AppendFlattenedShape_PreservesExistingUIDs) +TEST(BRepGraph_BuildTest, AddFlatten_PreservesExistingUIDs) { BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes46 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Edges().Nb(), 0); @@ -904,9 +992,10 @@ TEST(BRepGraph_BuildTest, AppendFlattenedShape_PreservesExistingUIDs) ASSERT_TRUE(anOrigUID.IsValid()); // Append a sphere. - BRepPrimAPI_MakeSphere aSphereMaker(5.0); - const TopoDS_Shape& aSphere = aSphereMaker.Shape(); - aGraph.Editor().AppendFlattenedShape(aSphere); + BRepPrimAPI_MakeSphere aSphereMaker(5.0); + const TopoDS_Shape& aSphere = aSphereMaker.Shape(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes47 = + BRepGraph_Builder::Add(aGraph, aSphere, BRepGraph_Builder::Options{{}, false, true, false}); ASSERT_TRUE(aGraph.IsDone()); // Verify original edge UID is unchanged. @@ -914,16 +1003,21 @@ TEST(BRepGraph_BuildTest, AppendFlattenedShape_PreservesExistingUIDs) EXPECT_EQ(anOrigUID, aPostUID); } -TEST(BRepGraph_BuildTest, AppendFlattenedShape_StandaloneVertex_AppendsIntoNonEmptyGraph) +TEST(BRepGraph_BuildTest, AddFlatten_StandaloneVertex_AppendsIntoNonEmptyGraph) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes48 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const int aNbVerticesBefore = aGraph.Topo().Vertices().Nb(); const TopoDS_Shape aVertexShape = BRepBuilderAPI_MakeVertex(gp_Pnt(100.0, 0.0, 0.0)).Shape(); - aGraph.Editor().AppendFlattenedShape(aVertexShape); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes49 = + BRepGraph_Builder::Add(aGraph, + aVertexShape, + BRepGraph_Builder::Options{{}, false, true, false}); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Vertices().Nb(), aNbVerticesBefore + 1); @@ -933,17 +1027,20 @@ TEST(BRepGraph_BuildTest, AppendFlattenedShape_StandaloneVertex_AppendsIntoNonEm EXPECT_FALSE(aGraph.Shapes().Shape(aNewVtx).IsNull()); } -TEST(BRepGraph_BuildTest, AppendFlattenedShape_StandaloneEdge_AppendsIntoNonEmptyGraph) +TEST(BRepGraph_BuildTest, AddFlatten_StandaloneEdge_AppendsIntoNonEmptyGraph) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes50 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const int aNbEdgesBefore = aGraph.Topo().Edges().Nb(); const TopoDS_Shape anEdgeShape = BRepBuilderAPI_MakeEdge(gp_Pnt(100.0, 0.0, 0.0), gp_Pnt(120.0, 0.0, 0.0)).Shape(); - aGraph.Editor().AppendFlattenedShape(anEdgeShape); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes51 = + BRepGraph_Builder::Add(aGraph, anEdgeShape, BRepGraph_Builder::Options{{}, false, true, false}); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Edges().Nb(), aNbEdgesBefore + 1); @@ -953,16 +1050,19 @@ TEST(BRepGraph_BuildTest, AppendFlattenedShape_StandaloneEdge_AppendsIntoNonEmpt EXPECT_FALSE(aGraph.Shapes().Shape(aNewEdge).IsNull()); } -TEST(BRepGraph_BuildTest, AppendFlattenedShape_StandaloneWire_AppendsIntoNonEmptyGraph) +TEST(BRepGraph_BuildTest, AddFlatten_StandaloneWire_AppendsIntoNonEmptyGraph) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes52 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const int aNbWiresBefore = aGraph.Topo().Wires().Nb(); const TopoDS_Shape aWireShape = makeStandaloneWire(); - aGraph.Editor().AppendFlattenedShape(aWireShape); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes53 = + BRepGraph_Builder::Add(aGraph, aWireShape, BRepGraph_Builder::Options{{}, false, true, false}); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Wires().Nb(), aNbWiresBefore + 1); @@ -972,10 +1072,12 @@ TEST(BRepGraph_BuildTest, AppendFlattenedShape_StandaloneWire_AppendsIntoNonEmpt EXPECT_FALSE(aGraph.Shapes().Shape(aNewWire).IsNull()); } -TEST(BRepGraph_BuildTest, AppendFlattenedShape_CompoundWithStandaloneShapes) +TEST(BRepGraph_BuildTest, AddFlatten_CompoundWithStandaloneShapes) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes54 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRep_Builder aBuilder; @@ -987,7 +1089,8 @@ TEST(BRepGraph_BuildTest, AppendFlattenedShape_CompoundWithStandaloneShapes) const int aNbVerticesBefore = aGraph.Topo().Vertices().Nb(); const int aNbEdgesBefore = aGraph.Topo().Edges().Nb(); - aGraph.Editor().AppendFlattenedShape(aCompound); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes55 = + BRepGraph_Builder::Add(aGraph, aCompound, BRepGraph_Builder::Options{{}, false, true, false}); ASSERT_TRUE(aGraph.IsDone()); // The compound should add at least 1 vertex and 1 edge. EXPECT_GT(aGraph.Topo().Vertices().Nb(), aNbVerticesBefore); @@ -999,13 +1102,19 @@ TEST(BRepGraph_BuildTest, Build_WithoutPostPasses_BasicQueriesWork) BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); const TopoDS_Shape& aBox = aBoxMaker.Shape(); - BRepGraph_Builder::BuildOptions anOpts; + BRepGraph_Builder::Options anOpts; anOpts.Populate.ExtractRegularities = false; anOpts.Populate.ExtractVertexPointReps = false; BRepGraph aGraph; registerStandardLayers(aGraph); - BRepGraph_Builder::Perform(aGraph, aBox, false, anOpts); + aGraph.Clear(); + { + BRepGraph_Builder::Options anOpts__ = anOpts; + anOpts__.Parallel = false; + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes56 = + BRepGraph_Builder::Add(aGraph, aBox, anOpts__); + }; ASSERT_TRUE(aGraph.IsDone()); const occ::handle aParamLayer = aGraph.LayerRegistry().FindLayer(); @@ -1037,7 +1146,9 @@ TEST(BRepGraph_BuildTest, ParamLayer_EdgeMutation_InvalidatesVertexBindings) { BRepGraph aGraph; registerStandardLayers(aGraph); - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes57 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const occ::handle aParamLayer = aGraph.LayerRegistry().FindLayer(); @@ -1060,7 +1171,9 @@ TEST(BRepGraph_BuildTest, ParamLayer_FaceMutation_InvalidatesVertexBindings) { BRepGraph aGraph; registerStandardLayers(aGraph); - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes58 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const occ::handle aParamLayer = aGraph.LayerRegistry().FindLayer(); @@ -1086,7 +1199,9 @@ TEST(BRepGraph_BuildTest, ParamLayer_CoEdgeMutation_InvalidatesPCurveBindings) { BRepGraph aGraph; registerStandardLayers(aGraph); - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes59 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const occ::handle aParamLayer = aGraph.LayerRegistry().FindLayer(); @@ -1109,7 +1224,9 @@ TEST(BRepGraph_BuildTest, RegularityLayer_EdgeMutation_InvalidatesBindings) { BRepGraph aGraph; registerStandardLayers(aGraph); - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes60 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const occ::handle aRegularityLayer = aGraph.LayerRegistry().FindLayer(); @@ -1161,7 +1278,9 @@ TEST(BRepGraph_BuildTest, RegularityLayer_FaceMutation_InvalidatesBindings) { BRepGraph aGraph; registerStandardLayers(aGraph); - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes61 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const occ::handle aRegularityLayer = aGraph.LayerRegistry().FindLayer(); @@ -1327,10 +1446,12 @@ TEST(BRepGraph_BuildTest, RootProductIds_Box_ReturnsOneProduct) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes62 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); - // BRepGraph_Builder::Perform() from a solid should produce exactly one root product. + // BRepGraph_Builder::Add() from a solid should produce exactly one root product. const NCollection_DynamicArray& aRoots = aGraph.RootProductIds(); ASSERT_EQ(aRoots.Length(), 1); @@ -1347,11 +1468,17 @@ TEST(BRepGraph_BuildTest, BuildOptions_DisableAutoProduct_DoesNotCreateProducts) BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); const TopoDS_Shape& aBox = aBoxMaker.Shape(); - BRepGraph_Builder::BuildOptions anOptions; + BRepGraph_Builder::Options anOptions; anOptions.CreateAutoProduct = false; BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox, false, anOptions); + aGraph.Clear(); + { + BRepGraph_Builder::Options anOpts__ = anOptions; + anOpts__.Parallel = false; + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes63 = + BRepGraph_Builder::Add(aGraph, aBox, anOpts__); + }; ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Products().Nb(), 0); @@ -1359,13 +1486,15 @@ TEST(BRepGraph_BuildTest, BuildOptions_DisableAutoProduct_DoesNotCreateProducts) EXPECT_EQ(aGraph.Topo().Solids().Nb(), 1); } -TEST(BRepGraph_BuildTest, RootProductIds_AppendFlattenedShape_ProductCountUnchanged) +TEST(BRepGraph_BuildTest, RootProductIds_AddFlatten_ProductCountUnchanged) { BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes64 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_EQ(aGraph.RootProductIds().Length(), 1); @@ -1377,10 +1506,11 @@ TEST(BRepGraph_BuildTest, RootProductIds_AppendFlattenedShape_ProductCountUnchan ASSERT_TRUE(anExp.More()); const TopoDS_Face aFace = TopoDS::Face(anExp.Current()); - aGraph.Editor().AppendFlattenedShape(aFace); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes65 = + BRepGraph_Builder::Add(aGraph, aFace, BRepGraph_Builder::Options{{}, false, true, false}); ASSERT_TRUE(aGraph.IsDone()); - // AppendFlattenedShape does not create new products. + // Flatten Add does not create new products. const NCollection_DynamicArray& aRoots = aGraph.RootProductIds(); EXPECT_EQ(aRoots.Length(), 1); diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Builder_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Builder_Test.cxx index 036486cdf4..26675fec10 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Builder_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Builder_Test.cxx @@ -205,7 +205,7 @@ TEST(BRepGraph_BuilderTest, AddShellAndSolid) } // ============================================================ -// Task 2B: Incremental Build (AppendFlattenedShape) +// Incremental Build (flattened Add) // ============================================================ TEST(BRepGraph_BuilderTest, AppendTwoBoxFaces) @@ -224,12 +224,17 @@ TEST(BRepGraph_BuilderTest, AppendTwoBoxFaces) BRepBuilderAPI_Copy aCopy2(aFace2, true); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCopy1.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, aCopy1.Shape()); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Faces().Nb(), 1); // Append second face. - aGraph.Editor().AppendFlattenedShape(aCopy2.Shape()); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, + aCopy2.Shape(), + BRepGraph_Builder::Options{{}, false, true, false}); EXPECT_EQ(aGraph.Topo().Faces().Nb(), 2); EXPECT_TRUE(aGraph.IsDone()); } @@ -254,7 +259,9 @@ TEST(BRepGraph_BuilderTest, RemoveFaceFromBox) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_EQ(aGraph.Topo().Faces().Nb(), 6); @@ -471,7 +478,9 @@ TEST(BRepGraph_BuilderTest, MutableFaceDefinition_ChangesTolerance) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes4 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Faces().Nb(), 0); @@ -492,7 +501,9 @@ TEST(BRepGraph_BuilderTest, MutableShellDefinition) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes5 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Shells().Nb(), 0); @@ -509,7 +520,9 @@ TEST(BRepGraph_BuilderTest, MutableSolidDefinition) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes6 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Solids().Nb(), 0); @@ -558,7 +571,9 @@ TEST(BRepGraph_BuilderTest, SkipsRemovedFaces) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes7 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_EQ(aGraph.Topo().Faces().Nb(), 6); @@ -582,7 +597,9 @@ TEST(BRepGraph_BuilderTest, SkipsRemovedEdges) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes8 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); const int aNbEdges = aGraph.Topo().Edges().Nb(); ASSERT_GT(aNbEdges, 0); @@ -674,7 +691,9 @@ TEST(BRepGraph_BuilderTest, RemoveSolid_CascadesToFaces) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes9 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_SolidId aSolidId(0); @@ -701,7 +720,9 @@ TEST(BRepGraph_BuilderTest, RemoveSubgraph_SharedFace_PreservesSharedEdgesAndVer const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes10 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); const int aNbFaces = aGraph.Topo().Faces().Nb(); @@ -744,7 +765,9 @@ TEST(BRepGraph_BuilderTest, FacesOfEdge_BoxSharedEdge) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes11 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); // Every edge in a box is shared by exactly 2 faces. @@ -763,7 +786,9 @@ TEST(BRepGraph_BuilderTest, SharedEdges_AdjacentBoxFaces) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes12 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_EQ(aGraph.Topo().Faces().Nb(), 6); @@ -790,7 +815,9 @@ TEST(BRepGraph_BuilderTest, AdjacentFaces_BoxFace) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes13 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_EQ(aGraph.Topo().Faces().Nb(), 6); @@ -824,7 +851,9 @@ TEST(BRepGraph_BuilderTest, FacesOfEdge_NoFaces_Programmatic) TEST(BRepGraph_BuilderTest, EdgesOfFace_Box_HasEdges) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes14 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); // Each box face has 4 edges (rectangular loop). @@ -841,7 +870,9 @@ TEST(BRepGraph_BuilderTest, EdgesOfFace_Box_HasEdges) TEST(BRepGraph_BuilderTest, VerticesOfEdge_Box_HasTwoVertices) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes15 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aNbVertices = 0; @@ -857,7 +888,9 @@ TEST(BRepGraph_BuilderTest, VerticesOfEdge_Box_HasTwoVertices) TEST(BRepGraph_BuilderTest, EdgesOfVertex_Box_ThreeEdges) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes16 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); // Each box corner vertex is shared by 3 edges. @@ -869,7 +902,9 @@ TEST(BRepGraph_BuilderTest, EdgesOfVertex_Box_ThreeEdges) TEST(BRepGraph_BuilderTest, AdjacentEdges_Box_SharedVertex) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes17 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); // Box edge shares 2 vertices, each with 3 incident edges. @@ -882,7 +917,9 @@ TEST(BRepGraph_BuilderTest, AdjacentEdges_Box_SharedVertex) TEST(BRepGraph_BuilderTest, NbFacesOfEdge_Box_TwoFaces) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes18 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); // Every box edge is shared by exactly 2 faces (manifold). @@ -892,7 +929,9 @@ TEST(BRepGraph_BuilderTest, NbFacesOfEdge_Box_TwoFaces) TEST(BRepGraph_BuilderTest, IsManifoldEdge_Box_True) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes19 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); EXPECT_TRUE(aGraph.Topo().Edges().IsManifold(BRepGraph_EdgeId::Start())); @@ -902,7 +941,9 @@ TEST(BRepGraph_BuilderTest, IsManifoldEdge_Box_True) TEST(BRepGraph_BuilderTest, InvalidInput_ReturnsEmpty) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes20 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); // Out-of-range typed ids return empty results. diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_ChildExplorer_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_ChildExplorer_Test.cxx index 16c1f834a7..9f68223eca 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_ChildExplorer_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_ChildExplorer_Test.cxx @@ -64,7 +64,9 @@ static BRepGraph_ChildExplorer makeDirectChildExplorer(const BRepGraph& TEST(BRepGraph_ChildExplorerTest, Box_EdgeOccurrences_Count24) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aCount = 0; @@ -81,7 +83,9 @@ TEST(BRepGraph_ChildExplorerTest, Box_EdgeOccurrences_Count24) TEST(BRepGraph_ChildExplorerTest, Box_FaceOccurrences_Count6) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aFaceCount = 0; @@ -97,7 +101,9 @@ TEST(BRepGraph_ChildExplorerTest, Box_FaceOccurrences_Count6) TEST(BRepGraph_ChildExplorerTest, Box_VertexOccurrences) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); // Count unique vertices. @@ -119,7 +125,9 @@ TEST(BRepGraph_ChildExplorerTest, Box_VertexOccurrences) TEST(BRepGraph_ChildExplorerTest, Face_EdgeOccurrences_4) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes4 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aCount = 0; @@ -135,7 +143,9 @@ TEST(BRepGraph_ChildExplorerTest, Face_EdgeOccurrences_4) TEST(BRepGraph_ChildExplorerTest, InvalidRoot_Empty) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes5 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_ChildExplorer anExp(aGraph, BRepGraph_NodeId(), BRepGraph_NodeId::Kind::Edge); @@ -145,7 +155,9 @@ TEST(BRepGraph_ChildExplorerTest, InvalidRoot_Empty) TEST(BRepGraph_ChildExplorerTest, RootEqualsTarget_ReturnsSelf) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes6 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_ChildExplorer anExp(aGraph, BRepGraph_FaceId::Start(), BRepGraph_NodeId::Kind::Face); @@ -158,7 +170,9 @@ TEST(BRepGraph_ChildExplorerTest, RootEqualsTarget_ReturnsSelf) TEST(BRepGraph_ChildExplorerTest, AvoidKind_Shell_SkipsContainedFaces) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes7 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_ChildExplorer anExp(aGraph, @@ -172,7 +186,9 @@ TEST(BRepGraph_ChildExplorerTest, AvoidKind_Shell_SkipsContainedFaces) TEST(BRepGraph_ChildExplorerTest, AvoidKind_EmitBoundary_ReturnsFacesInsteadOfEdges) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes8 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aFaceCount = 0; @@ -193,7 +209,9 @@ TEST(BRepGraph_ChildExplorerTest, AvoidKind_EmitBoundary_ReturnsFacesInsteadOfEd TEST(BRepGraph_ChildExplorerTest, AvoidKind_SameAsTarget_IsIgnored) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes9 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aFaceCount = 0; @@ -214,7 +232,9 @@ TEST(BRepGraph_ChildExplorerTest, AvoidKind_SameAsTarget_IsIgnored) TEST(BRepGraph_ChildExplorerTest, AllDescendants_Recursive_YieldsAllKinds) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes10 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aShellCount = 0; @@ -263,7 +283,9 @@ TEST(BRepGraph_ChildExplorerTest, AllDescendants_Recursive_YieldsAllKinds) TEST(BRepGraph_ChildExplorerTest, AllDescendants_AvoidFaceBoundary_StopsBelowFaces) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes11 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aShellCount = 0; @@ -294,7 +316,9 @@ TEST(BRepGraph_ChildExplorerTest, AllDescendants_AvoidFaceBoundary_StopsBelowFac TEST(BRepGraph_ChildExplorerTest, NoCumLoc_IdentityLocation) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes12 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); for (BRepGraph_ChildExplorer @@ -309,7 +333,9 @@ TEST(BRepGraph_ChildExplorerTest, NoCumLoc_IdentityLocation) TEST(BRepGraph_ChildExplorerTest, NoCumOri_ForwardOrientation) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes13 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); for (BRepGraph_ChildExplorer @@ -326,7 +352,9 @@ TEST(BRepGraph_ChildExplorerTest, NoCumOri_ForwardOrientation) TEST(BRepGraph_ChildExplorerTest, GlobalLocation_Box_Identity) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes14 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); // All paths in a simple box should compose to identity. @@ -340,7 +368,9 @@ TEST(BRepGraph_ChildExplorerTest, GlobalLocation_Box_Identity) TEST(BRepGraph_ChildExplorerTest, GlobalOrientation_BoxEdges_ForwardOrReversed) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes15 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_ChildExplorer anExp(aGraph, BRepGraph_SolidId::Start(), BRepGraph_NodeId::Kind::Edge); @@ -363,7 +393,9 @@ TEST(BRepGraph_ChildExplorerTest, Compound_FaceCount) aBB.Add(aComp, BRepPrimAPI_MakeBox(20, 20, 20).Shape()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aComp); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes16 = + BRepGraph_Builder::Add(aGraph, aComp); ASSERT_TRUE(aGraph.IsDone()); int aCount = 0; @@ -381,7 +413,9 @@ TEST(BRepGraph_ChildExplorerTest, Compound_FaceCount) TEST(BRepGraph_ChildExplorerTest, NodeOf_Kind_Face) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes17 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_ChildExplorer anExp(aGraph, BRepGraph_SolidId::Start(), BRepGraph_NodeId::Kind::Edge); @@ -408,7 +442,9 @@ TEST(BRepGraph_ChildExplorerTest, DeepCompound_NoStackOverflow) aInner = aComp; } BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aInner); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes18 = + BRepGraph_Builder::Add(aGraph, aInner); ASSERT_TRUE(aGraph.IsDone()); // Should not crash (stack overflow) and should find the box's faces. @@ -425,7 +461,9 @@ TEST(BRepGraph_ChildExplorerTest, DeepCompound_NoStackOverflow) TEST(BRepGraph_ChildExplorerTest, Recreate_ResetAndReexplore) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes19 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aFaceCount = 0; @@ -450,7 +488,9 @@ TEST(BRepGraph_ChildExplorerTest, Recreate_ResetAndReexplore) TEST(BRepGraph_ChildExplorerTest, CoEdgeTarget_Reachable) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes20 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); // CoEdge target from Solid must find all coedges (24 edge occurrences = 24 coedges). @@ -470,7 +510,9 @@ TEST(BRepGraph_ChildExplorerTest, CoEdgeTarget_Reachable) TEST(BRepGraph_ChildExplorerTest, CoEdgeTarget_FromFace_Count4) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes21 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aCount = 0; @@ -489,7 +531,9 @@ TEST(BRepGraph_ChildExplorerTest, CoEdgeTarget_FromFace_Count4) TEST(BRepGraph_ChildExplorerTest, DirectChildren_ShellFaces_CountAndOrder) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes22 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ShellId aShellId(0); @@ -522,7 +566,9 @@ TEST(BRepGraph_ChildExplorerTest, DirectChildren_ShellFaces_CountAndOrder) TEST(BRepGraph_ChildExplorerTest, DirectChildren_ShellFaces_ExposeParentAndRef) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes23 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ShellId aShellId(0); @@ -542,10 +588,13 @@ TEST(BRepGraph_ChildExplorerTest, DirectChildren_ShellFaces_ExposeParentAndRef) TEST(BRepGraph_ChildExplorerTest, DirectChildren_ProductShapeRoot_ViaOccurrenceRef) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes24 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); - const BRepGraph_ProductId aProductId = aGraph.Editor().Products().Add(BRepGraph_SolidId::Start()); + const BRepGraph_ProductId aProductId = + aGraph.Editor().Products().LinkProductToTopology(BRepGraph_SolidId::Start()); ASSERT_TRUE(aProductId.IsValid()); // In the new model, products reference children through OccurrenceRefIds. @@ -567,7 +616,9 @@ TEST(BRepGraph_ChildExplorerTest, DirectChildren_ProductShapeRoot_ViaOccurrenceR TEST(BRepGraph_ChildExplorerTest, RootEqualsTarget_LinkKindNone) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes25 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_ChildExplorer anExp(aGraph, BRepGraph_FaceId::Start(), BRepGraph_NodeId::Kind::Face); @@ -580,18 +631,21 @@ TEST(BRepGraph_ChildExplorerTest, RootEqualsTarget_LinkKindNone) TEST(BRepGraph_ChildExplorerTest, DirectChildren_ProductOccurrences_ExposeOccurrenceRefs) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes26 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); - const BRepGraph_ProductId aPart = aGraph.Editor().Products().Add(BRepGraph_SolidId::Start()); - const BRepGraph_ProductId anAssembly = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aPart = + aGraph.Editor().Products().LinkProductToTopology(BRepGraph_SolidId::Start()); + const BRepGraph_ProductId anAssembly = aGraph.Editor().Products().CreateEmptyProduct(); ASSERT_TRUE(aPart.IsValid()); ASSERT_TRUE(anAssembly.IsValid()); const BRepGraph_OccurrenceId anOcc0 = - aGraph.Editor().Products().AddOccurrence(anAssembly, aPart, TopLoc_Location()); + aGraph.Editor().Products().LinkProducts(anAssembly, aPart, TopLoc_Location()); const BRepGraph_OccurrenceId anOcc1 = - aGraph.Editor().Products().AddOccurrence(anAssembly, aPart, TopLoc_Location()); + aGraph.Editor().Products().LinkProducts(anAssembly, aPart, TopLoc_Location()); ASSERT_TRUE(anOcc0.IsValid()); ASSERT_TRUE(anOcc1.IsValid()); @@ -615,7 +669,9 @@ TEST(BRepGraph_ChildExplorerTest, DirectChildren_ProductOccurrences_ExposeOccurr TEST(BRepGraph_ChildExplorerTest, DirectChildren_RemovedFaceRef_IsSkipped) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes27 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_ShellId aShellId(0); @@ -648,7 +704,9 @@ TEST(BRepGraph_ChildExplorerTest, DirectChildren_RemovedFaceRef_IsSkipped) TEST(BRepGraph_ChildExplorerTest, DirectChildren_WireChildren_AreCoEdges) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes28 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_FaceId aFaceId(0); @@ -683,7 +741,9 @@ TEST(BRepGraph_ChildExplorerTest, DirectChildren_CompoundChildren_Basic) aBuilder.Add(aComp, BRepPrimAPI_MakeBox(20, 20, 20).Shape()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aComp); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes29 = + BRepGraph_Builder::Add(aGraph, aComp); ASSERT_TRUE(aGraph.IsDone()); int aCount = 0; @@ -714,7 +774,9 @@ TEST(BRepGraph_ChildExplorerTest, DirectChildren_ChainedTraversal_ParityWithRecu aBuilder.Add(aComp, aBox); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aComp); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes30 = + BRepGraph_Builder::Add(aGraph, aComp); ASSERT_TRUE(aGraph.IsDone()); NCollection_DataMap aExpectedLoc; @@ -775,12 +837,15 @@ TEST(BRepGraph_ChildExplorerTest, DirectChildren_ChainedTraversal_ParityWithRecu TEST(BRepGraph_ChildExplorerTest, Recursive_SharedProduct_ChildrenHaveDistinctContexts) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes31 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); - const BRepGraph_ProductId aPart = aGraph.Editor().Products().Add(BRepGraph_SolidId::Start()); + const BRepGraph_ProductId aPart = + aGraph.Editor().Products().LinkProductToTopology(BRepGraph_SolidId::Start()); ASSERT_TRUE(aPart.IsValid()); - const BRepGraph_ProductId anAssembly = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId anAssembly = aGraph.Editor().Products().CreateEmptyProduct(); ASSERT_TRUE(anAssembly.IsValid()); gp_Trsf aT1; @@ -789,9 +854,9 @@ TEST(BRepGraph_ChildExplorerTest, Recursive_SharedProduct_ChildrenHaveDistinctCo aT2.SetTranslation(gp_Vec(20.0, 0.0, 0.0)); const BRepGraph_OccurrenceId anOcc1 = - aGraph.Editor().Products().AddOccurrence(anAssembly, aPart, TopLoc_Location(aT1)); + aGraph.Editor().Products().LinkProducts(anAssembly, aPart, TopLoc_Location(aT1)); const BRepGraph_OccurrenceId anOcc2 = - aGraph.Editor().Products().AddOccurrence(anAssembly, aPart, TopLoc_Location(aT2)); + aGraph.Editor().Products().LinkProducts(anAssembly, aPart, TopLoc_Location(aT2)); ASSERT_TRUE(anOcc1.IsValid()); ASSERT_TRUE(anOcc2.IsValid()); @@ -817,18 +882,21 @@ TEST(BRepGraph_ChildExplorerTest, Recursive_SharedProduct_ChildrenHaveDistinctCo TEST(BRepGraph_ChildExplorerTest, Recursive_ProductPartRootContext_ComposedWithOccurrence) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes32 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); - const BRepGraph_ProductId aPart = aGraph.Editor().Products().Add(BRepGraph_SolidId::Start()); + const BRepGraph_ProductId aPart = + aGraph.Editor().Products().LinkProductToTopology(BRepGraph_SolidId::Start()); ASSERT_TRUE(aPart.IsValid()); - const BRepGraph_ProductId anAssembly = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId anAssembly = aGraph.Editor().Products().CreateEmptyProduct(); ASSERT_TRUE(anAssembly.IsValid()); gp_Trsf aOccTrsf; aOccTrsf.SetTranslation(gp_Vec(10.0, 0.0, 0.0)); const BRepGraph_OccurrenceId anOcc = - aGraph.Editor().Products().AddOccurrence(anAssembly, aPart, TopLoc_Location(aOccTrsf)); + aGraph.Editor().Products().LinkProducts(anAssembly, aPart, TopLoc_Location(aOccTrsf)); ASSERT_TRUE(anOcc.IsValid()); gp_Trsf aRootTrsf; @@ -844,7 +912,7 @@ TEST(BRepGraph_ChildExplorerTest, Recursive_ProductPartRootContext_ComposedWithO if (BRepGraph_NodeId::IsTopologyKind(anOccDef.ChildDefId.NodeKind)) { BRepGraph_MutGuard aMutRef = - aGraph.Editor().Products().MutOccurrenceRef(aRefId); + aGraph.Editor().Occurrences().MutRef(aRefId); aMutRef->LocalLocation = TopLoc_Location(aRootTrsf); break; } @@ -885,7 +953,9 @@ TEST(BRepGraph_ChildExplorerTest, DirectChildren_HighFanout_DirectChildrenComple aBuilder.Add(aComp, BRepPrimAPI_MakeBox(1.0 + i, 2.0, 3.0).Shape()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aComp); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes33 = + BRepGraph_Builder::Add(aGraph, aComp); ASSERT_TRUE(aGraph.IsDone()); int aCount = 0; @@ -910,7 +980,9 @@ TEST(BRepGraph_ChildExplorerTest, HighFanout_CompletesAllChildren) aBB.Add(aComp, BRepPrimAPI_MakeBox(1, 1, 1).Shape()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aComp); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes34 = + BRepGraph_Builder::Add(aGraph, aComp); ASSERT_TRUE(aGraph.IsDone()); int aFaceCount = 0; @@ -938,7 +1010,9 @@ TEST(BRepGraph_ChildExplorerTest, StructuredBindings_NodeInstance) aBuilder.Add(aComp, aBox); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aComp); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes35 = + BRepGraph_Builder::Add(aGraph, aComp); ASSERT_TRUE(aGraph.IsDone()); int aCount = 0; @@ -960,7 +1034,9 @@ TEST(BRepGraph_ChildExplorerTest, StructuredBindings_NodeInstance) TEST(BRepGraph_ChildExplorerTest, RangeFor_NodeInstance) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes36 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aCount = 0; diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Compact_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Compact_Test.cxx index 5bee837ce4..fe116097d9 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Compact_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Compact_Test.cxx @@ -125,7 +125,9 @@ TEST(BRepGraph_CompactTest, NoRemovedNodes_Noop) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); const uint32_t aNbVerticesBefore = aGraph.Topo().Vertices().Nb(); @@ -146,7 +148,9 @@ TEST(BRepGraph_CompactTest, NoRemovedNodes_Noop) TEST(BRepGraph_CompactTest, AfterDeduplicate_RemovesNodes) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedFaces()); ASSERT_TRUE(aGraph.IsDone()); // Run geometry dedup which replaces duplicate surface/curve handles directly. @@ -166,7 +170,9 @@ TEST(BRepGraph_CompactTest, AfterDeduplicate_RemovesNodes) TEST(BRepGraph_CompactTest, IndexDensity_NoGaps) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedFaces()); ASSERT_TRUE(aGraph.IsDone()); (void)BRepGraph_Deduplicate::Perform(aGraph); @@ -194,7 +200,9 @@ TEST(BRepGraph_CompactTest, IndexDensity_NoGaps) TEST(BRepGraph_CompactTest, CrossReferences_Valid) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes4 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedFaces()); ASSERT_TRUE(aGraph.IsDone()); (void)BRepGraph_Deduplicate::Perform(aGraph); @@ -207,7 +215,9 @@ TEST(BRepGraph_CompactTest, CrossReferences_Valid) TEST(BRepGraph_CompactTest, HistoryMode_RecordsMapping) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes5 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedFaces()); ASSERT_TRUE(aGraph.IsDone()); // Use full entity merge so that duplicate topology nodes are actually removed. @@ -230,7 +240,9 @@ TEST(BRepGraph_CompactTest, HistoryMode_RecordsMapping) TEST(BRepGraph_CompactTest, FullPipeline_Deduplicate_Compact_Validate) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes6 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedFaces()); ASSERT_TRUE(aGraph.IsDone()); // Full dedup (replaces duplicate handles directly on defs). @@ -252,7 +264,9 @@ TEST(BRepGraph_CompactTest, RemovalCompact_PreservesBounds_AndDoesNotGrowTopolog const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes7 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().CoEdges().Nb(), 0); ASSERT_GT(aGraph.Topo().Faces().Nb(), 2); @@ -279,7 +293,9 @@ TEST(BRepGraph_CompactTest, RemovalCompact_PreservesBounds_AndDoesNotGrowTopolog TEST(BRepGraph_CompactTest, RemovalCompact_PreservesClosedTopologyAndValidShape) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeBoxWithLooseEdge()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes8 = + BRepGraph_Builder::Add(aGraph, makeBoxWithLooseEdge()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_EdgeId aLooseEdge; @@ -320,7 +336,9 @@ TEST(BRepGraph_CompactTest, RemovalCompact_PreservesClosedTopologyAndValidShape) TEST(BRepGraph_CompactTest, AuditMode_PassesAfterDedupCompact) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes9 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedFaces()); ASSERT_TRUE(aGraph.IsDone()); ASSERT_TRUE(BRepGraph_Validate::Perform(aGraph, BRepGraph_Validate::Mode::Audit).IsValid()); @@ -333,7 +351,9 @@ TEST(BRepGraph_CompactTest, AuditMode_PassesAfterDedupCompact) TEST(BRepGraph_CompactTest, AuditMode_PassesAfterRemovalCompact) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeBoxWithLooseEdge()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes10 = + BRepGraph_Builder::Add(aGraph, makeBoxWithLooseEdge()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_EdgeId aLooseEdge; @@ -356,7 +376,9 @@ TEST(BRepGraph_CompactTest, AuditMode_PassesAfterRemovalCompact) TEST(BRepGraph_CompactTest, Compact_PreservesTopologyUIDs) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes11 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedFaces()); ASSERT_TRUE(aGraph.IsDone()); // Collect the set of all original topology UIDs before dedup+compact. @@ -443,7 +465,9 @@ TEST(BRepGraph_CompactTest, OwnGen_SurvivesCompact) constexpr uint32_t THE_EXPECTED_OWN_GEN = 2; BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes12 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedFaces()); ASSERT_TRUE(aGraph.IsDone()); // Mutate edge 0 twice so OwnGen == THE_EXPECTED_OWN_GEN. @@ -481,7 +505,9 @@ TEST(BRepGraph_CompactTest, UIDRoundTrip_AfterCompaction) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes13 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GE(aGraph.Topo().Faces().Nb(), 3); ASSERT_GE(aGraph.Topo().Edges().Nb(), 3); @@ -529,7 +555,9 @@ TEST(BRepGraph_CompactTest, CoEdgeUID_AfterCompaction) BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBoxMaker.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes14 = + BRepGraph_Builder::Add(aGraph, aBoxMaker.Shape()); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GE(aGraph.Topo().Wires().Nb(), 1); @@ -570,7 +598,9 @@ TEST(BRepGraph_CompactTest, UIDRoundTrip_RefUIDs_AfterCompaction) BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBoxMaker.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes15 = + BRepGraph_Builder::Add(aGraph, aBoxMaker.Shape()); ASSERT_TRUE(aGraph.IsDone()); // VertexRef - from Edge 0 start vertex ref. @@ -701,12 +731,14 @@ TEST(BRepGraph_CompactTest, FindNodeStillWorksAfterCompact) { // Regression for Bug B2: BRepGraph_Compact must preserve the TShape-to-NodeId // bindings so that BRepGraph::Shapes().FindNode() / HasNode() still resolves - // original BRepGraph_Builder::Perform()-time shapes after compaction. + // original BRepGraph_Builder::Add()-time shapes after compaction. BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes16 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); // Pick one face from the original build input. diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Convenience_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Convenience_Test.cxx index bc58ac6ec1..b1f9a027a2 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Convenience_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Convenience_Test.cxx @@ -34,7 +34,9 @@ protected: { BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); const TopoDS_Shape& aBox = aBoxMaker.Shape(); - BRepGraph_Builder::Perform(myGraph, aBox); + myGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(myGraph, aBox); } BRepGraph myGraph; @@ -207,7 +209,9 @@ TEST_F(BRepGraph_ConvenienceTest, FindPCurve_WithOrientation_SeamEdge) const TopoDS_Shape& aCyl = aCylMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCyl); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, aCyl); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph::TopoView aDefs = aGraph.Topo(); diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Copy_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Copy_Test.cxx index 9c3af9f158..161704b2a6 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Copy_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Copy_Test.cxx @@ -66,7 +66,9 @@ TEST(BRepGraph_CopyTest, CopyBox_FaceCount) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); BRepGraph aCopyGraph = BRepGraph_Copy::Perform(aGraph, true); @@ -94,7 +96,9 @@ TEST(BRepGraph_CopyTest, CopyBox_AreaPreserved) const double anOrigArea = aOrigProps.Mass(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); BRepGraph aCopyGraph = BRepGraph_Copy::Perform(aGraph, true); @@ -121,7 +125,9 @@ TEST(BRepGraph_CopyTest, CopyBox_GeometryIsIndependent) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); BRepGraph aCopyGraph = BRepGraph_Copy::Perform(aGraph, true); @@ -140,7 +146,9 @@ TEST(BRepGraph_CopyTest, CopyBox_SharedGeometry) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes4 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); // theCopyGeom = false: geometry is shared. @@ -160,7 +168,9 @@ TEST(BRepGraph_CopyTest, CopyBox_PreservesFreshNodeCache) const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes5 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_FaceId aFaceId(0); @@ -181,7 +191,9 @@ TEST(BRepGraph_CopyTest, CopyBox_DoesNotPreserveStaleNodeCache) const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes6 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_FaceId aFaceId(0); @@ -210,7 +222,9 @@ TEST(BRepGraph_CopyTest, CopyBox_PreservesFreshFaceRefCache) const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes7 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Refs().Faces().Nb(), 0); @@ -231,7 +245,9 @@ TEST(BRepGraph_CopyTest, CopyBox_DoesNotPreserveStaleFaceRefCache) const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes8 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Refs().Faces().Nb(), 0); @@ -262,7 +278,9 @@ TEST(BRepGraph_CopyTest, CopyCylinder_FaceCount) const TopoDS_Shape& aCyl = aCylMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCyl); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes9 = + BRepGraph_Builder::Add(aGraph, aCyl); ASSERT_TRUE(aGraph.IsDone()); BRepGraph aCopyGraph = BRepGraph_Copy::Perform(aGraph, true); @@ -276,7 +294,9 @@ TEST(BRepGraph_CopyTest, CopySingleFace) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes10 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Faces().Nb(), 0); @@ -318,7 +338,9 @@ TEST(BRepGraph_CopyTest, CopyFacesOnly_Compound) } BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes11 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); ASSERT_EQ(aGraph.Topo().Faces().Nb(), 6); ASSERT_EQ(aGraph.Topo().Solids().Nb(), 0); @@ -340,7 +362,9 @@ TEST(BRepGraph_CopyTest, CopyBox_SameParameter_Preserved) const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes12 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); BRepGraph aCopyGraph = BRepGraph_Copy::Perform(aGraph, true); @@ -376,7 +400,9 @@ TEST(BRepGraph_CopyTest, FusedBoxes_Regularity_AreaPreserved) const double anOrigArea = aOrigProps.Mass(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aFused); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes13 = + BRepGraph_Builder::Add(aGraph, aFused); ASSERT_TRUE(aGraph.IsDone()); BRepGraph aCopyGraph = BRepGraph_Copy::Perform(aGraph, true); @@ -408,7 +434,9 @@ TEST(BRepGraph_CopyTest, CopyBox_UIDsPreserved) const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes14 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); BRepGraph aCopyGraph = BRepGraph_Copy::Perform(aGraph, true); diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Deduplicate_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Deduplicate_Test.cxx index ee8553c8e4..8ad47fb811 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Deduplicate_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Deduplicate_Test.cxx @@ -293,7 +293,9 @@ int addDuplicatePCurvesToAllEdges(BRepGraph& theGraph) TEST(BRepGraph_DeduplicateTest, AnalyzeOnly_DoesNotRewrite) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); ASSERT_EQ(nbUniqueFaceSurfaceDefs(aGraph), 2); @@ -310,7 +312,9 @@ TEST(BRepGraph_DeduplicateTest, AnalyzeOnly_DoesNotRewrite) TEST(BRepGraph_DeduplicateTest, AnalyzeOnly_ReportsCanonicalCandidates) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_Deduplicate::Options anOpts; @@ -327,7 +331,9 @@ TEST(BRepGraph_DeduplicateTest, AnalyzeOnly_ReportsCanonicalCandidates) TEST(BRepGraph_DeduplicateTest, CanonicalizeSurfaces_RewritesAndRecordsHistory) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); ASSERT_EQ(nbUniqueFaceSurfaceDefs(aGraph), 2); @@ -348,7 +354,9 @@ TEST(BRepGraph_DeduplicateTest, CanonicalizeSurfaces_RewritesAndRecordsHistory) TEST(BRepGraph_DeduplicateTest, CanonicalizeCurves_RewritesAndReducesUnique) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes4 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); ASSERT_EQ(nbUniqueEdgeCurveDefs(aGraph), 8); @@ -364,7 +372,9 @@ TEST(BRepGraph_DeduplicateTest, CanonicalizeCurves_RewritesAndReducesUnique) TEST(BRepGraph_DeduplicateTest, HistoryModeOff_DoesNotAddHistory) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes5 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); ASSERT_EQ(aGraph.History().NbRecords(), 0); @@ -381,7 +391,9 @@ TEST(BRepGraph_DeduplicateTest, HistoryModeOff_DoesNotAddHistory) TEST(BRepGraph_DeduplicateTest, RestoresHistoryEnabledFlag) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes6 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); aGraph.History().SetEnabled(false); @@ -397,7 +409,9 @@ TEST(BRepGraph_DeduplicateTest, RestoresHistoryEnabledFlag) TEST(BRepGraph_DeduplicateTest, DefaultOverload_PerformWorks) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes7 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_Deduplicate::Result aRes = BRepGraph_Deduplicate::Perform(aGraph); @@ -417,7 +431,9 @@ TEST(BRepGraph_DeduplicateTest, SingleFace_NoSurfaceRewrite) ASSERT_TRUE(anExp.More()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, anExp.Current()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes8 = + BRepGraph_Builder::Add(aGraph, anExp.Current()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_Deduplicate::Result aRes = BRepGraph_Deduplicate::Perform(aGraph); @@ -429,7 +445,7 @@ TEST(BRepGraph_DeduplicateTest, SingleFace_NoSurfaceRewrite) TEST(BRepGraph_DeduplicateTest, NotDoneGraph_ReturnsEmptyResult) { BRepGraph aGraph; - // Do not call BRepGraph_Builder::Perform() - graph is not done. + // Do not call BRepGraph_Builder::Add() - graph is not done. ASSERT_FALSE(aGraph.IsDone()); const BRepGraph_Deduplicate::Result aRes = BRepGraph_Deduplicate::Perform(aGraph); @@ -446,7 +462,9 @@ TEST(BRepGraph_DeduplicateTest, NotDoneGraph_ReturnsEmptyResult) TEST(BRepGraph_DeduplicateTest, Idempotent_SecondRunNoRewrites) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes9 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_Deduplicate::Result aRes1 = BRepGraph_Deduplicate::Perform(aGraph); @@ -472,7 +490,9 @@ TEST(BRepGraph_DeduplicateTest, FullBox_AllSurfacesUnique) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes10 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); // A box has 6 faces with 6 distinct Geom_Plane instances (different origins/normals). @@ -485,7 +505,9 @@ TEST(BRepGraph_DeduplicateTest, FullBox_AllSurfacesUnique) TEST(BRepGraph_DeduplicateTest, ResultCountersConsistency) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes11 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); // TwoCopiedFaces: 2 surfaces, 8 curves, 8 PCurves. @@ -514,7 +536,9 @@ TEST(BRepGraph_DeduplicateTest, EmptyCompound_NoRewrites) aBuilder.MakeCompound(aCompound); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes12 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_Deduplicate::Result aRes = BRepGraph_Deduplicate::Perform(aGraph); @@ -526,7 +550,9 @@ TEST(BRepGraph_DeduplicateTest, MultipleCopies_NWayDedup) { const int aNbCopies = 4; BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeNCopiedIdenticalFaces(aNbCopies)); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes13 = + BRepGraph_Builder::Add(aGraph, makeNCopiedIdenticalFaces(aNbCopies)); ASSERT_TRUE(aGraph.IsDone()); ASSERT_EQ(aGraph.Topo().Faces().Nb(), aNbCopies); @@ -540,7 +566,9 @@ TEST(BRepGraph_DeduplicateTest, MultipleCopies_NWayDedup) TEST(BRepGraph_DeduplicateTest, MixedGeometry_OnlyIdenticalDeduped) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeMixedCompound()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes14 = + BRepGraph_Builder::Add(aGraph, makeMixedCompound()); ASSERT_TRUE(aGraph.IsDone()); // 2 box face copies + 1 cylinder face = 3 faces, 3 surfaces, 11 curves. @@ -564,7 +592,9 @@ TEST(BRepGraph_DeduplicateTest, AfterDedup_AllCopiedFacesShareCanonicalSurface) { const int aNbCopies = 3; BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeNCopiedIdenticalFaces(aNbCopies)); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes15 = + BRepGraph_Builder::Add(aGraph, makeNCopiedIdenticalFaces(aNbCopies)); ASSERT_TRUE(aGraph.IsDone()); (void)BRepGraph_Deduplicate::Perform(aGraph); @@ -586,7 +616,9 @@ TEST(BRepGraph_DeduplicateTest, AfterDedup_AllCopiedFacesShareCanonicalSurface) TEST(BRepGraph_DeduplicateTest, HistoryRecordNames_MatchExpectedOps) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes16 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_Deduplicate::Options anOpts; @@ -610,7 +642,9 @@ TEST(BRepGraph_DeduplicateTest, HistoryRecordNames_MatchExpectedOps) TEST(BRepGraph_DeduplicateTest, AnalyzeOnly_CurveAndPCurveCountsReported) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes17 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_Deduplicate::Options anOpts; @@ -657,7 +691,9 @@ TEST(BRepGraph_DeduplicateTest, DefaultResultStruct_AllZeroed) TEST(BRepGraph_DeduplicateTest, MergeDefsWhenSafe_MergesVertices) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes18 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); const int aNbVerticesBefore = aGraph.Topo().Vertices().Nb(); @@ -679,7 +715,9 @@ TEST(BRepGraph_DeduplicateTest, MergeDefsWhenSafe_MergesVertices) TEST(BRepGraph_DeduplicateTest, NestedCompound_AllCopiesDeduped) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeNestedCompound()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes19 = + BRepGraph_Builder::Add(aGraph, makeNestedCompound()); ASSERT_TRUE(aGraph.IsDone()); // 3 copies of the same face across nested compounds: 3 surfaces, 12 curves. @@ -702,7 +740,9 @@ TEST(BRepGraph_DeduplicateTest, NestedCompound_AllCopiesDeduped) TEST(BRepGraph_DeduplicateTest, ThreeDistinctPrimitives_MinimalDedup) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeThreeDistinctPrimitives()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes20 = + BRepGraph_Builder::Add(aGraph, makeThreeDistinctPrimitives()); ASSERT_TRUE(aGraph.IsDone()); // Box(6 faces) + Sphere(1 face) + Cone(3 faces) = 10 faces, 18 edges. @@ -721,7 +761,9 @@ TEST(BRepGraph_DeduplicateTest, ThreeDistinctPrimitives_MinimalDedup) TEST(BRepGraph_DeduplicateTest, TwoIdenticalBoxes_SurfacesAndCurvesDeduped) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoIdenticalBoxes()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes21 = + BRepGraph_Builder::Add(aGraph, makeTwoIdenticalBoxes()); ASSERT_TRUE(aGraph.IsDone()); // Two identical boxes: 12 faces, 24 edges, 12 geom surfaces, 24 geom curves. @@ -748,7 +790,9 @@ TEST(BRepGraph_DeduplicateTest, TwoIdenticalBoxes_SurfacesAndCurvesDeduped) TEST(BRepGraph_DeduplicateTest, CurveRewriteCount_MatchesDuplicateEdgeCurves) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes22 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); // TwoCopiedFaces: 8 geom curves, 4 canonical -> 4 duplicates. @@ -768,7 +812,9 @@ TEST(BRepGraph_DeduplicateTest, CurveRewriteCount_MatchesDuplicateEdgeCurves) TEST(BRepGraph_DeduplicateTest, AfterDedup_AllCopiedEdgesShareCanonicalCurve) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes23 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); ASSERT_EQ(nbUniqueEdgeCurveDefs(aGraph), 8); @@ -790,7 +836,9 @@ TEST(BRepGraph_DeduplicateTest, MultiplePCurveDups_AllEdgesDeduped) BRepBuilderAPI_Copy aCopy(anExp.Current(), true); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCopy.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes24 = + BRepGraph_Builder::Add(aGraph, aCopy.Shape()); ASSERT_TRUE(aGraph.IsDone()); const int aDupCount = addDuplicatePCurvesToAllEdges(aGraph); @@ -806,7 +854,9 @@ TEST(BRepGraph_DeduplicateTest, PCurveDup_AnalyzeOnly_CountsButNoRewrite) BRepBuilderAPI_Copy aCopy(anExp.Current(), true); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCopy.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes25 = + BRepGraph_Builder::Add(aGraph, aCopy.Shape()); ASSERT_TRUE(aGraph.IsDone()); const int aDupCount = addDuplicatePCurvesToAllEdges(aGraph); @@ -830,7 +880,9 @@ TEST(BRepGraph_DeduplicateTest, NoPCurveDuplicates_ZeroPCurveRewrites) BRepBuilderAPI_Copy aCopy(anExp.Current(), true); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCopy.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes26 = + BRepGraph_Builder::Add(aGraph, aCopy.Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_Deduplicate::Result aRes = BRepGraph_Deduplicate::Perform(aGraph); @@ -843,7 +895,9 @@ TEST(BRepGraph_DeduplicateTest, NoPCurveDuplicates_ZeroPCurveRewrites) TEST(BRepGraph_DeduplicateTest, HistoryFindOriginal_TracesBackToCanonical) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes27 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_Deduplicate::Options anOpts; @@ -879,7 +933,9 @@ TEST(BRepGraph_DeduplicateTest, HistoryFindOriginal_TracesBackToCanonical) TEST(BRepGraph_DeduplicateTest, HistoryFindDerived_ContainsCanonicalNode) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes28 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_Deduplicate::Options anOpts; @@ -913,7 +969,9 @@ TEST(BRepGraph_DeduplicateTest, HistoryFindDerived_ContainsCanonicalNode) TEST(BRepGraph_DeduplicateTest, HistoryRecordSequenceNumbers_AreMonotonic) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes29 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_Deduplicate::Options anOpts; @@ -938,7 +996,9 @@ TEST(BRepGraph_DeduplicateTest, HistoryRecordSequenceNumbers_AreMonotonic) TEST(BRepGraph_DeduplicateTest, HistoryOff_NbRecordsUnchanged) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes30 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); // Run once with history to get 5 records (1 surface + 4 curve canonicalizes). @@ -949,7 +1009,9 @@ TEST(BRepGraph_DeduplicateTest, HistoryOff_NbRecordsUnchanged) // Fresh graph, run with history off - no records should be added. BRepGraph aGraph2; - BRepGraph_Builder::Perform(aGraph2, makeTwoCopiedIdenticalFaces()); + aGraph2.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes31 = + BRepGraph_Builder::Add(aGraph2, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph2.IsDone()); BRepGraph_Deduplicate::Options anOpts2; @@ -968,7 +1030,9 @@ TEST(BRepGraph_DeduplicateTest, HistoryOff_NbRecordsUnchanged) TEST(BRepGraph_DeduplicateTest, AfterDedup_AllSurfacesValid) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes32 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); (void)BRepGraph_Deduplicate::Perform(aGraph); @@ -985,7 +1049,9 @@ TEST(BRepGraph_DeduplicateTest, AfterDedup_AllSurfacesValid) TEST(BRepGraph_DeduplicateTest, AfterDedup_AllCurve3dsValid) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes33 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); (void)BRepGraph_Deduplicate::Perform(aGraph); @@ -1009,7 +1075,9 @@ TEST(BRepGraph_DeduplicateTest, AfterDedup_AllInlinePCurvesHaveCurve2d) BRepBuilderAPI_Copy aCopy(anExp.Current(), true); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCopy.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes34 = + BRepGraph_Builder::Add(aGraph, aCopy.Shape()); ASSERT_TRUE(aGraph.IsDone()); (void)addDuplicatePCurvesToAllEdges(aGraph); @@ -1033,7 +1101,9 @@ TEST(BRepGraph_DeduplicateTest, AfterDedup_AllInlinePCurvesHaveCurve2d) TEST(BRepGraph_DeduplicateTest, AfterDedup_CanonicalSurfaceGeomNotNull) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeNCopiedIdenticalFaces(4)); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes35 = + BRepGraph_Builder::Add(aGraph, makeNCopiedIdenticalFaces(4)); ASSERT_TRUE(aGraph.IsDone()); (void)BRepGraph_Deduplicate::Perform(aGraph); @@ -1051,7 +1121,9 @@ TEST(BRepGraph_DeduplicateTest, AfterDedup_CanonicalSurfaceGeomNotNull) TEST(BRepGraph_DeduplicateTest, AfterDedup_CanonicalCurveGeomNotNull) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes36 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); (void)BRepGraph_Deduplicate::Perform(aGraph); @@ -1077,11 +1149,17 @@ TEST(BRepGraph_DeduplicateTest, ParallelBuild_SameResultAsSequential) const TopoDS_Compound aCompound = makeTwoCopiedIdenticalFaces(); BRepGraph aGraphSeq; - BRepGraph_Builder::Perform(aGraphSeq, aCompound, false); + aGraphSeq.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes37 = + BRepGraph_Builder::Add(aGraphSeq, + aCompound, + BRepGraph_Builder::Options{{}, true, false, false}); ASSERT_TRUE(aGraphSeq.IsDone()); BRepGraph aGraphPar; - BRepGraph_Builder::Perform(aGraphPar, aCompound, true); + aGraphPar.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes38 = + BRepGraph_Builder::Add(aGraphPar, aCompound, BRepGraph_Builder::Options{{}, true, false, true}); ASSERT_TRUE(aGraphPar.IsDone()); const BRepGraph_Deduplicate::Result aResSeq = BRepGraph_Deduplicate::Perform(aGraphSeq); @@ -1106,7 +1184,9 @@ TEST(BRepGraph_DeduplicateTest, TenCopies_AllDeduplicatedToOneSurface) { const int aNbCopies = 10; BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeNCopiedIdenticalFaces(aNbCopies)); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes39 = + BRepGraph_Builder::Add(aGraph, makeNCopiedIdenticalFaces(aNbCopies)); ASSERT_TRUE(aGraph.IsDone()); ASSERT_EQ(aGraph.Topo().Faces().Nb(), aNbCopies); @@ -1120,7 +1200,9 @@ TEST(BRepGraph_DeduplicateTest, TenCopies_AllDeduplicatedToOneSurface) TEST(BRepGraph_DeduplicateTest, TwoCopies_CurveCanonicalCountLessThanTotal) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes40 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); // 8 geom curves, 4 canonical. @@ -1140,7 +1222,9 @@ TEST(BRepGraph_DeduplicateTest, TwoCopies_CurveCanonicalCountLessThanTotal) TEST(BRepGraph_DeduplicateTest, Idempotent_MixedCompound_SurfacesAndCurves) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeMixedCompound()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes41 = + BRepGraph_Builder::Add(aGraph, makeMixedCompound()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_Deduplicate::Result aRes1 = BRepGraph_Deduplicate::Perform(aGraph); @@ -1161,7 +1245,9 @@ TEST(BRepGraph_DeduplicateTest, Idempotent_MixedCompound_SurfacesAndCurves) TEST(BRepGraph_DeduplicateTest, Idempotent_TwoIdenticalBoxes) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoIdenticalBoxes()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes42 = + BRepGraph_Builder::Add(aGraph, makeTwoIdenticalBoxes()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_Deduplicate::Result aRes1 = BRepGraph_Deduplicate::Perform(aGraph); @@ -1186,7 +1272,9 @@ TEST(BRepGraph_DeduplicateTest, DISABLED_PCurveDedup_RewritesReduceUniquePCurveN BRepBuilderAPI_Copy aCopy(anExp.Current(), true); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCopy.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes43 = + BRepGraph_Builder::Add(aGraph, aCopy.Shape()); ASSERT_TRUE(aGraph.IsDone()); (void)addDuplicatePCurvesToAllEdges(aGraph); @@ -1206,7 +1294,9 @@ TEST(BRepGraph_DeduplicateTest, DISABLED_PCurveDedup_RewritesReduceUniquePCurveN TEST(BRepGraph_DeduplicateTest, RestoresHistoryFlag_WhenHistoryModeOff) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes44 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); aGraph.History().SetEnabled(true); @@ -1223,7 +1313,9 @@ TEST(BRepGraph_DeduplicateTest, RestoresHistoryFlag_WhenHistoryModeOff) TEST(BRepGraph_DeduplicateTest, RestoresHistoryFlag_AnalyzeOnlyPath) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes45 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); aGraph.History().SetEnabled(true); @@ -1244,7 +1336,9 @@ TEST(BRepGraph_DeduplicateTest, RestoresHistoryFlag_AnalyzeOnlyPath) TEST(BRepGraph_DeduplicateTest, GeomCountsUnchanged_AfterDedup) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes46 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); // TwoCopiedFaces: 2 surfaces, 8 curves, 8 PCurves. @@ -1263,7 +1357,9 @@ TEST(BRepGraph_DeduplicateTest, GeomCountsUnchanged_AfterDedup) TEST(BRepGraph_DeduplicateTest, DefCountsUnchanged_AfterDedup) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes47 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); // TwoCopiedFaces: 2 face defs, 8 edge defs. @@ -1284,7 +1380,9 @@ TEST(BRepGraph_DeduplicateTest, PCurveEntryCount_UnchangedAfterDedup) BRepBuilderAPI_Copy aCopy(anExp.Current(), true); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCopy.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes48 = + BRepGraph_Builder::Add(aGraph, aCopy.Shape()); ASSERT_TRUE(aGraph.IsDone()); (void)addDuplicatePCurvesToAllEdges(aGraph); @@ -1320,7 +1418,9 @@ TEST(BRepGraph_DeduplicateTest, TwoCopiedSphereFaces_Deduped) aBuilder.Add(aCompound, aCopy2.Shape()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes49 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); // Two sphere face copies: 2 faces, 6 edges. @@ -1355,7 +1455,9 @@ TEST(BRepGraph_DeduplicateTest, TwoCopiedCylinderFaces_Deduped) aBuilder.Add(aCompound, aCopy2.Shape()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes50 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); // Two cylinder face copies: 2 faces, 6 edges, 2 surfaces, 6 curves, 12 PCurves. @@ -1389,7 +1491,9 @@ TEST(BRepGraph_DeduplicateTest, DifferentSizedCylinders_NotDeduped) aBuilder.Add(aCompound, anExp2.Current()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes51 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); // Two distinct cylinder faces: 2 surfaces, 6 curves. @@ -1414,7 +1518,9 @@ TEST(BRepGraph_DeduplicateTest, DifferentSizedCylinders_NotDeduped) TEST(BRepGraph_DeduplicateTest, BackRefs_SurfaceRewrite_UpdatesFaceDefUsers) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes52 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); // Before dedup: each face has its own surface handle. @@ -1432,7 +1538,9 @@ TEST(BRepGraph_DeduplicateTest, BackRefs_SurfaceRewrite_UpdatesFaceDefUsers) TEST(BRepGraph_DeduplicateTest, BackRefs_CurveRewrite_UpdatesEdgeDefUsers) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes53 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); // Before dedup: 8 edges, each with its own curve handle. @@ -1457,7 +1565,9 @@ TEST(BRepGraph_DeduplicateTest, BackRefs_CurveRewrite_UpdatesEdgeDefUsers) TEST(BRepGraph_DeduplicateTest, FacesOnSurface_AfterDedup_ReturnsCorrectDefs) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes54 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); (void)BRepGraph_Deduplicate::Perform(aGraph); @@ -1473,7 +1583,9 @@ TEST(BRepGraph_DeduplicateTest, FacesOnSurface_AfterDedup_ReturnsCorrectDefs) TEST(BRepGraph_DeduplicateTest, Nullify_OrphanedSurface_HandleIsNull) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes55 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_Deduplicate::Result aRes = BRepGraph_Deduplicate::Perform(aGraph); @@ -1492,7 +1604,9 @@ TEST(BRepGraph_DeduplicateTest, Nullify_OrphanedSurface_HandleIsNull) TEST(BRepGraph_DeduplicateTest, Nullify_OrphanedCurve_HandleIsNull) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes56 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_Deduplicate::Result aRes = BRepGraph_Deduplicate::Perform(aGraph); @@ -1521,7 +1635,9 @@ TEST(BRepGraph_DeduplicateTest, Nullify_OrphanedPCurve_HandleIsNull) BRepBuilderAPI_Copy aCopy(anExp.Current(), true); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCopy.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes57 = + BRepGraph_Builder::Add(aGraph, aCopy.Shape()); ASSERT_TRUE(aGraph.IsDone()); const int aDupCount = addDuplicatePCurvesToAllEdges(aGraph); @@ -1536,7 +1652,9 @@ TEST(BRepGraph_DeduplicateTest, Nullify_OrphanedPCurve_HandleIsNull) TEST(BRepGraph_DeduplicateTest, AnalyzeOnly_NoBackRefChangesOrNullification) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes58 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); // Snapshot surface/curve pointers before. @@ -1598,7 +1716,9 @@ TEST(BRepGraph_DeduplicateTest, RoundTrip_TwoCopiedFaces_FewerSurfaces) // First graph: build and dedup. BRepGraph aGraph1; - BRepGraph_Builder::Perform(aGraph1, aCompound); + aGraph1.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes59 = + BRepGraph_Builder::Add(aGraph1, aCompound); ASSERT_TRUE(aGraph1.IsDone()); ASSERT_EQ(aGraph1.Topo().Faces().Nb(), 2); @@ -1619,7 +1739,9 @@ TEST(BRepGraph_DeduplicateTest, RoundTrip_TwoCopiedFaces_FewerSurfaces) // Second graph: build from reconstructed shape. BRepGraph aGraph2; - BRepGraph_Builder::Perform(aGraph2, aReconstructed); + aGraph2.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes60 = + BRepGraph_Builder::Add(aGraph2, aReconstructed); ASSERT_TRUE(aGraph2.IsDone()); // Face defs count stays 2 (topology defs, not geometry nodes). @@ -1634,7 +1756,9 @@ TEST(BRepGraph_DeduplicateTest, RoundTrip_TwoCopiedFaces_FewerCurves) const TopoDS_Compound aCompound = makeTwoCopiedIdenticalFaces(); BRepGraph aGraph1; - BRepGraph_Builder::Perform(aGraph1, aCompound); + aGraph1.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes61 = + BRepGraph_Builder::Add(aGraph1, aCompound); ASSERT_TRUE(aGraph1.IsDone()); ASSERT_EQ(aGraph1.Topo().Edges().Nb(), 8); @@ -1654,7 +1778,9 @@ TEST(BRepGraph_DeduplicateTest, RoundTrip_TwoCopiedFaces_FewerCurves) } BRepGraph aGraph2; - BRepGraph_Builder::Perform(aGraph2, aReconstructed); + aGraph2.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes62 = + BRepGraph_Builder::Add(aGraph2, aReconstructed); ASSERT_TRUE(aGraph2.IsDone()); // Edge defs count stays 8 (topology defs, not geometry nodes). @@ -1682,7 +1808,9 @@ TEST(BRepGraph_DeduplicateTest, Build_SharedTFace_OneSurfaceNode) aBuilder.Add(aCompound, aFace1); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes63 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); // Both face usages share the same TFace -> same raw surface pointer -> one surface node. @@ -1694,7 +1822,9 @@ TEST(BRepGraph_DeduplicateTest, RoundTrip_TwoBoxes_GeomReduction) const TopoDS_Compound aCompound = makeTwoIdenticalBoxes(); BRepGraph aGraph1; - BRepGraph_Builder::Perform(aGraph1, aCompound); + aGraph1.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes64 = + BRepGraph_Builder::Add(aGraph1, aCompound); ASSERT_TRUE(aGraph1.IsDone()); const int aSurfsBefore = aGraph1.Topo().Faces().Nb(); @@ -1711,7 +1841,9 @@ TEST(BRepGraph_DeduplicateTest, RoundTrip_TwoBoxes_GeomReduction) // Build second graph. BRepGraph aGraph2; - BRepGraph_Builder::Perform(aGraph2, aReconstructed); + aGraph2.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes65 = + BRepGraph_Builder::Add(aGraph2, aReconstructed); ASSERT_TRUE(aGraph2.IsDone()); // Face/edge def counts stay the same (topology defs, not geometry nodes). @@ -1731,7 +1863,9 @@ TEST(BRepGraph_DeduplicateTest, RoundTrip_TwoBoxes_GeomReduction) TEST(BRepGraph_DeduplicateTest, MergeVertices_SharedVerticesReduced) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes66 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); const int aNbVerticesBefore = aGraph.Topo().Vertices().Nb(); @@ -1755,7 +1889,9 @@ TEST(BRepGraph_DeduplicateTest, MergeVertices_SharedVerticesReduced) TEST(BRepGraph_DeduplicateTest, MergeEdges_SharedEdgesReduced) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes67 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_Deduplicate::Options anOpts; @@ -1768,7 +1904,9 @@ TEST(BRepGraph_DeduplicateTest, MergeEdges_SharedEdgesReduced) TEST(BRepGraph_DeduplicateTest, MergeWires_IdenticalWiresMerged) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes68 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_Deduplicate::Options anOpts; @@ -1782,7 +1920,9 @@ TEST(BRepGraph_DeduplicateTest, MergeWires_IdenticalWiresMerged) TEST(BRepGraph_DeduplicateTest, MergeFaces_IdenticalFacesMerged) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes69 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_Deduplicate::Options anOpts; @@ -1796,7 +1936,9 @@ TEST(BRepGraph_DeduplicateTest, MergeFaces_IdenticalFacesMerged) TEST(BRepGraph_DeduplicateTest, MergeDefsWhenSafe_False_NoMerge) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes70 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); // Default: MergeEntitiesWhenSafe = false. @@ -1811,7 +1953,9 @@ TEST(BRepGraph_DeduplicateTest, MergeDefsWhenSafe_False_NoMerge) TEST(BRepGraph_DeduplicateTest, AnalyzeOnly_MergeDefsWhenSafe_CountsOnly) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes71 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); const int aNbVerticesBefore = aGraph.Topo().Vertices().Nb(); @@ -1831,7 +1975,9 @@ TEST(BRepGraph_DeduplicateTest, AnalyzeOnly_MergeDefsWhenSafe_CountsOnly) TEST(BRepGraph_DeduplicateTest, HistoryRecords_MergePhases) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes72 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_Deduplicate::Options anOpts; @@ -1852,7 +1998,9 @@ TEST(BRepGraph_DeduplicateTest, HistoryRecords_MergePhases) TEST(BRepGraph_DeduplicateTest, AfterMerge_Validate_NoIssues) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes73 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_Deduplicate::Options anOpts; @@ -1876,7 +2024,9 @@ TEST(BRepGraph_DeduplicateTest, VertexMerge_UpdatesInternalEdgeVertexRefs) // Regression for Bug A1: Phase 1 vertex merge must update EdgeDef.InternalVertexRefIds. // Without the fix, BRepGraph_Compact would silently drop the internal vertex ref. BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes74 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Edges().Nb(), 0); ASSERT_GT(aGraph.Topo().Vertices().Nb(), 0); @@ -1935,7 +2085,9 @@ TEST(BRepGraph_DeduplicateTest, VertexMerge_UpdatesFaceDirectVertexRefs) // Regression for Bug A2: Phase 1 vertex merge must update FaceDef.VertexRefIds. // Without the fix, BRepGraph_Compact would silently drop the direct face vertex ref. BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes75 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Faces().Nb(), 0); ASSERT_GT(aGraph.Topo().Vertices().Nb(), 0); @@ -1994,7 +2146,9 @@ TEST(BRepGraph_DeduplicateTest, WireDedup_PreservesShellAuxChildRefs) // Regression for Bug A3: Phase 3 wire merge must update ShellDef.AuxChildRefIds. // Deduplicate redirects AuxChildRef from the removed (old) wire to the canonical wire. BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeTwoCopiedIdenticalFaces()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes76 = + BRepGraph_Builder::Add(aGraph, makeTwoCopiedIdenticalFaces()); ASSERT_TRUE(aGraph.IsDone()); // Two wires are built (one outer wire per copied face). diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_DeferredInvalidation_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_DeferredInvalidation_Test.cxx index de546a6070..eb00054321 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_DeferredInvalidation_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_DeferredInvalidation_Test.cxx @@ -37,7 +37,9 @@ protected: { BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); const TopoDS_Shape& aBox = aBoxMaker.Shape(); - BRepGraph_Builder::Perform(myGraph, aBox); + myGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(myGraph, aBox); ASSERT_TRUE(myGraph.IsDone()); } @@ -310,9 +312,9 @@ TEST_F(BRepGraph_DeferredInvalidationTest, { // Build an assembly: root product + child occurrence referencing it. const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aAssemblyId = myGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aAssemblyId = myGraph.Editor().Products().CreateEmptyProduct(); const BRepGraph_OccurrenceId anOccId = - myGraph.Editor().Products().AddOccurrence(aAssemblyId, aPartId, TopLoc_Location()); + myGraph.Editor().Products().LinkProducts(aAssemblyId, aPartId, TopLoc_Location()); ASSERT_TRUE(anOccId.IsValid()); // Verify parent product starts clean. @@ -329,8 +331,7 @@ TEST_F(BRepGraph_DeferredInvalidationTest, { gp_Trsf aTrsf; aTrsf.SetTranslation(gp_Vec(100.0, 0.0, 0.0)); - myGraph.Editor().Products().MutOccurrenceRef(anOccRefId)->LocalLocation = - TopLoc_Location(aTrsf); + myGraph.Editor().Occurrences().MutRef(anOccRefId)->LocalLocation = TopLoc_Location(aTrsf); } // During deferred mode: ref modified. diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_DefsIterator_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_DefsIterator_Test.cxx index e313b40187..fe5feea727 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_DefsIterator_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_DefsIterator_Test.cxx @@ -99,7 +99,9 @@ protected: void SetUp() override { BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); - BRepGraph_Builder::Perform(myGraph, aBoxMaker.Shape()); + myGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(myGraph, aBoxMaker.Shape()); } BRepGraph myGraph; @@ -135,7 +137,9 @@ TEST_F(BRepGraph_DefsIteratorTest, CoEdgeOfWire_YieldsCoEdgeDefinitions) TEST(BRepGraph_DefsIteratorTestStandalone, VertexOfEdge_IncludesInternalVertices) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, wrapEdgeInFace(makeEdgeWithInternalVertex())); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, wrapEdgeInFace(makeEdgeWithInternalVertex())); BRepGraph_EdgeId aEdgeWithInternal; for (BRepGraph_EdgeIterator anEdgeIt(aGraph); anEdgeIt.More(); anEdgeIt.Next()) @@ -168,7 +172,9 @@ TEST(BRepGraph_DefsIteratorTestStandalone, VertexOfEdge_IncludesInternalVertices TEST(BRepGraph_DefsIteratorTestStandalone, VertexOfFace_EnumeratesDirectVertices) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeFaceWithDirectVertex()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(aGraph, makeFaceWithDirectVertex()); ASSERT_EQ(countIterator(BRepGraph_DefsWireOfFace(aGraph, BRepGraph_FaceId::Start())), 1); ASSERT_EQ(countIterator(BRepGraph_DefsVertexOfFace(aGraph, BRepGraph_FaceId::Start())), 1); @@ -217,15 +223,16 @@ TEST_F(BRepGraph_DefsIteratorTest, SolidOfCompSolid_EnumeratesDirectSolids) TEST_F(BRepGraph_DefsIteratorTest, OccurrenceOfProduct_EnumeratesDirectOccurrences) { - const BRepGraph_ProductId aPart = myGraph.Editor().Products().Add(BRepGraph_SolidId::Start()); - const BRepGraph_ProductId anAssembly = myGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aPart = + myGraph.Editor().Products().LinkProductToTopology(BRepGraph_SolidId::Start()); + const BRepGraph_ProductId anAssembly = myGraph.Editor().Products().CreateEmptyProduct(); ASSERT_TRUE(aPart.IsValid()); ASSERT_TRUE(anAssembly.IsValid()); EXPECT_TRUE( - myGraph.Editor().Products().AddOccurrence(anAssembly, aPart, TopLoc_Location()).IsValid()); + myGraph.Editor().Products().LinkProducts(anAssembly, aPart, TopLoc_Location()).IsValid()); EXPECT_TRUE( - myGraph.Editor().Products().AddOccurrence(anAssembly, aPart, TopLoc_Location()).IsValid()); + myGraph.Editor().Products().LinkProducts(anAssembly, aPart, TopLoc_Location()).IsValid()); EXPECT_EQ(countIterator(BRepGraph_DefsOccurrenceOfProduct(myGraph, anAssembly)), 2); } diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_EdgeCases_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_EdgeCases_Test.cxx index 746e68d398..c902d4f10c 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_EdgeCases_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_EdgeCases_Test.cxx @@ -32,7 +32,9 @@ TEST(BRepGraph_EdgeCasesTest, Build_NullShape_IsDoneFalse) { BRepGraph aGraph; TopoDS_Shape aNullShape; - BRepGraph_Builder::Perform(aGraph, aNullShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, aNullShape); EXPECT_FALSE(aGraph.IsDone()); } @@ -42,7 +44,9 @@ TEST(BRepGraph_EdgeCasesTest, Build_EmptyCompound_IsDoneZeroCounts) BRep_Builder aBuilder; TopoDS_Compound aCompound; aBuilder.MakeCompound(aCompound); - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, aCompound); // Whether IsDone is true or false for an empty compound is implementation-defined; // the key invariant is that all definition counts are zero. @@ -60,7 +64,9 @@ TEST(BRepGraph_EdgeCasesTest, Shape_InvalidNodeId_ReturnsNull) { BRepGraph aGraph; BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); - BRepGraph_Builder::Perform(aGraph, aBoxMaker.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(aGraph, aBoxMaker.Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_NodeId anInvalidId; // default: Index = -1 @@ -72,7 +78,9 @@ TEST(BRepGraph_EdgeCasesTest, ReconstructShape_InvalidNodeId_ReturnsNull) { BRepGraph aGraph; BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); - BRepGraph_Builder::Perform(aGraph, aBoxMaker.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes4 = + BRepGraph_Builder::Add(aGraph, aBoxMaker.Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_NodeId anInvalidId; @@ -84,7 +92,9 @@ TEST(BRepGraph_EdgeCasesTest, TopoEntity_InvalidNodeId_ReturnsNull) { BRepGraph aGraph; BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); - BRepGraph_Builder::Perform(aGraph, aBoxMaker.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes5 = + BRepGraph_Builder::Add(aGraph, aBoxMaker.Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_NodeId anInvalidId; @@ -109,11 +119,15 @@ TEST(BRepGraph_EdgeCasesTest, Build_TwiceOnSameGraph_GenerationIncrements) BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); const TopoDS_Shape aBox = aBoxMaker.Shape(); - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes6 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); const uint32_t aFirstGen = aGraph.UIDs().Generation(); - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes7 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); const uint32_t aSecondGen = aGraph.UIDs().Generation(); @@ -128,7 +142,9 @@ TEST(BRepGraph_EdgeCasesTest, Build_TwiceOnSameGraph_OldUIDsInvalidated) const TopoDS_Shape aBox = aBoxMaker.Shape(); // First build: collect total UID counter used. - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes8 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); const uint32_t aFirstGen = aGraph.UIDs().Generation(); @@ -137,7 +153,9 @@ TEST(BRepGraph_EdgeCasesTest, Build_TwiceOnSameGraph_OldUIDsInvalidated) ASSERT_GT(aTotalFirstBuild, 0u); // Second build. - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes9 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); const uint32_t aSecondGen = aGraph.UIDs().Generation(); EXPECT_NE(aFirstGen, aSecondGen); @@ -156,7 +174,9 @@ TEST(BRepGraph_EdgeCasesTest, Build_TwiceOnSameGraph_CountsResetCorrectly) BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); const TopoDS_Shape aBox = aBoxMaker.Shape(); - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes10 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); const int aSolids1 = aGraph.Topo().Solids().Nb(); @@ -169,7 +189,9 @@ TEST(BRepGraph_EdgeCasesTest, Build_TwiceOnSameGraph_CountsResetCorrectly) const int aCurves1 = aGraph.Topo().Edges().Nb(); // Rebuild with same shape. - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes11 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Solids().Nb(), aSolids1); @@ -191,7 +213,9 @@ TEST(BRepGraph_EdgeCasesTest, UID_AlwaysEnabled_AfterBuild) BRepGraph aGraph; BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); - BRepGraph_Builder::Perform(aGraph, aBoxMaker.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes12 = + BRepGraph_Builder::Add(aGraph, aBoxMaker.Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_NodeId aSolidId(BRepGraph_NodeId::Kind::Solid, 0); @@ -209,11 +233,15 @@ TEST(BRepGraph_EdgeCasesTest, ParallelBuild_Sphere_SameAsSequential) const TopoDS_Shape aSphere = aSphereMaker.Shape(); BRepGraph aSeqGraph; - BRepGraph_Builder::Perform(aSeqGraph, aSphere, false); + aSeqGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes13 = + BRepGraph_Builder::Add(aSeqGraph, aSphere, BRepGraph_Builder::Options{{}, true, false, false}); ASSERT_TRUE(aSeqGraph.IsDone()); BRepGraph aParGraph; - BRepGraph_Builder::Perform(aParGraph, aSphere, true); + aParGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes14 = + BRepGraph_Builder::Add(aParGraph, aSphere, BRepGraph_Builder::Options{{}, true, false, true}); ASSERT_TRUE(aParGraph.IsDone()); EXPECT_EQ(aParGraph.Topo().Solids().Nb(), aSeqGraph.Topo().Solids().Nb()); @@ -242,11 +270,17 @@ TEST(BRepGraph_EdgeCasesTest, ParallelBuild_Compound_SameAsSequential) aBuilder.Add(aCompound, aBox3.Shape()); BRepGraph aSeqGraph; - BRepGraph_Builder::Perform(aSeqGraph, aCompound, false); + aSeqGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes15 = + BRepGraph_Builder::Add(aSeqGraph, + aCompound, + BRepGraph_Builder::Options{{}, true, false, false}); ASSERT_TRUE(aSeqGraph.IsDone()); BRepGraph aParGraph; - BRepGraph_Builder::Perform(aParGraph, aCompound, true); + aParGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes16 = + BRepGraph_Builder::Add(aParGraph, aCompound, BRepGraph_Builder::Options{{}, true, false, true}); ASSERT_TRUE(aParGraph.IsDone()); EXPECT_EQ(aParGraph.Topo().Solids().Nb(), aSeqGraph.Topo().Solids().Nb()); diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_EventBus_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_EventBus_Test.cxx index 4bd95629e4..1f1320cfed 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_EventBus_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_EventBus_Test.cxx @@ -205,7 +205,9 @@ protected: { BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); const TopoDS_Shape& aBox = aBoxMaker.Shape(); - BRepGraph_Builder::Perform(myGraph, aBox); + myGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(myGraph, aBox); ASSERT_TRUE(myGraph.IsDone()); } diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Fuzz_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Fuzz_Test.cxx index 8225abe162..d9b10f9fd3 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Fuzz_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Fuzz_Test.cxx @@ -179,7 +179,9 @@ TEST_P(BRepGraph_FuzzSeedTest, BoxSeed_RandomMutations_RemainValid) const uint32_t aSeed = GetParam(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); ASSERT_TRUE(BRepGraph_Validate::Perform(aGraph, BRepGraph_Validate::Options::Audit()).IsValid()) << "Seed graph must be clean before fuzzing"; @@ -194,7 +196,9 @@ TEST_P(BRepGraph_FuzzSeedTest, CylinderSeed_RandomMutations_RemainValid) const uint32_t aSeed = GetParam(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeCylinder(5.0, 15.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeCylinder(5.0, 15.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); ASSERT_TRUE(BRepGraph_Validate::Perform(aGraph, BRepGraph_Validate::Options::Audit()).IsValid()); diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Geometry_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Geometry_Test.cxx index 40080c400d..cf4faa4de7 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Geometry_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Geometry_Test.cxx @@ -94,7 +94,9 @@ static NCollection_DataMap faceCountsByComponent(const BRepGraph& theG TEST(BRepGraph_GeometryTest, Sphere_AllFaces_SameSurface) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeSphere(15.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeSphere(15.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); // All face defs of a sphere share the same surface handle. @@ -118,7 +120,9 @@ TEST(BRepGraph_GeometryTest, Sphere_AllFaces_SameSurface) TEST(BRepGraph_GeometryTest, Sphere_AllFacesShareSurface) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeSphere(15.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeSphere(15.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); // All faces of a sphere share the same surface pointer. @@ -140,7 +144,9 @@ TEST(BRepGraph_GeometryTest, Sphere_AllFacesShareSurface) TEST(BRepGraph_GeometryTest, Box_Curve3d_ValidForAll12Edges) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Edges().Nb(), 12); @@ -155,7 +161,9 @@ TEST(BRepGraph_GeometryTest, Box_Curve3d_ValidForAll12Edges) TEST(BRepGraph_GeometryTest, Box_AllEdgesHaveCurve3d) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes4 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); for (BRepGraph_EdgeIterator anEdgeIt(aGraph); anEdgeIt.More(); anEdgeIt.Next()) @@ -169,7 +177,9 @@ TEST(BRepGraph_GeometryTest, Box_AllEdgesHaveCurve3d) TEST(BRepGraph_GeometryTest, Box_FindPCurve_AllEdgeFacePairs_Valid) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes5 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aPCurveCount = 0; @@ -193,7 +203,9 @@ TEST(BRepGraph_GeometryTest, Box_FindPCurve_AllEdgeFacePairs_Valid) TEST(BRepGraph_GeometryTest, CoEdge_FaceDefIdValid) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes6 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); for (BRepGraph_EdgeIterator anEdgeIt(aGraph); anEdgeIt.More(); anEdgeIt.Next()) @@ -213,7 +225,9 @@ TEST(BRepGraph_GeometryTest, CoEdge_FaceDefIdValid) TEST(BRepGraph_GeometryTest, CoEdge_ParamRange_NonZero) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes7 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aCoEdgeCount = 0; @@ -238,7 +252,9 @@ TEST(BRepGraph_GeometryTest, CoEdge_Continuity_Valid) const TopoDS_Shape aShape = BRepPrimAPI_MakeCylinder(10.0, 20.0).Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes8 = + BRepGraph_Builder::Add(aGraph, aShape); ASSERT_TRUE(aGraph.IsDone()); bool hasNonC0Continuity = false; @@ -262,7 +278,9 @@ TEST(BRepGraph_GeometryTest, CoEdge_Continuity_Valid) TEST(BRepGraph_GeometryTest, FaceDef_Surface_IsNotNull) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes9 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); for (BRepGraph_FaceIterator aFaceIt(aGraph); aFaceIt.More(); aFaceIt.Next()) @@ -275,7 +293,9 @@ TEST(BRepGraph_GeometryTest, FaceDef_Surface_IsNotNull) TEST(BRepGraph_GeometryTest, EdgeDef_Curve3d_IsNotNull) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes10 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); for (BRepGraph_EdgeIterator anEdgeIt(aGraph); anEdgeIt.More(); anEdgeIt.Next()) @@ -288,7 +308,9 @@ TEST(BRepGraph_GeometryTest, EdgeDef_Curve3d_IsNotNull) TEST(BRepGraph_GeometryTest, SameDomainFaces_SimpleBox_Empty) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes11 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); // For a simple box each face has a unique surface, so SameDomainFaces is empty. @@ -317,7 +339,9 @@ TEST(BRepGraph_GeometryTest, CompoundWithMovedChild_SharedSolidDef) aBuilder.Add(aCompound, aMoved); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes12 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); // Moved() preserves TShape - one solid definition, two compound ChildRefs. @@ -329,7 +353,9 @@ TEST(BRepGraph_GeometryTest, CompoundWithMovedChild_SharedSolidDef) TEST(BRepGraph_GeometryTest, FaceDef_Triangulation_NullForAnalyticNoCrash) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes13 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); // Analytical box faces should have null triangulation (no mesh computed). @@ -349,7 +375,9 @@ TEST(BRepGraph_GeometryTest, FaceDef_Triangulation_NullForAnalyticNoCrash) TEST(BRepGraph_GeometryTest, SolidDef_CountMatchesNb) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes14 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aCount = 0; @@ -364,7 +392,9 @@ TEST(BRepGraph_GeometryTest, SolidDef_CountMatchesNb) TEST(BRepGraph_GeometryTest, ShellDef_CountMatchesNb) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes15 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aCount = 0; @@ -379,7 +409,9 @@ TEST(BRepGraph_GeometryTest, ShellDef_CountMatchesNb) TEST(BRepGraph_GeometryTest, FaceDef_CountMatchesNb) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes16 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aCount = 0; @@ -394,7 +426,9 @@ TEST(BRepGraph_GeometryTest, FaceDef_CountMatchesNb) TEST(BRepGraph_GeometryTest, WireDef_CountMatchesNb) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes17 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aCount = 0; @@ -409,7 +443,9 @@ TEST(BRepGraph_GeometryTest, WireDef_CountMatchesNb) TEST(BRepGraph_GeometryTest, EdgeDef_CountMatchesNb) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes18 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aCount = 0; @@ -424,7 +460,9 @@ TEST(BRepGraph_GeometryTest, EdgeDef_CountMatchesNb) TEST(BRepGraph_GeometryTest, VertexDef_CountMatchesNb) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes19 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aCount = 0; @@ -439,7 +477,9 @@ TEST(BRepGraph_GeometryTest, VertexDef_CountMatchesNb) TEST(BRepGraph_GeometryTest, FaceDef_CountViaIterator_MatchesNb) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes20 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aCount = 0; @@ -454,7 +494,9 @@ TEST(BRepGraph_GeometryTest, FaceDef_CountViaIterator_MatchesNb) TEST(BRepGraph_GeometryTest, FaceDef_AllSurfacesNonNull) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes21 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aCount = 0; @@ -469,7 +511,9 @@ TEST(BRepGraph_GeometryTest, FaceDef_AllSurfacesNonNull) TEST(BRepGraph_GeometryTest, EdgeDef_AllCurves3dNonNull) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes22 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aCount = 0; @@ -487,7 +531,9 @@ TEST(BRepGraph_GeometryTest, EdgeDef_AllCurves3dNonNull) TEST(BRepGraph_GeometryTest, AllCoEdgesHaveCurve2d) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes23 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); int aCount = 0; @@ -507,7 +553,9 @@ TEST(BRepGraph_GeometryTest, AllCoEdgesHaveCurve2d) TEST(BRepGraph_GeometryTest, CoEdgePCurveAdaptor_FallsBackOnPlaneWhenStoredPCurveRemoved) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes24 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_CoEdgeId aCoEdgeId; @@ -548,7 +596,9 @@ TEST(BRepGraph_GeometryTest, CoEdgePCurveAdaptor_FallsBackOnPlaneWhenStoredPCurv TEST(BRepGraph_GeometryTest, ConnectedComponents_SingleBox_OneComponent) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes25 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const NCollection_DataMap aFaceCounts = faceCountsByComponent(aGraph); @@ -574,7 +624,9 @@ TEST(BRepGraph_GeometryTest, ConnectedComponents_TwoBoxCompound_TwoComponents) aBuilder.Add(aCompound, aBox2); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes26 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); const NCollection_DataMap aFaceCounts = faceCountsByComponent(aGraph); @@ -594,7 +646,9 @@ TEST(BRepGraph_GeometryTest, ConnectedComponents_TwoBoxCompound_FacesGroupedPerR aBuilder.Add(aCompound, aBox2); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes27 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); const NCollection_DataMap aFaceCounts = faceCountsByComponent(aGraph); @@ -618,7 +672,9 @@ TEST(BRepGraph_GeometryTest, ConnectedComponents_TwoBoxCompound_CoverAllFaces) aBuilder.Add(aCompound, aBox2); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes28 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); const NCollection_DataMap aFaceCounts = faceCountsByComponent(aGraph); @@ -638,7 +694,9 @@ TEST(BRepGraph_GeometryTest, ConnectedComponents_TwoBoxCompound_CoverAllFaces) TEST(BRepGraph_GeometryTest, Box_EdgeDef_SameParameter_IsSet) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes29 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Edges().Nb(), 0); @@ -653,7 +711,9 @@ TEST(BRepGraph_GeometryTest, Box_EdgeDef_SameParameter_IsSet) TEST(BRepGraph_GeometryTest, Box_EdgeDef_SameRange_IsSet) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes30 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Edges().Nb(), 0); @@ -672,7 +732,9 @@ TEST(BRepGraph_GeometryTest, Cylinder_SeamEdge_HasTwoCoEdges) { // A cylinder has a seam edge on its lateral face. BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeCylinder(5.0, 20.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes31 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeCylinder(5.0, 20.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); // Find a seam edge via CoEdge SeamPairId. @@ -703,7 +765,9 @@ TEST(BRepGraph_GeometryTest, Cylinder_SeamEdge_FindPCurve_WithOrientation) { // Verify FindPCurve(edge, face, orientation) returns different entries for FORWARD vs REVERSED. BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeCylinder(5.0, 20.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes32 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeCylinder(5.0, 20.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); for (BRepGraph_EdgeIterator anEdgeIt(aGraph); anEdgeIt.More(); anEdgeIt.Next()) @@ -737,7 +801,9 @@ TEST(BRepGraph_GeometryTest, Cylinder_SeamEdge_FindPCurve_WithOrientation) TEST(BRepGraph_GeometryTest, Box_FindPCurve_MatchesToolOverload) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes33 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); for (BRepGraph_EdgeIterator anEdgeIt(aGraph); anEdgeIt.More(); anEdgeIt.Next()) @@ -766,7 +832,9 @@ TEST(BRepGraph_GeometryTest, Box_FindPCurve_MatchesToolOverload) TEST(BRepGraph_GeometryTest, Cylinder_SeamEdge_FindPCurve_DistinguishesOrientation) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeCylinder(5.0, 20.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes34 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeCylinder(5.0, 20.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); for (BRepGraph_EdgeIterator anEdgeIt(aGraph); anEdgeIt.More(); anEdgeIt.Next()) @@ -805,7 +873,9 @@ TEST(BRepGraph_GeometryTest, Cylinder_SeamEdge_FindPCurve_DistinguishesOrientati TEST(BRepGraph_GeometryTest, Box_RepCounts_MatchTopology) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes35 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); EXPECT_GT(aGraph.Topo().Geometry().NbSurfaces(), 0); @@ -846,7 +916,9 @@ TEST(BRepGraph_GeometryTest, Box_RepCounts_MatchTopology) TEST(BRepGraph_GeometryTest, Sphere_SurfaceDedup_SharedHandle) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeSphere(15.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes36 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeSphere(15.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); // All faces of a sphere share the same TShape -> same entity -> same surface. @@ -865,7 +937,9 @@ TEST(BRepGraph_GeometryTest, Sphere_SurfaceDedup_SharedHandle) TEST(BRepGraph_GeometryTest, Cylinder_TriangulationReps_Populated) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeCylinder(5.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes37 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeCylinder(5.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); for (BRepGraph_FaceIterator aFaceIt(aGraph); aFaceIt.More(); aFaceIt.Next()) @@ -934,7 +1008,9 @@ TEST(BRepGraph_GeometryTest, Compound_TwoBoxes_SurfaceDedup) aBuilder.Add(aCompound, aBox2); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes38 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Faces().Nb(), 12); @@ -958,7 +1034,9 @@ TEST(BRepGraph_GeometryTest, Compound_TwoBoxes_SurfaceDedup) TEST(BRepGraph_GeometryTest, Box_Polygon2DRep_MatchesInline) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes39 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); // Every coedge with a Polygon2DRepId has a valid polygon rep. diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_History_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_History_Test.cxx index b2b133bebc..059501f2df 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_History_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_History_Test.cxx @@ -34,7 +34,9 @@ protected: void SetUp() override { BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); - BRepGraph_Builder::Perform(myGraph, aBoxMaker.Shape()); + myGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(myGraph, aBoxMaker.Shape()); } BRepGraph myGraph; diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Iterator_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Iterator_Test.cxx index d29cadfada..f1e708cadd 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Iterator_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Iterator_Test.cxx @@ -29,7 +29,9 @@ protected: void SetUp() override { BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); - BRepGraph_Builder::Perform(myGraph, aBoxMaker.Shape()); + myGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(myGraph, aBoxMaker.Shape()); } BRepGraph myGraph; diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_MeshCache_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_MeshCache_Test.cxx index e292fc6986..64a24e9882 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_MeshCache_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_MeshCache_Test.cxx @@ -34,7 +34,9 @@ namespace BRepGraph makeBoxGraph() { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); return aGraph; } diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_MutGuard_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_MutGuard_Test.cxx index 1ba956015a..0422a4d870 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_MutGuard_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_MutGuard_Test.cxx @@ -38,7 +38,9 @@ namespace BRepGraph makeBoxGraph() { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); return aGraph; } diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_MutationGen_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_MutationGen_Test.cxx index d8bb249744..47926ebc80 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_MutationGen_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_MutationGen_Test.cxx @@ -27,7 +27,9 @@ protected: { BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); const TopoDS_Shape& aBox = aBoxMaker.Shape(); - BRepGraph_Builder::Perform(myGraph, aBox); + myGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(myGraph, aBox); ASSERT_TRUE(myGraph.IsDone()); } diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_NodeId_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_NodeId_Test.cxx index e75f992ad3..5ee65d121d 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_NodeId_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_NodeId_Test.cxx @@ -58,7 +58,9 @@ TEST(BRepGraph_NodeIdTest, ImplicitConversion_PassToFunction) { // Typed ids work with existing APIs that take BRepGraph_NodeId. BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_FaceId aFace(0); diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_ParentExplorer_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_ParentExplorer_Test.cxx index 36eb1fbf08..8c934d47a5 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_ParentExplorer_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_ParentExplorer_Test.cxx @@ -27,7 +27,9 @@ TEST(BRepGraph_ParentExplorerTest, FaceParents_All_CountAndOrder) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_ParentExplorer anExp(aGraph, BRepGraph_FaceId::Start()); @@ -49,7 +51,9 @@ TEST(BRepGraph_ParentExplorerTest, FaceParents_All_CountAndOrder) TEST(BRepGraph_ParentExplorerTest, FaceParents_TypedSolid_OneResult) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_ParentExplorer anExp(aGraph, BRepGraph_FaceId::Start(), BRepGraph_NodeId::Kind::Solid); @@ -63,7 +67,9 @@ TEST(BRepGraph_ParentExplorerTest, FaceParents_TypedSolid_OneResult) TEST(BRepGraph_ParentExplorerTest, FaceParents_DirectParents_StopsAtImmediateShell) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_ParentExplorer anExp(aGraph, @@ -79,7 +85,9 @@ TEST(BRepGraph_ParentExplorerTest, FaceParents_DirectParents_StopsAtImmediateShe TEST(BRepGraph_ParentExplorerTest, FaceParents_DirectParents_ExposeChildAndRef) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes4 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_ParentExplorer anExp(aGraph, @@ -98,7 +106,9 @@ TEST(BRepGraph_ParentExplorerTest, FaceParents_DirectParents_ExposeChildAndRef) TEST(BRepGraph_ParentExplorerTest, AvoidKind_Solid_PrunesProducts) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes5 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_ParentExplorer anExp(aGraph, @@ -112,7 +122,9 @@ TEST(BRepGraph_ParentExplorerTest, AvoidKind_Solid_PrunesProducts) TEST(BRepGraph_ParentExplorerTest, AvoidKind_EmitBoundary_ReturnsSolidInsteadOfProducts) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes6 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_ParentExplorer anExp(aGraph, @@ -130,7 +142,9 @@ TEST(BRepGraph_ParentExplorerTest, AvoidKind_EmitBoundary_ReturnsSolidInsteadOfP TEST(BRepGraph_ParentExplorerTest, AvoidKind_SameAsTarget_IsIgnored) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes7 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_ParentExplorer anExp(aGraph, @@ -148,7 +162,9 @@ TEST(BRepGraph_ParentExplorerTest, AvoidKind_SameAsTarget_IsIgnored) TEST(BRepGraph_ParentExplorerTest, AllParents_AvoidSolid_PrunesProducts) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes8 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_ParentExplorer anExp(aGraph, @@ -165,7 +181,9 @@ TEST(BRepGraph_ParentExplorerTest, AllParents_AvoidSolid_PrunesProducts) TEST(BRepGraph_ParentExplorerTest, AllParents_AvoidSolidEmitBoundary_ReturnsShellAndSolid) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes9 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_ParentExplorer anExp(aGraph, @@ -186,11 +204,14 @@ TEST(BRepGraph_ParentExplorerTest, AllParents_AvoidSolidEmitBoundary_ReturnsShel TEST(BRepGraph_ParentExplorerTest, SharedProduct_ProductParentsKeepDistinctContexts) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes10 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); - const BRepGraph_ProductId aPart = aGraph.Editor().Products().Add(BRepGraph_SolidId::Start()); - const BRepGraph_ProductId anAssembly = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aPart = + aGraph.Editor().Products().LinkProductToTopology(BRepGraph_SolidId::Start()); + const BRepGraph_ProductId anAssembly = aGraph.Editor().Products().CreateEmptyProduct(); ASSERT_TRUE(aPart.IsValid()); ASSERT_TRUE(anAssembly.IsValid()); @@ -199,9 +220,9 @@ TEST(BRepGraph_ParentExplorerTest, SharedProduct_ProductParentsKeepDistinctConte gp_Trsf aT2; aT2.SetTranslation(gp_Vec(25.0, 0.0, 0.0)); ASSERT_TRUE( - aGraph.Editor().Products().AddOccurrence(anAssembly, aPart, TopLoc_Location(aT1)).IsValid()); + aGraph.Editor().Products().LinkProducts(anAssembly, aPart, TopLoc_Location(aT1)).IsValid()); ASSERT_TRUE( - aGraph.Editor().Products().AddOccurrence(anAssembly, aPart, TopLoc_Location(aT2)).IsValid()); + aGraph.Editor().Products().LinkProducts(anAssembly, aPart, TopLoc_Location(aT2)).IsValid()); int aPartCount = 0; TopLoc_Location aLoc1; @@ -234,10 +255,12 @@ TEST(BRepGraph_ParentExplorerTest, SharedProduct_ProductParentsKeepDistinctConte TEST(BRepGraph_ParentExplorerTest, ShapeRootProductParent_HasChildButNoRef) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes11 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); - // BRepGraph_Builder::Perform() auto-creates a root Product for the shape root node. + // BRepGraph_Builder::Add() auto-creates a root Product for the shape root node. // Use that product instead of creating a duplicate. ASSERT_GT(aGraph.Topo().Products().Nb(), 0); const BRepGraph_ProductId aPart(0); @@ -259,16 +282,19 @@ TEST(BRepGraph_ParentExplorerTest, ShapeRootProductParent_HasChildButNoRef) TEST(BRepGraph_ParentExplorerTest, OccurrenceParent_ExposeOccurrenceRef) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes12 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); - const BRepGraph_ProductId aPart = aGraph.Editor().Products().Add(BRepGraph_SolidId::Start()); - const BRepGraph_ProductId anAssembly = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aPart = + aGraph.Editor().Products().LinkProductToTopology(BRepGraph_SolidId::Start()); + const BRepGraph_ProductId anAssembly = aGraph.Editor().Products().CreateEmptyProduct(); ASSERT_TRUE(aPart.IsValid()); ASSERT_TRUE(anAssembly.IsValid()); const BRepGraph_OccurrenceId anOccurrence = - aGraph.Editor().Products().AddOccurrence(anAssembly, aPart, TopLoc_Location()); + aGraph.Editor().Products().LinkProducts(anAssembly, aPart, TopLoc_Location()); ASSERT_TRUE(anOccurrence.IsValid()); BRepGraph_ParentExplorer anExp(aGraph, @@ -288,16 +314,19 @@ TEST(BRepGraph_ParentExplorerTest, OccurrenceParent_ExposeOccurrenceRef) TEST(BRepGraph_ParentExplorerTest, ProductParents_ImmediateOccurrence_IsStructural) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes13 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); - const BRepGraph_ProductId aPart = aGraph.Editor().Products().Add(BRepGraph_SolidId::Start()); - const BRepGraph_ProductId anAssembly = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aPart = + aGraph.Editor().Products().LinkProductToTopology(BRepGraph_SolidId::Start()); + const BRepGraph_ProductId anAssembly = aGraph.Editor().Products().CreateEmptyProduct(); ASSERT_TRUE(aPart.IsValid()); ASSERT_TRUE(anAssembly.IsValid()); const BRepGraph_OccurrenceId anOccurrence = - aGraph.Editor().Products().AddOccurrence(anAssembly, aPart, TopLoc_Location()); + aGraph.Editor().Products().LinkProducts(anAssembly, aPart, TopLoc_Location()); ASSERT_TRUE(anOccurrence.IsValid()); BRepGraph_ParentExplorer anExp(aGraph, @@ -313,7 +342,9 @@ TEST(BRepGraph_ParentExplorerTest, ProductParents_ImmediateOccurrence_IsStructur TEST(BRepGraph_ParentExplorerTest, CoEdgeParents_ImmediateWireIsVisible) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes14 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); const NCollection_DynamicArray& aWireRefIds = @@ -339,10 +370,12 @@ TEST(BRepGraph_ParentExplorerTest, CoEdgeParents_ImmediateWireIsVisible) TEST(BRepGraph_ParentExplorerTest, ProductRoot_HasNoParents) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes15 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10, 20, 30).Shape()); ASSERT_TRUE(aGraph.IsDone()); - const BRepGraph_ProductId aRootProduct = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aRootProduct = aGraph.Editor().Products().CreateEmptyProduct(); ASSERT_TRUE(aRootProduct.IsValid()); BRepGraph_ParentExplorer anExp(aGraph, aRootProduct); diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Polygon_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Polygon_Test.cxx index 5874a123fb..37d1cdbff2 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Polygon_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Polygon_Test.cxx @@ -56,7 +56,9 @@ TEST(BRepGraph_PolygonTest, MultiTriangulation_Roundtrip_PreservesAll) BRepMesh_IncrementalMesh aMesher(aBox, 0.5); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); // Verify triangulations were captured on face definitions. @@ -99,7 +101,9 @@ TEST(BRepGraph_PolygonTest, Polygon3D_Captured_WhenPresent) BRepMesh_IncrementalMesh aMesher(aBox, 0.5); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); // Count Polygon3D on edges - matches what BRep_Tool reports for the original shape. @@ -143,7 +147,9 @@ TEST(BRepGraph_PolygonTest, PolyOnTri_Captured_AfterMesh) BRepMesh_IncrementalMesh aMesher(aBox, 0.5); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); // Count PolygonOnTriangulation entries on coedges. @@ -187,7 +193,9 @@ TEST(BRepGraph_PolygonTest, PolyOnTri_Roundtrip_PreservedOnReconstruct) BRepMesh_IncrementalMesh aMesher(aBox, 0.5); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes4 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); // Reconstruct solid and verify polygon-on-triangulation is re-attached. @@ -227,7 +235,9 @@ TEST(BRepGraph_PolygonTest, UVPoints_Captured_OnPCurves) TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10., 20., 30.).Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes5 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); // At least some CoEdge entries should have non-origin UV points. @@ -331,7 +341,9 @@ TEST(BRepGraph_PolygonTest, VertexPointRepresentations_StructurallyValid) BRepGraph aGraph; registerStandardLayers(aGraph); - BRepGraph_Builder::Perform(aGraph, aShape); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes6 = + BRepGraph_Builder::Add(aGraph, aShape); ASSERT_TRUE(aGraph.IsDone()); const occ::handle aParamLayer = aGraph.LayerRegistry().FindLayer(); @@ -391,7 +403,9 @@ TEST(BRepGraph_PolygonTest, EdgeRegularity_MatchesOriginal) BRepGraph aGraph; registerStandardLayers(aGraph); - BRepGraph_Builder::Perform(aGraph, aCyl); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes7 = + BRepGraph_Builder::Add(aGraph, aCyl); ASSERT_TRUE(aGraph.IsDone()); const occ::handle aRegularityLayer = aGraph.LayerRegistry().FindLayer(); @@ -418,7 +432,9 @@ TEST(BRepGraph_PolygonTest, SeamEdge_PolyOnTri_TwoEntries) BRepMesh_IncrementalMesh aMesher(aCyl, 0.1); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCyl); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes8 = + BRepGraph_Builder::Add(aGraph, aCyl); ASSERT_TRUE(aGraph.IsDone()); // Find an edge with two PolyOnTri entries for the same face (seam edge pattern). diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Reconstruct_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Reconstruct_Test.cxx index 693ce82d5c..68a7ada2b8 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Reconstruct_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Reconstruct_Test.cxx @@ -85,7 +85,9 @@ TEST(BRepGraph_ReconstructTest, Box_Area_Preserved) const double anOrigArea = computeArea(aBox); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); TopoDS_Shape aRecon = @@ -102,7 +104,9 @@ TEST(BRepGraph_ReconstructTest, Box_Volume_Preserved) const double anOrigVol = computeVolume(aBox); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); TopoDS_Shape aRecon = @@ -119,7 +123,9 @@ TEST(BRepGraph_ReconstructTest, Sphere_Area_Preserved) const double anOrigArea = computeArea(aSphere); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aSphere); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(aGraph, aSphere); ASSERT_TRUE(aGraph.IsDone()); TopoDS_Shape aRecon = @@ -136,7 +142,9 @@ TEST(BRepGraph_ReconstructTest, Sphere_Volume_Preserved) const double anOrigVol = computeVolume(aSphere); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aSphere); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes4 = + BRepGraph_Builder::Add(aGraph, aSphere); ASSERT_TRUE(aGraph.IsDone()); TopoDS_Shape aRecon = @@ -153,7 +161,9 @@ TEST(BRepGraph_ReconstructTest, Cylinder_Area_Preserved) const double anOrigArea = computeArea(aCyl); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCyl); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes5 = + BRepGraph_Builder::Add(aGraph, aCyl); ASSERT_TRUE(aGraph.IsDone()); TopoDS_Shape aRecon = @@ -170,7 +180,9 @@ TEST(BRepGraph_ReconstructTest, Cylinder_Volume_Preserved) const double anOrigVol = computeVolume(aCyl); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCyl); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes6 = + BRepGraph_Builder::Add(aGraph, aCyl); ASSERT_TRUE(aGraph.IsDone()); TopoDS_Shape aRecon = @@ -191,7 +203,9 @@ TEST(BRepGraph_ReconstructTest, Shell_FaceCount_MatchesOriginal) const int anOrigFaceCount = countSubShapes(aBox, TopAbs_FACE); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes7 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); TopoDS_Shape aReconShell = @@ -207,7 +221,9 @@ TEST(BRepGraph_ReconstructTest, Wire_EdgeCount_FourPerBoxFace) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes8 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); // Each wire of a box face should have exactly 4 edges. @@ -226,7 +242,9 @@ TEST(BRepGraph_ReconstructTest, Edge_HasCurve_NonNull) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes9 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); for (BRepGraph_EdgeIterator anEdgeIt(aGraph); anEdgeIt.More(); anEdgeIt.Next()) @@ -250,7 +268,9 @@ TEST(BRepGraph_ReconstructTest, Edge_ParameterRange_Preserved) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes10 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); for (BRepGraph_EdgeIterator anEdgeIt(aGraph); anEdgeIt.More(); anEdgeIt.Next()) @@ -278,7 +298,9 @@ TEST(BRepGraph_ReconstructTest, Vertex_Point_MatchesDefPoint) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes11 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); for (BRepGraph_VertexIterator aVertexIt(aGraph); aVertexIt.More(); aVertexIt.Next()) @@ -303,7 +325,9 @@ TEST(BRepGraph_ReconstructTest, Face_PCurvesPresent_OnAllEdges) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes12 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); for (BRepGraph_FaceIterator aFaceIt(aGraph); aFaceIt.More(); aFaceIt.Next()) @@ -334,7 +358,9 @@ TEST(BRepGraph_ReconstructTest, Face_OrientationPreserved) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes13 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); // Verify that reconstructed faces have valid orientations matching ref entries. @@ -366,7 +392,9 @@ TEST(BRepGraph_ReconstructTest, Shape_UnmodifiedGraph_SameAsOriginalOf) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes14 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); // For an unmodified graph, Shape(id) should be the same TShape as OriginalOf(id). @@ -384,7 +412,9 @@ TEST(BRepGraph_ReconstructTest, HasOriginal_BuildFace_ReturnsTrue) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes15 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); EXPECT_TRUE(aGraph.Shapes().HasOriginal(BRepGraph_FaceId::Start())); @@ -400,7 +430,9 @@ TEST(BRepGraph_ReconstructTest, OriginalOf_Face_IsSameAsBuildInputFace) const TopoDS_Shape aFirstFace = anExp.Current(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes16 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); EXPECT_TRUE(aGraph.Shapes().OriginalOf(BRepGraph_FaceId::Start()).IsSame(aFirstFace)); @@ -412,7 +444,9 @@ TEST(BRepGraph_ReconstructTest, HasOriginal_ManualVertex_ReturnsFalse) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes17 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_VertexId aVertexId = @@ -428,7 +462,9 @@ TEST(BRepGraph_ReconstructTest, FindNode_OriginalFace_RoundTrip) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes18 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_NodeId aFaceId = BRepGraph_FaceId::Start(); @@ -442,7 +478,9 @@ TEST(BRepGraph_ReconstructTest, Reconstruct_Face_ValidShape) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes19 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Faces().Nb(), 0); @@ -457,7 +495,9 @@ TEST(BRepGraph_ReconstructTest, Reconstruct_Edge_ValidShape) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes20 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Edges().Nb(), 0); @@ -481,7 +521,9 @@ TEST(BRepGraph_ReconstructTest, Reconstruct_Vertex_CorrectPoint) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes21 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Vertices().Nb(), 0); @@ -506,7 +548,9 @@ TEST(BRepGraph_ReconstructTest, AfterVertexMutation_ModifiedFlagAndPointChanged) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes22 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); // Find a vertex belonging to face 0 and move it significantly. @@ -550,7 +594,9 @@ TEST(BRepGraph_ReconstructTest, AfterToleranceMutation_NewTShape) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes23 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_EdgeId anEdgeId(0); @@ -584,7 +630,9 @@ TEST(BRepGraph_ReconstructTest, CompoundRoot_TwoSolids_Preserved) aBuilder.Add(aCompound, aBox2); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes24 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); ASSERT_EQ(aGraph.Topo().Solids().Nb(), 2); diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_RefId_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_RefId_Test.cxx index fc0f86e883..0be355a9e0 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_RefId_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_RefId_Test.cxx @@ -198,7 +198,9 @@ TEST(BRepGraph_RefIdTest, RefUID_Equality_IgnoresGeneration) TEST(BRepGraph_RefIdTest, RefsView_AfterBuild_HasFaceRefs) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const int aFaceRefCount = aGraph.Refs().Faces().Nb(); EXPECT_GE(aFaceRefCount, 0); @@ -219,7 +221,9 @@ TEST(BRepGraph_RefIdTest, RefsView_AfterBuild_HasFaceRefs) TEST(BRepGraph_RefIdTest, RefDomain_StampGUIDGeneration_IfSupported) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); if (aGraph.Refs().Faces().Nb() <= 0) @@ -244,7 +248,9 @@ TEST(BRepGraph_RefIdTest, RefDomain_StampGUIDGeneration_IfSupported) TEST(BRepGraph_RefIdTest, RefsView_AfterBuild_CountsMatchInlineStorage) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Refs().Faces().Nb(), countInlineFaceRefs(aGraph)); @@ -259,7 +265,9 @@ TEST(BRepGraph_RefIdTest, RefsView_AfterBuild_CountsMatchInlineStorage) TEST(BRepGraph_RefIdTest, RefsView_AfterBuild_UIDRoundtripAndParentKinds) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes4 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); for (BRepGraph_FaceRefId aFaceRefId = BRepGraph_FaceRefId::Start(); @@ -396,7 +404,9 @@ TEST(BRepGraph_RefIdTest, StaleRefUID_HasReturnsFalseAndLookupBecomesInvalidAfte BRepPrimAPI_MakeBox aBoxMaker2(11.0, 21.0, 31.0); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBoxMaker1.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes5 = + BRepGraph_Builder::Add(aGraph, aBoxMaker1.Shape()); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Refs().Faces().Nb(), 0); @@ -404,7 +414,9 @@ TEST(BRepGraph_RefIdTest, StaleRefUID_HasReturnsFalseAndLookupBecomesInvalidAfte ASSERT_TRUE(anOldUID.IsValid()); ASSERT_TRUE(aGraph.UIDs().Has(anOldUID)); - BRepGraph_Builder::Perform(aGraph, aBoxMaker2.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes6 = + BRepGraph_Builder::Add(aGraph, aBoxMaker2.Shape()); EXPECT_FALSE(aGraph.UIDs().Has(anOldUID)); EXPECT_FALSE(aGraph.UIDs().RefIdFrom(anOldUID).IsValid()); @@ -413,7 +425,9 @@ TEST(BRepGraph_RefIdTest, StaleRefUID_HasReturnsFalseAndLookupBecomesInvalidAfte TEST(BRepGraph_RefIdTest, MutFaceRef_UpdatesRefStampAndParentModifiedFlag) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes7 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); if (aGraph.Refs().Faces().Nb() <= 0) @@ -448,7 +462,9 @@ TEST(BRepGraph_RefIdTest, MutFaceRef_UpdatesRefStampAndParentModifiedFlag) TEST(BRepGraph_RefIdTest, MutFaceRef_MarkRemoved_PersistsAndInvalidatesStamp) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes8 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); if (aGraph.Refs().Faces().Nb() <= 0) @@ -475,7 +491,9 @@ TEST(BRepGraph_RefIdTest, MutFaceRef_MarkRemoved_PersistsAndInvalidatesStamp) TEST(BRepGraph_RefIdTest, ChildRefs_CompoundEntriesAreValid) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes9 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph::RefsView& aRefs = aGraph.Refs(); diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_RefsIterator_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_RefsIterator_Test.cxx index c96c0037db..d50006a7bd 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_RefsIterator_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_RefsIterator_Test.cxx @@ -98,7 +98,9 @@ protected: void SetUp() override { BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); - BRepGraph_Builder::Perform(myGraph, aBoxMaker.Shape()); + myGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(myGraph, aBoxMaker.Shape()); } BRepGraph myGraph; @@ -125,7 +127,9 @@ TEST_F(BRepGraph_RefsIteratorTest, CurrentId_ResolvesToExpectedEntry) TEST(BRepGraph_RefsIteratorTestStandalone, VertexOfEdge_ExposesInternalVertexRef) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, wrapEdgeInFace(makeEdgeWithInternalVertex())); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, wrapEdgeInFace(makeEdgeWithInternalVertex())); BRepGraph_EdgeId aEdgeWithInternal; for (BRepGraph_EdgeIterator anEdgeIt(aGraph); anEdgeIt.More(); anEdgeIt.Next()) @@ -158,7 +162,9 @@ TEST(BRepGraph_RefsIteratorTestStandalone, VertexOfEdge_ExposesInternalVertexRef TEST(BRepGraph_RefsIteratorTestStandalone, VertexOfFace_ExposesDirectVertexRef) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, makeFaceWithDirectVertex()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(aGraph, makeFaceWithDirectVertex()); BRepGraph_RefsVertexOfFace anIt(aGraph, BRepGraph_FaceId::Start()); ASSERT_TRUE(anIt.More()); @@ -192,15 +198,16 @@ TEST_F(BRepGraph_RefsIteratorTest, ChildOfCompound_EnumeratesChildRefs) TEST_F(BRepGraph_RefsIteratorTest, OccurrenceOfProduct_EnumeratesOccurrenceRefs) { - const BRepGraph_ProductId aPart = myGraph.Editor().Products().Add(BRepGraph_SolidId::Start()); - const BRepGraph_ProductId anAssembly = myGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aPart = + myGraph.Editor().Products().LinkProductToTopology(BRepGraph_SolidId::Start()); + const BRepGraph_ProductId anAssembly = myGraph.Editor().Products().CreateEmptyProduct(); ASSERT_TRUE(aPart.IsValid()); ASSERT_TRUE(anAssembly.IsValid()); EXPECT_TRUE( - myGraph.Editor().Products().AddOccurrence(anAssembly, aPart, TopLoc_Location()).IsValid()); + myGraph.Editor().Products().LinkProducts(anAssembly, aPart, TopLoc_Location()).IsValid()); EXPECT_TRUE( - myGraph.Editor().Products().AddOccurrence(anAssembly, aPart, TopLoc_Location()).IsValid()); + myGraph.Editor().Products().LinkProducts(anAssembly, aPart, TopLoc_Location()).IsValid()); EXPECT_EQ(countIterator(BRepGraph_RefsOccurrenceOfProduct(myGraph, anAssembly)), 2); } diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_RelatedIterator_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_RelatedIterator_Test.cxx index 17221963ac..4051de8e26 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_RelatedIterator_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_RelatedIterator_Test.cxx @@ -68,7 +68,9 @@ protected: void SetUp() override { BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); - BRepGraph_Builder::Perform(myGraph, aBoxMaker.Shape()); + myGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(myGraph, aBoxMaker.Shape()); } BRepGraph myGraph; @@ -118,13 +120,13 @@ TEST_F(BRepGraph_RelatedIteratorTest, AssemblyNodes_YieldNoRelations) { // Assembly/container nodes have no topological relations - use ChildExplorer instead. const BRepGraph_ProductId aPartProduct = - myGraph.Editor().Products().Add(BRepGraph_NodeId(BRepGraph_SolidId::Start())); - const BRepGraph_ProductId aRootAssembly = myGraph.Editor().Products().AddAssembly(); + myGraph.Editor().Products().LinkProductToTopology(BRepGraph_NodeId(BRepGraph_SolidId::Start())); + const BRepGraph_ProductId aRootAssembly = myGraph.Editor().Products().CreateEmptyProduct(); gp_Trsf aTrsf; aTrsf.SetTranslation(gp_Vec(1.0, 2.0, 3.0)); const BRepGraph_OccurrenceId anOccurrenceId = - myGraph.Editor().Products().AddOccurrence(aRootAssembly, aPartProduct, TopLoc_Location(aTrsf)); + myGraph.Editor().Products().LinkProducts(aRootAssembly, aPartProduct, TopLoc_Location(aTrsf)); ASSERT_TRUE(anOccurrenceId.IsValid()); BRepGraph_RelatedIterator aProductIt(myGraph, BRepGraph_NodeId(aRootAssembly)); @@ -227,7 +229,9 @@ TEST(BRepGraph_RelatedIteratorStandalone, Compound_YieldsNoRelations) aBuilder.Add(aCompound, BRepPrimAPI_MakeBox(20.0, 20.0, 20.0).Shape()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_CompoundId aCompoundId; diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_ReplaceVertex_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_ReplaceVertex_Test.cxx index f9ba999eeb..e8305792cf 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_ReplaceVertex_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_ReplaceVertex_Test.cxx @@ -32,7 +32,9 @@ namespace BRepGraph makeBoxGraph() { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); return aGraph; } diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_ReverseIterator_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_ReverseIterator_Test.cxx index 2fb99cc993..7e04812a3a 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_ReverseIterator_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_ReverseIterator_Test.cxx @@ -42,7 +42,9 @@ protected: void SetUp() override { BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); - BRepGraph_Builder::Perform(myGraph, aBoxMaker.Shape()); + myGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(myGraph, aBoxMaker.Shape()); } BRepGraph myGraph; diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_ScenarioMatrix_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_ScenarioMatrix_Test.cxx index 0ad96c2bf2..191bad262a 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_ScenarioMatrix_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_ScenarioMatrix_Test.cxx @@ -102,7 +102,9 @@ TEST(BRepGraph_ScenarioMatrix, Box_MutateVertex_ValidateReconstructPopulateRound // --- Build BRepGraph --- BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); // --- Validate clean graph (full audit) --- @@ -192,7 +194,9 @@ TEST(BRepGraph_ScenarioMatrix, Cylinder_SeamEdge_MutationAndBothSubsystemsConsis // --- Build both representations from the original shape --- BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCyl); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, aCyl); ASSERT_TRUE(aGraph.IsDone()); BRepGraphInc_Storage aOrigStorage; @@ -324,7 +328,9 @@ TEST(BRepGraph_ScenarioMatrix, CompSolid_TwoBoxes_BothSubsystemsMutateReconstruc // --- BRepGraph build --- BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompSolid); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(aGraph, aCompSolid); ASSERT_TRUE(aGraph.IsDone()); // --- Validate(Audit) clean graph --- @@ -376,7 +382,9 @@ TEST(BRepGraph_ScenarioMatrix, Assembly_TwoOccurrences_ValidateDAGReconstructPar { // Build the graph from a simple solid. BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(8.0, 8.0, 8.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes4 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(8.0, 8.0, 8.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const int anOrigFaces = @@ -384,7 +392,7 @@ TEST(BRepGraph_ScenarioMatrix, Assembly_TwoOccurrences_ValidateDAGReconstructPar // Build assembly: two occurrences of the auto-created part at distinct translations. const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aAssemblyId = aGraph.Editor().Products().CreateEmptyProduct(); ASSERT_TRUE(aAssemblyId.IsValid()); gp_Trsf aTrsf1; @@ -393,9 +401,9 @@ TEST(BRepGraph_ScenarioMatrix, Assembly_TwoOccurrences_ValidateDAGReconstructPar aTrsf2.SetTranslation(gp_Vec(0.0, 200.0, 0.0)); const BRepGraph_OccurrenceId anOcc1 = - aGraph.Editor().Products().AddOccurrence(aAssemblyId, aPartId, TopLoc_Location(aTrsf1)); + aGraph.Editor().Products().LinkProducts(aAssemblyId, aPartId, TopLoc_Location(aTrsf1)); const BRepGraph_OccurrenceId anOcc2 = - aGraph.Editor().Products().AddOccurrence(aAssemblyId, aPartId, TopLoc_Location(aTrsf2)); + aGraph.Editor().Products().LinkProducts(aAssemblyId, aPartId, TopLoc_Location(aTrsf2)); ASSERT_TRUE(anOcc1.IsValid()); ASSERT_TRUE(anOcc2.IsValid()); @@ -470,7 +478,9 @@ TEST(BRepGraph_ScenarioMatrix, Compound_FreeWireFreeEdgeFreeVertex_ValidateAndPo // --- BRepGraph build --- BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes5 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Compounds().Nb(), 1); @@ -591,7 +601,9 @@ TEST(BRepGraph_ScenarioMatrix, Compound_BoxAndCylinder_MutationReconstructAreaRe // --- BRepGraph build --- BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes6 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Solids().Nb(), 2); @@ -668,14 +680,16 @@ TEST(BRepGraph_ScenarioMatrix, Compound_BoxAndCylinder_MutationReconstructAreaRe TEST(BRepGraph_ScenarioMatrix, Assembly_ThreeLevelNesting_CleanAudit_CycleDetection) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes7 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); // Four-level chain: Top -> Root -> Mid -> Leaf (leaf is the auto-built part). const BRepGraph_ProductId aLeafPart = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aMidAsm = aGraph.Editor().Products().AddAssembly(); - const BRepGraph_ProductId aRootAsm = aGraph.Editor().Products().AddAssembly(); - const BRepGraph_ProductId aTopAsm = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aMidAsm = aGraph.Editor().Products().CreateEmptyProduct(); + const BRepGraph_ProductId aRootAsm = aGraph.Editor().Products().CreateEmptyProduct(); + const BRepGraph_ProductId aTopAsm = aGraph.Editor().Products().CreateEmptyProduct(); gp_Trsf aT1, aT2, aT3; aT1.SetTranslation(gp_Vec(1.0, 0.0, 0.0)); @@ -683,11 +697,11 @@ TEST(BRepGraph_ScenarioMatrix, Assembly_ThreeLevelNesting_CleanAudit_CycleDetect aT3.SetTranslation(gp_Vec(0.0, 0.0, 3.0)); const BRepGraph_OccurrenceId anOccRoot = - aGraph.Editor().Products().AddOccurrence(aTopAsm, aRootAsm, TopLoc_Location(aT3)); + aGraph.Editor().Products().LinkProducts(aTopAsm, aRootAsm, TopLoc_Location(aT3)); const BRepGraph_OccurrenceId anOccMid = - aGraph.Editor().Products().AddOccurrence(aRootAsm, aMidAsm, TopLoc_Location(aT2), anOccRoot); + aGraph.Editor().Products().LinkProducts(aRootAsm, aMidAsm, TopLoc_Location(aT2), anOccRoot); const BRepGraph_OccurrenceId anOccLeaf = - aGraph.Editor().Products().AddOccurrence(aMidAsm, aLeafPart, TopLoc_Location(aT1), anOccMid); + aGraph.Editor().Products().LinkProducts(aMidAsm, aLeafPart, TopLoc_Location(aT1), anOccMid); ASSERT_TRUE(anOccRoot.IsValid()); ASSERT_TRUE(anOccMid.IsValid()); ASSERT_TRUE(anOccLeaf.IsValid()); @@ -704,14 +718,14 @@ TEST(BRepGraph_ScenarioMatrix, Assembly_ThreeLevelNesting_CleanAudit_CycleDetect // --- Transitive cycle: C -> D, then D -> C. Self-ref guard skips this because // C.Index != D.Index, but the BFS-based Audit check must still catch it. --- - const BRepGraph_ProductId aProdC = aGraph.Editor().Products().AddAssembly(); - const BRepGraph_ProductId aProdD = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aProdC = aGraph.Editor().Products().CreateEmptyProduct(); + const BRepGraph_ProductId aProdD = aGraph.Editor().Products().CreateEmptyProduct(); gp_Trsf aIdTrsf; ASSERT_TRUE( - aGraph.Editor().Products().AddOccurrence(aProdC, aProdD, TopLoc_Location(aIdTrsf)).IsValid()); + aGraph.Editor().Products().LinkProducts(aProdC, aProdD, TopLoc_Location(aIdTrsf)).IsValid()); ASSERT_TRUE( - aGraph.Editor().Products().AddOccurrence(aProdD, aProdC, TopLoc_Location(aIdTrsf)).IsValid()); + aGraph.Editor().Products().LinkProducts(aProdD, aProdC, TopLoc_Location(aIdTrsf)).IsValid()); const BRepGraph_Validate::Result aCycleResult = BRepGraph_Validate::Perform(aGraph, BRepGraph_Validate::Options::Audit()); @@ -738,7 +752,9 @@ TEST(BRepGraph_ScenarioMatrix, Assembly_ThreeLevelNesting_CleanAudit_CycleDetect TEST(BRepGraph_ScenarioMatrix, Assembly_SharedPartBetweenTwoRootAssemblies) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(5.0, 5.0, 5.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes8 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(5.0, 5.0, 5.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); // Snapshot topology entity counts before any assembly wiring. @@ -746,8 +762,8 @@ TEST(BRepGraph_ScenarioMatrix, Assembly_SharedPartBetweenTwoRootAssemblies) const int aNbFacesBefore = aGraph.Topo().Faces().Nb(); const BRepGraph_ProductId aSharedPart = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aAsmA = aGraph.Editor().Products().AddAssembly(); - const BRepGraph_ProductId aAsmB = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aAsmA = aGraph.Editor().Products().CreateEmptyProduct(); + const BRepGraph_ProductId aAsmB = aGraph.Editor().Products().CreateEmptyProduct(); gp_Trsf aOffsetA, aOffsetB; aOffsetA.SetTranslation(gp_Vec(100.0, 0.0, 0.0)); @@ -755,11 +771,11 @@ TEST(BRepGraph_ScenarioMatrix, Assembly_SharedPartBetweenTwoRootAssemblies) ASSERT_TRUE(aGraph.Editor() .Products() - .AddOccurrence(aAsmA, aSharedPart, TopLoc_Location(aOffsetA)) + .LinkProducts(aAsmA, aSharedPart, TopLoc_Location(aOffsetA)) .IsValid()); ASSERT_TRUE(aGraph.Editor() .Products() - .AddOccurrence(aAsmB, aSharedPart, TopLoc_Location(aOffsetB)) + .LinkProducts(aAsmB, aSharedPart, TopLoc_Location(aOffsetB)) .IsValid()); // The shared part must not have grown the topology pool. @@ -838,7 +854,9 @@ TEST(BRepGraph_ScenarioMatrix, Compound_MixedAtomicChildren_ReverseIndexCoverage aBB.Add(aCompound, aFreeVertex); // free vertex BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes9 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Compounds().Nb(), 0); @@ -933,7 +951,9 @@ TEST(BRepGraph_ScenarioMatrix, CompSolid_ThreeBoxes_ReverseIndexPerSolid) aBB.Add(aCompSolid, BRepPrimAPI_MakeBox(gp_Pnt(40.0, 0.0, 0.0), 5.0, 5.0, 5.0).Shape()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompSolid); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes10 = + BRepGraph_Builder::Add(aGraph, aCompSolid); ASSERT_TRUE(aGraph.IsDone()); EXPECT_TRUE(BRepGraph_Validate::Perform(aGraph, BRepGraph_Validate::Options::Audit()).IsValid()) @@ -993,7 +1013,9 @@ TEST(BRepGraph_ScenarioMatrix, Sphere_SeamCoEdgePair_Bidirectional) // Build the graph, audit, reconstruct, repopulate, re-verify bidirectionality. BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aSphere); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes11 = + BRepGraph_Builder::Add(aGraph, aSphere); ASSERT_TRUE(aGraph.IsDone()); EXPECT_TRUE(BRepGraph_Validate::Perform(aGraph, BRepGraph_Validate::Options::Audit()).IsValid()) << "Sphere graph must pass full audit"; @@ -1029,7 +1051,9 @@ TEST(BRepGraph_ScenarioMatrix, Sphere_SeamCoEdgePair_Bidirectional) TEST(BRepGraph_ScenarioMatrix, Validate_OrphanCurve3DRep_FlaggedByAudit) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes12 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); // Find an edge with a Curve3DRepId. @@ -1084,7 +1108,9 @@ TEST(BRepGraph_ScenarioMatrix, Validate_OrphanCurve3DRep_FlaggedByAudit) TEST(BRepGraph_ScenarioMatrix, Cylinder_SeamEdgeSplit_AuditStable) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeCylinder(5.0, 15.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes13 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeCylinder(5.0, 15.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); // Locate a seam edge: an edge with at least one seam-paired coedge. @@ -1158,7 +1184,9 @@ TEST(BRepGraph_ScenarioMatrix, Cylinder_SeamEdgeSplit_AuditStable) TEST(BRepGraph_ScenarioMatrix, Cylinder_SeamEdgeSplit_CoEdgeFaceIncidence) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeCylinder(5.0, 15.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes14 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeCylinder(5.0, 15.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_EdgeId aSeamEdgeId; @@ -1227,7 +1255,9 @@ TEST(BRepGraph_ScenarioMatrix, Cylinder_SeamEdgeSplit_CoEdgeFaceIncidence) TEST(BRepGraph_ScenarioMatrix, BoxEdgeSplit_BoundaryVertexRetirement) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes15 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_EdgeId anEdgeId; @@ -1277,7 +1307,9 @@ TEST(BRepGraph_ScenarioMatrix, BoxEdgeSplit_BoundaryVertexRetirement) TEST(BRepGraph_ScenarioMatrix, BoxEdgeSplit_SubEdgesHaveNoOriginal) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes16 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_EdgeId anEdgeId; @@ -1316,7 +1348,9 @@ TEST(BRepGraph_ScenarioMatrix, BoxEdgeSplit_SubEdgesHaveNoOriginal) TEST(BRepGraph_ScenarioMatrix, BoxEdgeSplit_ShapeReconstructsSubEdge) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes17 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); BRepGraph_EdgeId anEdgeId; @@ -1350,7 +1384,9 @@ TEST(BRepGraph_ScenarioMatrix, BoxEdgeSplit_ShapeReconstructsSubEdge) TEST(BRepGraph_ScenarioMatrix, EditorAddedVertex_HasNoOriginal) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes18 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_VertexId aFreshVertex = diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Sharing_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Sharing_Test.cxx index 2f1043225f..2f46a34062 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Sharing_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Sharing_Test.cxx @@ -40,7 +40,9 @@ protected: { BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); const TopoDS_Shape& aBox = aBoxMaker.Shape(); - BRepGraph_Builder::Perform(myGraph, aBox); + myGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(myGraph, aBox); } BRepGraph myGraph; @@ -234,7 +236,9 @@ TEST_F(BRepGraph_SharingTest, CompoundTwoIdenticalBoxes) aBuilder.Add(aCompound, aBox); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); // Same TShape added twice to compound: definition is shared (1 solid def), @@ -269,7 +273,9 @@ TEST_F(BRepGraph_SharingTest, CompoundTwoDistinctBoxes) aBuilder.Add(aCompound, aBox2); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); // Two different TShapes: no sharing, definitions are independent @@ -295,7 +301,9 @@ TEST_F(BRepGraph_SharingTest, CompoundWithLocation_MoreUsagesThanDefs) aBuilder.Add(aCompound, aMovedBox); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes4 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); // Same TShape with different locations: defs are shared. @@ -320,7 +328,9 @@ TEST_F(BRepGraph_SharingTest, TranslatedCopy_SameTShape_SharedDefs) aBuilder.Add(aCompound, aCopy); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes5 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); // Moved() preserves TShape, so all definitions are shared (1 solid def). diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Test.cxx index d4b87143c5..834f8a3436 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Test.cxx @@ -585,7 +585,9 @@ protected: { BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); const TopoDS_Shape& aBox = aBoxMaker.Shape(); - BRepGraph_Builder::Perform(myGraph, aBox); + myGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(myGraph, aBox); } BRepGraph myGraph; @@ -1120,7 +1122,9 @@ TEST_F(BRepGraphTest, Decompose_TwoSeparateFaces) aBuilder.Add(aCompound, aFace2); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Faces().Nb(), 2); @@ -1149,7 +1153,9 @@ TEST_F(BRepGraphTest, ReBuild_UIDMonotonic) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(aGraph, aBox); const uint32_t aGen1 = aGraph.UIDs().Generation(); // Access a UID from the first build to verify it works. @@ -1159,7 +1165,9 @@ TEST_F(BRepGraphTest, ReBuild_UIDMonotonic) EXPECT_TRUE(aFirstUID.IsValid()); EXPECT_EQ(aFirstUID.Generation(), aGen1); - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes4 = + BRepGraph_Builder::Add(aGraph, aBox); const uint32_t aGen2 = aGraph.UIDs().Generation(); EXPECT_GT(aGen2, aGen1); @@ -1321,11 +1329,15 @@ TEST_F(BRepGraphTest, ParallelBuild_SameAsSequential) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aSeqGraph; - BRepGraph_Builder::Perform(aSeqGraph, aBox, false); + aSeqGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes5 = + BRepGraph_Builder::Add(aSeqGraph, aBox, BRepGraph_Builder::Options{{}, true, false, false}); ASSERT_TRUE(aSeqGraph.IsDone()); BRepGraph aParGraph; - BRepGraph_Builder::Perform(aParGraph, aBox, true); + aParGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes6 = + BRepGraph_Builder::Add(aParGraph, aBox, BRepGraph_Builder::Options{{}, true, false, true}); ASSERT_TRUE(aParGraph.IsDone()); EXPECT_EQ(aParGraph.Topo().Solids().Nb(), aSeqGraph.Topo().Solids().Nb()); @@ -1353,7 +1365,9 @@ TEST_F(BRepGraphTest, ParallelBuild_CompoundOfFaces) aBuilder.Add(aCompound, anExp.Current()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound, true); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes7 = + BRepGraph_Builder::Add(aGraph, aCompound, BRepGraph_Builder::Options{{}, true, false, true}); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Faces().Nb(), 12); } @@ -1580,14 +1594,14 @@ TEST_F(BRepGraphTest, HasOriginalShape_AfterBuild_True) BRepGraph_NodeId aFaceId(aFaceIt.CurrentId()); EXPECT_TRUE(myGraph.Shapes().HasOriginal(aFaceId)) << "Face " << aFaceIt.CurrentId().Index - << " should have original shape after BRepGraph_Builder::Perform()"; + << " should have original shape after BRepGraph_Builder::Add()"; } for (BRepGraph_EdgeIterator anEdgeIt(myGraph); anEdgeIt.More(); anEdgeIt.Next()) { BRepGraph_NodeId anEdgeId(anEdgeIt.CurrentId()); EXPECT_TRUE(myGraph.Shapes().HasOriginal(anEdgeId)) << "Edge " << anEdgeIt.CurrentId().Index - << " should have original shape after BRepGraph_Builder::Perform()"; + << " should have original shape after BRepGraph_Builder::Add()"; } } @@ -1618,7 +1632,9 @@ TEST_F(BRepGraphTest, DefaultBuild_AssignsValidUIDs) BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBoxMaker.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes8 = + BRepGraph_Builder::Add(aGraph, aBoxMaker.Shape()); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Faces().Nb(), 0); @@ -1637,10 +1653,14 @@ TEST_F(BRepGraphTest, UIDsGeneration_IncrementsAcrossBuilds) BRepPrimAPI_MakeBox aBoxMaker2(11.0, 21.0, 31.0); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBoxMaker1.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes9 = + BRepGraph_Builder::Add(aGraph, aBoxMaker1.Shape()); const uint32_t aGeneration1 = aGraph.UIDs().Generation(); - BRepGraph_Builder::Perform(aGraph, aBoxMaker2.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes10 = + BRepGraph_Builder::Add(aGraph, aBoxMaker2.Shape()); const uint32_t aGeneration2 = aGraph.UIDs().Generation(); EXPECT_GT(aGeneration1, 0u); @@ -1653,14 +1673,18 @@ TEST_F(BRepGraphTest, StaleUID_HasReturnsFalseAfterRebuild) BRepPrimAPI_MakeBox aBoxMaker2(11.0, 21.0, 31.0); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBoxMaker1.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes11 = + BRepGraph_Builder::Add(aGraph, aBoxMaker1.Shape()); ASSERT_GT(aGraph.Topo().Faces().Nb(), 0); const BRepGraph_UID anOldUID = aGraph.UIDs().Of(BRepGraph_NodeId(BRepGraph_NodeId::Kind::Face, 0)); ASSERT_TRUE(anOldUID.IsValid()); ASSERT_TRUE(aGraph.UIDs().Has(anOldUID)); - BRepGraph_Builder::Perform(aGraph, aBoxMaker2.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes12 = + BRepGraph_Builder::Add(aGraph, aBoxMaker2.Shape()); EXPECT_FALSE(aGraph.UIDs().Has(anOldUID)); EXPECT_FALSE(aGraph.UIDs().NodeIdFrom(anOldUID).IsValid()); @@ -2099,10 +2123,10 @@ TEST_F(BRepGraphTest, RemoveVertex_PrunesDirectVertexUsage) TEST_F(BRepGraphTest, RemoveOccurrence_PrunesOccurrenceSubtreeAndRebuildsReverseIndex) { const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); - const BRepGraph_ProductId aAssemblyId = myGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aAssemblyId = myGraph.Editor().Products().CreateEmptyProduct(); ASSERT_TRUE(aAssemblyId.IsValid()); const BRepGraph_OccurrenceId anOccId = - myGraph.Editor().Products().AddOccurrence(aAssemblyId, aPartId, TopLoc_Location()); + myGraph.Editor().Products().LinkProducts(aAssemblyId, aPartId, TopLoc_Location()); ASSERT_TRUE(anOccId.IsValid()); const NCollection_DynamicArray& aOccurrenceRefsBefore = @@ -2254,7 +2278,9 @@ TEST_F(BRepGraphTest, FreeEdges_SingleFace_AllEdgesFree) const TopoDS_Face& aFace = TopoDS::Face(anExp.Current()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aFace); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes13 = + BRepGraph_Builder::Add(aGraph, aFace); ASSERT_TRUE(aGraph.IsDone()); NCollection_DynamicArray aFreeEdges = collectFreeEdges(aGraph); @@ -2279,7 +2305,9 @@ TEST_F(BRepGraphTest, Decompose_ThreeDisconnectedFaces_ThreeComponents) aBuilder.Add(aCompound, anExp3.Current()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes14 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Faces().Nb(), 3); @@ -2387,7 +2415,9 @@ TEST_F(BRepGraphTest, Build_EmptyCompound_IsDoneZeroCounts) aBuilder.MakeCompound(aCompound); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes15 = + BRepGraph_Builder::Add(aGraph, aCompound); EXPECT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Solids().Nb(), 0); EXPECT_EQ(aGraph.Topo().Shells().Nb(), 0); @@ -2455,7 +2485,9 @@ TEST_F(BRepGraphTest, Build_WithCustomAllocator_IsDone) BRepGraph aGraph(anAlloc); BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); - BRepGraph_Builder::Perform(aGraph, aBoxMaker.Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes16 = + BRepGraph_Builder::Add(aGraph, aBoxMaker.Shape()); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Faces().Nb(), 6); EXPECT_FALSE(aGraph.Allocator().IsNull()); @@ -2647,7 +2679,9 @@ TEST_F(BRepGraphTest, Build_SingleFace_CorrectCounts) const TopoDS_Face& aFace = TopoDS::Face(anExp.Current()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aFace); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes17 = + BRepGraph_Builder::Add(aGraph, aFace); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Solids().Nb(), 0); EXPECT_EQ(aGraph.Topo().Shells().Nb(), 0); @@ -2664,7 +2698,9 @@ TEST_F(BRepGraphTest, Build_Shell_CorrectCounts) ASSERT_TRUE(anExp.More()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, anExp.Current()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes18 = + BRepGraph_Builder::Add(aGraph, anExp.Current()); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Solids().Nb(), 0); EXPECT_EQ(aGraph.Topo().Shells().Nb(), 1); @@ -2685,7 +2721,9 @@ TEST_F(BRepGraphTest, Build_CompoundOfTwoSolids) aBuilder.Add(aCompound, aBox2.Shape()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes19 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); EXPECT_EQ(aGraph.Topo().Solids().Nb(), 2); EXPECT_EQ(aGraph.Topo().Shells().Nb(), 2); @@ -2699,7 +2737,9 @@ TEST_F(BRepGraphTest, ReconstructShape_ShellRoot_SameFaceCount) ASSERT_TRUE(anExp.More()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, anExp.Current()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes20 = + BRepGraph_Builder::Add(aGraph, anExp.Current()); ASSERT_TRUE(aGraph.IsDone()); ASSERT_EQ(aGraph.Topo().Shells().Nb(), 1); diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Tool_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Tool_Test.cxx index 11fe1868d6..a4e5253216 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Tool_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Tool_Test.cxx @@ -30,10 +30,14 @@ protected: void SetUp() override { BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); - BRepGraph_Builder::Perform(myBoxGraph, aBoxMaker.Shape()); + myBoxGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(myBoxGraph, aBoxMaker.Shape()); BRepPrimAPI_MakeCylinder aCylMaker(5.0, 15.0); - BRepGraph_Builder::Perform(myCylGraph, aCylMaker.Shape()); + myCylGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(myCylGraph, aCylMaker.Shape()); } BRepGraph myBoxGraph; diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Transform_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Transform_Test.cxx index 22865117df..89212cca62 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Transform_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Transform_Test.cxx @@ -42,7 +42,9 @@ TEST(BRepGraph_TransformTest, TranslateBox_FaceCount) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); gp_Trsf aTrsf; @@ -64,7 +66,9 @@ TEST(BRepGraph_TransformTest, TranslateBox_AreaPreserved) const double anOrigArea = aOrigProps.Mass(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); gp_Trsf aTrsf; @@ -93,7 +97,9 @@ TEST(BRepGraph_TransformTest, TranslateBox_VertexPointsShifted) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Vertices().Nb(), 0); @@ -126,7 +132,9 @@ TEST(BRepGraph_TransformTest, LocationOnly_NoCopyGeom) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes4 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Vertices().Nb(), 0); @@ -185,7 +193,9 @@ TEST(BRepGraph_TransformTest, TransformSingleFace) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes5 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Faces().Nb(), 0); diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Validate_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Validate_Test.cxx index 0580cc440f..73fefc3915 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Validate_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Validate_Test.cxx @@ -70,7 +70,9 @@ TEST(BRepGraph_ValidateTest, CleanGraph_NoIssues) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); const BRepGraph_Validate::Result aResult = BRepGraph_Validate::Perform(aGraph); @@ -107,7 +109,9 @@ TEST(BRepGraph_ValidateTest, AfterGeomDeduplicate_NoIssues) aBuilder.Add(aCompound, aCopy2.Shape()); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aCompound); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(aGraph, aCompound); ASSERT_TRUE(aGraph.IsDone()); (void)BRepGraph_Deduplicate::Perform(aGraph); @@ -123,7 +127,9 @@ TEST(BRepGraph_ValidateTest, DetectsRemovedNodeReference) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Vertices().Nb(), 0); @@ -160,7 +166,9 @@ TEST(BRepGraph_ValidateTest, WireConnectivity_DisconnectedEdges) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes4 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Wires().Nb(), 0); @@ -239,7 +247,9 @@ TEST(BRepGraph_ValidateTest, BoundsCheck_InvalidIndex) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes5 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Edges().Nb(), 0); @@ -260,7 +270,9 @@ TEST(BRepGraph_ValidateTest, AfterSplitEdge_ProducesSubEdges) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes6 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); const int anOrigEdgeCount = aGraph.Topo().Edges().Nb(); @@ -313,7 +325,9 @@ TEST(BRepGraph_ValidateTest, CorruptedPCurve_FaceDefIdOutOfBounds) const TopoDS_Shape& aBox = aBoxMaker.Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes7 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Edges().Nb(), 0); @@ -338,7 +352,9 @@ TEST(BRepGraph_ValidateTest, CorruptedPCurve_FaceDefIdOutOfBounds) TEST(BRepGraph_ValidateTest, LightweightAndAudit_DetectActiveCountDrift) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes8 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); const int aNbActiveFacesBefore = aGraph.Topo().Faces().NbActive(); @@ -388,7 +404,9 @@ TEST(BRepGraph_ValidateTest, LightweightAndAudit_DetectActiveCountDrift) TEST(BRepGraph_ValidateTest, Audit_ValidatesCoEdgeUIDsFromBuilderWireCreation) { BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes9 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Edges().Nb(), 0); @@ -426,30 +444,30 @@ TEST(BRepGraph_ValidateTest, Audit_ValidatesCoEdgeUIDsFromBuilderWireCreation) TEST(BRepGraph_ValidateTest, AssemblyGraph_ValidProduct_NoIssuesInAudit) { - // Build a box; BRepGraph_Builder::Perform() auto-creates a root part product. + // Build a box; BRepGraph_Builder::Add() auto-creates a root part product. const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes10 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GE(aGraph.Topo().Products().Nb(), 1); - // BRepGraph_Builder::Perform() auto-creates the part product at index 0. + // BRepGraph_Builder::Add() auto-creates the part product at index 0. const BRepGraph_ProductId aPartProduct = BRepGraph_ProductId::Start(); ASSERT_TRUE(aGraph.Topo().Products().IsPart(aPartProduct)); // Explicitly create an assembly product and add two occurrences of the part. - const BRepGraph_ProductId aAssemblyProduct = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aAssemblyProduct = aGraph.Editor().Products().CreateEmptyProduct(); ASSERT_TRUE(aAssemblyProduct.IsValid()); gp_Trsf aTrsf; aTrsf.SetTranslation(gp_Vec(20.0, 0.0, 0.0)); const BRepGraph_OccurrenceId anOcc1 = - aGraph.Editor().Products().AddOccurrence(aAssemblyProduct, aPartProduct, TopLoc_Location()); + aGraph.Editor().Products().LinkProducts(aAssemblyProduct, aPartProduct, TopLoc_Location()); const BRepGraph_OccurrenceId anOcc2 = - aGraph.Editor().Products().AddOccurrence(aAssemblyProduct, - aPartProduct, - TopLoc_Location(aTrsf)); + aGraph.Editor().Products().LinkProducts(aAssemblyProduct, aPartProduct, TopLoc_Location(aTrsf)); ASSERT_TRUE(anOcc1.IsValid()); ASSERT_TRUE(anOcc2.IsValid()); @@ -481,14 +499,16 @@ TEST(BRepGraph_ValidateTest, AssemblyGraph_CorruptedOccurrenceChildDefId_Detecte const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes11 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GE(aGraph.Topo().Products().Nb(), 1); ASSERT_GE(aGraph.Topo().Occurrences().Nb(), 1); // Corrupt the first occurrence's ChildDefId to an out-of-bounds value. BRepGraph_MutGuard anOccDef = - aGraph.Editor().Products().MutOccurrence(BRepGraph_OccurrenceId::Start()); + aGraph.Editor().Occurrences().Mut(BRepGraph_OccurrenceId::Start()); anOccDef->ChildDefId = BRepGraph_NodeId(BRepGraph_NodeId::Kind::Solid, aGraph.Topo().Solids().Nb() + 999); @@ -519,11 +539,13 @@ TEST(BRepGraph_ValidateTest, const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes12 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); // Create an assembly with one occurrence. - const BRepGraph_ProductId aRootAssembly = aGraph.Editor().Products().AddAssembly(); + const BRepGraph_ProductId aRootAssembly = aGraph.Editor().Products().CreateEmptyProduct(); ASSERT_TRUE(aRootAssembly.IsValid()); const BRepGraph_ProductId aPartId = BRepGraph_ProductId::Start(); @@ -531,12 +553,12 @@ TEST(BRepGraph_ValidateTest, ASSERT_TRUE(aPartId.IsValid()); const BRepGraph_OccurrenceId anOccId = - aGraph.Editor().Products().AddOccurrence(aRootAssembly, aPartId, TopLoc_Location()); + aGraph.Editor().Products().LinkProducts(aRootAssembly, aPartId, TopLoc_Location()); ASSERT_TRUE(anOccId.IsValid()); // Corrupt the occurrence's ChildDefId to an invalid index. BRepGraph_MutGuard anOccDef = - aGraph.Editor().Products().MutOccurrence(anOccId); + aGraph.Editor().Occurrences().Mut(anOccId); anOccDef->ChildDefId = BRepGraph_NodeId(BRepGraph_NodeId::Kind::Product, aGraph.Topo().Products().Nb() + 999); @@ -566,12 +588,14 @@ TEST(BRepGraph_ValidateTest, AssemblyGraph_OccurrenceChildRefersToOccurrence_Det const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape(); BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes13 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Occurrences().Nb(), 0); BRepGraph_MutGuard anOccDef = - aGraph.Editor().Products().MutOccurrence(BRepGraph_OccurrenceId::Start()); + aGraph.Editor().Occurrences().Mut(BRepGraph_OccurrenceId::Start()); anOccDef->ChildDefId = BRepGraph_OccurrenceId::Start(); const BRepGraph_Validate::Result aAuditResult = @@ -600,7 +624,9 @@ TEST(BRepGraph_ValidateTest, LightweightVsAudit_RemovedVertexReference_Different // RemoveNode(vertex) correctly updates active counts (Lightweight passes) // but leaves edges referencing the removed vertex (Audit detects). BRepGraph aGraph; - BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes14 = + BRepGraph_Builder::Add(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape()); ASSERT_TRUE(aGraph.IsDone()); ASSERT_GT(aGraph.Topo().Vertices().Nb(), 0); @@ -656,7 +682,9 @@ TEST(BRepGraph_ValidateTest, Audit_DetectsOrphanWireRef_AfterFaceRemoval) // at a removed face index. The new audit block for orphan WireRefs must flag it. BRepGraph aGraph; const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Shape(); - BRepGraph_Builder::Perform(aGraph, aBox); + aGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes15 = + BRepGraph_Builder::Add(aGraph, aBox); ASSERT_TRUE(aGraph.IsDone()); // Find a live wire ref and rewrite its ParentId to a definitely-invalid Face id. diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_VersionStamp_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_VersionStamp_Test.cxx index d6ba7b1ee6..7e0e25f9ea 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_VersionStamp_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_VersionStamp_Test.cxx @@ -29,7 +29,9 @@ protected: { BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); const TopoDS_Shape& aBox = aBoxMaker.Shape(); - BRepGraph_Builder::Perform(myGraph, aBox); + myGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(myGraph, aBox); ASSERT_TRUE(myGraph.IsDone()); } @@ -95,7 +97,9 @@ TEST_F(BRepGraph_VersionStampTest, IsStale_DifferentGeneration_ReturnsTrue) // Rebuild the graph - generation changes. BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); - BRepGraph_Builder::Perform(myGraph, aBoxMaker.Shape()); + myGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes2 = + BRepGraph_Builder::Add(myGraph, aBoxMaker.Shape()); ASSERT_TRUE(myGraph.IsDone()); EXPECT_TRUE(myGraph.UIDs().IsStale(aStamp)); @@ -181,7 +185,9 @@ TEST_F(BRepGraph_VersionStampTest, GraphGUID_Rebuild_Changes) const Standard_GUID aGUID1 = myGraph.UIDs().GraphGUID(); BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); - BRepGraph_Builder::Perform(myGraph, aBoxMaker.Shape()); + myGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes3 = + BRepGraph_Builder::Add(myGraph, aBoxMaker.Shape()); ASSERT_TRUE(myGraph.IsDone()); const Standard_GUID aGUID2 = myGraph.UIDs().GraphGUID(); diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_Views_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_Views_Test.cxx index 2b03efa424..874d1a4cc3 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_Views_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_Views_Test.cxx @@ -89,7 +89,9 @@ protected: { BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); const TopoDS_Shape& aBox = aBoxMaker.Shape(); - BRepGraph_Builder::Perform(myGraph, aBox); + myGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(myGraph, aBox); } BRepGraph myGraph; @@ -449,20 +451,20 @@ TEST_F(BRepGraph_ViewsTest, TopoView_GroupedCoEdgeOps_Parity) TEST_F(BRepGraph_ViewsTest, TopoView_GroupedProductAndOccurrenceOps_Parity) { const BRepGraph_ProductId aPartProduct = - myGraph.Editor().Products().Add(BRepGraph_NodeId(BRepGraph_SolidId::Start())); - const BRepGraph_ProductId aSubAssembly = myGraph.Editor().Products().AddAssembly(); - const BRepGraph_ProductId aRootAssembly = myGraph.Editor().Products().AddAssembly(); + myGraph.Editor().Products().LinkProductToTopology(BRepGraph_NodeId(BRepGraph_SolidId::Start())); + const BRepGraph_ProductId aSubAssembly = myGraph.Editor().Products().CreateEmptyProduct(); + const BRepGraph_ProductId aRootAssembly = myGraph.Editor().Products().CreateEmptyProduct(); ASSERT_TRUE(aPartProduct.IsValid()); ASSERT_TRUE(aSubAssembly.IsValid()); ASSERT_TRUE(aRootAssembly.IsValid()); const BRepGraph_OccurrenceId aSubOccurrence = - myGraph.Editor().Products().AddOccurrence(aRootAssembly, aSubAssembly, TopLoc_Location()); + myGraph.Editor().Products().LinkProducts(aRootAssembly, aSubAssembly, TopLoc_Location()); const BRepGraph_OccurrenceId aPartOccurrence = - myGraph.Editor().Products().AddOccurrence(aSubAssembly, - aPartProduct, - TopLoc_Location(), - aSubOccurrence); + myGraph.Editor().Products().LinkProducts(aSubAssembly, + aPartProduct, + TopLoc_Location(), + aSubOccurrence); ASSERT_TRUE(aSubOccurrence.IsValid()); ASSERT_TRUE(aPartOccurrence.IsValid()); @@ -482,7 +484,7 @@ TEST_F(BRepGraph_ViewsTest, TopoView_GroupedProductAndOccurrenceOps_Parity) ASSERT_EQ(aOccurrenceRefs.Length(), 1); { BRepGraph_MutGuard anOccurrenceRef = - myGraph.Editor().Products().MutOccurrenceRef(aOccurrenceRefs.Value(0)); + myGraph.Editor().Occurrences().MutRef(aOccurrenceRefs.Value(0)); anOccurrenceRef->IsRemoved = true; } @@ -865,8 +867,8 @@ TEST_F(BRepGraph_ViewsTest, RefsView_RefAtStep_RoundTrip) TEST_F(BRepGraph_ViewsTest, RefsView_GenericRefHelpers_OccurrenceDefaults) { const BRepGraph_ProductId aPartProduct = - myGraph.Editor().Products().Add(BRepGraph_NodeId(BRepGraph_SolidId::Start())); - const BRepGraph_ProductId anAssembly = myGraph.Editor().Products().AddAssembly(); + myGraph.Editor().Products().LinkProductToTopology(BRepGraph_NodeId(BRepGraph_SolidId::Start())); + const BRepGraph_ProductId anAssembly = myGraph.Editor().Products().CreateEmptyProduct(); ASSERT_TRUE(aPartProduct.IsValid()); ASSERT_TRUE(anAssembly.IsValid()); @@ -874,7 +876,7 @@ TEST_F(BRepGraph_ViewsTest, RefsView_GenericRefHelpers_OccurrenceDefaults) aTrsf.SetTranslation(gp_Vec(4.0, 5.0, 6.0)); ASSERT_TRUE(myGraph.Editor() .Products() - .AddOccurrence(anAssembly, aPartProduct, TopLoc_Location(aTrsf)) + .LinkProducts(anAssembly, aPartProduct, TopLoc_Location(aTrsf)) .IsValid()); const NCollection_DynamicArray& anOccurrenceRefs = diff --git a/src/ModelingData/TKBRep/GTests/BRepGraph_WireExplorer_Test.cxx b/src/ModelingData/TKBRep/GTests/BRepGraph_WireExplorer_Test.cxx index c83171caaf..70c672185b 100644 --- a/src/ModelingData/TKBRep/GTests/BRepGraph_WireExplorer_Test.cxx +++ b/src/ModelingData/TKBRep/GTests/BRepGraph_WireExplorer_Test.cxx @@ -27,7 +27,9 @@ protected: void SetUp() override { BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0); - BRepGraph_Builder::Perform(myGraph, aBoxMaker.Shape()); + myGraph.Clear(); + [[maybe_unused]] const BRepGraph_Builder::Result aBuildRes1 = + BRepGraph_Builder::Add(myGraph, aBoxMaker.Shape()); } BRepGraph myGraph;