mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-08-29 14:28:23 +08:00
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:
@@ -26,12 +26,19 @@ int BRepGraph_LayerRegistry::RegisterLayer(const occ::handle<BRepGraph_Layer>& t
|
||||
const int* aSlot = myGuidToSlot.Seek(aGUID);
|
||||
if (aSlot != nullptr)
|
||||
{
|
||||
const occ::handle<BRepGraph_Layer>& aPrev = myLayers.Value(*aSlot);
|
||||
if (!aPrev.IsNull() && aPrev.get() != theLayer.get())
|
||||
{
|
||||
aPrev->setOwningGraph(nullptr);
|
||||
}
|
||||
theLayer->setOwningGraph(myOwningGraph);
|
||||
myLayers.ChangeValue(*aSlot) = theLayer;
|
||||
recomputeSubscribedKindsMask();
|
||||
return *aSlot;
|
||||
}
|
||||
|
||||
const int aNewSlot = myLayers.Length();
|
||||
theLayer->setOwningGraph(myOwningGraph);
|
||||
myLayers.Append(theLayer);
|
||||
myGuidToSlot.Bind(aGUID, aNewSlot);
|
||||
mySubscribedKindsMask |= theLayer->SubscribedKinds();
|
||||
@@ -47,8 +54,9 @@ void BRepGraph_LayerRegistry::UnregisterLayer(const Standard_GUID& theGUID)
|
||||
if (aSlotPtr == nullptr)
|
||||
return;
|
||||
|
||||
const int aSlot = *aSlotPtr;
|
||||
const int aLastSlot = myLayers.Length() - 1;
|
||||
const int aSlot = *aSlotPtr;
|
||||
const int aLastSlot = myLayers.Length() - 1;
|
||||
const occ::handle<BRepGraph_Layer> aRemoved = myLayers.Value(aSlot);
|
||||
if (aSlot != aLastSlot)
|
||||
{
|
||||
const occ::handle<BRepGraph_Layer>& aLastLayer = myLayers.Value(aLastSlot);
|
||||
@@ -59,6 +67,22 @@ void BRepGraph_LayerRegistry::UnregisterLayer(const Standard_GUID& theGUID)
|
||||
myLayers.EraseLast();
|
||||
myGuidToSlot.UnBind(theGUID);
|
||||
recomputeSubscribedKindsMask();
|
||||
if (!aRemoved.IsNull())
|
||||
{
|
||||
aRemoved->setOwningGraph(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void BRepGraph_LayerRegistry::SetOwningGraph(BRepGraph* theGraph) noexcept
|
||||
{
|
||||
myOwningGraph = theGraph;
|
||||
for (const occ::handle<BRepGraph_Layer>& aLayer : myLayers)
|
||||
{
|
||||
if (!aLayer.IsNull())
|
||||
aLayer->setOwningGraph(theGraph);
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
Reference in New Issue
Block a user