#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>
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);
+ 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)
+ {
+ continue;
+ }
+
+ Handle(Standard_Transient) aCurEnt = anEntity;
+ if (themodel->IsRedefinedContent(aNumber))
+ aCurEnt = themodel->ReportEntity(aNumber)->Content();
- // Resultat obtenu via GeneralLib
- Interface_EntityIterator iter = GetShareds(ent);
+ Handle(Interface_GeneralModule) aModule;
+ Standard_Integer aCN;
+ if (themodel->GTool()->Select(aCurEnt, aModule, aCN))
+ {
+ aModule->FillShared(themodel, aCN, aCurEnt, anIter);
+ }
- // Mise en forme : liste d entiers
- for (iter.Start(); iter.More(); iter.Next())
+ for (anIter.Start(); anIter.More(); anIter.Next())
{
- // num = 0 -> on sort du Model de depart, le noter "Error" et passer
- const Handle(Standard_Transient)& entshare = iter.Value();
- if (entshare == ent)
+ const Handle(Standard_Transient)& anEntShare = anIter.Value();
+ if (anEntShare == anEntity)
+ {
continue;
+ }
- Standard_Integer num = EntityNumber(entshare);
+ const Standard_Integer aShareNum = EntityNumber(anEntShare);
- if (!num)
+ if (aShareNum == 0)
{
if (!thestats.IsNull())
+ {
theflags.SetTrue(i, Graph_ShareError);
+ }
continue;
}
- thesharings->ChangeValue(num).Append(i);
+ aSharingArrayOfLists(aShareNum).Append(i);
}
}
}
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(
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,