mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-06-30 12:14:08 +03:00
Coding, Data Exchange - Optimize entity graph evaluating #562
Updated the Evaluate() function to integrate memory pool usage and streamline the evaluation loop. Simplified shared entity retrieval in GetShareds() and Sharings(). Added necessary include for NCollection_IncAllocator to support memory pooling.
This commit is contained in:
parent
4629ee0ca3
commit
9ddcdae3f9
@ -22,6 +22,7 @@
|
||||
#include <Interface_ShareTool.hxx>
|
||||
#include <Standard_DomainError.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <NCollection_IncAllocator.hxx>
|
||||
#include <TCollection_HAsciiString.hxx>
|
||||
#include <TColStd_HSequenceOfTransient.hxx>
|
||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||
@ -136,42 +137,76 @@ const Handle(TColStd_HArray1OfListOfInteger)& Interface_Graph::SharingTable() co
|
||||
|
||||
void Interface_Graph::Evaluate()
|
||||
{
|
||||
// Evaluation d un Graphe de dependances : sur chaque Entite, on prend sa
|
||||
// liste "Shared". On en deduit les "Sharing" directement
|
||||
Standard_Integer n = Size();
|
||||
// clang-format off
|
||||
thesharings = new TColStd_HArray1OfListOfInteger(1,n);//TColStd_HArray1OfTransient(1,n);//Clear();
|
||||
// clang-format on
|
||||
// Evaluation is performed on all entities of the model
|
||||
const Standard_Integer anEntityNumber = Size();
|
||||
|
||||
// Global allocator stored as a field of the single container of the sharings
|
||||
// and will be destructed with the container.
|
||||
Handle(NCollection_IncAllocator) anAlloc =
|
||||
new NCollection_IncAllocator(NCollection_IncAllocator::THE_DEFAULT_BLOCK_SIZE);
|
||||
thesharings = new TColStd_HArray1OfListOfInteger(1, anEntityNumber);
|
||||
TColStd_Array1OfListOfInteger& aSharingArrayOfLists = thesharings->ChangeArray1();
|
||||
for (Standard_Integer i = 1; i <= anEntityNumber; i++)
|
||||
{
|
||||
aSharingArrayOfLists(i).Clear(anAlloc);
|
||||
}
|
||||
|
||||
if (themodel->GTool().IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Standard_Integer i; // svv Jan11 2000 : porting on DEC
|
||||
for (i = 1; i <= n; i++)
|
||||
// Fill the sharing table with the entities shared by each entity
|
||||
// and the entities which share each entity.
|
||||
// The entities are iterated in the order of their numbers in the model.
|
||||
// The entities which are not present in the model are ignored.
|
||||
// The entities which are not shared by any other entity are ignored.
|
||||
// Allocator is used to reuse memory for the lists of shared entities.
|
||||
Handle(NCollection_IncAllocator) anAlloc2 =
|
||||
new NCollection_IncAllocator(NCollection_IncAllocator::THE_MINIMUM_BLOCK_SIZE);
|
||||
Handle(TColStd_HSequenceOfTransient) aListOfEntities = new TColStd_HSequenceOfTransient();
|
||||
for (Standard_Integer i = 1; i <= anEntityNumber; i++)
|
||||
{
|
||||
// ATTENTION : Si Entite non chargee donc illisible, basculer sur son
|
||||
// "Contenu" equivalent
|
||||
Handle(Standard_Transient) ent = themodel->Value(i);
|
||||
|
||||
// Resultat obtenu via GeneralLib
|
||||
Interface_EntityIterator iter = GetShareds(ent);
|
||||
|
||||
// Mise en forme : liste d entiers
|
||||
for (iter.Start(); iter.More(); iter.Next())
|
||||
aListOfEntities->Clear(anAlloc2);
|
||||
anAlloc2->Reset();
|
||||
const Handle(Standard_Transient)& anEntity = themodel->Value(i);
|
||||
Interface_EntityIterator anIter(aListOfEntities);
|
||||
const Standard_Integer aNumber = EntityNumber(anEntity);
|
||||
if (aNumber == 0)
|
||||
{
|
||||
// num = 0 -> on sort du Model de depart, le noter "Error" et passer
|
||||
const Handle(Standard_Transient)& entshare = iter.Value();
|
||||
if (entshare == ent)
|
||||
continue;
|
||||
|
||||
Standard_Integer num = EntityNumber(entshare);
|
||||
|
||||
if (!num)
|
||||
{
|
||||
if (!thestats.IsNull())
|
||||
theflags.SetTrue(i, Graph_ShareError);
|
||||
continue;
|
||||
}
|
||||
thesharings->ChangeValue(num).Append(i);
|
||||
|
||||
Handle(Standard_Transient) aCurEnt = anEntity;
|
||||
if (themodel->IsRedefinedContent(aNumber))
|
||||
aCurEnt = themodel->ReportEntity(aNumber)->Content();
|
||||
|
||||
Handle(Interface_GeneralModule) aModule;
|
||||
Standard_Integer aCN;
|
||||
if (themodel->GTool()->Select(aCurEnt, aModule, aCN))
|
||||
{
|
||||
aModule->FillShared(themodel, aCN, aCurEnt, anIter);
|
||||
}
|
||||
|
||||
for (anIter.Start(); anIter.More(); anIter.Next())
|
||||
{
|
||||
const Handle(Standard_Transient)& anEntShare = anIter.Value();
|
||||
if (anEntShare == anEntity)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const Standard_Integer aShareNum = EntityNumber(anEntShare);
|
||||
|
||||
if (aShareNum == 0)
|
||||
{
|
||||
if (!thestats.IsNull())
|
||||
{
|
||||
theflags.SetTrue(i, Graph_ShareError);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
aSharingArrayOfLists(aShareNum).Append(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -456,11 +491,7 @@ Interface_EntityIterator Interface_Graph::Shareds(const Handle(Standard_Transien
|
||||
Handle(TColStd_HSequenceOfTransient) Interface_Graph::GetShareds(
|
||||
const Handle(Standard_Transient)& ent) const
|
||||
{
|
||||
Handle(TColStd_HSequenceOfTransient) aseq = new TColStd_HSequenceOfTransient;
|
||||
Interface_EntityIterator iter = Shareds(ent);
|
||||
for (; iter.More(); iter.Next())
|
||||
aseq->Append(iter.Value());
|
||||
return aseq;
|
||||
return Shareds(ent).Content();
|
||||
}
|
||||
|
||||
Handle(TColStd_HSequenceOfTransient) Interface_Graph::GetSharings(
|
||||
@ -480,9 +511,7 @@ Handle(TColStd_HSequenceOfTransient) Interface_Graph::GetSharings(
|
||||
|
||||
Interface_EntityIterator Interface_Graph::Sharings(const Handle(Standard_Transient)& ent) const
|
||||
{
|
||||
Interface_EntityIterator iter;
|
||||
iter.AddList(GetSharings(ent));
|
||||
return iter;
|
||||
return Interface_EntityIterator(GetSharings(ent));
|
||||
}
|
||||
|
||||
static void AddTypedSharings(const Handle(Standard_Transient)& ent,
|
||||
|
Loading…
x
Reference in New Issue
Block a user