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
@@ -135,7 +135,7 @@ bool OpenGl_Font::createTexture(const occ::handle<OpenGl_Context>& theCtx)
aParams->SetFilter(Graphic3d_TOTF_BILINEAR);
aParams->SetAnisoFilter(Graphic3d_LOTA_OFF);
myTextures.Append(new OpenGl_Texture(myKey + "_texture" + myTextures.Size(), aParams));
myTextures.Append(new OpenGl_Texture(myKey + "_texture" + myTextures.Length(), aParams));
occ::handle<OpenGl_Texture>& aTexture = myTextures.ChangeLast();
Image_PixMap aBlackImg;
@@ -137,7 +137,7 @@ void OpenGl_FrameStatsPrs::updateChart(const occ::handle<OpenGl_Workspace>& theW
const occ::handle<OpenGl_FrameStats>& aStats = aCtx->FrameStats();
const Graphic3d_RenderingParams& aRendParams = theWorkspace->View()->RenderingParams();
const int aNbBins = aStats->DataFrames().Size();
const int aNbBins = aStats->DataFrames().Length();
if (aNbBins <= 1)
{
myChartIndices->Release(aCtx.get());
@@ -224,7 +224,7 @@ void OpenGl_LayerList::InsertLayerBefore(const Graphic3d_ZLayerId theNewL
}
myLayerIds.Bind(theNewLayerId, aNewLayer);
myTransparentToProcess.Allocate(myLayers.Size());
myTransparentToProcess.Allocate(myLayers.Length());
}
//=================================================================================================
@@ -261,7 +261,7 @@ void OpenGl_LayerList::InsertLayerAfter(const Graphic3d_ZLayerId theNewLa
}
myLayerIds.Bind(theNewLayerId, aNewLayer);
myTransparentToProcess.Allocate(myLayers.Size());
myTransparentToProcess.Allocate(myLayers.Length());
}
//=================================================================================================
@@ -281,7 +281,7 @@ void OpenGl_LayerList::RemoveLayer(const Graphic3d_ZLayerId theLayerId)
myLayers.Remove(aLayerToRemove);
myLayerIds.UnBind(theLayerId);
myTransparentToProcess.Allocate(myLayers.Size());
myTransparentToProcess.Allocate(myLayers.Length());
}
//=================================================================================================
@@ -36,7 +36,7 @@ public:
//! Pushes current matrix into stack.
void Push()
{
if (++myStackHead >= myStack.Size())
if (++myStackHead >= myStack.Length())
{
myStack.Append(myCurrent);
}
@@ -101,7 +101,7 @@ public:
myCurrent.GetValue(3, 2),
myCurrent.GetValue(3, 3))
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myStack.Size())
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myStack.Length())
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myStackHead)
}
@@ -264,7 +264,7 @@ bool OpenGl_RaytraceGeometry::ProcessAcceleration()
const int anObjectIdx = aBVH->BegPrimitive(aNodeIdx);
Standard_ASSERT_RETURN(
anObjectIdx < myObjects.Size(),
anObjectIdx < myObjects.Length(),
"Error! Invalid leaf node in high-level BVH (contains out-of-range object)",
false);
@@ -362,7 +362,7 @@ OpenGl_TriangleSet* OpenGl_RaytraceGeometry::TriangleSet(int theNodeIdx)
if (theNodeIdx >= aBVH->Length() || !aBVH->IsOuter(theNodeIdx))
return nullptr;
if (aBVH->NodeInfoBuffer().at(theNodeIdx).x() > myObjects.Size())
if (aBVH->NodeInfoBuffer().at(theNodeIdx).x() > myObjects.Length())
return nullptr;
return dynamic_cast<OpenGl_TriangleSet*>(
@@ -430,7 +430,7 @@ void OpenGl_ShaderManager::pushLightSourceState(
return;
}
if (myLightTypeArray.Size() < aNbLightsMax)
if (myLightTypeArray.Length() < aNbLightsMax)
{
myLightTypeArray.Resize(0, aNbLightsMax - 1, false);
myLightParamsArray.Resize(0, aNbLightsMax - 1, false);
@@ -581,7 +581,7 @@ void OpenGl_ShaderManager::pushLightSourceState(
if (const OpenGl_ShaderUniformLocation aShadowMatLoc =
theProgram->GetStateLocation(OpenGl_OCC_LIGHT_SHADOWMAP_MATRICES))
{
if (myShadowMatArray.Size() < theProgram->NbShadowMaps())
if (myShadowMatArray.Length() < theProgram->NbShadowMaps())
{
myShadowMatArray.Resize(0, theProgram->NbShadowMaps() - 1, false);
}
@@ -593,7 +593,7 @@ void OpenGl_ShaderManager::pushLightSourceState(
/ (float)myLightSourceState.ShadowMaps()->First()->Texture()->SizeX(),
myLightSourceState.ShadowMaps()->First()->ShadowMapBias());
const int aNbShadows =
std::min(theProgram->NbShadowMaps(), myLightSourceState.ShadowMaps()->Size());
std::min(theProgram->NbShadowMaps(), myLightSourceState.ShadowMaps()->Length());
for (int aShadowIter = 0; aShadowIter < aNbShadows; ++aShadowIter)
{
const occ::handle<OpenGl_ShadowMap>& aShadow =
@@ -769,7 +769,7 @@ void OpenGl_ShaderManager::pushClippingState(
}
const int aNbMaxPlanes = myContext->MaxClipPlanes();
if (myClipPlaneArrayFfp.Size() < aNbMaxPlanes)
if (myClipPlaneArrayFfp.Length() < aNbMaxPlanes)
{
myClipPlaneArrayFfp.Resize(0, aNbMaxPlanes - 1, false);
}
@@ -852,7 +852,7 @@ void OpenGl_ShaderManager::pushClippingState(
return;
}
if (myClipPlaneArray.Size() < aNbClipPlanesMax)
if (myClipPlaneArray.Length() < aNbClipPlanesMax)
{
myClipPlaneArray.Resize(0, aNbClipPlanesMax - 1, false);
myClipChainArray.Resize(0, aNbClipPlanesMax - 1, false);
@@ -842,7 +842,7 @@ bool OpenGl_Texture::InitCompressed(const occ::handle<OpenGl_Context>& theCtx,
mySizedFormat = aFormat.Internal();
myIsTopDown = theImage.IsTopDown();
mySize.SetValues(theImage.SizeX(), theImage.SizeY(), 1);
myMaxMipLevel = std::max(theImage.MipMaps().Size() - 1, 0);
myMaxMipLevel = std::max(theImage.MipMaps().Length() - 1, 0);
if (myMaxMipLevel > 0 && !theImage.IsCompleteMipMapSet())
{
const NCollection_Vec2<int> aMipSize = computeSmallestMipMapSize(mySize.xy(), myMaxMipLevel);
@@ -1233,7 +1233,7 @@ bool OpenGl_Texture::InitCubeMap(const occ::handle<OpenGl_Context>& theCtx,
theToGenMipmap = false;
theSize = aCompImage->SizeX();
theFormat = aCompImage->BaseFormat();
myMaxMipLevel = std::max(aCompImage->MipMaps().Size() - 1, 0);
myMaxMipLevel = std::max(aCompImage->MipMaps().Length() - 1, 0);
if (myMaxMipLevel > 0 && !aCompImage->IsCompleteMipMapSet())
{
const NCollection_Vec2<int> aMipSize = computeSmallestMipMapSize(
@@ -107,7 +107,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(); }
@@ -563,7 +563,7 @@ bool OpenGl_View::ShadowMapDump(Image_PixMap& theImage, const TCollection_AsciiS
}
const occ::handle<OpenGl_Context>& aGlCtx = myWorkspace->GetGlContext();
for (int aShadowIter = 0; aShadowIter < myShadowMaps->Size(); ++aShadowIter)
for (int aShadowIter = 0; aShadowIter < myShadowMaps->Length(); ++aShadowIter)
{
occ::handle<OpenGl_ShadowMap>& aShadow = myShadowMaps->ChangeValue(aShadowIter);
if (!aShadow.IsNull() && aShadow->LightSource()->Name() == theLightName)
@@ -1649,14 +1649,14 @@ bool OpenGl_View::prepareFrameBuffers(Graphic3d_Camera::Projection& theProj)
&& myRenderParams.Method != Graphic3d_RM_RAYTRACING;
if (toUseShadowMap)
{
if (myShadowMaps->Size() != myLights->NbCastShadows())
if (myShadowMaps->Length() != myLights->NbCastShadows())
{
myShadowMaps->Release(aCtx.get());
myShadowMaps->Resize(0, myLights->NbCastShadows() - 1, true);
}
const GLint aSamplFrom = GLint(aCtx->ShadowMapTexUnit()) - myLights->NbCastShadows() + 1;
for (int aShadowIter = 0; aShadowIter < myShadowMaps->Size(); ++aShadowIter)
for (int aShadowIter = 0; aShadowIter < myShadowMaps->Length(); ++aShadowIter)
{
occ::handle<OpenGl_ShadowMap>& aShadow = myShadowMaps->ChangeValue(aShadowIter);
if (aShadow.IsNull())