Modeling - Refactor BRepGraph for uint32_t ids (#1229)

- Migrated node/ref/rep ID types and many count-returning APIs from `int` to `uint32_t`/`size_t` (history indices), updating iterators and bounds checks accordingly.
- Reworked numerous loops from raw integer indexing to typed-id iteration (`Start()`, `IsValid()`, range-for) across core code and tests.
- Expanded compaction test coverage (incl. bounding-box preservation assertion), plus clearer assertions/messages.
This commit is contained in:
Pasukhin Dmitry
2026-04-23 22:09:31 +01:00
committed by GitHub
parent 48e84c53a9
commit 7eb211cc2e
55 changed files with 1934 additions and 1878 deletions
@@ -1347,11 +1347,13 @@ TEST(BRepGraphIncTest, ReverseIndex_CompSolid_ReverseMaintained_AfterBuild)
ASSERT_GE(aStorage.NbSolids(), 2);
// Both solids must appear in myCompSolidsOfSolid.
for (int i = 0; i < aStorage.NbSolids(); ++i)
for (BRepGraph_SolidId aSolidId = BRepGraph_SolidId::Start();
aSolidId.IsValid(aStorage.NbSolids());
++aSolidId)
{
const NCollection_Vector<BRepGraph_CompSolidId>* aCSVec =
aStorage.ReverseIndex().CompSolidsOfSolid(BRepGraph_SolidId(i));
EXPECT_NE(aCSVec, nullptr) << "Solid " << i << " not in any CompSolid";
aStorage.ReverseIndex().CompSolidsOfSolid(aSolidId);
EXPECT_NE(aCSVec, nullptr) << "Solid " << aSolidId.Index << " not in any CompSolid";
if (aCSVec != nullptr)
{
EXPECT_EQ(aCSVec->Length(), 1);
@@ -83,7 +83,7 @@ TopoDS_Compound makeBoxWithLooseEdge()
int countHistoryRecordsByOp(const BRepGraph& theGraph, const TCollection_AsciiString& theOp)
{
int aCount = 0;
for (int aRecIdx = 0; aRecIdx < theGraph.History().NbRecords(); ++aRecIdx)
for (size_t aRecIdx = 0; aRecIdx < theGraph.History().NbRecords(); ++aRecIdx)
{
if (theGraph.History().Record(aRecIdx).OperationName == theOp)
++aCount;
@@ -91,6 +91,32 @@ int countHistoryRecordsByOp(const BRepGraph& theGraph, const TCollection_AsciiSt
return aCount;
}
void addGraphBounds(const BRepGraph& theGraph, Bnd_Box& theBox)
{
for (BRepGraph_VertexIterator aVertIt(theGraph); aVertIt.More(); aVertIt.Next())
{
theBox.Add(theGraph.Topo().Vertices().Definition(aVertIt.CurrentId()).Point);
}
}
void expectBoxNear(const Bnd_Box& theLeft, const Bnd_Box& theRight, const double theTol)
{
ASSERT_FALSE(theLeft.IsVoid());
ASSERT_FALSE(theRight.IsVoid());
double aLeftMinX, aLeftMinY, aLeftMinZ, aLeftMaxX, aLeftMaxY, aLeftMaxZ;
double aRightMinX, aRightMinY, aRightMinZ, aRightMaxX, aRightMaxY, aRightMaxZ;
theLeft.Get(aLeftMinX, aLeftMinY, aLeftMinZ, aLeftMaxX, aLeftMaxY, aLeftMaxZ);
theRight.Get(aRightMinX, aRightMinY, aRightMinZ, aRightMaxX, aRightMaxY, aRightMaxZ);
EXPECT_NEAR(aLeftMinX, aRightMinX, theTol);
EXPECT_NEAR(aLeftMinY, aRightMinY, theTol);
EXPECT_NEAR(aLeftMinZ, aRightMinZ, theTol);
EXPECT_NEAR(aLeftMaxX, aRightMaxX, theTol);
EXPECT_NEAR(aLeftMaxY, aRightMaxY, theTol);
EXPECT_NEAR(aLeftMaxZ, aRightMaxZ, theTol);
}
} // namespace
TEST(BRepGraph_CompactTest, NoRemovedNodes_Noop)
@@ -102,9 +128,9 @@ TEST(BRepGraph_CompactTest, NoRemovedNodes_Noop)
BRepGraph_Builder::Perform(aGraph, aBox);
ASSERT_TRUE(aGraph.IsDone());
const int aNbVerticesBefore = aGraph.Topo().Vertices().Nb();
const int aNbEdgesBefore = aGraph.Topo().Edges().Nb();
const int aNbFacesBefore = aGraph.Topo().Faces().Nb();
const uint32_t aNbVerticesBefore = aGraph.Topo().Vertices().Nb();
const uint32_t aNbEdgesBefore = aGraph.Topo().Edges().Nb();
const uint32_t aNbFacesBefore = aGraph.Topo().Faces().Nb();
const BRepGraph_Compact::Result aRes = BRepGraph_Compact::Perform(aGraph);
@@ -147,17 +173,21 @@ TEST(BRepGraph_CompactTest, IndexDensity_NoGaps)
(void)BRepGraph_Compact::Perform(aGraph);
// After compaction, there should be no removed defs.
const int aNbVertices = aGraph.Topo().Vertices().Nb();
for (BRepGraph_VertexId aVertexId(0); aVertexId.IsValid(aNbVertices); ++aVertexId)
for (BRepGraph_VertexId aVertexId = BRepGraph_VertexId::Start();
aVertexId.IsValid(aGraph.Topo().Vertices().Nb());
++aVertexId)
EXPECT_FALSE(aGraph.Topo().Vertices().Definition(aVertexId).IsRemoved);
const int aNbEdges = aGraph.Topo().Edges().Nb();
for (BRepGraph_EdgeId anEdgeId(0); anEdgeId.IsValid(aNbEdges); ++anEdgeId)
for (BRepGraph_EdgeId anEdgeId = BRepGraph_EdgeId::Start();
anEdgeId.IsValid(aGraph.Topo().Edges().Nb());
++anEdgeId)
EXPECT_FALSE(aGraph.Topo().Edges().Definition(anEdgeId).IsRemoved);
const int aNbFaces = aGraph.Topo().Faces().Nb();
for (BRepGraph_FaceId aFaceId(0); aFaceId.IsValid(aNbFaces); ++aFaceId)
for (BRepGraph_FaceId aFaceId = BRepGraph_FaceId::Start();
aFaceId.IsValid(aGraph.Topo().Faces().Nb());
++aFaceId)
EXPECT_FALSE(aGraph.Topo().Faces().Definition(aFaceId).IsRemoved);
const int aNbWires = aGraph.Topo().Wires().Nb();
for (BRepGraph_WireId aWireId(0); aWireId.IsValid(aNbWires); ++aWireId)
for (BRepGraph_WireId aWireId = BRepGraph_WireId::Start();
aWireId.IsValid(aGraph.Topo().Wires().Nb());
++aWireId)
EXPECT_FALSE(aGraph.Topo().Wires().Definition(aWireId).IsRemoved);
}
@@ -216,6 +246,36 @@ TEST(BRepGraph_CompactTest, FullPipeline_Deduplicate_Compact_Validate)
EXPECT_TRUE(aValResult.IsValid());
}
TEST(BRepGraph_CompactTest, RemovalCompact_PreservesBounds_AndDoesNotGrowTopology)
{
BRepPrimAPI_MakeBox aBoxMaker(10.0, 20.0, 30.0);
const TopoDS_Shape& aBox = aBoxMaker.Shape();
BRepGraph aGraph;
BRepGraph_Builder::Perform(aGraph, aBox);
ASSERT_TRUE(aGraph.IsDone());
ASSERT_GT(aGraph.Topo().CoEdges().Nb(), 0);
ASSERT_GT(aGraph.Topo().Faces().Nb(), 2);
aGraph.Editor().Gen().RemoveNode(BRepGraph_FaceId(2));
const uint32_t aCoEdgesBeforeCompact = aGraph.Topo().CoEdges().Nb();
Bnd_Box aBoxBeforeCompact;
addGraphBounds(aGraph, aBoxBeforeCompact);
const BRepGraph_Compact::Result aRes = BRepGraph_Compact::Perform(aGraph);
EXPECT_GE(aRes.NbNodesBefore, aRes.NbNodesAfter);
EXPECT_LE(aGraph.Topo().CoEdges().Nb(), aCoEdgesBeforeCompact);
Bnd_Box aBoxAfterCompact;
addGraphBounds(aGraph, aBoxAfterCompact);
expectBoxNear(aBoxAfterCompact, aBoxBeforeCompact, Precision::Confusion());
const BRepGraph_Validate::Result aValResult = BRepGraph_Validate::Perform(aGraph);
EXPECT_TRUE(aValResult.IsValid());
}
TEST(BRepGraph_CompactTest, RemovalCompact_PreservesClosedTopologyAndValidShape)
{
BRepGraph aGraph;
@@ -398,9 +458,10 @@ TEST(BRepGraph_CompactTest, OwnGen_SurvivesCompact)
// Edge 0 may have been remapped. Find the edge that carries the mutated
// tolerance and verify both the tolerance value and OwnGen are preserved.
bool aFound = false;
const int aNbEdgesAfterCompact = aGraph.Topo().Edges().Nb();
for (BRepGraph_EdgeId anEdgeId(0); anEdgeId.IsValid(aNbEdgesAfterCompact); ++anEdgeId)
bool aFound = false;
for (BRepGraph_EdgeId anEdgeId = BRepGraph_EdgeId::Start();
anEdgeId.IsValid(aGraph.Topo().Edges().Nb());
++anEdgeId)
{
const BRepGraphInc::EdgeDef& anEdge = aGraph.Topo().Edges().Definition(anEdgeId);
if (std::abs(anEdge.Tolerance - THE_MUTATED_EDGE_TOLERANCE) < Precision::Confusion())
@@ -132,7 +132,7 @@ int nbPCurveEntries(const BRepGraph& theGraph)
int countHistoryRecordsByOp(const BRepGraph& theGraph, const TCollection_AsciiString& theOp)
{
int aCount = 0;
for (int aRecIdx = 0; aRecIdx < theGraph.History().NbRecords(); ++aRecIdx)
for (size_t aRecIdx = 0; aRecIdx < theGraph.History().NbRecords(); ++aRecIdx)
{
if (theGraph.History().Record(aRecIdx).OperationName == theOp)
{
@@ -336,7 +336,7 @@ TEST(BRepGraph_DeduplicateTest, CanonicalizeSurfaces_RewritesAndRecordsHistory)
anOpts.AnalyzeOnly = false;
anOpts.HistoryMode = true;
const int aHistoryBefore = aGraph.History().NbRecords();
const size_t aHistoryBefore = aGraph.History().NbRecords();
const BRepGraph_Deduplicate::Result aRes = BRepGraph_Deduplicate::Perform(aGraph, anOpts);
EXPECT_EQ(aRes.NbSurfaceRewrites, 1);
@@ -853,7 +853,7 @@ TEST(BRepGraph_DeduplicateTest, HistoryFindOriginal_TracesBackToCanonical)
ASSERT_EQ(aRes.NbHistoryRecords, 5);
// For each history record, FindOriginal on the replacement should trace back.
for (int aRecIdx = 0; aRecIdx < aGraph.History().NbRecords(); ++aRecIdx)
for (size_t aRecIdx = 0; aRecIdx < aGraph.History().NbRecords(); ++aRecIdx)
{
const BRepGraph_HistoryRecord& aRec = aGraph.History().Record(aRecIdx);
for (NCollection_DataMap<BRepGraph_NodeId, NCollection_Vector<BRepGraph_NodeId>>::Iterator
@@ -892,7 +892,7 @@ TEST(BRepGraph_DeduplicateTest, HistoryFindDerived_ContainsCanonicalNode)
// For each history record, FindDerived on the original should contain the replacements.
// All records are canonicalize records with 1 replacement (no nullify records).
int aNbCanonMappings = 0;
for (int aRecIdx = 0; aRecIdx < aGraph.History().NbRecords(); ++aRecIdx)
for (size_t aRecIdx = 0; aRecIdx < aGraph.History().NbRecords(); ++aRecIdx)
{
const BRepGraph_HistoryRecord& aRec = aGraph.History().Record(aRecIdx);
for (NCollection_DataMap<BRepGraph_NodeId, NCollection_Vector<BRepGraph_NodeId>>::Iterator
@@ -921,12 +921,17 @@ TEST(BRepGraph_DeduplicateTest, HistoryRecordSequenceNumbers_AreMonotonic)
(void)BRepGraph_Deduplicate::Perform(aGraph, anOpts);
int aPrevSeq = -1;
for (int aRecIdx = 0; aRecIdx < aGraph.History().NbRecords(); ++aRecIdx)
bool isFirst = true;
size_t aPrevSeq = 0;
for (size_t aRecIdx = 0; aRecIdx < aGraph.History().NbRecords(); ++aRecIdx)
{
const BRepGraph_HistoryRecord& aRec = aGraph.History().Record(aRecIdx);
EXPECT_GT(aRec.SequenceNumber, aPrevSeq);
if (!isFirst)
{
EXPECT_GT(aRec.SequenceNumber, aPrevSeq);
}
aPrevSeq = aRec.SequenceNumber;
isFirst = false;
}
}
@@ -1557,13 +1562,14 @@ TEST(BRepGraph_DeduplicateTest, AnalyzeOnly_NoBackRefChangesOrNullification)
for (BRepGraph_FullFaceIterator aFaceIt(aGraph); aFaceIt.More(); aFaceIt.Next())
{
const BRepGraph_FaceId aFaceId = aFaceIt.CurrentId();
EXPECT_EQ(BRepGraph_Tool::Face::Surface(aGraph, aFaceId).get(), aSurfPtrs.Value(aFaceId.Index));
EXPECT_EQ(BRepGraph_Tool::Face::Surface(aGraph, aFaceId).get(),
aSurfPtrs.Value(static_cast<int>(aFaceId.Index)));
}
for (BRepGraph_FullEdgeIterator anEdgeIt(aGraph); anEdgeIt.More(); anEdgeIt.Next())
{
const BRepGraph_EdgeId anEdgeId = anEdgeIt.CurrentId();
EXPECT_EQ(BRepGraph_Tool::Edge::Curve(aGraph, anEdgeId).get(),
aCurvePtrs.Value(anEdgeId.Index));
aCurvePtrs.Value(static_cast<int>(anEdgeId.Index)));
}
// All handles still non-null.
@@ -885,19 +885,19 @@ TEST(BRepGraph_GeometryTest, Cylinder_TriangulationReps_Populated)
TEST(BRepGraph_GeometryTest, RepId_FactoryMethods)
{
const BRepGraph_SurfaceRepId aSurfId = BRepGraph_RepId::Surface(42);
const BRepGraph_SurfaceRepId aSurfId(42);
EXPECT_EQ(BRepGraph_RepId(aSurfId).RepKind, BRepGraph_RepId::Kind::Surface);
EXPECT_EQ(aSurfId.Index, 42);
EXPECT_EQ(aSurfId.Index, 42u);
EXPECT_TRUE(aSurfId.IsValid());
const BRepGraph_Curve3DRepId aCurve3DId = BRepGraph_RepId::Curve3D(7);
const BRepGraph_Curve3DRepId aCurve3DId(7);
EXPECT_EQ(BRepGraph_RepId(aCurve3DId).RepKind, BRepGraph_RepId::Kind::Curve3D);
EXPECT_EQ(aCurve3DId.Index, 7);
EXPECT_EQ(aCurve3DId.Index, 7u);
const BRepGraph_RepId aDefaultId;
EXPECT_FALSE(aDefaultId.IsValid());
EXPECT_EQ(aSurfId, BRepGraph_RepId::Surface(42));
EXPECT_EQ(aSurfId, BRepGraph_SurfaceRepId(42));
EXPECT_NE(BRepGraph_RepId(aSurfId), BRepGraph_RepId(aCurve3DId));
}
@@ -137,7 +137,7 @@ TEST_F(BRepGraph_HistoryTest, FindDerived_UnmodifiedNode_ReturnsEmpty)
TEST_F(BRepGraph_HistoryTest, Disabled_RecordHistory_NoRecordStored)
{
const int aNbBefore = myGraph.History().NbRecords();
const size_t aNbBefore = myGraph.History().NbRecords();
myGraph.History().SetEnabled(false);
const BRepGraph_NodeId anEdge0(BRepGraph_NodeId::Kind::Edge, 0);
@@ -173,7 +173,7 @@ TEST_F(BRepGraph_HistoryTest, ReEnabled_RecordsAfterReEnable)
myGraph.History().SetEnabled(true);
EXPECT_TRUE(myGraph.History().IsEnabled());
const int aNbBefore = myGraph.History().NbRecords();
const size_t aNbBefore = myGraph.History().NbRecords();
const BRepGraph_NodeId anEdge0(BRepGraph_NodeId::Kind::Edge, 0);
NCollection_Vector<BRepGraph_NodeId> aReplacements;
aReplacements.Append(BRepGraph_NodeId(BRepGraph_NodeId::Kind::Edge, 1));
@@ -185,7 +185,7 @@ TEST_F(BRepGraph_HistoryTest, ReEnabled_RecordsAfterReEnable)
TEST_F(BRepGraph_HistoryTest, ApplyModification_EmptyReplacements)
{
const BRepGraph_NodeId anEdge0(BRepGraph_NodeId::Kind::Edge, 0);
const int aNbBefore = myGraph.History().NbRecords();
const size_t aNbBefore = myGraph.History().NbRecords();
myGraph.Editor().Gen().ApplyModification(
anEdge0,
@@ -234,7 +234,7 @@ TEST_F(BRepGraph_HistoryTest, ApplyModification_MultipleReplacements)
TEST_F(BRepGraph_HistoryTest, RecordHistory_EmptyReplacements_Stored)
{
const int aNbBefore = myGraph.History().NbRecords();
const size_t aNbBefore = myGraph.History().NbRecords();
const BRepGraph_NodeId anEdge0(BRepGraph_NodeId::Kind::Edge, 0);
NCollection_Vector<BRepGraph_NodeId> anEmpty;
myGraph.History().Record("Erase", anEdge0, anEmpty);
@@ -256,7 +256,7 @@ TEST_F(BRepGraph_HistoryTest, HistoryRecord_SequenceNumber_Monotonic)
aRepl2.Append(anEdge2);
myGraph.History().Record("Op2", anEdge1, aRepl2);
const int aNb = myGraph.History().NbRecords();
const size_t aNb = myGraph.History().NbRecords();
ASSERT_GE(aNb, 2);
const BRepGraph_HistoryRecord& aRec1 = myGraph.History().Record(aNb - 2);
const BRepGraph_HistoryRecord& aRec2 = myGraph.History().Record(aNb - 1);
@@ -276,7 +276,7 @@ TEST_F(BRepGraph_HistoryTest, HistoryRecord_OperationName_Stored)
TEST_F(BRepGraph_HistoryTest, NbHistoryRecords_AfterMultipleOps_Correct)
{
const int aNbBefore = myGraph.History().NbRecords();
const size_t aNbBefore = myGraph.History().NbRecords();
const BRepGraph_NodeId anEdge0(BRepGraph_NodeId::Kind::Edge, 0);
NCollection_Vector<BRepGraph_NodeId> aRepl;
@@ -328,7 +328,7 @@ TEST_F(BRepGraph_HistoryTest, FindOriginal_TwoApply_TransitiveTrace)
TEST_F(BRepGraph_HistoryTest, ApplyModification_WhenModifierThrows_DoesNotRecordHistory)
{
const int aNbRecordsBefore = myGraph.History().NbRecords();
const size_t aNbRecordsBefore = myGraph.History().NbRecords();
const BRepGraph_NodeId anEdge(BRepGraph_NodeId::Kind::Edge, 0);
@@ -364,8 +364,8 @@ TEST_F(BRepGraph_HistoryTest, SplitEdge_RewritesAllContainingWires)
const NCollection_Vector<BRepGraph_WireId>& aWireIndices = myGraph.Topo().Edges().Wires(anEdgeId);
ASSERT_GT(aWireIndices.Length(), 0);
const int aNbEdgesBefore = myGraph.Topo().Edges().Nb();
const int aNbActiveEdgesBefore = myGraph.Topo().Edges().NbActive();
const uint32_t aNbEdgesBefore = myGraph.Topo().Edges().Nb();
const uint32_t aNbActiveEdgesBefore = myGraph.Topo().Edges().NbActive();
BRepGraph_EdgeId aSubA;
BRepGraph_EdgeId aSubB;
@@ -480,10 +480,11 @@ TEST_F(BRepGraph_HistoryTest, SplitEdge_IgnoresRemovedCoEdgeRefEntries)
myGraph.Topo().CoEdges().Definition(aRemovedCoEdgeId);
EXPECT_EQ(aRemovedCoEdgeAfter.EdgeDefId, anEdgeId);
bool hasSubA = false;
bool hasSubB = false;
const int aNbCoEdgeRefs = myGraph.Refs().CoEdges().Nb();
for (BRepGraph_CoEdgeRefId aRefId(0); aRefId.IsValid(aNbCoEdgeRefs); ++aRefId)
bool hasSubA = false;
bool hasSubB = false;
for (BRepGraph_CoEdgeRefId aRefId = BRepGraph_CoEdgeRefId::Start();
aRefId.IsValid(myGraph.Refs().CoEdges().Nb());
++aRefId)
{
const BRepGraphInc::CoEdgeRef& aRef = myGraph.Refs().CoEdges().Entry(aRefId);
if (aRef.IsRemoved || !aRef.CoEdgeDefId.IsValid(myGraph.Topo().CoEdges().Nb()))
@@ -510,7 +511,7 @@ TEST_F(BRepGraph_HistoryTest, ApplyModification_SplitEdge_RecordsBothDerivedNode
myGraph.Editor().Vertices().Add(gp_Pnt(4.0, 5.0, 6.0), 1.0e-7);
ASSERT_TRUE(aSplitVertex.IsValid());
const int aNbRecordsBefore = myGraph.History().NbRecords();
const size_t aNbRecordsBefore = myGraph.History().NbRecords();
myGraph.Editor().Gen().ApplyModification(
anEdgeId,
@@ -149,14 +149,16 @@ TEST_F(BRepGraph_MutationGenTest, SubtreeGen_DeferredPropagatedParent_Incremente
// At least one parent wire must have SubtreeGen incremented vs its baseline.
bool aAnyWireSubtreeIncremented = false;
for (BRepGraph_WireIterator aWireIt(myGraph); aWireIt.More(); aWireIt.Next())
if (aWireIt.Current().SubtreeGen > aWireSubtreeGensBefore.Value(aWireIt.CurrentId().Index))
if (aWireIt.Current().SubtreeGen
> aWireSubtreeGensBefore.Value(static_cast<int>(aWireIt.CurrentId().Index)))
aAnyWireSubtreeIncremented = true;
EXPECT_TRUE(aAnyWireSubtreeIncremented);
// At least one parent face must have SubtreeGen incremented vs its baseline.
bool aAnyFaceSubtreeIncremented = false;
for (BRepGraph_FaceIterator aFaceIt(myGraph); aFaceIt.More(); aFaceIt.Next())
if (aFaceIt.Current().SubtreeGen > aFaceSubtreeGensBefore.Value(aFaceIt.CurrentId().Index))
if (aFaceIt.Current().SubtreeGen
> aFaceSubtreeGensBefore.Value(static_cast<int>(aFaceIt.CurrentId().Index)))
aAnyFaceSubtreeIncremented = true;
EXPECT_TRUE(aAnyFaceSubtreeIncremented);
}
@@ -262,8 +262,9 @@ TEST(BRepGraph_RefIdTest, RefsView_AfterBuild_UIDRoundtripAndParentKinds)
BRepGraph_Builder::Perform(aGraph, BRepPrimAPI_MakeBox(10.0, 20.0, 30.0).Shape());
ASSERT_TRUE(aGraph.IsDone());
const int aNbFaceRefs = aGraph.Refs().Faces().Nb();
for (BRepGraph_FaceRefId aFaceRefId(0); aFaceRefId.IsValid(aNbFaceRefs); ++aFaceRefId)
for (BRepGraph_FaceRefId aFaceRefId = BRepGraph_FaceRefId::Start();
aFaceRefId.IsValid(aGraph.Refs().Faces().Nb());
++aFaceRefId)
{
const BRepGraph_RefId aRefId = aFaceRefId;
const BRepGraph_RefUID aUID = aGraph.UIDs().Of(aRefId);
@@ -280,8 +281,9 @@ TEST(BRepGraph_RefIdTest, RefsView_AfterBuild_UIDRoundtripAndParentKinds)
EXPECT_TRUE(anEntry.FaceDefId.IsValid(aGraph.Topo().Faces().Nb()));
}
const int aNbWireRefs = aGraph.Refs().Wires().Nb();
for (BRepGraph_WireRefId aWireRefId(0); aWireRefId.IsValid(aNbWireRefs); ++aWireRefId)
for (BRepGraph_WireRefId aWireRefId = BRepGraph_WireRefId::Start();
aWireRefId.IsValid(aGraph.Refs().Wires().Nb());
++aWireRefId)
{
const BRepGraph_RefId aRefId = aWireRefId;
const BRepGraph_RefUID aUID = aGraph.UIDs().Of(aRefId);
@@ -292,8 +294,9 @@ TEST(BRepGraph_RefIdTest, RefsView_AfterBuild_UIDRoundtripAndParentKinds)
EXPECT_TRUE(anEntry.WireDefId.IsValid(aGraph.Topo().Wires().Nb()));
}
const int aNbCoEdgeRefs = aGraph.Refs().CoEdges().Nb();
for (BRepGraph_CoEdgeRefId aCoEdgeRefId(0); aCoEdgeRefId.IsValid(aNbCoEdgeRefs); ++aCoEdgeRefId)
for (BRepGraph_CoEdgeRefId aCoEdgeRefId = BRepGraph_CoEdgeRefId::Start();
aCoEdgeRefId.IsValid(aGraph.Refs().CoEdges().Nb());
++aCoEdgeRefId)
{
const BRepGraph_RefId aRefId = aCoEdgeRefId;
const BRepGraph_RefUID aUID = aGraph.UIDs().Of(aRefId);
@@ -304,8 +307,9 @@ TEST(BRepGraph_RefIdTest, RefsView_AfterBuild_UIDRoundtripAndParentKinds)
EXPECT_TRUE(anEntry.CoEdgeDefId.IsValid(aGraph.Topo().CoEdges().Nb()));
}
const int aNbShellRefs = aGraph.Refs().Shells().Nb();
for (BRepGraph_ShellRefId aShellRefId(0); aShellRefId.IsValid(aNbShellRefs); ++aShellRefId)
for (BRepGraph_ShellRefId aShellRefId = BRepGraph_ShellRefId::Start();
aShellRefId.IsValid(aGraph.Refs().Shells().Nb());
++aShellRefId)
{
const BRepGraph_RefId aRefId = aShellRefId;
const BRepGraph_RefUID aUID = aGraph.UIDs().Of(aRefId);
@@ -316,8 +320,9 @@ TEST(BRepGraph_RefIdTest, RefsView_AfterBuild_UIDRoundtripAndParentKinds)
EXPECT_TRUE(anEntry.ShellDefId.IsValid(aGraph.Topo().Shells().Nb()));
}
const int aNbVertexRefs = aGraph.Refs().Vertices().Nb();
for (BRepGraph_VertexRefId aVertexRefId(0); aVertexRefId.IsValid(aNbVertexRefs); ++aVertexRefId)
for (BRepGraph_VertexRefId aVertexRefId = BRepGraph_VertexRefId::Start();
aVertexRefId.IsValid(aGraph.Refs().Vertices().Nb());
++aVertexRefId)
{
const BRepGraph_RefId aRefId = aVertexRefId;
const BRepGraph_RefUID aUID = aGraph.UIDs().Of(aRefId);
@@ -329,8 +334,9 @@ TEST(BRepGraph_RefIdTest, RefsView_AfterBuild_UIDRoundtripAndParentKinds)
EXPECT_TRUE(anEntry.VertexDefId.IsValid(aGraph.Topo().Vertices().Nb()));
}
const int aNbSolidRefs = aGraph.Refs().Solids().Nb();
for (BRepGraph_SolidRefId aSolidRefId(0); aSolidRefId.IsValid(aNbSolidRefs); ++aSolidRefId)
for (BRepGraph_SolidRefId aSolidRefId = BRepGraph_SolidRefId::Start();
aSolidRefId.IsValid(aGraph.Refs().Solids().Nb());
++aSolidRefId)
{
const BRepGraph_RefId aRefId = aSolidRefId;
const BRepGraph_RefUID aUID = aGraph.UIDs().Of(aRefId);
@@ -341,8 +347,9 @@ TEST(BRepGraph_RefIdTest, RefsView_AfterBuild_UIDRoundtripAndParentKinds)
EXPECT_TRUE(anEntry.SolidDefId.IsValid(aGraph.Topo().Solids().Nb()));
}
const int aNbChildRefs = aGraph.Refs().Children().Nb();
for (BRepGraph_ChildRefId aChildRefId(0); aChildRefId.IsValid(aNbChildRefs); ++aChildRefId)
for (BRepGraph_ChildRefId aChildRefId = BRepGraph_ChildRefId::Start();
aChildRefId.IsValid(aGraph.Refs().Children().Nb());
++aChildRefId)
{
const BRepGraph_RefId aRefId = aChildRefId;
const BRepGraph_RefUID aUID = aGraph.UIDs().Of(aRefId);
@@ -312,11 +312,13 @@ TEST(BRepGraph_ScenarioMatrix, CompSolid_TwoBoxes_BothSubsystemsMutateReconstruc
ASSERT_GE(aOrigStorage.NbSolids(), 2);
// Both solids must be reverse-indexed into the CompSolid.
for (int i = 0; i < aOrigStorage.NbSolids(); ++i)
for (BRepGraph_SolidId aSolidId = BRepGraph_SolidId::Start();
aSolidId.IsValid(aOrigStorage.NbSolids());
++aSolidId)
{
const NCollection_Vector<BRepGraph_CompSolidId>* aCSVec =
aOrigStorage.ReverseIndex().CompSolidsOfSolid(BRepGraph_SolidId(i));
EXPECT_NE(aCSVec, nullptr) << "Solid " << i << " not in any CompSolid";
aOrigStorage.ReverseIndex().CompSolidsOfSolid(aSolidId);
EXPECT_NE(aCSVec, nullptr) << "Solid " << aSolidId.Index << " not in any CompSolid";
}
EXPECT_TRUE(aOrigStorage.ValidateReverseIndex()) << "Reverse index must be consistent";
@@ -58,9 +58,9 @@ TEST_F(BRepGraph_SharingTest, EdgeDef_EachSharedByTwoFaces)
for (BRepGraph_EdgeIterator anEdgeIt(myGraph); anEdgeIt.More(); anEdgeIt.Next())
{
const BRepGraph_EdgeId anEdgeId = anEdgeIt.CurrentId();
const int aFaceCount = myGraph.Topo().Edges().NbFaces(anEdgeId);
EXPECT_EQ(aFaceCount, 2) << "Edge def " << anEdgeId.Index
<< " expected to be shared by 2 faces, got " << aFaceCount;
const uint32_t aFaceCount = myGraph.Topo().Edges().NbFaces(anEdgeId);
EXPECT_EQ(aFaceCount, 2u) << "Edge def " << anEdgeId.Index
<< " expected to be shared by 2 faces, got " << aFaceCount;
}
}
@@ -1264,9 +1264,9 @@ TEST_F(BRepGraphTest, NbFacesOfEdge_SharedEdge)
{
if (!BRepGraph_Tool::Edge::Degenerated(myGraph, anEdgeIt.CurrentId()))
{
const int aCount = myGraph.Topo().Edges().NbFaces(anEdgeIt.CurrentId());
EXPECT_EQ(aCount, 2) << "Edge " << anEdgeIt.CurrentId().Index
<< " should be shared by 2 faces";
const uint32_t aCount = myGraph.Topo().Edges().NbFaces(anEdgeIt.CurrentId());
EXPECT_EQ(aCount, 2u) << "Edge " << anEdgeIt.CurrentId().Index
<< " should be shared by 2 faces";
}
}
}
@@ -1279,7 +1279,7 @@ TEST_F(BRepGraphTest, FreeEdges_ClosedBox_Empty)
TEST_F(BRepGraphTest, RecordHistory_BasicEntry)
{
int aBefore = myGraph.History().NbRecords();
size_t aBefore = myGraph.History().NbRecords();
BRepGraph_NodeId anEdge0(BRepGraph_NodeId::Kind::Edge, 0);
BRepGraph_NodeId anEdge1(BRepGraph_NodeId::Kind::Edge, 1);
NCollection_Vector<BRepGraph_NodeId> aRepl;
@@ -1693,7 +1693,7 @@ TEST(BRepGraph_UIDsViewTest, ReverseLookupStaysCurrentAfterProgrammaticAdd)
TEST_F(BRepGraphTest, RecordHistory_MultipleRecords_SequenceNumbers)
{
const int aBefore = myGraph.History().NbRecords();
const size_t aBefore = myGraph.History().NbRecords();
BRepGraph_NodeId anEdge0(BRepGraph_NodeId::Kind::Edge, 0);
BRepGraph_NodeId anEdge1(BRepGraph_NodeId::Kind::Edge, 1);
@@ -1707,7 +1707,7 @@ TEST_F(BRepGraphTest, RecordHistory_MultipleRecords_SequenceNumbers)
EXPECT_EQ(myGraph.History().NbRecords(), aBefore + 3);
// Check monotonically increasing sequence numbers.
for (int anIdx = aBefore + 1; anIdx < aBefore + 3; ++anIdx)
for (size_t anIdx = aBefore + 1; anIdx < aBefore + 3; ++anIdx)
{
EXPECT_GT(myGraph.History().Record(anIdx).SequenceNumber,
myGraph.History().Record(anIdx - 1).SequenceNumber)
@@ -2289,8 +2289,8 @@ TEST_F(BRepGraphTest, Decompose_ThreeDisconnectedFaces_ThreeComponents)
TEST_F(BRepGraphTest, DetectToleranceConflicts_ManualConflict_Detected)
{
// Find two edges that share the same Curve3d handle.
bool isConflictSetUp = false;
const int aNbEdges = myGraph.Topo().Edges().Nb();
bool isConflictSetUp = false;
const uint32_t aNbEdges = myGraph.Topo().Edges().Nb();
for (BRepGraph_EdgeId anEdgeId(0); anEdgeId.IsValid(aNbEdges) && !isConflictSetUp; ++anEdgeId)
{
if (BRepGraph_Tool::Edge::Degenerated(myGraph, anEdgeId)
@@ -2781,7 +2781,7 @@ TEST_F(BRepGraphTest, SetHistoryEnabled_DisableAndQuery)
TEST_F(BRepGraphTest, RecordHistory_Disabled_NoRecordAdded)
{
const int aBefore = myGraph.History().NbRecords();
const size_t aBefore = myGraph.History().NbRecords();
myGraph.History().SetEnabled(false);
@@ -2798,7 +2798,7 @@ TEST_F(BRepGraphTest, RecordHistory_ReEnabled_RecordsAgain)
{
myGraph.History().SetEnabled(false);
const int aBefore = myGraph.History().NbRecords();
const size_t aBefore = myGraph.History().NbRecords();
BRepGraph_NodeId anEdge0(BRepGraph_NodeId::Kind::Edge, 0);
BRepGraph_NodeId anEdge1(BRepGraph_NodeId::Kind::Edge, 1);
@@ -2817,7 +2817,7 @@ TEST_F(BRepGraphTest, ApplyModification_HistoryDisabled_NoHistoryNoDerivedEdges)
{
myGraph.History().SetEnabled(false);
const int aNbHistBefore = myGraph.History().NbRecords();
const size_t aNbHistBefore = myGraph.History().NbRecords();
BRepGraph_NodeId anEdge0(BRepGraph_NodeId::Kind::Edge, 0);
BRepGraph_NodeId anEdge1(BRepGraph_NodeId::Kind::Edge, 1);
@@ -42,11 +42,12 @@ protected:
TEST_F(BRepGraph_QuerySurfaceTest, Face_NbWires_BoxFaceHasOneWire)
{
const int aNbFaces = myBoxGraph.Topo().Faces().Nb();
for (BRepGraph_FaceId aFaceId(0); aFaceId.IsValid(aNbFaces); ++aFaceId)
for (BRepGraph_FaceId aFaceId = BRepGraph_FaceId::Start();
aFaceId.IsValid(myBoxGraph.Topo().Faces().Nb());
++aFaceId)
{
const int aNb = BRepGraph_Tool::Face::NbWires(myBoxGraph, aFaceId);
EXPECT_EQ(aNb, 1) << "Box face " << aFaceId.Index << " should have exactly 1 wire";
const uint32_t aNb = BRepGraph_Tool::Face::NbWires(myBoxGraph, aFaceId);
EXPECT_EQ(aNb, 1u) << "Box face " << aFaceId.Index << " should have exactly 1 wire";
}
}
@@ -102,12 +103,13 @@ TEST_F(BRepGraph_QuerySurfaceTest, Wire_IsOuter_FirstWireOfBoxFaceIsOuter)
TEST_F(BRepGraph_QuerySurfaceTest, Edge_NbFaces_BoxEdgeHasExactlyTwoFaces)
{
const int aNbEdges = myBoxGraph.Topo().Edges().Nb();
for (BRepGraph_EdgeId anEdgeId(0); anEdgeId.IsValid(aNbEdges); ++anEdgeId)
for (BRepGraph_EdgeId anEdgeId = BRepGraph_EdgeId::Start();
anEdgeId.IsValid(myBoxGraph.Topo().Edges().Nb());
++anEdgeId)
{
const int aNbFaces = BRepGraph_Tool::Edge::NbFaces(myBoxGraph, anEdgeId);
EXPECT_EQ(aNbFaces, 2) << "Box edge " << anEdgeId.Index
<< " should be shared by exactly 2 faces";
const uint32_t aNbFaces = BRepGraph_Tool::Edge::NbFaces(myBoxGraph, anEdgeId);
EXPECT_EQ(aNbFaces, 2u) << "Box edge " << anEdgeId.Index
<< " should be shared by exactly 2 faces";
}
}
@@ -636,18 +636,19 @@ TEST_F(BRepGraph_ViewsTest, EdgeOps_FindCoEdgeId_InvalidPair_ReturnsInvalid)
{
// Use a valid edge but a face that doesn't share it.
// Edge 0 and the last face are very unlikely to share a coedge in a box.
const int aNbFaces = myGraph.Topo().Faces().Nb();
const BRepGraph_EdgeId anEdge(0);
const NCollection_Vector<BRepGraph_FaceId>& aEdgeFaces = myGraph.Topo().Edges().Faces(anEdge);
// Find a face NOT adjacent to edge 0.
BRepGraph_FaceId aNonAdjacentFace;
for (int aFaceIdx = 0; aFaceIdx < aNbFaces; ++aFaceIdx)
for (BRepGraph_FaceId aFaceId = BRepGraph_FaceId::Start();
aFaceId.IsValid(myGraph.Topo().Faces().Nb());
++aFaceId)
{
bool isAdjacent = false;
for (const BRepGraph_FaceId& aFace : aEdgeFaces)
{
if (aFace.Index == aFaceIdx)
if (aFace.Index == aFaceId.Index)
{
isAdjacent = true;
break;
@@ -655,7 +656,7 @@ TEST_F(BRepGraph_ViewsTest, EdgeOps_FindCoEdgeId_InvalidPair_ReturnsInvalid)
}
if (!isAdjacent)
{
aNonAdjacentFace = BRepGraph_FaceId(aFaceIdx);
aNonAdjacentFace = aFaceId;
break;
}
}