Foundation, Modeling - NCollection modernization and BRepGraph overhaul (#1212)

- Migrate NCollection map/sequence/array size APIs from int to size_t; Size() returns size_t, Length() remains the int accessor; int overloads delegate through NbBucketsFromInt() with a negative-input guard.
- Add NCollection_LinearVector: contiguous flat-buffer dynamic array with Standard::Reallocate-based growth for trivial types and move-construction for non-trivial types.
- Rewrite NCollection_DynamicArray on top of LinearVector<T*>; switch to power-of-two block sizing with precomputed shift/mask.
- Rework NCollection_BaseMap iterator with a forward findFirst() helper (no negative-bucket arithmetic); unify ReSize/BeginResize/EndResize on size_t.
- Enable thread-safe fast path in NCollection_IncAllocator via std::shared_mutex + CAS bump allocation on atomic AvailableSize; exclusive lock is taken only for new-block allocation and list reordering.
- Remove NCollection_BasePointerVector (superseded by NCollection_LinearVector).
- Remove NCollection_BaseMap::Statistics (unused).
- Add <cstddef> include in NCollection_Primes.hxx so size_t resolves on clean builds.
- Document iterator invalidation contract on NCollection_LinearVector.
- Unify BRepGraph programmatic mutation behind EditorView: delete BuilderView (2648+552 lines); EditorView (3186+930 lines) and EditorView_Mut.cxx own both structural creation (Add*/Remove*) and field-level RAII-scoped mutation (Mut*()) with automatic OwnGen and SubtreeGen propagation.
- Add BRepGraph_MeshCache and BRepGraph_MeshView: two-tier mesh storage separating algorithm-derived caches from persistent (definition) triangulations; freshness is keyed on FaceDef.OwnGen; cache writes do not mutate the model.
- Document the MeshCache invalidation contract in BRepGraph_MeshCache.hxx (which mutations bump Face.OwnGen and how markRepModified closes the loop for Surface/Triangulation reps).
- Add BRepGraph_RefsIterator (generic flat ref scan with RefTraits dispatch) and BRepGraph_ReverseIterator (typed parent-traversal wrappers over reverse-index vectors).
- Rework RefId entity model: replace inline refs with typed RefId vectors; add OccurrenceRef and Kind::Occurrence=7; BRepGraphInc_WireExplorer now requires a VertexRefLookup.
- Rename layers for consistency: BRepGraph_ParamLayer to BRepGraph_LayerParam, BRepGraph_RegularityLayer to BRepGraph_LayerRegularity; rename BRepGraphInc_Usage to BRepGraphInc_Instance.
- Replace RootNodeIds() with RootProductIds() returning product roots only.
- Update BRepGraph and BRepGraphInc READMEs; fix stale RootNodeIds reference.
- Sweep Size() to Length() renames across ~200 callers in TKG2d, TKG3d, TKMath, TKMesh, TKBO, TKOffset, TKShHealing, TKTopAlgo, TKBRep, TKService, TKV3d, TKOpenGl, TKMeshVS, TKDE*, TKXCAF, TKXSBase, TKLCAF, TKStd, and Draw harness.
- Add GTest coverage for new containers and the BRepGraph overhaul: NCollection_DynamicArray_Test, NCollection_LinearVector_Test, BRepGraph_Fuzz_Test, BRepGraph_Iterator_Test, BRepGraph_LayerIterator_Test, BRepGraph_MeshCache_Test, BRepGraph_MutGuard_Test, BRepGraph_ReplaceVertex_Test, BRepGraph_ReverseIterator_Test, BRepGraph_ScenarioMatrix_Test, BRepGraph_TypedIdDispatch_Test, BRepGraph_WireExplorer_Test.
This commit is contained in:
Pasukhin Dmitry
2026-04-19 18:47:54 +01:00
committed by GitHub
parent b3ccf20b1c
commit 0755b6f31d
312 changed files with 23723 additions and 10569 deletions

View File

@@ -230,12 +230,12 @@ void Font_TextFormatter::Format()
}
else
{
for (int aLineIt = 0; aLineIt < myNewLines.Size(); aLineIt++)
for (int aLineIt = 0; aLineIt < myNewLines.Length(); aLineIt++)
{
aMaxLineWidth = std::max(aMaxLineWidth, LineWidth(aLineIt));
}
// clang-format off
aMaxLineWidth = std::max(aMaxLineWidth, LineWidth (myNewLines.Size())); // processing the last line also
aMaxLineWidth = std::max(aMaxLineWidth, LineWidth (myNewLines.Length())); // processing the last line also
// clang-format on
}
}
@@ -316,7 +316,7 @@ void Font_TextFormatter::Format()
bool Font_TextFormatter::GlyphBoundingBox(const int theIndex, Font_Rect& theBndBox) const
{
if (theIndex < 0 || theIndex >= Corners().Size())
if (theIndex < 0 || theIndex >= Corners().Length())
{
return false;
}

View File

@@ -34,7 +34,7 @@ public:
//! Allocates new empty array
bool Init(const int theNbElems, const NCollection_Array1<Graphic3d_Attribute>& theAttribs)
{
return Init(theNbElems, &theAttribs.First(), theAttribs.Size());
return Init(theNbElems, &theAttribs.First(), theAttribs.Length());
}
//! Return TRUE if data can be invalidated; FALSE by default.

View File

@@ -291,7 +291,7 @@ public:
//! Allocates new empty array
bool Init(const int theNbElems, const NCollection_Array1<Graphic3d_Attribute>& theAttribs)
{
return Init(theNbElems, &theAttribs.First(), theAttribs.Size());
return Init(theNbElems, &theAttribs.First(), theAttribs.Length());
}
public:

View File

@@ -32,7 +32,7 @@ Graphic3d_BvhCStructureSet::Graphic3d_BvhCStructureSet()
int Graphic3d_BvhCStructureSet::Size() const
{
return myStructs.Size();
return myStructs.Length();
}
//=================================================================================================
@@ -65,7 +65,7 @@ void Graphic3d_BvhCStructureSet::Swap(const int theIdx1, const int theIdx2)
bool Graphic3d_BvhCStructureSet::Add(const Graphic3d_CStructure* theStruct)
{
const int aSize = myStructs.Size();
const int aSize = myStructs.Length();
if (myStructs.Add(theStruct) > aSize) // new structure?
{

View File

@@ -31,7 +31,7 @@ Graphic3d_BvhCStructureSetTrsfPers::Graphic3d_BvhCStructureSetTrsfPers(
int Graphic3d_BvhCStructureSetTrsfPers::Size() const
{
return myStructs.Size();
return myStructs.Length();
}
//=================================================================================================
@@ -64,7 +64,7 @@ void Graphic3d_BvhCStructureSetTrsfPers::Swap(const int theIdx1, const int theId
bool Graphic3d_BvhCStructureSetTrsfPers::Add(const Graphic3d_CStructure* theStruct)
{
const int aSize = myStructs.Size();
const int aSize = myStructs.Length();
if (myStructs.Add(theStruct) > aSize) // new structure?
{
@@ -124,9 +124,9 @@ const opencascade::handle<BVH_Tree<double, 3>>& Graphic3d_BvhCStructureSetTrsfPe
return myBVH;
}
myStructBoxes.ReSize(myStructs.Size());
myStructBoxes.ReSize(myStructs.Length());
for (int aStructIdx = 1; aStructIdx <= myStructs.Size(); ++aStructIdx)
for (int aStructIdx = 1; aStructIdx <= myStructs.Length(); ++aStructIdx)
{
const Graphic3d_CStructure* aStructure = myStructs(aStructIdx);

View File

@@ -687,7 +687,7 @@ void Graphic3d_FrameStats::FrameStart(const occ::handle<Graphic3d_CView>& theVie
const int aNbFrames =
std::max(!theView.IsNull() ? theView->RenderingParams().StatsNbFrames : 1, 1);
if (myCounters.Size() != aNbFrames)
if (myCounters.Length() != aNbFrames)
{
myCounters.Resize(0, aNbFrames - 1, false);
myCounters.Init(Graphic3d_FrameStatsData());

View File

@@ -95,7 +95,7 @@ bool Graphic3d_Layer::Remove(const Graphic3d_CStructure* theStruct,
continue;
}
aStructures.Swap(anIndex, aStructures.Size());
aStructures.Swap(anIndex, aStructures.Length());
aStructures.RemoveLast();
if (!isForChangePriority)
@@ -116,7 +116,7 @@ bool Graphic3d_Layer::Remove(const Graphic3d_CStructure* theStruct,
const int anIndex2 = myAlwaysRenderedMap.FindIndex(theStruct);
if (anIndex2 != 0)
{
myAlwaysRenderedMap.Swap(myAlwaysRenderedMap.Size(), anIndex2);
myAlwaysRenderedMap.Swap(myAlwaysRenderedMap.Length(), anIndex2);
myAlwaysRenderedMap.RemoveLast();
}
}

View File

@@ -81,7 +81,7 @@ public:
bool IsEmpty() const { return myItems.IsEmpty(); }
//! Return the number of items in sequence.
int Size() const { return myItems.Size(); }
int Size() const { return myItems.Length(); }
//! Append a plane.
//! @return TRUE if new item has been added (FALSE if item already existed)

View File

@@ -116,12 +116,12 @@ void Graphic3d_Structure::Remove()
// It is necessary to remove the eventual pointer on the structure that can be destroyed, in the
// list of descendants of ancestors of this structure and in the list of ancestors of descendants
// of the same structure.
for (int aStructIdx = 1, aNbDesc = myDescendants.Size(); aStructIdx <= aNbDesc; ++aStructIdx)
for (int aStructIdx = 1, aNbDesc = myDescendants.Length(); aStructIdx <= aNbDesc; ++aStructIdx)
{
myDescendants.FindKey(aStructIdx)->Remove(this, Graphic3d_TOC_ANCESTOR);
}
for (int aStructIdx = 1, aNbAnces = myAncestors.Size(); aStructIdx <= aNbAnces; ++aStructIdx)
for (int aStructIdx = 1, aNbAnces = myAncestors.Length(); aStructIdx <= aNbAnces; ++aStructIdx)
{
myAncestors.FindKey(aStructIdx)->Remove(this, Graphic3d_TOC_DESCENDANT);
}
@@ -428,7 +428,7 @@ void Graphic3d_Structure::Descendants(
bool Graphic3d_Structure::AppendAncestor(Graphic3d_Structure* theAncestor)
{
const int aSize = myAncestors.Size();
const int aSize = myAncestors.Length();
return myAncestors.Add(theAncestor) > aSize; // new object
}
@@ -437,7 +437,7 @@ bool Graphic3d_Structure::AppendAncestor(Graphic3d_Structure* theAncestor)
bool Graphic3d_Structure::AppendDescendant(Graphic3d_Structure* theDescendant)
{
const int aSize = myDescendants.Size();
const int aSize = myDescendants.Length();
return myDescendants.Add(theDescendant) > aSize; // new object
}
@@ -450,7 +450,7 @@ bool Graphic3d_Structure::RemoveAncestor(Graphic3d_Structure* theAncestor)
if (anIndex != 0)
{
myAncestors.Swap(anIndex, myAncestors.Size());
myAncestors.Swap(anIndex, myAncestors.Length());
myAncestors.RemoveLast();
}
@@ -465,7 +465,7 @@ bool Graphic3d_Structure::RemoveDescendant(Graphic3d_Structure* theDescendant)
if (anIndex != 0)
{
myDescendants.Swap(anIndex, myDescendants.Size());
myDescendants.Swap(anIndex, myDescendants.Length());
myDescendants.RemoveLast();
}
@@ -556,7 +556,7 @@ void Graphic3d_Structure::DisconnectAll(const Graphic3d_TypeOfConnection theType
switch (theType)
{
case Graphic3d_TOC_DESCENDANT: {
for (int anIdx = 1, aLength = myDescendants.Size(); anIdx <= aLength; ++anIdx)
for (int anIdx = 1, aLength = myDescendants.Length(); anIdx <= aLength; ++anIdx)
{
// Value (1) instead of Value (i) as myDescendants
// is modified by :
@@ -567,7 +567,7 @@ void Graphic3d_Structure::DisconnectAll(const Graphic3d_TypeOfConnection theType
break;
}
case Graphic3d_TOC_ANCESTOR: {
for (int anIdx = 1, aLength = myAncestors.Size(); anIdx <= aLength; ++anIdx)
for (int anIdx = 1, aLength = myAncestors.Length(); anIdx <= aLength; ++anIdx)
{
// Value (1) instead of Value (i) as myAncestors
// is modified by :

View File

@@ -244,7 +244,7 @@ void Graphic3d_StructureManager::UnIdentification(Graphic3d_CView* theView)
{
if (myDefinedViews.Contains(theView))
{
myDefinedViews.Swap(myDefinedViews.FindIndex(theView), myDefinedViews.Size());
myDefinedViews.Swap(myDefinedViews.FindIndex(theView), myDefinedViews.Length());
myDefinedViews.RemoveLast();
myViewGenId.Free(theView->Identification());
}

View File

@@ -61,7 +61,7 @@ public:
bool IsEmpty() const { return myTextures.IsEmpty(); }
//! Return number of textures.
int Size() const { return myTextures.Size(); }
int Size() const { return myTextures.Length(); }
//! Return the lower index in texture set.
int Lower() const { return myTextures.Lower(); }