1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-05-06 10:36:12 +03:00

0022807: Loading of STEP entities in model during reading of STEP file requires redundant memory

This commit is contained in:
GKA 2011-12-16 08:41:10 +00:00 committed by bugmaster
parent 251450e53f
commit bc650d4170
25 changed files with 745 additions and 942 deletions

View File

@ -13,7 +13,8 @@
(const Interface_Graph& G) const (const Interface_Graph& G) const
{ {
Interface_EntityIterator iter = RootResult(G); Interface_EntityIterator iter = RootResult(G);
if (HasUniqueResult()) return iter; if (HasUniqueResult() || !G.ModeStat())
return iter;
Interface_Graph GG(G); Interface_Graph GG(G);
GG.GetFromIter(iter,0); GG.GetFromIter(iter,0);
return Interface_GraphContent(GG); // EntityIterator specialise (meme taille) return Interface_GraphContent(GG); // EntityIterator specialise (meme taille)

View File

@ -55,6 +55,14 @@ is
---Purpose : Sets a new ShareOut. Fills Items which its content ---Purpose : Sets a new ShareOut. Fills Items which its content
-- Warning : data from the former ShareOut are lost -- Warning : data from the former ShareOut are lost
SetModeStat(me : mutable; theMode : Boolean);
---Purpose : Set value of mode responsible for precence of selections after loading
-- If mode set to true that different selections will be accessible after loading
-- else selections will be not accessible after loading( for economy memory in applicatios)
GetModeStat(me) returns Boolean from Standard;
---Purpose : Return value of mode defining of filling selection during loading
SetLibrary (me : mutable; lib : WorkLibrary); SetLibrary (me : mutable; lib : WorkLibrary);
---Purpose : Sets a WorkLibrary, which will be used to Read and Write Files ---Purpose : Sets a WorkLibrary, which will be used to Read and Write Files
@ -1146,5 +1154,5 @@ fields
thecopier : ModelCopier; -- produces + memorizes transferred data thecopier : ModelCopier; -- produces + memorizes transferred data
theoldel : InterfaceModel; theoldel : InterfaceModel;
themodelstat : Boolean;
end WorkSession; end WorkSession;

View File

@ -78,6 +78,7 @@ IFSelect_WorkSession::IFSelect_WorkSession ()
thecopier->SetShareOut (theshareout); thecopier->SetShareOut (theshareout);
thecheckdone = Standard_False; thecheckdone = Standard_False;
thegtool = new Interface_GTool; thegtool = new Interface_GTool;
themodelstat = Standard_False;
} }
@ -228,7 +229,7 @@ void IFSelect_WorkSession::SetModel
if (!thegtool.IsNull()) thegtool->ClearEntities(); //smh#14 FRA62479 if (!thegtool.IsNull()) thegtool->ClearEntities(); //smh#14 FRA62479
// themodel->SetProtocol(theprotocol); // themodel->SetProtocol(theprotocol);
themodel->SetGTool (thegtool); themodel->SetGTool (thegtool);
thegtool->Reservate (themodel->NbEntities()+20,Standard_True);
thegraph.Nullify(); thegraph.Nullify();
ComputeGraph(); // fait qqchose si Protocol present. Sinon, ne fait rien ComputeGraph(); // fait qqchose si Protocol present. Sinon, ne fait rien
ClearData(3); // RAZ CheckList, a refaire ClearData(3); // RAZ CheckList, a refaire
@ -244,7 +245,6 @@ void IFSelect_WorkSession::SetModel
//function : //function :
//purpose : //purpose :
//======================================================================= //=======================================================================
Handle(Interface_InterfaceModel) IFSelect_WorkSession::Model () const Handle(Interface_InterfaceModel) IFSelect_WorkSession::Model () const
{ {
return themodel; return themodel;
@ -369,8 +369,7 @@ Standard_Integer IFSelect_WorkSession::NumberFromLabel
} }
if (cnt == 1) return num; if (cnt == 1) return num;
num = -num; num = -num;
// if (cnt == 0) cout<<" Label:"<<val<<" -> 0 ent"<<endl;
// if (cnt > 0) cout<<" Label:"<<val<<" ->"<<cnt<<" ent.s, refus"<<endl;
return num; return num;
} }
@ -513,29 +512,35 @@ Standard_Boolean IFSelect_WorkSession::ComputeGraph
{ {
if (theprotocol.IsNull()) return Standard_False; if (theprotocol.IsNull()) return Standard_False;
if (themodel.IsNull()) return Standard_False; if (themodel.IsNull()) return Standard_False;
if (themodel->NbEntities() == 0) return Standard_False; //if (themodel->NbEntities() == 0) return Standard_False;
if (enforce) thegraph.Nullify(); if (enforce) thegraph.Nullify();
if (!thegraph.IsNull()) { if (!thegraph.IsNull()) {
if (themodel->NbEntities() == thegraph->Graph().Size()) return Standard_True; if (themodel->NbEntities() == thegraph->Graph().Size()) return Standard_True;
thegraph.Nullify(); thegraph.Nullify();
} }
if (themodel->NbEntities() == 0) return Standard_False;
// Il faut calculer le graphe pour de bon // Il faut calculer le graphe pour de bon
thegraph = new Interface_HGraph (themodel,thegtool); thegraph = new Interface_HGraph (themodel,themodelstat);
Standard_Integer nb = themodel->NbEntities(); Standard_Integer nb = themodel->NbEntities();
Standard_Integer i; // svv #1 if(themodelstat)
for (i = 1; i <= nb; i ++) thegraph->CGraph().SetStatus(i,0); {
Interface_BitMap& bm = thegraph->CGraph().CBitMap(); Standard_Integer i; // svv #1
bm.AddFlag(); for (i = 1; i <= nb; i ++) thegraph->CGraph().SetStatus(i,0);
bm.SetFlagName (Flag_Incorrect,"Incorrect"); Interface_BitMap& bm = thegraph->CGraph().CBitMap();
bm.AddFlag();
bm.SetFlagName (Flag_Incorrect,"Incorrect");
}
ComputeCheck(); ComputeCheck();
thecheckdone = Standard_True; thecheckdone = Standard_True;
if(themodelstat)
// Calcul des categories, a present memorisees dans le modele {
Interface_Category categ(thegtool); // Calcul des categories, a present memorisees dans le modele
Interface_ShareTool sht(thegraph); Interface_Category categ(thegtool);
for (i = 1; i <= nb; i ++) themodel->SetCategoryNumber Interface_ShareTool sht(thegraph);
(i,categ.CatNum(themodel->Value(i),sht)); Standard_Integer i =1;
for ( ; i <= nb; i ++) themodel->SetCategoryNumber
(i,categ.CatNum(themodel->Value(i),sht));
}
return Standard_True; return Standard_True;
} }
@ -629,20 +634,21 @@ Standard_Boolean IFSelect_WorkSession::ComputeCheck
Interface_CheckTool cht(thegraph); Interface_CheckTool cht(thegraph);
Interface_CheckIterator checklist = cht.VerifyCheckList(); Interface_CheckIterator checklist = cht.VerifyCheckList();
themodel->FillSemanticChecks(checklist,Standard_False); themodel->FillSemanticChecks(checklist,Standard_False);
if(themodelstat)
// Et on met a jour le Graphe (BitMap) ! Flag Incorrect (STX + SEM) {
Interface_BitMap& BM = CG.CBitMap(); // Et on met a jour le Graphe (BitMap) ! Flag Incorrect (STX + SEM)
BM.Init (Standard_False,Flag_Incorrect); Interface_BitMap& BM = CG.CBitMap();
Standard_Integer num, nb = CG.Size(); BM.Init (Standard_False,Flag_Incorrect);
for (checklist.Start(); checklist.More(); checklist.Next()) { Standard_Integer num, nb = CG.Size();
const Handle(Interface_Check) chk = checklist.Value(); for (checklist.Start(); checklist.More(); checklist.Next()) {
if (!chk->HasFailed()) continue; const Handle(Interface_Check) chk = checklist.Value();
num = checklist.Number(); if (!chk->HasFailed()) continue;
if (num > 0 && num <= nb) BM.SetTrue (num,Flag_Incorrect); num = checklist.Number();
if (num > 0 && num <= nb) BM.SetTrue (num,Flag_Incorrect);
}
for (num = 1; num <= nb; num ++)
if (themodel->IsErrorEntity (num)) BM.SetTrue (num,Flag_Incorrect);
} }
for (num = 1; num <= nb; num ++)
if (themodel->IsErrorEntity (num)) BM.SetTrue (num,Flag_Incorrect);
return Standard_True; return Standard_True;
} }
@ -852,7 +858,6 @@ Standard_Integer IFSelect_WorkSession::AddItem
if (id > 0) { if (id > 0) {
Handle(Standard_Transient)& att = theitems.ChangeFromIndex(id); Handle(Standard_Transient)& att = theitems.ChangeFromIndex(id);
if (att.IsNull()) att = item; if (att.IsNull()) att = item;
//// if (theitems.FindFromIndex(id).IsNull()) id0 = theitems.Add(item,item);
} }
else id = theitems.Add(item,item); else id = theitems.Add(item,item);
@ -923,17 +928,7 @@ Standard_Boolean IFSelect_WorkSession::SetActive
return Standard_True; return Standard_True;
} }
} }
/* UTILISER EXPLICITEMENT SetAppliedModifier
if (item->IsKind(STANDARD_TYPE(IFSelect_GeneralModifier))) {
DeclareAndCast(IFSelect_GeneralModifier,modif,item);
if (mode) {
theshareout->AddModifier(modif,0);
return Standard_True;
} else {
return theshareout->RemoveItem(modif);
}
}
*/
return Standard_False; return Standard_False;
} }
@ -1362,8 +1357,7 @@ Interface_EntityIterator IFSelect_WorkSession::EvalSelection
} }
if (thegraph.IsNull()) return iter; if (thegraph.IsNull()) return iter;
// if (ItemIdent(sel) != 0) iter = sel->UniqueResult(thegraph->Graph()); iter = sel->UniqueResult(thegraph->Graph());
iter = sel->UniqueResult(thegraph->Graph());
return iter; return iter;
} }
@ -1444,11 +1438,7 @@ Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::SelectionResultFromLi
// ssel est la derniere selection auscultee, deduct son downcast // ssel est la derniere selection auscultee, deduct son downcast
// input son Input (nulle si sel pas une deduction) // input son Input (nulle si sel pas une deduction)
deduct = GetCasted(IFSelect_SelectDeduct,ssel); deduct = GetCasted(IFSelect_SelectDeduct,ssel);
/*
Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed;
sp->AddList(list);
deduct->SetInput (sp);
*/
deduct->Alternate()->SetList (list); deduct->Alternate()->SetList (list);
// On execute puis on nettoie // On execute puis on nettoie
@ -2491,7 +2481,7 @@ IFSelect_ReturnStatus IFSelect_WorkSession::SendAll
Handle_Interface_Check aMainFail = checks.CCheck(0); Handle_Interface_Check aMainFail = checks.CCheck(0);
if (!aMainFail.IsNull() && aMainFail->HasFailed ()) if (!aMainFail.IsNull() && aMainFail->HasFailed ())
{ {
return IFSelect_RetStop; return IFSelect_RetStop;
} }
if (theloaded.Length() == 0) theloaded.AssignCat(filename); if (theloaded.Length() == 0) theloaded.AssignCat(filename);
thecheckrun = checks; thecheckrun = checks;
@ -2828,7 +2818,7 @@ void IFSelect_WorkSession::QueryCheckList (const Interface_CheckIterator& chl)
// analyse selon le graphe ... codes : blc = rien // analyse selon le graphe ... codes : blc = rien
// 1 W/place 2 F/place 3 Wprop 4Wprop+W/place 5Wprop+F/place // 1 W/place 2 F/place 3 Wprop 4Wprop+W/place 5Wprop+F/place
// 6 Fprop 7 Fprop+W/place 8 Fprop+F/place // 6 Fprop 7 Fprop+W/place 8 Fprop+F/place
Interface_IntList list = thegraph->Graph().SharingNums(0); Interface_IntList list;// = thegraph->Graph().SharingNums(0);
// deux passes : d abord Warning, puis Fail // deux passes : d abord Warning, puis Fail
for (i = 1; i <= nb; i ++) { for (i = 1; i <= nb; i ++) {
char val = thecheckana.Value(i); char val = thecheckana.Value(i);
@ -2899,16 +2889,6 @@ Standard_Integer IFSelect_WorkSession::QueryParent
Standard_Integer stat = QueryParent ( entdad,list->Value(i) ); Standard_Integer stat = QueryParent ( entdad,list->Value(i) );
if (stat >= 0) return stat+1; if (stat >= 0) return stat+1;
} }
/*
Interface_IntList sharings = thegraph->Graph().SharingNums (nson);
Standard_Integer i, nb = sharings.Length();
for (i = 1; i <= nb; i ++) {
if (sharings.Value(i) == nson) return 1;
Standard_Integer stat = QueryParent
( entson,StartingEntity(sharings.Value(i)) );
if (stat >= 0) return stat+1;
}
*/
return -1; // not yet implemented ... return -1; // not yet implemented ...
} }
@ -3602,7 +3582,7 @@ void IFSelect_WorkSession::PrintCheckList
Interface_CheckIterator chks = checklist; Interface_CheckIterator chks = checklist;
Handle(IFSelect_CheckCounter) counter = Handle(IFSelect_CheckCounter) counter =
new IFSelect_CheckCounter (mode>1 && mode != IFSelect_CountSummary); new IFSelect_CheckCounter (mode>1 && mode != IFSelect_CountSummary);
counter->Analyse (chks,themodel,Standard_True,failsonly); counter->Analyse (chks,themodel,Standard_False,failsonly);
counter->PrintList (sout,themodel,mode); counter->PrintList (sout,themodel,mode);
} }
} }
@ -3884,3 +3864,13 @@ void IFSelect_WorkSession::ListEntities
sout<<"\n Abandon"<<endl; sout<<"\n Abandon"<<endl;
} }
} }
void IFSelect_WorkSession::SetModeStat( Standard_Boolean theStatMode)
{
themodelstat = theStatMode;
}
Standard_Boolean IFSelect_WorkSession::GetModeStat() const
{
return themodelstat;
}

View File

@ -39,7 +39,8 @@
Standard_Integer IGESGeom_BoundedSurface::NbBoundaries () const Standard_Integer IGESGeom_BoundedSurface::NbBoundaries () const
{ {
return theBoundaries->Length();
return ( theBoundaries.IsNull() ? 0 : theBoundaries->Length());
} }
Handle(IGESGeom_Boundary) IGESGeom_BoundedSurface::Boundary Handle(IGESGeom_Boundary) IGESGeom_BoundedSurface::Boundary

View File

@ -25,17 +25,29 @@ uses CString, HSequenceOfAsciiString from TColStd,
is is
Create returns BitMap;
---Purpose : Creates a empty BitMap
Create (nbitems : Integer; resflags : Integer = 0) returns BitMap; Create (nbitems : Integer; resflags : Integer = 0) returns BitMap;
---Purpose : Creates a BitMap for <nbitems> items ---Purpose : Creates a BitMap for <nbitems> items
-- One flag is defined, n0 0 -- One flag is defined, n0 0
-- <resflags> prepares allocation for <resflags> more flags -- <resflags> prepares allocation for <resflags> more flags
-- Flags values start at false -- Flags values start at false
Initialize(me : in out; nbitems : Integer; resflags : Integer = 0);
---Purpose : Initialize empty bit by <nbitems> items
-- One flag is defined, n0 0
-- <resflags> prepares allocation for <resflags> more flags
-- Flags values start at false
Create (other : BitMap; copied : Boolean = Standard_False) returns BitMap; Create (other : BitMap; copied : Boolean = Standard_False) returns BitMap;
---Purpose : Creates a BitMap from another one ---Purpose : Creates a BitMap from another one
-- if <copied> is True, copies data -- if <copied> is True, copies data
-- else, data are not copied, only the header object is -- else, data are not copied, only the header object is
Initialize(me : in out; other : BitMap; copied : Boolean = Standard_False);
---Purpose : Initialize a BitMap from another one
Internals (me; nbitems , nbwords, nbflags : out Integer; Internals (me; nbitems , nbwords, nbflags : out Integer;
flags : out mutable HArray1OfInteger; flags : out mutable HArray1OfInteger;
names : out mutable HSequenceOfAsciiString); names : out mutable HSequenceOfAsciiString);
@ -109,6 +121,9 @@ is
---Purpose : Initialises all the values of Flag Number <flag> to a given ---Purpose : Initialises all the values of Flag Number <flag> to a given
-- value <val> -- value <val>
Clear(me: in out);
---Purpose : Clear all field of bit map
fields fields
thenbitems : Integer; thenbitems : Integer;

View File

@ -2,18 +2,39 @@
#include <TCollection_AsciiString.hxx> #include <TCollection_AsciiString.hxx>
#include <Standard_NotImplemented.hxx> #include <Standard_NotImplemented.hxx>
Interface_BitMap::Interface_BitMap()
{
Initialize(0);
}
Interface_BitMap::Interface_BitMap
(const Standard_Integer nbitems, const Standard_Integer resflags) Interface_BitMap::Interface_BitMap
(const Standard_Integer nbitems, const Standard_Integer resflags)
{
Initialize(nbitems,resflags);
}
void Interface_BitMap::Initialize(const Standard_Integer nbitems, const Standard_Integer resflags)
{ {
thenbitems = nbitems; thenbitems = nbitems;
thenbwords = nbitems/32 + 1; thenbwords = nbitems/32 + 1;
thenbflags = 0; thenbflags = 0;
theflags = new TColStd_HArray1OfInteger (0,thenbwords*(resflags+1)); theflags->Init(0); if(nbitems)
{
theflags = new TColStd_HArray1OfInteger (0,thenbwords*(resflags+1));
theflags->Init(0);
}
} }
Interface_BitMap::Interface_BitMap Interface_BitMap::Interface_BitMap
(const Interface_BitMap& other, const Standard_Boolean copied) (const Interface_BitMap& other, const Standard_Boolean copied)
{
Initialize(other,copied);
}
void Interface_BitMap::Initialize(const Interface_BitMap& other,
const Standard_Boolean copied)
{ {
other.Internals (thenbitems,thenbwords,thenbflags,theflags,thenames); other.Internals (thenbitems,thenbwords,thenbflags,theflags,thenames);
if (!copied) return; if (!copied) return;
@ -31,18 +52,18 @@
thenames = names; thenames = names;
} }
void Interface_BitMap::Internals void Interface_BitMap::Internals
(Standard_Integer& nbitems, Standard_Integer& nbwords, (Standard_Integer& nbitems, Standard_Integer& nbwords,
Standard_Integer& nbflags, Standard_Integer& nbflags,
Handle(TColStd_HArray1OfInteger)& flags, Handle(TColStd_HArray1OfInteger)& flags,
Handle(TColStd_HSequenceOfAsciiString)& names) const Handle(TColStd_HSequenceOfAsciiString)& names) const
{ {
nbitems = thenbitems; nbwords = thenbwords; nbflags = thenbflags; nbitems = thenbitems; nbwords = thenbwords; nbflags = thenbflags;
flags = theflags; names = thenames; flags = theflags; names = thenames;
} }
void Interface_BitMap::Reservate (const Standard_Integer moreflags) void Interface_BitMap::Reservate (const Standard_Integer moreflags)
{ {
Standard_Integer nb = theflags->Upper (); Standard_Integer nb = theflags->Upper ();
Standard_Integer nbflags = nb / thenbwords - 1; // flag 0 non compte ... Standard_Integer nbflags = nb / thenbwords - 1; // flag 0 non compte ...
@ -57,7 +78,7 @@
} }
void Interface_BitMap::SetLength (const Standard_Integer nbitems) void Interface_BitMap::SetLength (const Standard_Integer nbitems)
{ {
Standard_Integer nbw = nbitems/32 + 1; Standard_Integer nbw = nbitems/32 + 1;
if (nbw == thenbwords) return; if (nbw == thenbwords) return;
@ -77,7 +98,7 @@
} }
Standard_Integer Interface_BitMap::AddFlag (const Standard_CString name) Standard_Integer Interface_BitMap::AddFlag (const Standard_CString name)
{ {
Reservate(1); Reservate(1);
Standard_Integer deja = 0; Standard_Integer deja = 0;
@ -86,7 +107,7 @@
Standard_Integer i, nb = thenames->Length(); Standard_Integer i, nb = thenames->Length();
for (i = 1; i <= nb; i ++) { for (i = 1; i <= nb; i ++) {
if (thenames->Value(i).IsEqual(".")) if (thenames->Value(i).IsEqual("."))
{ thenames->ChangeValue(i).AssignCat(name); deja = i; } { thenames->ChangeValue(i).AssignCat(name); deja = i; }
} }
} }
if (!deja) thenames->Append (TCollection_AsciiString(name)); if (!deja) thenames->Append (TCollection_AsciiString(name));
@ -94,8 +115,8 @@
return (deja ? deja : thenbflags); return (deja ? deja : thenbflags);
} }
Standard_Integer Interface_BitMap::AddSomeFlags Standard_Integer Interface_BitMap::AddSomeFlags
(const Standard_Integer more) (const Standard_Integer more)
{ {
Reservate(more); Reservate(more);
if (thenames.IsNull()) thenames = new TColStd_HSequenceOfAsciiString(); if (thenames.IsNull()) thenames = new TColStd_HSequenceOfAsciiString();
@ -105,8 +126,8 @@
return thenbflags; return thenbflags;
} }
Standard_Boolean Interface_BitMap::RemoveFlag Standard_Boolean Interface_BitMap::RemoveFlag
(const Standard_Integer num) (const Standard_Integer num)
{ {
if (num < 1 || num > thenames->Length()) return Standard_False; if (num < 1 || num > thenames->Length()) return Standard_False;
if (num == thenames->Length()) thenames->Remove (thenames->Length()); if (num == thenames->Length()) thenames->Remove (thenames->Length());
@ -115,8 +136,8 @@
return Standard_True; return Standard_True;
} }
Standard_Boolean Interface_BitMap::SetFlagName Standard_Boolean Interface_BitMap::SetFlagName
(const Standard_Integer num, const Standard_CString name) (const Standard_Integer num, const Standard_CString name)
{ {
if (num < 1 || num > thenames->Length()) return Standard_False; if (num < 1 || num > thenames->Length()) return Standard_False;
Standard_Integer deja = (name[0] == '\0' ? 0 : FlagNumber (name) ); Standard_Integer deja = (name[0] == '\0' ? 0 : FlagNumber (name) );
@ -125,22 +146,22 @@
return Standard_True; return Standard_True;
} }
Standard_Integer Interface_BitMap::NbFlags () const Standard_Integer Interface_BitMap::NbFlags () const
{ return thenbflags; } { return thenbflags; }
Standard_Integer Interface_BitMap::Length () const Standard_Integer Interface_BitMap::Length () const
{ return thenbitems; } { return thenbitems; }
Standard_CString Interface_BitMap::FlagName Standard_CString Interface_BitMap::FlagName
(const Standard_Integer num) const (const Standard_Integer num) const
{ {
if (theflags.IsNull()) return ""; if (theflags.IsNull()) return "";
if (num < 1 || num > thenames->Length()) return ""; if (num < 1 || num > thenames->Length()) return "";
return thenames->Value(num).ToCString(); return thenames->Value(num).ToCString();
} }
Standard_Integer Interface_BitMap::FlagNumber Standard_Integer Interface_BitMap::FlagNumber
(const Standard_CString name) const (const Standard_CString name) const
{ {
if (name[0] == '\0') return 0; if (name[0] == '\0') return 0;
if (thenames.IsNull()) return 0; if (thenames.IsNull()) return 0;
@ -153,8 +174,8 @@
// Les valeurs ... // Les valeurs ...
Standard_Boolean Interface_BitMap::Value Standard_Boolean Interface_BitMap::Value
(const Standard_Integer item, const Standard_Integer flag) const (const Standard_Integer item, const Standard_Integer flag) const
{ {
Standard_Integer numw = (thenbwords * flag) + (item >> 5); Standard_Integer numw = (thenbwords * flag) + (item >> 5);
const Standard_Integer& val = theflags->Value (numw); const Standard_Integer& val = theflags->Value (numw);
@ -164,24 +185,24 @@
return ( ((1 << numb) & val) != 0); return ( ((1 << numb) & val) != 0);
} }
void Interface_BitMap::SetValue void Interface_BitMap::SetValue
(const Standard_Integer item, const Standard_Boolean val, (const Standard_Integer item, const Standard_Boolean val,
const Standard_Integer flag) const const Standard_Integer flag) const
{ {
if (val) SetTrue (item,flag); if (val) SetTrue (item,flag);
else SetFalse (item,flag); else SetFalse (item,flag);
} }
void Interface_BitMap::SetTrue void Interface_BitMap::SetTrue
(const Standard_Integer item, const Standard_Integer flag) const (const Standard_Integer item, const Standard_Integer flag) const
{ {
Standard_Integer numw = (thenbwords * flag) + (item >> 5); Standard_Integer numw = (thenbwords * flag) + (item >> 5);
Standard_Integer numb = item & 31; Standard_Integer numb = item & 31;
theflags->ChangeValue (numw) |= (1 << numb); theflags->ChangeValue (numw) |= (1 << numb);
} }
void Interface_BitMap::SetFalse void Interface_BitMap::SetFalse
(const Standard_Integer item, const Standard_Integer flag) const (const Standard_Integer item, const Standard_Integer flag) const
{ {
Standard_Integer numw = (thenbwords * flag) + (item >> 5); Standard_Integer numw = (thenbwords * flag) + (item >> 5);
Standard_Integer& val = theflags->ChangeValue (numw); Standard_Integer& val = theflags->ChangeValue (numw);
@ -190,8 +211,8 @@
theflags->ChangeValue (numw) &= ~(1 << numb); theflags->ChangeValue (numw) &= ~(1 << numb);
} }
Standard_Boolean Interface_BitMap::CTrue Standard_Boolean Interface_BitMap::CTrue
(const Standard_Integer item, const Standard_Integer flag) const (const Standard_Integer item, const Standard_Integer flag) const
{ {
Standard_Integer numw = (thenbwords * flag) + (item >> 5); Standard_Integer numw = (thenbwords * flag) + (item >> 5);
Standard_Integer numb = item & 31; Standard_Integer numb = item & 31;
@ -203,8 +224,8 @@
return (res != 0); return (res != 0);
} }
Standard_Boolean Interface_BitMap::CFalse Standard_Boolean Interface_BitMap::CFalse
(const Standard_Integer item, const Standard_Integer flag) const (const Standard_Integer item, const Standard_Integer flag) const
{ {
Standard_Integer numw = (thenbwords * flag) + (item >> 5); Standard_Integer numw = (thenbwords * flag) + (item >> 5);
Standard_Integer numb = item & 31; Standard_Integer numb = item & 31;
@ -217,11 +238,17 @@
} }
void Interface_BitMap::Init void Interface_BitMap::Init
(const Standard_Boolean val, const Standard_Integer flag) const (const Standard_Boolean val, const Standard_Integer flag) const
{ {
Standard_Integer i, ii = thenbwords, i1 = thenbwords *flag; Standard_Integer i, ii = thenbwords, i1 = thenbwords *flag;
if (flag < 0) { i1 = 0; ii = thenbwords*(thenbflags+1); } if (flag < 0) { i1 = 0; ii = thenbwords*(thenbflags+1); }
if (val) for (i = 0; i < ii; i ++) theflags->SetValue (i1+i,~(0)); if (val) for (i = 0; i < ii; i ++) theflags->SetValue (i1+i,~(0));
else for (i = 0; i < ii; i ++) theflags->SetValue (i1+i, 0 ); else for (i = 0; i < ii; i ++) theflags->SetValue (i1+i, 0 );
} }
void Interface_BitMap::Clear()
{
theflags.Nullify();
Initialize(0);
}

View File

@ -176,6 +176,9 @@ is
-- default is doing nothing; redefinable as necessary -- default is doing nothing; redefinable as necessary
Clear(me : in out);
---Purpose : Clear filelds
fields fields
theproto : Protocol from Interface; theproto : Protocol from Interface;

View File

@ -547,5 +547,13 @@ Handle(Standard_Transient) Interface_FileReaderTool::LoadedEntity
//purpose : //purpose :
//======================================================================= //=======================================================================
void Interface_FileReaderTool::Destroy(){} void Interface_FileReaderTool::Destroy()
{}
void Interface_FileReaderTool::Clear()
{
theproto.Nullify();
thereader.Nullify();
themodel.Nullify();
thereports.Nullify();
}

View File

@ -67,17 +67,17 @@ Standard_Boolean Interface_GTool::Select (const Handle(Standard_Transient)& ent
Standard_Integer& CN, Standard_Integer& CN,
const Standard_Boolean enforce) const Standard_Boolean enforce)
{ {
// const Handle(Standard_Type)& aType = ent->DynamicType(); const Handle(Standard_Type)& aType = ent->DynamicType();
Standard_Integer num = thentmod.FindIndex (ent); Standard_Integer num = thentmod.FindIndex(aType);// (ent);
if (num == 0 || enforce) { if (num == 0 || enforce) {
if (thelib.Select (ent,gmod,CN)) { if (thelib.Select (ent,gmod,CN)) {
num = thentmod.Add (ent,gmod); num = thentmod.Add (aType,gmod);
thentnum.Bind (ent,CN); thentnum.Bind (aType,CN);
return Standard_True; return Standard_True;
} }
return Standard_False; return Standard_False;
} }
gmod = Handle(Interface_GeneralModule)::DownCast (thentmod.FindFromIndex(num)); gmod = Handle(Interface_GeneralModule)::DownCast (thentmod.FindFromKey(aType));
CN = thentnum.Find (ent); CN = thentnum.Find (aType);
return Standard_True; return Standard_True;
} }

View File

@ -28,39 +28,45 @@ class Graph from Interface
-- be changed or reset (i.e. to come back to standard answer) -- be changed or reset (i.e. to come back to standard answer)
uses Transient, Type, uses Transient, Type,
Array1OfInteger from TColStd, HArray1OfInteger from TColStd,
HArray1OfTransient from TColStd,
HSequenceOfTransient from TColStd,
HArray1OfListOfInteger from TColStd,
AsciiString from TCollection, HAsciiString from TCollection, AsciiString from TCollection, HAsciiString from TCollection,
Protocol from Interface, GeneralLib, InterfaceModel, GTool, Protocol from Interface, GeneralLib, InterfaceModel, GTool,
EntityIterator, IntList, BitMap EntityIterator, BitMap
raises DomainError raises DomainError
is is
Create (amodel : InterfaceModel; lib : GeneralLib) returns Graph; Create (amodel : InterfaceModel; lib : GeneralLib; theModeStats : Boolean = Standard_True ) returns Graph;
---Purpose : Creates an empty graph, ready to receive Entities from amodel ---Purpose : Creates an empty graph, ready to receive Entities from amodel
-- Note that this way of Creation allows <me> to verify that -- Note that this way of Creation allows <me> to verify that
-- Entities to work with are contained in <amodel> -- Entities to work with are contained in <amodel>
-- Basic Shared and Sharing lists are obtained from a General -- Basic Shared and Sharing lists are obtained from a General
-- Services Library, given directly as an argument -- Services Library, given directly as an argument
Create (amodel : InterfaceModel; protocol : Protocol from Interface) Create (amodel : InterfaceModel; protocol : Protocol from Interface;
theModeStats : Boolean = Standard_True)
returns Graph; returns Graph;
---Purpose : Same as above, but the Library is defined through a Protocol ---Purpose : Same as above, but the Library is defined through a Protocol
Create (amodel : InterfaceModel; gtool : GTool from Interface) Create (amodel : InterfaceModel; gtool : GTool from Interface;
theModeStats : Boolean = Standard_True)
returns Graph; returns Graph;
---Purpose : Same as above, but the Library is defined through a Protocol ---Purpose : Same as above, but the Library is defined through a Protocol
Create (amodel : InterfaceModel) returns Graph; Create (amodel : InterfaceModel;theModeStats : Boolean = Standard_True) returns Graph;
---Purpose : Same a above but works with the Protocol recorded in the Model ---Purpose : Same a above but works with the Protocol recorded in the Model
Create (agraph : Graph; copied : Boolean = Standard_False) returns Graph; Create (agraph : Graph; copied : Boolean = Standard_False) returns Graph;
---Purpose : Creates a Graph from another one, getting all its data ---Purpose : Creates a Graph from another one, getting all its data
-- Remark that status are copied from <agraph>, but the other -- Remark that status are copied from <agraph>, but the other
-- lists (sharing/shared) are copied only if <copied> = True -- lists (sharing/shared) are copied only if <copied> = True
Evaluate (me : in out; lib : GeneralLib; gtool : GTool) is static private;
Evaluate (me : in out ) is static private;
---Purpose : Performs the Evaluation of the Graph, from an initial Library, ---Purpose : Performs the Evaluation of the Graph, from an initial Library,
-- either defined through a Protocol, or given dierctly -- either defined through a Protocol, or given dierctly
-- Called by the non-empty Constructors -- Called by the non-empty Constructors
@ -69,25 +75,6 @@ is
-- GeneralLib directly, it cannot be used -- GeneralLib directly, it cannot be used
-- If <gtool> is defined, it has priority -- If <gtool> is defined, it has priority
EvalSharings (me : in out) is static;
---Purpose : Reevaluates the Sharing Lists of the Graph, starting from the
-- Shared Lists (priority to the redefined ones)
BasicSharedTable (me) returns IntList is static private;
---Purpose : Returns the Table of Basic Shared lists. Used to Create
-- another Graph from <me>
RedefinedSharedTable (me) returns IntList is static private;
---Purpose : Returns the Table of redefined Shared lists. Used to Create
-- another Graph from <me>. Null Handle is no one redefinition
SharingTable (me) returns IntList is static private;
---Purpose : Returns the Table of Sharing lists. Used to Create
-- another Graph from <me>
-- NbVertex(me) returns Integer is static; -- for GraphTools requirements
Reset (me : in out) is static; Reset (me : in out) is static;
---Purpose : Erases data, making graph ready to rebegin from void ---Purpose : Erases data, making graph ready to rebegin from void
@ -102,6 +89,9 @@ is
-- -- Fine Actions -- -- -- -- Fine Actions -- --
NbStatuses(me) returns Integer;
---Purpose : Returns size of array of statuses
EntityNumber (me; ent : Transient) returns Integer is static; EntityNumber (me; ent : Transient) returns Integer is static;
---Purpose : Returns the Number of the entity in the Map, computed at ---Purpose : Returns the Number of the entity in the Map, computed at
-- creation time (Entities loaded from the Model) -- creation time (Entities loaded from the Model)
@ -125,10 +115,6 @@ is
Status (me; num : Integer) returns Integer is static; Status (me; num : Integer) returns Integer is static;
---Purpose : Returns Status associated to a numero (only to read it) ---Purpose : Returns Status associated to a numero (only to read it)
CStatus (me : in out; num : Integer) returns Integer is static;
---Purpose : Returns Status associated to a numero, to be read or changed
---C++ : return &
SetStatus (me : in out; num : Integer; stat : Integer) is static; SetStatus (me : in out; num : Integer; stat : Integer) is static;
---Purpose : Modifies Status associated to a numero ---Purpose : Modifies Status associated to a numero
@ -215,10 +201,8 @@ is
-- Remark : apart from the status HasShareError, these items -- Remark : apart from the status HasShareError, these items
-- are ignored -- are ignored
HasRedefinedShareds (me; ent : Transient) returns Boolean is static; GetShareds(me; ent : Transient) returns HSequenceOfTransient;
---Purpose : Returns True if Shared list of <ent> has been redefined ---Purpose : Returns the sequence of Entities Shared by an Entity
-- (Thus, Shareds from Graph gives a result different from
-- general service Shareds)
Shareds (me; ent : Transient) returns EntityIterator Shareds (me; ent : Transient) returns EntityIterator
---Purpose : Returns the list of Entities Shared by an Entity, as recorded ---Purpose : Returns the list of Entities Shared by an Entity, as recorded
@ -227,11 +211,6 @@ is
raises DomainError is static; raises DomainError is static;
-- Error if <ent> is not contained by the model used for Creation -- Error if <ent> is not contained by the model used for Creation
SharedNums (me; num : Integer) returns IntList is static;
---Purpose : Same as Shareds, but under the form of a list of Integers,
-- each one beeing the Number of a Shared Entity in the Graph
-- Especially intended for fast internal uses
-- Returns a Null Handle if <num> is not contained by <themodel>
Sharings (me; ent : Transient) returns EntityIterator Sharings (me; ent : Transient) returns EntityIterator
---Purpose : Returns the list of Entities which Share an Entity, computed ---Purpose : Returns the list of Entities which Share an Entity, computed
@ -239,11 +218,11 @@ is
raises DomainError is static; raises DomainError is static;
-- Error if <ent> is not contained by the model used for Creation -- Error if <ent> is not contained by the model used for Creation
SharingNums (me; num : Integer) returns IntList is static;
---Purpose : Same as Sharings, but under the form of a list of Integers
-- each one beeing the Number of a Sharing Entity in the Graph
TypedSharings (me; ent : Transient; type : Type) returns EntityIterator; GetSharings(me; ent : Transient) returns HSequenceOfTransient;
---Purpose : Returns the sequence of Entities Sharings by an Entity
TypedSharings (me; ent : Transient; type : Type) returns EntityIterator;
---Purpose : Returns the list of sharings entities, AT ANY LEVEL, which are ---Purpose : Returns the list of sharings entities, AT ANY LEVEL, which are
-- kind of a given type. A sharing entity kind of this type -- kind of a given type. A sharing entity kind of this type
-- ends the exploration of its branch -- ends the exploration of its branch
@ -254,52 +233,6 @@ is
-- -- Redefinitions of Shared-Sharing Lists -- -- -- -- Redefinitions of Shared-Sharing Lists -- --
SetShare (me : in out; ent : Transient) is static;
---Purpose : Sets explicit the shared list of an Entity <ent>, that is,
-- available for a further edit (Add/Remove). All SetShare and
-- SetNoShare methods allow further edit operations.
-- Effect cancelled by ResetShare
-- Remark that all Redefinition methods work on Shared Lists,
-- but also manage (update) the Sharing Lists
SetShare (me : in out; ent : Transient; list : EntityIterator)
is static;
---Purpose : Sets as Shared list of an Entity <ent> considered by <me>,
-- the list given as an EntityIterator <iter>. It can be empty.
-- This list will now be considered by method Shareds above
-- Does nothing if <ent> is not contained by <themodel>
SetShare (me : in out; ent : Transient; list : IntList)
is static;
---Purpose : Same as above, but the list is given as the list of Numbers
-- of the Entities shared by <ent>
SetNoShare (me : in out; ent : Transient) is static;
---Purpose : Sets the Shared list of an Entity considered in <me> as beeing
-- Empty (if <ent> is contained by <themodel>)
SetNoShare (me : in out; list : EntityIterator) is static;
---Purpose : Sets the Shared lists of a list of Entities to be Empty
AddShared (me : in out; ent,shared : Transient)
---Purpose : Adds a shared Entity to a redefined Shared List (formerly
-- defined by SetShare or SetNoShare). Does nothing if already in
raises DomainError is static;
-- Error if no shared list was formerly redefined for <ent>
RemoveShared (me : in out; ent,shared : Transient)
---Purpose : Removes a shared Entity from a redefined Shared List (formerly
-- defined ...). Does nothing if <shared> no in the list
raises DomainError is static;
-- Error if no shared list was formerly redefined for <ent>
ResetShare (me : in out; ent : Transient) is static;
---Purpose : Comes back to the standard Shared list for <ent> : Cancels all
-- the former redefinitions for it
ResetAllShare (me : in out) is static;
---Purpose : Clears all effects of former redefinition of Shared lists
Name (me; ent : Transient) returns HAsciiString; Name (me; ent : Transient) returns HAsciiString;
---Purpose : Determines the name attached to an entity, by using the ---Purpose : Determines the name attached to an entity, by using the
@ -307,15 +240,24 @@ is
-- Returns a null handle if no name could be computed or if -- Returns a null handle if no name could be computed or if
-- the entity is not in the model -- the entity is not in the model
SharingTable (me) returns HArray1OfListOfInteger from TColStd; --HArray1OfTransient from TColStd ;
---C++ : return const &
---Purpose : Returns the Table of Sharing lists. Used to Create
-- another Graph from <me>
InitStats(me : in out) is protected;
---Purpose : Initialize statuses and flags
ModeStat(me) returns Boolean;
---Purpose : Returns mode resposible for computation of statuses;
fields fields
themodel : InterfaceModel; -- Model which contains the Entities themodel : InterfaceModel is protected ; -- Model which contains the Entities
thepresents : AsciiString from TCollection; -- flags present/or not thepresents : AsciiString from TCollection is protected ; -- flags present/or not
thestats : Array1OfInteger from TColStd; -- numeric status thestats : HArray1OfInteger from TColStd is protected; -- numeric status
theflags : BitMap; -- logical flags status theflags : BitMap; -- logical flags status
thesharings : HArray1OfListOfInteger from TColStd is protected; --HArray1OfTransient from TColStd is protected;
theshareds : IntList; -- Basic Shared Lists (one per Entity)
thesharnews : IntList; -- Shared Lists Redefinitions
thesharings : IntList; -- The Sharing Lists (one per Entity)
end Graph; end Graph;

View File

@ -4,8 +4,9 @@
#include <Standard_DomainError.hxx> #include <Standard_DomainError.hxx>
#include <TColStd_Array1OfInteger.hxx> #include <TColStd_Array1OfInteger.hxx>
#include <Interface_ShareTool.hxx> #include <Interface_ShareTool.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <Interface_GTool.hxx>
// Flags : 0 = Presence, 1 = Sharing Error // Flags : 0 = Presence, 1 = Sharing Error
#define Graph_Present 0 #define Graph_Present 0
@ -19,362 +20,327 @@
// .... Construction a partir de la connaissance des Entites .... // .... Construction a partir de la connaissance des Entites ....
Interface_Graph::Interface_Graph Interface_Graph::Interface_Graph
(const Handle(Interface_InterfaceModel)& amodel, (const Handle(Interface_InterfaceModel)& amodel,
const Interface_GeneralLib& lib) const Interface_GeneralLib& lib,
: themodel (amodel), thepresents ("") , thestats (0,amodel->NbEntities()) , Standard_Boolean theModeStat)
theflags (amodel->NbEntities(),2) , : themodel (amodel), thepresents ("")
theshareds (amodel->NbEntities()) , /*thesharnews(amodel->NbEntities()) , */
thesharings (amodel->NbEntities())
{ {
Handle(Interface_GTool) gtool; // null if(theModeStat)
theflags.AddFlag ("ShareError"); // -> flag n0 1 InitStats();
Evaluate(lib,gtool); Evaluate();
} }
Interface_Graph::Interface_Graph Interface_Graph::Interface_Graph
(const Handle(Interface_InterfaceModel)& amodel, (const Handle(Interface_InterfaceModel)& amodel,
const Handle(Interface_Protocol)& protocol) const Handle(Interface_Protocol)& protocol,
: themodel (amodel) , thepresents ("") , Standard_Boolean theModeStat)
thestats (0,amodel->NbEntities()) , theflags (amodel->NbEntities(),2) , : themodel (amodel) , thepresents ("")
theshareds (amodel->NbEntities()) , /*thesharnews(amodel->NbEntities()) ,*/
thesharings (amodel->NbEntities())
{ {
Handle(Interface_GTool) gtool; // null if(theModeStat)
theflags.AddFlag ("ShareError"); // -> flag n0 1 InitStats();
Evaluate(Interface_GeneralLib(protocol),gtool); Evaluate();
} }
Interface_Graph::Interface_Graph Interface_Graph::Interface_Graph
(const Handle(Interface_InterfaceModel)& amodel, (const Handle(Interface_InterfaceModel)& amodel,
const Handle(Interface_GTool)& gtool) const Handle(Interface_GTool)& gtool,
: themodel (amodel) , thepresents ("") , Standard_Boolean theModeStat)
thestats (0,amodel->NbEntities()) , theflags (amodel->NbEntities(),2) , : themodel (amodel) , thepresents ("")
theshareds (amodel->NbEntities()) , /*thesharnews(amodel->NbEntities()) , */
thesharings (amodel->NbEntities())
{ {
theflags.AddFlag ("ShareError"); // -> flag n0 1 if(theModeStat)
Evaluate(gtool->Lib(),gtool); InitStats();
Evaluate();
} }
Interface_Graph::Interface_Graph Interface_Graph::Interface_Graph
(const Handle(Interface_InterfaceModel)& amodel) (const Handle(Interface_InterfaceModel)& amodel,
: themodel (amodel) , thepresents ("") , Standard_Boolean theModeStat)
thestats (0,amodel->NbEntities()) , theflags (amodel->NbEntities(),2) , : themodel (amodel) , thepresents ("")
theshareds (amodel->NbEntities()) ,
/*thesharnews(amodel->NbEntities()) ,*/ thesharings (amodel->NbEntities())
{ {
theflags.AddFlag ("ShareError"); // -> flag n0 1 if(theModeStat)
Handle(Interface_GTool) gtool = amodel->GTool(); InitStats();
if (gtool.IsNull()) return; Evaluate ();
gtool->Reservate(amodel->NbEntities());
Evaluate (gtool->Lib(),gtool);
} }
void Interface_Graph::Evaluate
(const Interface_GeneralLib& lib, const Handle(Interface_GTool)& gtool)
{
// Evaluation d un Graphe de dependances : sur chaque Entite, on prend sa
// liste "Shared". On en deduit les "Sharing" directement
Standard_Boolean patool = gtool.IsNull();
Standard_Integer n = Size(), total = 0;
theshareds.Clear();
thesharings.Clear();
TColStd_Array1OfInteger counts (0,n); counts.Init(0);
TColStd_Array1OfInteger lasts (0,n); lasts.Init(0);
Standard_Integer i; // svv Jan11 2000 : porting on DEC
for (i = 1; i <= n; i ++) {
theshareds.SetNumber (i);
// ATTENTION : Si Entite non chargee donc illisible, basculer sur son
// "Contenu" equivalent
Handle(Standard_Transient) ent = themodel->Value(i);
if (themodel->IsRedefinedContent(i)) ent = themodel->ReportEntity(i)->Content();
// Resultat obtenu via GeneralLib
Interface_EntityIterator iter;
Handle(Interface_GeneralModule) module;
Standard_Integer CN;
if (patool) {
if (lib.Select(ent,module,CN)) module->FillShared(themodel,CN,ent,iter);
} else {
if (gtool->Select(ent,module,CN)) module->FillShared(themodel,CN,ent,iter);
}
theshareds.Reservate (iter.NbEntities());
// Mise en forme : liste d entiers
for (iter.Start(); iter.More(); iter.Next()) {
// num = 0 -> on sort du Model de depart, le noter "Error" et passer
Standard_Integer num = EntityNumber(iter.Value());
if (num == 0) theflags.SetTrue (i,Graph_ShareError);
else {
// controle d unicite de couple (pere-fils)
if (lasts(num) == i) continue;
total ++;
lasts.ChangeValue(num) = i;
theshareds.Add (num);
counts.ChangeValue(num) ++;
// References inverses : plus tard
}
}
}
// Les references inverses : preallocation (pour compte > 1 seulement)
thesharings.SetNumber(0); thesharings.Reservate (total);
for (i = 1; i <= n; i ++) {
if (counts(i) < 2) continue;
thesharings.SetNumber(i);
thesharings.Reservate (-counts(i));
}
// Enregistrement par inversion
for (i = 1; i <= n; i ++) {
theshareds.SetNumber (i);
Standard_Integer j,num, nb = theshareds.Length();
for (j = 1; j <= nb; j ++) {
num = theshareds.Value(j);
thesharings.SetNumber(-num);
thesharings.Add(-i);
}
}
}
void Interface_Graph::EvalSharings ()
{
thesharings.Clear();
Standard_Integer n = thesharings.NbEntities();
// Difference avec Evaluate : SharedNums prend les Redefinis si necessaire
for (Standard_Integer i = 1; i <= n; i ++) {
Standard_Integer nb, num;
if (thesharnews.IsRedefined(i)) {
thesharnews.SetNumber(i);
nb = thesharnews.Length();
for (Standard_Integer j = 1; j <= nb; j ++) {
num = thesharnews.Value (j);
thesharings.SetNumber (num);
thesharings.Reservate (thesharings.Length()+1);
thesharings.Add (i);
}
} else {
theshareds.SetNumber(i);
nb = theshareds.Length();
for (Standard_Integer j = 1; j <= nb; j ++) {
num = theshareds.Value (j);
thesharings.SetNumber (num);
thesharings.Reservate (thesharings.Length()+1);
thesharings.Add (i);
}
}
}
}
// .... Construction depuis un autre Graph .... // .... Construction depuis un autre Graph ....
Interface_Graph::Interface_Graph Interface_Graph::Interface_Graph
(const Interface_Graph& agraph, const Standard_Boolean /*copied*/) (const Interface_Graph& agraph, const Standard_Boolean /*copied*/)
: themodel (agraph.Model()), thepresents ("") , : themodel (agraph.Model()), thepresents ("")
thestats (0,agraph.Size()) ,
theflags (agraph.BitMap(),Standard_True) ,
theshareds (agraph.BasicSharedTable(),Standard_True) ,
thesharnews (agraph.RedefinedSharedTable(),Standard_True) ,
thesharings (agraph.SharingTable(),Standard_True)
{ {
Standard_Integer nb = Size(); thesharings = agraph.SharingTable();
Standard_Integer nb = agraph.NbStatuses();
if(!nb)
return;
if(thestats.IsNull())
thestats = new TColStd_HArray1OfInteger(1,nb);
for (Standard_Integer i = 1; i <= nb; i ++) for (Standard_Integer i = 1; i <= nb; i ++)
thestats.SetValue (i,agraph.Status(i)); thestats->SetValue (i,agraph.Status(i));
theflags.Initialize(agraph.BitMap(),Standard_True);
} }
Interface_IntList Interface_Graph::BasicSharedTable () const void Interface_Graph::InitStats()
{ return theshareds; } {
thestats = new TColStd_HArray1OfInteger(1,themodel->NbEntities()) ,
theflags.Initialize(themodel->NbEntities(),2);
theflags.AddFlag ("ShareError");
}
Interface_IntList Interface_Graph::RedefinedSharedTable () const Standard_Integer Interface_Graph::NbStatuses() const
{ return thesharnews; } {
return (thestats.IsNull() ? 0 : thestats->Length());
}
Interface_IntList Interface_Graph::SharingTable () const const Handle(TColStd_HArray1OfListOfInteger)& Interface_Graph::SharingTable () const
{ return thesharings; } { return thesharings; }
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(), total = 0;
thesharings = new TColStd_HArray1OfListOfInteger(1,n);//TColStd_HArray1OfTransient(1,n);//Clear();
if(themodel->GTool().IsNull())
return;
Standard_Integer i; // svv Jan11 2000 : porting on DEC
for (i = 1; i <= n; 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()) {
// num = 0 -> on sort du Model de depart, le noter "Error" et passer
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);
}
}
}
// .... Construction depuis un autre Graph ....
// ########################################################################### // ###########################################################################
// .... ACCES UNITAIRES AUX DONNEES DE BASE .... // .... ACCES UNITAIRES AUX DONNEES DE BASE ....
void Interface_Graph::Reset () void Interface_Graph::Reset ()
{ {
thestats.Init(0); if(!thestats.IsNull())
theflags.Init (Standard_False, Graph_Present); {
thesharnews.Clear(); thestats.Nullify();
EvalSharings(); theflags.Init (Standard_False, Graph_Present);
}
} }
void Interface_Graph::ResetStatus () void Interface_Graph::ResetStatus ()
{ thestats.Init(0); theflags.Init (Standard_False, Graph_Present); }
Standard_Integer Interface_Graph::Size () const
{ return thestats.Upper(); }
Standard_Integer Interface_Graph::EntityNumber
(const Handle(Standard_Transient)& ent) const
{ return themodel->Number(ent); }
Standard_Boolean Interface_Graph::IsPresent
(const Standard_Integer num) const
{ {
if (num <= 0 || num > Size()) return Standard_False; if(!thestats.IsNull())
return theflags.Value (num,Graph_Present); {
} thestats->Init(0);
theflags.Init (Standard_False, Graph_Present);
Standard_Boolean Interface_Graph::IsPresent
(const Handle(Standard_Transient)& ent) const
{ return IsPresent(EntityNumber(ent)); }
const Handle(Standard_Transient)& Interface_Graph::Entity
(const Standard_Integer num) const
{ return themodel->Value(num); }
Standard_Integer Interface_Graph::Status (const Standard_Integer num) const
{ return thestats.Value(num); }
Standard_Integer& Interface_Graph::CStatus (const Standard_Integer num)
{ return thestats.ChangeValue(num); }
void Interface_Graph::SetStatus
(const Standard_Integer num, const Standard_Integer stat)
{ thestats.SetValue(num,stat); }
void Interface_Graph::RemoveItem(const Standard_Integer num)
{
thestats.SetValue(num,0); theflags.SetFalse (num,Graph_Present);
}
void Interface_Graph::ChangeStatus
(const Standard_Integer oldstat, const Standard_Integer newstat)
{
Standard_Integer nb = thestats.Upper();
for (Standard_Integer i = 1; i <= nb; i ++) {
if (thestats.Value(i) == oldstat) thestats.SetValue(i,newstat);
} }
} }
void Interface_Graph::RemoveStatus(const Standard_Integer stat)
Standard_Integer Interface_Graph::Size () const
{ return themodel->NbEntities(); }//thestats.Upper(); }
Standard_Integer Interface_Graph::EntityNumber
(const Handle(Standard_Transient)& ent) const
{ return themodel->Number(ent); }
Standard_Boolean Interface_Graph::IsPresent
(const Standard_Integer num) const
{ {
Standard_Integer nb = thestats.Upper(); if (num <= 0 || num > Size())
for (Standard_Integer i = 1; i <= nb; i ++) { return Standard_False;
if (thestats.Value(i) == stat) RemoveItem(i); return (!thestats.IsNull() ? theflags.Value (num,Graph_Present) : Standard_False);
}
Standard_Boolean Interface_Graph::IsPresent
(const Handle(Standard_Transient)& ent) const
{ return IsPresent(EntityNumber(ent)); }
const Handle(Standard_Transient)& Interface_Graph::Entity
(const Standard_Integer num) const
{
return themodel->Value(num);
}
Standard_Integer Interface_Graph::Status (const Standard_Integer num) const
{
return (!thestats.IsNull() ? thestats->Value(num) : 0);
}
void Interface_Graph::SetStatus
(const Standard_Integer num, const Standard_Integer stat)
{
if(!thestats.IsNull())
thestats->SetValue(num,stat);
}
void Interface_Graph::RemoveItem(const Standard_Integer num)
{
if(!thestats.IsNull())
{
thestats->SetValue(num,0);
theflags.SetFalse (num,Graph_Present);
} }
} }
const Interface_BitMap& Interface_Graph::BitMap () const void Interface_Graph::ChangeStatus
{ return theflags; } (const Standard_Integer oldstat, const Standard_Integer newstat)
{
if(thestats.IsNull())
return;
Standard_Integer nb = thestats->Upper();
for (Standard_Integer i = 1; i <= nb; i ++) {
if (thestats->Value(i) == oldstat)
thestats->SetValue(i,newstat);
}
}
Interface_BitMap& Interface_Graph::CBitMap () void Interface_Graph::RemoveStatus(const Standard_Integer stat)
{ return theflags; } {
if(thestats.IsNull())
return;
Standard_Integer nb = thestats->Upper();
for (Standard_Integer i = 1; i <= nb; i ++) {
if (thestats->Value(i) == stat) RemoveItem(i);
}
}
const Interface_BitMap& Interface_Graph::BitMap () const
{ return theflags; }
Interface_BitMap& Interface_Graph::CBitMap ()
{ return theflags; }
// ########################################################################### // ###########################################################################
// .... Chargements Elementaires avec Propagation de "Share" .... // // .... Chargements Elementaires avec Propagation de "Share" .... //
const Handle(Interface_InterfaceModel)& Interface_Graph::Model() const const Handle(Interface_InterfaceModel)& Interface_Graph::Model() const
{ return themodel; } { return themodel; }
void Interface_Graph::GetFromModel () void Interface_Graph::GetFromModel ()
{ {
if (themodel.IsNull()) return; // no model ... (-> on n ira pas loin) if (themodel.IsNull() || thestats.IsNull())
return; // no model ... (-> on n ira pas loin)
theflags.Init (Standard_True,Graph_Present); theflags.Init (Standard_True,Graph_Present);
thestats.Init (0); thestats->Init (0);
} }
void Interface_Graph::GetFromEntity void Interface_Graph::GetFromEntity
(const Handle(Standard_Transient)& ent, const Standard_Boolean shared, (const Handle(Standard_Transient)& ent, const Standard_Boolean shared,
const Standard_Integer newstat) const Standard_Integer newstat)
{ {
if(thestats.IsNull())
return;
Standard_Integer num = EntityNumber(ent); Standard_Integer num = EntityNumber(ent);
if (num == 0) return; if (!num )
return;
if (theflags.CTrue(num,Graph_Present)) return; // deja pris : on passe if (theflags.CTrue(num,Graph_Present)) return; // deja pris : on passe
thestats.SetValue(num,newstat); thestats->SetValue(num,newstat);
if (!shared) return; if (!shared) return;
// Attention a la redefinition ! // Attention a la redefinition !
Interface_IntList list = thesharnews; Interface_EntityIterator aIter = GetShareds(ent);
if (!list.IsRedefined(num)) list = theshareds;
list.SetNumber (num);
Standard_Integer nb = list.Length(); for ( ; aIter.More() ; aIter.Next())
for (Standard_Integer i = 1; i <= nb; i ++) GetFromEntity GetFromEntity(aIter.Value(),Standard_True,newstat);
(themodel->Value (list.Value(i)),Standard_True,newstat);
} }
void Interface_Graph::GetFromEntity void Interface_Graph::GetFromEntity
(const Handle(Standard_Transient)& ent, const Standard_Boolean shared, (const Handle(Standard_Transient)& ent, const Standard_Boolean shared,
const Standard_Integer newstat, const Standard_Integer overlapstat, const Standard_Integer newstat, const Standard_Integer overlapstat,
const Standard_Boolean cumul) const Standard_Boolean cumul)
{ {
if(thestats.IsNull())
return;
Standard_Integer num = EntityNumber(ent); Standard_Integer num = EntityNumber(ent);
if (num == 0) return; if (!num ) return;
Standard_Boolean pasla = !theflags.CTrue (num,Graph_Present); Standard_Boolean pasla = !theflags.CTrue (num,Graph_Present);
Standard_Integer stat = thestats.Value(num); Standard_Integer stat = thestats->Value(num);
if (pasla) { if (pasla) {
/// theflags.SetTrue (num, Graph_Present); // nouveau : noter avec newstat /// theflags.SetTrue (num, Graph_Present); // nouveau : noter avec newstat
thestats.SetValue(num,newstat); thestats->SetValue(num,newstat);
} else { } else {
Standard_Integer overstat = stat; Standard_Integer overstat = stat;
if (stat != newstat) { // deja pris, meme statut : passer if (stat != newstat) { // deja pris, meme statut : passer
if (cumul) overstat += overlapstat; // nouveau statut : avec cumul ... if (cumul) overstat += overlapstat; // nouveau statut : avec cumul ...
else overstat = overlapstat; // ... ou sans (statut force) else overstat = overlapstat; // ... ou sans (statut force)
if (stat != overstat) // si repasse deja faite, passer if (stat != overstat) // si repasse deja faite, passer
thestats.SetValue(num,overstat); thestats->SetValue(num,overstat);
} }
} }
if (!shared) return; if (!shared) return;
// Attention a la redefinition ! // Attention a la redefinition !
Interface_IntList list = thesharnews; Interface_EntityIterator aIter = GetShareds(ent);
if (!list.IsRedefined(num)) list = theshareds;
list.SetNumber (num); for ( ; aIter.More() ; aIter.Next())
Standard_Integer nb = list.Length(); GetFromEntity(aIter.Value(),Standard_True,newstat);
for (Standard_Integer i = 1; i <= nb; i ++) GetFromEntity
(themodel->Value (list.Value(i)),Standard_True,newstat);
} }
void Interface_Graph::GetFromIter
(const Interface_EntityIterator& iter, const Standard_Integer newstat)
void Interface_Graph::GetFromIter
(const Interface_EntityIterator& iter, const Standard_Integer newstat)
{ {
if(thestats.IsNull())
return;
for (iter.Start(); iter.More(); iter.Next()) { for (iter.Start(); iter.More(); iter.Next()) {
Handle(Standard_Transient) ent = iter.Value(); Handle(Standard_Transient) ent = iter.Value();
Standard_Integer num = EntityNumber(ent); Standard_Integer num = EntityNumber(ent);
if (num == 0) continue; if (!num)
if (theflags.CTrue(num,Graph_Present)) continue; continue;
thestats.SetValue(num,newstat); if (theflags.CTrue(num,Graph_Present))
continue;
thestats->SetValue(num,newstat);
} }
} }
void Interface_Graph::GetFromIter void Interface_Graph::GetFromIter
(const Interface_EntityIterator& iter, (const Interface_EntityIterator& iter,
const Standard_Integer newstat, const Standard_Integer overlapstat, const Standard_Integer newstat, const Standard_Integer overlapstat,
const Standard_Boolean cumul) const Standard_Boolean cumul)
{ {
if(thestats.IsNull())
return;
for (iter.Start(); iter.More(); iter.Next()) { for (iter.Start(); iter.More(); iter.Next()) {
Handle(Standard_Transient) ent = iter.Value(); Handle(Standard_Transient) ent = iter.Value();
Standard_Integer num = EntityNumber(ent); Standard_Integer num = EntityNumber(ent);
if (num == 0) continue; if (!num)
continue;
/*Standard_Boolean pasla = !*/theflags.Value(num,Graph_Present); /*Standard_Boolean pasla = !*/theflags.Value(num,Graph_Present);
/*Standard_Integer stat = */thestats.Value(num); /*Standard_Integer stat = */thestats->Value(num);
GetFromEntity (ent,Standard_False,newstat,overlapstat,cumul); GetFromEntity (ent,Standard_False,newstat,overlapstat,cumul);
} }
} }
void Interface_Graph::GetFromGraph (const Interface_Graph& agraph) void Interface_Graph::GetFromGraph (const Interface_Graph& agraph)
{ {
if (Model() != agraph.Model()) Standard_DomainError::Raise if (Model() != agraph.Model()) Standard_DomainError::Raise
("Graph from Interface : GetFromGraph"); ("Graph from Interface : GetFromGraph");
@ -385,8 +351,8 @@
} }
} }
void Interface_Graph::GetFromGraph void Interface_Graph::GetFromGraph
(const Interface_Graph& agraph, const Standard_Integer stat) (const Interface_Graph& agraph, const Standard_Integer stat)
{ {
if (Model() != agraph.Model()) Standard_DomainError::Raise if (Model() != agraph.Model()) Standard_DomainError::Raise
("Graph from Interface : GetFromGraph"); ("Graph from Interface : GetFromGraph");
@ -401,90 +367,88 @@
// .... Listage des Entites Partagees .... // .... Listage des Entites Partagees ....
Standard_Boolean Interface_Graph::HasShareErrors Standard_Boolean Interface_Graph::HasShareErrors
(const Handle(Standard_Transient)& ent) const (const Handle(Standard_Transient)& ent) const
{ {
if(thestats.IsNull())
return Standard_False;
Standard_Integer num = EntityNumber(ent); Standard_Integer num = EntityNumber(ent);
if (num == 0) return Standard_True; if (num == 0) return Standard_True;
return theflags.Value (num,Graph_ShareError); return theflags.Value (num,Graph_ShareError);
} }
// A chaque entite, on peut attacher une Liste de numeros d entites partagees Interface_EntityIterator Interface_Graph::Shareds
// Si elle est nulle, BasicShareds convient, sinon on prend RedefinedShareds (const Handle(Standard_Transient)& ent) const
Standard_Boolean Interface_Graph::HasRedefinedShareds
(const Handle(Standard_Transient)& ent) const
{ {
Standard_Integer num = EntityNumber(ent);
if (num == 0) return Standard_False;
return thesharnews.IsRedefined (num);
}
Interface_EntityIterator Interface_Graph::Shareds
(const Handle(Standard_Transient)& ent) const
{
Standard_Integer num = EntityNumber(ent);
if (num == 0) Standard_DomainError::Raise ("Interface : Shareds");
Interface_EntityIterator iter; Interface_EntityIterator iter;
Interface_IntList list = thesharnews; Standard_Integer num = EntityNumber(ent);
if (!list.IsRedefined(num)) list = theshareds; if(!num)
list.SetNumber (num); return iter;
Standard_Integer nb = list.Length();
for (Standard_Integer i = 1; i <= nb; i ++) Handle(Standard_Transient) aCurEnt = ent;
iter.GetOneItem (themodel->Value (list.Value(i) )); if (themodel->IsRedefinedContent(num))
aCurEnt = themodel->ReportEntity(num)->Content();
//if (num == 0) Standard_DomainError::Raise ("Interface : Shareds");
Handle(Interface_GeneralModule) module;
Standard_Integer CN;
if (themodel->GTool()->Select(aCurEnt,module,CN))
module->FillShared(themodel,CN,aCurEnt,iter);
return iter; return iter;
} }
Interface_IntList Interface_Graph::SharedNums Handle(TColStd_HSequenceOfTransient) Interface_Graph::GetShareds(const Handle(Standard_Transient)& ent) const
(const Standard_Integer num) const
{ {
Interface_IntList list = thesharnews; Handle(TColStd_HSequenceOfTransient) aseq = new TColStd_HSequenceOfTransient;
if (!list.IsRedefined(num)) list = theshareds; Interface_EntityIterator iter = Shareds(ent);
list.SetNumber (num); for( ; iter.More(); iter.Next())
return list; aseq->Append(iter.Value());
return aseq;
} }
Interface_EntityIterator Interface_Graph::Sharings Handle(TColStd_HSequenceOfTransient) Interface_Graph::GetSharings(const Handle(Standard_Transient)& ent) const
(const Handle(Standard_Transient)& ent) const
{ {
Standard_Integer num = EntityNumber(ent); Standard_Integer num = EntityNumber(ent);
if (num == 0) Standard_DomainError::Raise ("Interface : Sharings"); if(!num)
return 0;
Interface_EntityIterator iter; //return Handle(TColStd_HSequenceOfTransient)::DownCast(thesharings->Value(num));
Interface_IntList list = thesharings; list.SetNumber (num); const TColStd_ListOfInteger& alist = thesharings->Value(num);
Standard_Integer nb = list.Length(); Handle(TColStd_HSequenceOfTransient) aSharings = new TColStd_HSequenceOfTransient;
for (Standard_Integer i = 1; i <= nb; i ++) TColStd_ListIteratorOfListOfInteger aIt(alist);
iter.GetOneItem (themodel->Value(list.Value(i))); for( ; aIt.More() ; aIt.Next())
return iter; aSharings->Append(Entity(aIt.Value()));
return aSharings;
} }
Interface_IntList Interface_Graph::SharingNums Interface_EntityIterator Interface_Graph::Sharings
(const Standard_Integer num) const (const Handle(Standard_Transient)& ent) const
{ {
Interface_IntList list = thesharings; Interface_EntityIterator iter;
if (num > 0) list.SetNumber (num); iter.AddList(GetSharings(ent));
return list; return iter;
}
}
static void AddTypedSharings static void AddTypedSharings
(const Handle(Standard_Transient)& ent, const Handle(Standard_Type)& type, (const Handle(Standard_Transient)& ent, const Handle(Standard_Type)& type,
Interface_EntityIterator& iter, const Standard_Integer n, Interface_EntityIterator& iter, const Standard_Integer n,
const Interface_Graph& G) const Interface_Graph& G)
{ {
if (ent.IsNull()) return; if (ent.IsNull()) return;
if (ent->IsKind(type)) { iter.AddItem (ent); return; } if (ent->IsKind(type)) { iter.AddItem (ent); return; }
if (iter.NbEntities() > n) return; if (iter.NbEntities() > n) return;
Interface_IntList list = G.SharingNums(G.EntityNumber(ent)); Handle(TColStd_HSequenceOfTransient) list = G.GetSharings(ent);
Standard_Integer nb = list.Length(); if(list.IsNull())
return;
Standard_Integer nb = list->Length();
for (Standard_Integer i = 1; i <= nb; i ++) for (Standard_Integer i = 1; i <= nb; i ++)
AddTypedSharings (G.Entity(list.Value(i)) ,type,iter,nb,G); AddTypedSharings (list->Value(i) ,type,iter,nb,G);
} }
Interface_EntityIterator Interface_Graph::TypedSharings Interface_EntityIterator Interface_Graph::TypedSharings
(const Handle(Standard_Transient)& ent, const Handle(Standard_Type)& type) const (const Handle(Standard_Transient)& ent, const Handle(Standard_Type)& type) const
{ {
Interface_EntityIterator iter; Interface_EntityIterator iter;
Standard_Integer n = Size(); Standard_Integer n = Size();
@ -493,188 +457,19 @@ static void AddTypedSharings
} }
Interface_EntityIterator Interface_Graph::RootEntities () const Interface_EntityIterator Interface_Graph::RootEntities () const
{ {
Interface_EntityIterator iter; Interface_EntityIterator iter;
Standard_Integer nb = Size(); Standard_Integer nb = thesharings->Length();
Interface_IntList list (thesharings);
for (Standard_Integer i = 1; i <= nb; i ++) { for (Standard_Integer i = 1; i <= nb; i ++) {
list.SetNumber (i); if(!thesharings->Value(i).IsEmpty())
if (list.Length() == 0) iter.GetOneItem (themodel->Value(i)); continue;
iter.AddItem(Entity(i));
} }
return iter; return iter;
} }
Handle(TCollection_HAsciiString) Interface_Graph::Name(const Handle(Standard_Transient)& ent) const
// ######################################################################
// .... Redefinition des listes Shared-Sharing ....
void Interface_Graph::SetShare
(const Handle(Standard_Transient)& ent)
{
Standard_Integer num = EntityNumber(ent);
if (num == 0) return;
SetShare (ent,SharedNums(num));
}
void Interface_Graph::SetShare
(const Handle(Standard_Transient)& ent,
const Interface_EntityIterator& list)
{
if(!thesharnews.NbEntities())
thesharnews.Initialize(themodel->NbEntities());
Standard_Integer num = EntityNumber(ent);
if (num == 0) return;
thesharnews.SetNumber (num);
thesharnews.SetRedefined (Standard_True);
thesharnews.Reservate (list.NbEntities());
for (list.Start(); list.More(); list.Next()) {
Standard_Integer nsh = EntityNumber(list.Value());
if (nsh != 0) thesharnews.Add (nsh);
}
}
void Interface_Graph::SetShare
(const Handle(Standard_Transient)& ent, const Interface_IntList& list)
{
Standard_Integer num = EntityNumber(ent);
if (num == 0) return;
if(!thesharnews.NbEntities())
thesharnews.Initialize(themodel->NbEntities());
Standard_Integer i, n = list.Length();
thesharnews.SetNumber (num);
thesharnews.SetRedefined (Standard_True);
thesharnews.Reservate (n);
for (i = 1; i <= n; i ++) {
Standard_Integer nsh = list.Value(i);
if (nsh != 0) thesharnews.Add (nsh);
}
}
void Interface_Graph::SetNoShare
(const Handle(Standard_Transient)& ent)
{
Standard_Integer num = EntityNumber(ent);
if (num == 0) return;
if(!thesharnews.NbEntities()) return;
thesharnews.SetNumber (num);
thesharnews.SetRedefined (Standard_False);
}
void Interface_Graph::SetNoShare (const Interface_EntityIterator& list)
{
for (list.Start(); list.More(); list.Next()) SetNoShare(list.Value());
}
void Interface_Graph::AddShared
(const Handle(Standard_Transient)& ent,
const Handle(Standard_Transient)& shared)
{
//Standard_Integer i, nb; svv Feb21 2000 : porting on SIL
Standard_Integer num = EntityNumber(ent);
Standard_Integer nsh = EntityNumber(shared);
if (!thesharnews.IsRedefined(num) || num == 0 || nsh == 0) Standard_DomainError::Raise
("Interface Graph : AddShared, cannot be applied");
if(!thesharnews.NbEntities())
thesharnews.Initialize(themodel->NbEntities());
// Liste Shared(ent)
thesharnews.SetNumber (num);
thesharnews.Reservate (thesharnews.Length()+1);
thesharnews.Add (nsh);
// Liste Sharing(shared)
thesharings.SetNumber (nsh);
thesharings.Reservate (thesharings.Length()+1);
thesharings.Add (num);
}
void Interface_Graph::RemoveShared
(const Handle(Standard_Transient)& ent,
const Handle(Standard_Transient)& shared)
{
Standard_Integer num = EntityNumber(ent);
Standard_Integer nsh = EntityNumber(shared);
if (!thesharnews.IsRedefined(num) || num == 0 || nsh == 0) Standard_DomainError::Raise
("Interface Graph : RemoveShared, cannot be applied");
// Liste Shared (ent)
if(!thesharnews.NbEntities())
thesharnews.Initialize(themodel->NbEntities());
thesharnews.SetNumber (num);
Standard_Integer i,nbsh = thesharnews.Length();
for (i = nbsh; i > 0; i --)
if (thesharnews.Value(i) == nsh) thesharnews.Remove(i);
// Liste Sharing (shared)
thesharings.SetNumber (nsh);
nbsh = thesharings.Length();
for (i = nbsh; i > 0; i --)
if (thesharings.Value(i) == num) thesharings.Remove(i);
}
void Interface_Graph::ResetShare
(const Handle(Standard_Transient)& ent)
{
Standard_Integer num = EntityNumber(ent);
if (num == 0) return;
Interface_IntList snew(thesharnews);
if (!thesharnews.NbEntities() || !snew.IsRedefined(num)) return;
snew.SetNumber (num);
Interface_IntList sold(theshareds);
sold.SetNumber (num);
// Attention aux Sharings ... Il va falloir ajouter, supprimer ... laisser !
// Tableau // Entites : 0 hors jeu 1 reapparait 2 disparait 3 reste
Standard_Integer n = Size();
TColStd_Array1OfInteger oldnew(1,n); oldnew.Init(0);
Standard_Integer ns = sold.Length();
Standard_Integer i; // svv Jan11 2000 : porting on DEC
for (i = 1; i <= ns; i ++)
oldnew.SetValue(sold.Value(i),1); // pourra passer en 3 plus tard ...
ns = snew.Length();
for (i = 1; i <= ns; i ++) {
Standard_Integer oldstat = oldnew.Value(snew.Value(i));
oldnew.SetValue(snew.Value(i),oldstat+2); // 0 -> 2, 1 -> 3
}
// Muni de ces donnees, on pourra modifier les listes Sharings impliquees
for (i = 1; i <= n; i ++) {
Standard_Integer oldstat = oldnew.Value(snew.Value(i));
if (oldstat == 0 || oldstat == 2) continue;
thesharings.SetNumber(i);
if (oldstat == 1) {
thesharings.Reservate (thesharings.Length()+1);
thesharings.Add (num);
} else if (oldstat == 3) {
Standard_Integer j,nbsh = thesharings.Length();
for (j = nbsh; j > 0; j --)
if (thesharings.Value(j) == num) thesharings.Remove(j);
}
}
// Shared : beaucoup plus simple, ANNULER Redefined
thesharnews.SetRedefined (Standard_False);
}
void Interface_Graph::ResetAllShare ()
{
thesharnews.Clear();
EvalSharings();
}
Handle(TCollection_HAsciiString) Interface_Graph::Name
(const Handle(Standard_Transient)& ent) const
{ {
Handle(TCollection_HAsciiString) str; Handle(TCollection_HAsciiString) str;
if (themodel.IsNull()) return str; if (themodel.IsNull()) return str;
@ -690,3 +485,8 @@ static void AddTypedSharings
Interface_ShareTool sht (*this); Interface_ShareTool sht (*this);
return module->Name (CN,ent,sht); return module->Name (CN,ent,sht);
} }
Standard_Boolean Interface_Graph::ModeStat() const
{
return (!thestats.IsNull());
}

View File

@ -17,14 +17,13 @@
Interface_GraphContent::Interface_GraphContent Interface_GraphContent::Interface_GraphContent
(const Interface_Graph& agraph, const Handle(Standard_Transient)& ent) (const Interface_Graph& agraph, const Handle(Standard_Transient)& ent)
{ {
Interface_IntList list = Interface_EntityIterator list = agraph.Shareds(ent);
agraph.SharedNums(agraph.EntityNumber(ent)); Standard_Integer nb = list.NbEntities();
Standard_Integer nb = list.Length();
if (nb == 0) return; // Liste redefinie a VIDE if (nb == 0) return; // Liste redefinie a VIDE
Handle(Interface_InterfaceModel) mod = agraph.Model(); for( ; list.More(); list.Next()) {
for (Standard_Integer i = 1; i <= nb; i ++) { Handle(Standard_Transient) curent = list.Value();
Standard_Integer num = list.Value(i); if (agraph.IsPresent(agraph.EntityNumber(curent)))
if (agraph.IsPresent(num)) GetOneItem (agraph.Entity(num)); GetOneItem (curent);
} }
} }

View File

@ -21,20 +21,24 @@ is
---Purpose : Creates an HGraph directly from a Graph. ---Purpose : Creates an HGraph directly from a Graph.
-- Remark that the starting Graph is duplicated -- Remark that the starting Graph is duplicated
Create (amodel : InterfaceModel; lib : GeneralLib) returns mutable HGraph; Create (amodel : InterfaceModel; lib : GeneralLib;
theModeStats : Boolean = Standard_True) returns mutable HGraph;
---Purpose : Creates an HGraph with a Graph created from <amodel> and <lib> ---Purpose : Creates an HGraph with a Graph created from <amodel> and <lib>
Create (amodel : InterfaceModel; protocol : Protocol from Interface) Create (amodel : InterfaceModel; protocol : Protocol from Interface;
theModeStats : Boolean = Standard_True)
returns mutable HGraph; returns mutable HGraph;
---Purpose : Creates an HGraph with a graph itself created from <amodel> ---Purpose : Creates an HGraph with a graph itself created from <amodel>
-- and <protocol> -- and <protocol>
Create (amodel : InterfaceModel; gtool : GTool from Interface) Create (amodel : InterfaceModel; gtool : GTool from Interface;
theModeStats : Boolean = Standard_True)
returns mutable HGraph; returns mutable HGraph;
---Purpose : Creates an HGraph with a graph itself created from <amodel> ---Purpose : Creates an HGraph with a graph itself created from <amodel>
-- and <protocol> -- and <protocol>
Create (amodel : InterfaceModel) returns mutable HGraph Create (amodel : InterfaceModel;
theModeStats : Boolean = Standard_True) returns mutable HGraph
---Purpose : Same a above, but works with the GTool in the model ---Purpose : Same a above, but works with the GTool in the model
raises DomainError; raises DomainError;
-- Error if no Active Protocol is defined -- Error if no Active Protocol is defined

View File

@ -1,32 +1,35 @@
#include <Interface_HGraph.ixx> #include <Interface_HGraph.ixx>
Interface_HGraph::Interface_HGraph (const Interface_Graph& agraph)
Interface_HGraph::Interface_HGraph (const Interface_Graph& agraph)
: thegraph(agraph) { } : thegraph(agraph) { }
Interface_HGraph::Interface_HGraph Interface_HGraph::Interface_HGraph
(const Handle(Interface_InterfaceModel)& amodel, (const Handle(Interface_InterfaceModel)& amodel,
const Interface_GeneralLib& lib) const Interface_GeneralLib& lib,
: thegraph (amodel,lib) { } const Standard_Boolean theModeStat)
: thegraph (amodel,lib,theModeStat) { }
Interface_HGraph::Interface_HGraph Interface_HGraph::Interface_HGraph
(const Handle(Interface_InterfaceModel)& amodel, (const Handle(Interface_InterfaceModel)& amodel,
const Handle(Interface_Protocol)& protocol) const Handle(Interface_Protocol)& protocol,
: thegraph (amodel,protocol) { } const Standard_Boolean theModeStat)
: thegraph (amodel,protocol,theModeStat) { }
Interface_HGraph::Interface_HGraph Interface_HGraph::Interface_HGraph
(const Handle(Interface_InterfaceModel)& amodel, (const Handle(Interface_InterfaceModel)& amodel,
const Handle(Interface_GTool)& gtool) const Handle(Interface_GTool)& gtool,
: thegraph (amodel,gtool) { } const Standard_Boolean theModeStat)
: thegraph (amodel,gtool,theModeStat) { }
Interface_HGraph::Interface_HGraph Interface_HGraph::Interface_HGraph
(const Handle(Interface_InterfaceModel)& amodel) (const Handle(Interface_InterfaceModel)& amodel,
: thegraph (amodel) { } const Standard_Boolean theModeStat)
: thegraph (amodel,theModeStat) { }
const Interface_Graph& Interface_HGraph::Graph () const const Interface_Graph& Interface_HGraph::Graph () const

View File

@ -46,19 +46,21 @@
} }
Interface_ShareFlags::Interface_ShareFlags (const Interface_Graph& agraph) Interface_ShareFlags::Interface_ShareFlags (const Interface_Graph& agraph)
: theflags (agraph.Model()->NbEntities()) : theflags (agraph.Model()->NbEntities())
{ {
themodel = agraph.Model(); themodel = agraph.Model();
Standard_Integer nb = themodel->NbEntities(); Standard_Integer nb = themodel->NbEntities();
if (nb == 0) return; if (nb == 0) return;
theroots = new TColStd_HSequenceOfTransient(); theroots = new TColStd_HSequenceOfTransient();
for (Standard_Integer i = 1; i <= nb; i ++) { for (Standard_Integer i = 1; i <= nb; i ++) {
// Resultat obtenu depuis le Graph // Resultat obtenu depuis le Graph
Interface_IntList list = agraph.SharingNums(i); Handle(Standard_Transient) ent = themodel->Value(i);
if (list.Length() > 0) theflags.SetTrue(i); Handle(TColStd_HSequenceOfTransient) list = agraph.GetSharings(ent);
else theroots->Append (themodel->Value(i));
} if (!list.IsNull() && list->Length() > 0) theflags.SetTrue(i);
} else theroots->Append (ent);
}
}
void Interface_ShareFlags::Evaluate void Interface_ShareFlags::Evaluate

View File

@ -46,7 +46,7 @@ is
Create (ahgraph : HGraph) returns ShareTool; Create (ahgraph : HGraph) returns ShareTool;
AddImplied (me : in out; gtool : GTool from Interface); --AddImplied (me : in out; gtool : GTool from Interface);
---Purpose : Completes the Graph by Adding Implied References. Hence, they ---Purpose : Completes the Graph by Adding Implied References. Hence, they
-- are considered as Sharing References in all the other queries -- are considered as Sharing References in all the other queries

View File

@ -31,15 +31,16 @@ Interface_ShareTool::Interface_ShareTool (const Handle(Interface_InterfaceModel)
Interface_ShareTool::Interface_ShareTool (const Interface_Graph& agraph) Interface_ShareTool::Interface_ShareTool (const Interface_Graph& agraph)
{ {
theHGraph = new Interface_HGraph(agraph); theHGraph = new Interface_HGraph(agraph.Model());
} }
Interface_ShareTool::Interface_ShareTool (const Handle(Interface_HGraph)& ahgraph) Interface_ShareTool::Interface_ShareTool (const Handle(Interface_HGraph)& ahgraph)
: theHGraph(ahgraph) {
{} theHGraph = ahgraph;
}
// Ajout des "Implied" sur toutes les Entites du Graphe // Ajout des "Implied" sur toutes les Entites du Graphe
void Interface_ShareTool::AddImplied (const Handle(Interface_GTool)& gtool) /*void Interface_ShareTool::AddImplied (const Handle(Interface_GTool)& gtool)
{ {
Interface_Graph& thegraph = theHGraph->CGraph(); Interface_Graph& thegraph = theHGraph->CGraph();
Standard_Integer nb = thegraph.Size(); Standard_Integer nb = thegraph.Size();
@ -59,7 +60,7 @@ void Interface_ShareTool::AddImplied (const Handle(Interface_GTool)& gtool)
} }
} }
if (yena) thegraph.EvalSharings(); if (yena) thegraph.EvalSharings();
} }*/
Handle(Interface_InterfaceModel) Interface_ShareTool::Model () const Handle(Interface_InterfaceModel) Interface_ShareTool::Model () const
@ -75,9 +76,9 @@ void Interface_ShareTool::AddImplied (const Handle(Interface_GTool)& gtool)
(const Handle(Standard_Transient)& ent) const (const Handle(Standard_Transient)& ent) const
{ {
const Interface_Graph& thegraph = theHGraph->Graph(); const Interface_Graph& thegraph = theHGraph->Graph();
Interface_IntList list = Handle(TColStd_HSequenceOfTransient) list =
thegraph.SharingNums (thegraph.EntityNumber(ent)); thegraph.GetShareds (ent);
return (list.Length() > 0); return (!list.IsNull() && list->Length() > 0);
} }
Interface_EntityIterator Interface_ShareTool::Shareds Interface_EntityIterator Interface_ShareTool::Shareds
@ -94,12 +95,14 @@ void Interface_ShareTool::AddImplied (const Handle(Interface_GTool)& gtool)
const Handle(Standard_Type)& atype) const const Handle(Standard_Type)& atype) const
{ {
Interface_Graph& thegraph = theHGraph->CGraph(); Interface_Graph& thegraph = theHGraph->CGraph();
Interface_IntList list = Handle(TColStd_HSequenceOfTransient) list = thegraph.GetSharings (ent);
thegraph.SharingNums (thegraph.EntityNumber(ent)); if(list.IsNull())
return 0;
Standard_Integer result = 0; Standard_Integer result = 0;
Standard_Integer n = list.Length(); Standard_Integer n = list->Length();
for (Standard_Integer i = 1; i <= n; i ++) { for (Standard_Integer i = 1; i <= n; i ++) {
Handle(Standard_Transient) entsh = thegraph.Entity(list.Value(i)); Handle(Standard_Transient) entsh = list->Value(i);
if (entsh.IsNull()) continue; if (entsh.IsNull()) continue;
if (entsh->IsKind(atype)) result ++; if (entsh->IsKind(atype)) result ++;
} }
@ -111,13 +114,14 @@ void Interface_ShareTool::AddImplied (const Handle(Interface_GTool)& gtool)
const Handle(Standard_Type)& atype) const const Handle(Standard_Type)& atype) const
{ {
Interface_Graph& thegraph = theHGraph->CGraph(); Interface_Graph& thegraph = theHGraph->CGraph();
Interface_IntList list = Handle(TColStd_HSequenceOfTransient) list = thegraph.GetSharings(ent);
thegraph.SharingNums (thegraph.EntityNumber(ent)); if(list.IsNull())
return 0;
Handle(Standard_Transient) entresult; Handle(Standard_Transient) entresult;
Standard_Integer result = 0; Standard_Integer result = 0;
Standard_Integer n = list.Length(); Standard_Integer n = list->Length();
for (Standard_Integer i = 1; i <= n; i ++) { for (Standard_Integer i = 1; i <= n; i ++) {
Handle(Standard_Transient) entsh = thegraph.Entity(list.Value(i)); Handle(Standard_Transient) entsh = list->Value(i);
if (entsh.IsNull()) continue; if (entsh.IsNull()) continue;
if (entsh->IsKind(atype)) { if (entsh->IsKind(atype)) {
entresult = entsh; entresult = entsh;

View File

@ -13,7 +13,7 @@ class StepModel from StepData inherits InterfaceModel
uses Type, HAsciiString from TCollection, uses Type, HAsciiString from TCollection,
Messenger from Message, Messenger from Message,
DataMapOfTransientInteger, HArray1OfInteger from TColStd,
EntityList, EntityIterator, Check EntityList, EntityIterator, Check
raises NoSuchObject raises NoSuchObject
@ -22,8 +22,6 @@ is
Create returns mutable StepModel; Create returns mutable StepModel;
---Purpose: Creates an empty STEP model with an empty header. ---Purpose: Creates an empty STEP model with an empty header.
Reservate (me : mutable; nbent : Integer) is redefined;
---Purpose : The standard reservation is completed for the map (id-num)
Entity (me; num : Integer) returns Transient; Entity (me; num : Integer) returns Transient;
---Purpose : returns entity given its rank. ---Purpose : returns entity given its rank.
@ -87,6 +85,6 @@ is
fields fields
theheader : EntityList; theheader : EntityList;
theidnums : DataMapOfTransientInteger; theidnums : HArray1OfInteger from TColStd;
end StepModel; end StepModel;

View File

@ -14,26 +14,21 @@
// Entete de fichier : liste d entites // Entete de fichier : liste d entites
StepData_StepModel::StepData_StepModel () { } StepData_StepModel::StepData_StepModel () { }
void StepData_StepModel::Reservate (const Standard_Integer nbent)
{
Interface_InterfaceModel::Reservate(nbent);
if (nbent > theidnums.NbBuckets()) theidnums.ReSize (nbent);
}
Handle(Standard_Transient) StepData_StepModel::Entity Handle(Standard_Transient) StepData_StepModel::Entity
(const Standard_Integer num) const (const Standard_Integer num) const
{ return Value(num); } // nom plus joli { return Value(num); } // nom plus joli
void StepData_StepModel::GetFromAnother void StepData_StepModel::GetFromAnother
(const Handle(Interface_InterfaceModel)& other) (const Handle(Interface_InterfaceModel)& other)
{ {
theheader.Clear(); theheader.Clear();
DeclareAndCast(StepData_StepModel,another,other); DeclareAndCast(StepData_StepModel,another,other);
if (another.IsNull()) return; if (another.IsNull()) return;
Interface_EntityIterator iter = another->Header(); Interface_EntityIterator iter = another->Header();
// recopier le header. Attention, header distinct du contenu ... // recopier le header. Attention, header distinct du contenu ...
Interface_CopyTool TC (this,StepData::HeaderProtocol()); Interface_CopyTool TC (this,StepData::HeaderProtocol());
for (; iter.More(); iter.Next()) { for (; iter.More(); iter.Next()) {
Handle(Standard_Transient) newhead; Handle(Standard_Transient) newhead;
@ -42,35 +37,35 @@
} }
} }
Handle(Interface_InterfaceModel) StepData_StepModel::NewEmptyModel () const Handle(Interface_InterfaceModel) StepData_StepModel::NewEmptyModel () const
{ return new StepData_StepModel; } { return new StepData_StepModel; }
Interface_EntityIterator StepData_StepModel::Header () const Interface_EntityIterator StepData_StepModel::Header () const
{ {
Interface_EntityIterator iter; Interface_EntityIterator iter;
theheader.FillIterator(iter); theheader.FillIterator(iter);
return iter; return iter;
} }
Standard_Boolean StepData_StepModel::HasHeaderEntity Standard_Boolean StepData_StepModel::HasHeaderEntity
(const Handle(Standard_Type)& atype) const (const Handle(Standard_Type)& atype) const
{ return (theheader.NbTypedEntities(atype) == 1); } { return (theheader.NbTypedEntities(atype) == 1); }
Handle(Standard_Transient) StepData_StepModel::HeaderEntity Handle(Standard_Transient) StepData_StepModel::HeaderEntity
(const Handle(Standard_Type)& atype) const (const Handle(Standard_Type)& atype) const
{ return theheader.TypedEntity(atype); } { return theheader.TypedEntity(atype); }
// Remplissage du Header // Remplissage du Header
void StepData_StepModel::ClearHeader () void StepData_StepModel::ClearHeader ()
{ theheader.Clear(); } { theheader.Clear(); }
void StepData_StepModel::AddHeaderEntity void StepData_StepModel::AddHeaderEntity
(const Handle(Standard_Transient)& ent) (const Handle(Standard_Transient)& ent)
{ theheader.Append(ent); } { theheader.Append(ent); }
void StepData_StepModel::VerifyCheck(Handle(Interface_Check)& ach) const void StepData_StepModel::VerifyCheck(Handle(Interface_Check)& ach) const
@ -86,10 +81,10 @@ void StepData_StepModel::VerifyCheck(Handle(Interface_Check)& ach) const
} }
void StepData_StepModel::DumpHeader void StepData_StepModel::DumpHeader
(const Handle(Message_Messenger)& S, const Standard_Integer /*level*/) const (const Handle(Message_Messenger)& S, const Standard_Integer /*level*/) const
{ {
// NB : level n est pas utilise // NB : level n est pas utilise
Handle(StepData_Protocol) stepro = StepData::HeaderProtocol(); Handle(StepData_Protocol) stepro = StepData::HeaderProtocol();
Standard_Boolean iapro = !stepro.IsNull(); Standard_Boolean iapro = !stepro.IsNull();
@ -114,45 +109,50 @@ void StepData_StepModel::VerifyCheck(Handle(Interface_Check)& ach) const
} }
void StepData_StepModel::ClearLabels () void StepData_StepModel::ClearLabels ()
{ theidnums.Clear(); } { theidnums.Nullify(); }
void StepData_StepModel::SetIdentLabel void StepData_StepModel::SetIdentLabel
(const Handle(Standard_Transient)& ent, const Standard_Integer ident) (const Handle(Standard_Transient)& ent, const Standard_Integer ident)
{ {
if (Number(ent) == 0) return; Standard_Integer num = Number(ent);
if (theidnums.NbBuckets() < NbEntities()) theidnums.ReSize (NbEntities()); if (!num)
if (theidnums.IsBound(ent)) theidnums.ChangeFind(ent) = ident; return;
else theidnums.Bind (ent,ident); if(theidnums.IsNull())
{
theidnums = new TColStd_HArray1OfInteger(1, NbEntities());
theidnums->Init(0);
}
theidnums->SetValue(num,ident);
} }
Standard_Integer StepData_StepModel::IdentLabel Standard_Integer StepData_StepModel::IdentLabel
(const Handle(Standard_Transient)& ent) const (const Handle(Standard_Transient)& ent) const
{ {
if (theidnums.IsBound(ent)) return theidnums.Find(ent); if(theidnums.IsNull())
return 0; return 0;
} Standard_Integer num = Number(ent);
return (!num ? 0 : theidnums->Value(num));
}
void StepData_StepModel::PrintLabel void StepData_StepModel::PrintLabel
(const Handle(Standard_Transient)& ent, const Handle(Message_Messenger)& S) const (const Handle(Standard_Transient)& ent, const Handle(Message_Messenger)& S) const
{ {
Standard_Integer num = 0 , nid = 0; Standard_Integer num = (theidnums.IsNull() ? 0 : Number(ent));
if (theidnums.IsBound(ent)) nid = theidnums.Find(ent); Standard_Integer nid = (!num ? 0 : theidnums->Value(num));
if (nid <= 0) num = Number(ent);
if (nid > 0) S<<"#"<<nid; if (nid > 0) S<<"#"<<nid;
else if (num > 0) S<<"(#"<<num<<")"; else if (num > 0) S<<"(#"<<num<<")";
else S<<"(#0..)"; else S<<"(#0..)";
} }
Handle(TCollection_HAsciiString) StepData_StepModel::StringLabel Handle(TCollection_HAsciiString) StepData_StepModel::StringLabel
(const Handle(Standard_Transient)& ent) const (const Handle(Standard_Transient)& ent) const
{ {
Handle(TCollection_HAsciiString) label; Handle(TCollection_HAsciiString) label;
char text[20]; char text[20];
Standard_Integer num = 0 , nid = 0; Standard_Integer num = (theidnums.IsNull() ? 0 : Number(ent));
if (theidnums.IsBound(ent)) nid = theidnums.Find(ent); Standard_Integer nid = (!num ? 0 : theidnums->Value(num));
if (nid <= 0) num = Number(ent);
if (nid > 0) sprintf (text, "#%d",nid); if (nid > 0) sprintf (text, "#%d",nid);
else if (num > 0) sprintf (text, "(#%d)",num); else if (num > 0) sprintf (text, "(#%d)",num);

View File

@ -190,6 +190,7 @@ Standard_Integer StepFile_Read
readtool.PrepareHeader(recoheader); // Header. reco nul -> pour Protocol readtool.PrepareHeader(recoheader); // Header. reco nul -> pour Protocol
readtool.Prepare(recodata); // Data. reco nul -> pour Protocol readtool.Prepare(recodata); // Data. reco nul -> pour Protocol
#ifdef CHRONOMESURE #ifdef CHRONOMESURE
sout << " ... Parameters prepared ... "; sout << " ... Parameters prepared ... ";
c.Show(); c.Show();
@ -198,6 +199,9 @@ Standard_Integer StepFile_Read
readtool.LoadModel(stepmodel); readtool.LoadModel(stepmodel);
if (stepmodel->Protocol().IsNull()) stepmodel->SetProtocol (protocol); if (stepmodel->Protocol().IsNull()) stepmodel->SetProtocol (protocol);
lir_file_fin(2); lir_file_fin(2);
readtool.Clear();
undirec.Nullify();
#ifdef CHRONOMESURE #ifdef CHRONOMESURE
sout << " ... Objets analysed ... " << endl; sout << " ... Objets analysed ... " << endl;
c.Show(); c.Show();

View File

@ -45,6 +45,8 @@ void Transfer_TransientProcess::SetGraph(const Handle(Interface_HGraph)& HG)
thegraph = HG; thegraph = HG;
if (!thegraph.IsNull()) if (!thegraph.IsNull())
SetModel(thegraph->Graph().Model()); SetModel(thegraph->Graph().Model());
else
themodel.Nullify();
} }

View File

@ -40,19 +40,6 @@
#include <ShapeFix.hxx> #include <ShapeFix.hxx>
#include <stdio.h> #include <stdio.h>
/*
#ifdef DEB
static void monDBPE
(const Handle(Message_Messenger)& S, const Handle(Standard_Transient)& ent, const Handle(Standard_Transient)& context)
{
if (ent.IsNull()) { S<<"(null)"; return; }
DeclareAndCast(Interface_InterfaceModel,model,context);
if (model.IsNull()) { S<<ent->DynamicType()->Name(); return; }
model->Print (ent,S);
S<<" "<<model->TypeName(ent,Standard_False);
}
#endif
*/
//======================================================================= //=======================================================================
//function : XSControl_TransferReader //function : XSControl_TransferReader
@ -121,9 +108,15 @@ void XSControl_TransferReader::SetModel(const Handle(Interface_InterfaceModel)&
void XSControl_TransferReader::SetGraph(const Handle(Interface_HGraph)& graph) void XSControl_TransferReader::SetGraph(const Handle(Interface_HGraph)& graph)
{ {
if (graph.IsNull()) return; if (graph.IsNull())
{
theModel.Nullify();
}
else
theModel = graph->Graph().Model();
theGraph = graph; theGraph = graph;
theModel = graph->Graph().Model();
if (!theTransfer.IsNull()) theTransfer->SetGraph(graph); if (!theTransfer.IsNull()) theTransfer->SetGraph(graph);
} }
@ -221,7 +214,7 @@ void XSControl_TransferReader::Clear (const Standard_Integer mode)
theTransfer.Nullify(); theTransfer.Nullify();
theActor.Nullify(); theActor.Nullify();
theFilename.Clear(); theFilename.Clear();
} // theContext.Nullify(); }
} }
@ -869,8 +862,6 @@ Standard_Integer XSControl_TransferReader::TransferOne
Handle(Message_Messenger) sout = theTransfer->Messenger(); Handle(Message_Messenger) sout = theTransfer->Messenger();
Standard_Integer level = theTransfer->TraceLevel(); Standard_Integer level = theTransfer->TraceLevel();
//BRepBuilderAPI::Precision (Interface_Static::RVal("read.precision.val")); //szv#11:CASCADE30:01Feb00
//Interface_Static::SetRVal("lastpreci",0.0);
Transfer_TransferOutput TP (theTransfer,theModel); Transfer_TransferOutput TP (theTransfer,theModel);
if (theGraph.IsNull()) theTransfer->SetModel(theModel); if (theGraph.IsNull()) theTransfer->SetModel(theModel);
@ -925,8 +916,6 @@ Standard_Integer XSControl_TransferReader::TransferList
Handle(Message_Messenger) sout = theTransfer->Messenger(); Handle(Message_Messenger) sout = theTransfer->Messenger();
Standard_Integer level = theTransfer->TraceLevel(); Standard_Integer level = theTransfer->TraceLevel();
//BRepBuilderAPI::Precision (Interface_Static::RVal("read.precision.val")); //szv#11:CASCADE30:01Feb00
//Interface_Static::SetRVal("lastpreci",0.0);
Transfer_TransferOutput TP (theTransfer,theModel); Transfer_TransferOutput TP (theTransfer,theModel);
if (theGraph.IsNull()) theTransfer->SetModel(theModel); if (theGraph.IsNull()) theTransfer->SetModel(theModel);
else theTransfer->SetGraph(theGraph); else theTransfer->SetGraph(theGraph);
@ -984,8 +973,6 @@ Standard_Integer XSControl_TransferReader::TransferRoots(const Interface_Graph&
Handle(Message_Messenger) sout = theTransfer->Messenger(); Handle(Message_Messenger) sout = theTransfer->Messenger();
Standard_Integer level = theTransfer->TraceLevel(); Standard_Integer level = theTransfer->TraceLevel();
//BRepBuilderAPI::Precision (Interface_Static::RVal("read.precision.val")); //szv#11:CASCADE30:01Feb00
//Interface_Static::SetRVal("lastpreci",0.0);
Transfer_TransferOutput TP (theTransfer,theModel); Transfer_TransferOutput TP (theTransfer,theModel);
if (theGraph.IsNull()) theTransfer->SetModel(theModel); if (theGraph.IsNull()) theTransfer->SetModel(theModel);
else theTransfer->SetGraph(theGraph); else theTransfer->SetGraph(theGraph);
@ -1035,15 +1022,9 @@ void XSControl_TransferReader::TransferClear(const Handle(Standard_Transient)& e
if (theTransfer.IsNull()) return; if (theTransfer.IsNull()) return;
if (ent == theModel) { theTransfer->Clear(); return; } if (ent == theModel) { theTransfer->Clear(); return; }
//// if (level > 0) list = TransferredList (list);
// Standard_Integer i, nb = list->Length();
// theTransfer->ComputeScopes();
// for (i = 1; i <= nb; i ++) {
// Handle(Standard_Transient) ent = list->Value(i);
// theTransfer->Unbind (ent);
theTransfer->RemoveResult (ent,level); theTransfer->RemoveResult (ent,level);
ClearResult (ent,-1); ClearResult (ent,-1);
// }
} }

View File

@ -282,32 +282,7 @@ Standard_Boolean XSControl_WorkSession::PrintTransferStatus(const Standard_Inte
binder = TP->MapItem (ne); binder = TP->MapItem (ne);
S<<endl; S<<endl;
TP->StartTrace (binder,ent,0,0); TP->StartTrace (binder,ent,0,0);
/*skl
if (!binder.IsNull()) {
// infos complementaires : cas et attributs
Standard_Integer icas, nbcas = binder->NbCases();
if (nbcas > 0) S<<"Recorded Cases : "<<nbcas<<" :";
for (icas = 1; icas <= nbcas; icas ++) S<<" "<<binder->CaseName(icas);
if (nbcas > 0) S<<endl;
Standard_Integer nbatr = 0;
Handle(Dico_DictionaryOfTransient) atrs = binder->AttrList();
Dico_IteratorOfDictionaryOfTransient iatr (atrs);
for (; iatr.More(); iatr.Next()) {
Handle(Standard_Transient) atr = iatr.Value();
if (atr.IsNull()) continue;
if (nbatr == 0) S<<"-- List of Attributes"<<endl;
nbatr ++;
S<<iatr.Name()<<" : ";
DeclareAndCast(Interface_IntVal,intatr,atr);
if (!intatr.IsNull()) S<<"Integer="<<intatr->Value();
DeclareAndCast(Geom2d_Point,realtr,atr);
if (!realtr.IsNull()) S<<"Real="<<realtr->X();
if (intatr.IsNull() && realtr.IsNull()) S<<"Type:"<<atr->DynamicType()->Name();
S<<endl;
}
if (nbatr > 0) S<<"-- Total of Attributes : "<<nbatr<<endl;
}
skl*/
} }
// *** CHECK (commun READ+WRITE) *** // *** CHECK (commun READ+WRITE) ***
@ -471,8 +446,6 @@ Handle(Standard_Transient) XSControl_WorkSession::Result
Standard_Integer XSControl_WorkSession::TransferReadOne Standard_Integer XSControl_WorkSession::TransferReadOne
(const Handle(Standard_Transient)& ent) (const Handle(Standard_Transient)& ent)
{ {
//Standard_OStream& sout = Interface_TraceFile::Def();
//Standard_Integer level = Interface_TraceFile::DefLevel();
Handle(Interface_InterfaceModel) model = Model(); Handle(Interface_InterfaceModel) model = Model();
if (ent == model) return TransferReadRoots(); if (ent == model) return TransferReadRoots();
@ -507,8 +480,14 @@ Handle(Interface_InterfaceModel) XSControl_WorkSession::NewModel ()
Handle(Interface_InterfaceModel) newmod; Handle(Interface_InterfaceModel) newmod;
if (theController.IsNull()) return newmod; if (theController.IsNull()) return newmod;
newmod = theController->NewModel(); newmod = theController->NewModel();
SetModel(newmod); SetModel(newmod);
if(!MapReader().IsNull())
MapReader()->Clear();
//clear all contains of WS
theTransferRead->Clear(3);
theTransferWrite->Clear(-1); theTransferWrite->Clear(-1);
return newmod; return newmod;
} }

View File

@ -85,6 +85,8 @@ static Standard_Integer igesbrep (Draw_Interpretor& di, Standard_Integer argc, c
progress->Show(); progress->Show();
IGESControl_Reader Reader (XSDRAW::Session(),Standard_False); IGESControl_Reader Reader (XSDRAW::Session(),Standard_False);
Standard_Boolean aFullMode = Standard_True;
Reader.WS()->SetModeStat(aFullMode);
if (ctl.IsNull()) if (ctl.IsNull())
ctl=Handle(IGESControl_Controller)::DownCast(XSDRAW::Controller()); ctl=Handle(IGESControl_Controller)::DownCast(XSDRAW::Controller());

View File

@ -81,10 +81,11 @@ void XSDRAWSTEP::Init ()
static Standard_Integer stepread (Draw_Interpretor& di/*theCommands*/, Standard_Integer argc, const char** argv) static Standard_Integer stepread (Draw_Interpretor& di/*theCommands*/, Standard_Integer argc, const char** argv)
{ {
// On admet le controller AP214 ou une variante // On admet le controller AP214 ou une variante
DeclareAndCast(STEPControl_Controller,ctl,XSDRAW::Controller()); DeclareAndCast(STEPControl_Controller,ctl,XSDRAW::Controller());
if (ctl.IsNull()) XSDRAW::SetNorm("STEP"); if (ctl.IsNull()) XSDRAW::SetNorm("STEP");
// Progress indicator // Progress indicator
Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 ); Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
progress->SetScale ( 0, 100, 1 ); progress->SetScale ( 0, 100, 1 );
@ -102,6 +103,35 @@ static Standard_Integer stepread (Draw_Interpretor& di/*theCommands*/, Standard_
progress->NewScope ( 20, "Loading" ); // On average loading takes 20% progress->NewScope ( 20, "Loading" ); // On average loading takes 20%
progress->Show(); progress->Show();
Standard_Boolean fromtcl = Standard_False;
Standard_Boolean aFullMode = 0;
Standard_Integer k = 3;
if(argc > k )
{
if(argv[k][0] == 'f' || argv[3][0] == 'F')
{
aFullMode = Standard_True;
k++;
}
else if(argv[k][0] == 'r' || argv[3][0] == 'R')
{
aFullMode = Standard_False;
k++;
}
else
fromtcl = Standard_True;
}
if(!fromtcl)
fromtcl = argc > k;
if(aFullMode)
cout<<"Full model for translation with additional info will be used \n"<<flush;
else
cout<<"Reduced model for translation without additional info will be used \n"<<flush;
sr.WS()->SetModeStat(aFullMode);
if (modfic) readstat = sr.ReadFile (fnom.ToCString()); if (modfic) readstat = sr.ReadFile (fnom.ToCString());
else if (XSDRAW::Session()->NbStartingEntities() > 0) readstat = IFSelect_RetDone; else if (XSDRAW::Session()->NbStartingEntities() > 0) readstat = IFSelect_RetDone;
@ -114,8 +144,8 @@ static Standard_Integer stepread (Draw_Interpretor& di/*theCommands*/, Standard_
return 1; return 1;
} }
Standard_Boolean fromtcl = (argc > 3);
// nom = "." -> fichier deja lu // nom = "." -> fichier deja lu
Standard_Integer i, num, nbs, modepri = 1; Standard_Integer i, num, nbs, modepri = 1;
if (fromtcl) modepri = 4; if (fromtcl) modepri = 4;
Handle(Message_Messenger) aDIMessenger = Handle(Message_Messenger) aDIMessenger =
@ -125,9 +155,9 @@ static Standard_Integer stepread (Draw_Interpretor& di/*theCommands*/, Standard_
if (!fromtcl) { if (!fromtcl) {
di<<"NbRootsForTransfer="<<num<<" :\n"; di<<"NbRootsForTransfer="<<num<<" :\n";
for (i = 1; i <= num; i ++) { for (i = 1; i <= num; i ++) {
di<<"Root."<<i<<", Ent. "; di<<"Root."<<i<<", Ent. ";
sr.Model()->Print(sr.RootForTransfer(i),aDIMessenger); sr.Model()->Print(sr.RootForTransfer(i),aDIMessenger);
di<<" Type:"<<sr.RootForTransfer(i)->DynamicType()->Name()<<"\n"; di<<" Type:"<<sr.RootForTransfer(i)->DynamicType()->Name()<<"\n";
} }
cout<<"Mode (0 End, 1 root n0 1, 2 one root/n0, 3 one entity/n0, 4 Selection) : "<<flush; cout<<"Mode (0 End, 1 root n0 1, 2 one root/n0, 3 one entity/n0, 4 Selection) : "<<flush;
@ -138,7 +168,7 @@ static Standard_Integer stepread (Draw_Interpretor& di/*theCommands*/, Standard_
if (modepri <= 2) { if (modepri <= 2) {
num = 1; num = 1;
if (modepri == 2) { if (modepri == 2) {
cout<<"Root N0 : "<<flush; cin>>num; cout<<"Root N0 : "<<flush; cin>>num;
} }
progress->NewScope ( 80, "Translation" ); progress->NewScope ( 80, "Translation" );
@ -147,12 +177,12 @@ static Standard_Integer stepread (Draw_Interpretor& di/*theCommands*/, Standard_
if (!sr.TransferRoot (num)) di<<"Transfer root n0 "<<num<<" : no result"<<"\n"; if (!sr.TransferRoot (num)) di<<"Transfer root n0 "<<num<<" : no result"<<"\n";
else { else {
nbs = sr.NbShapes(); nbs = sr.NbShapes();
char shname[30]; sprintf (shname,"%s_%d",rnom.ToCString(),nbs); char shname[30]; sprintf (shname,"%s_%d",rnom.ToCString(),nbs);
di<<"Transfer root n0 "<<num<<" OK -> DRAW Shape: "<<shname<<"\n"; di<<"Transfer root n0 "<<num<<" OK -> DRAW Shape: "<<shname<<"\n";
di<<"Now, "<<nbs<<" Shapes produced"<<"\n"; di<<"Now, "<<nbs<<" Shapes produced"<<"\n";
TopoDS_Shape sh = sr.Shape(nbs); TopoDS_Shape sh = sr.Shape(nbs);
DBRep::Set (shname,sh); DBRep::Set (shname,sh);
} }
sr.WS()->MapReader()->SetProgress ( 0 ); sr.WS()->MapReader()->SetProgress ( 0 );
@ -163,40 +193,40 @@ static Standard_Integer stepread (Draw_Interpretor& di/*theCommands*/, Standard_
cout<<"Entity : "<<flush; num = XSDRAW::GetEntityNumber(); cout<<"Entity : "<<flush; num = XSDRAW::GetEntityNumber();
if (!sr.TransferOne (num)) di<<"Transfer entity n0 "<<num<<" : no result"<<"\n"; if (!sr.TransferOne (num)) di<<"Transfer entity n0 "<<num<<" : no result"<<"\n";
else { else {
nbs = sr.NbShapes(); nbs = sr.NbShapes();
char shname[30]; sprintf (shname,"%s_%d",rnom.ToCString(),num); char shname[30]; sprintf (shname,"%s_%d",rnom.ToCString(),num);
di<<"Transfer entity n0 "<<num<<" OK -> DRAW Shape: "<<shname<<"\n"; di<<"Transfer entity n0 "<<num<<" OK -> DRAW Shape: "<<shname<<"\n";
di<<"Now, "<<nbs<<" Shapes produced"<<"\n"; di<<"Now, "<<nbs<<" Shapes produced"<<"\n";
TopoDS_Shape sh = sr.Shape(nbs); TopoDS_Shape sh = sr.Shape(nbs);
DBRep::Set (shname,sh); DBRep::Set (shname,sh);
} }
} }
else if (modepri == 4) { else if (modepri == 4) {
// char snm[100]; Standard_Integer answer = 1; // char snm[100]; Standard_Integer answer = 1;
Handle(TColStd_HSequenceOfTransient) list; Handle(TColStd_HSequenceOfTransient) list;
// Selection, nommee ou via tcl. tcl : raccourcis admis // Selection, nommee ou via tcl. tcl : raccourcis admis
// * donne xst-transferrable-roots // * donne xst-transferrable-roots
if (fromtcl) { if (fromtcl) {
modepri = 0; // d ioffice une seule passe modepri = 0; // d ioffice une seule passe
if (argv[3][0] == '*' && argv[3][1] == '\0') { if (argv[k][0] == '*' && argv[k][1] == '\0') {
di<<"Transferrable Roots : "; di<<"Transferrable Roots : ";
list = XSDRAW::GetList("xst-transferrable-roots"); list = XSDRAW::GetList("xst-transferrable-roots");
//list = new TColStd_HSequenceOfTransient; //list = new TColStd_HSequenceOfTransient;
//for(Standard_Integer j=1; j<=num; j++) //for(Standard_Integer j=1; j<=num; j++)
// list->Append(sr.RootForTransfer(j)); // list->Append(sr.RootForTransfer(j));
} }
else { else {
di<<"List given by "<<argv[3]; di<<"List given by "<<argv[k];
if (argc > 4) di<<" "<<argv[4]; if (argc > k+1) di<<" "<<argv[k+1];
di<<" : "; di<<" : ";
list = XSDRAW::GetList (argv[3], ( argc > 4 ? argv[4] : 0 ) ); list = XSDRAW::GetList (argv[k], ( argc > (k+1) ? argv[k+1] : 0 ) );
} }
if (list.IsNull()) { di<<"No list defined. Give a selection name or * for all transferrable roots"<<"\n"; continue; } if (list.IsNull()) { di<<"No list defined. Give a selection name or * for all transferrable roots"<<"\n"; continue; }
} else { } else {
cout<<"Name of Selection :"<<flush; cout<<"Name of Selection :"<<flush;
list = XSDRAW::GetList(); list = XSDRAW::GetList();
if (list.IsNull()) { di<<"No list defined"<<"\n"; continue; } if (list.IsNull()) { di<<"No list defined"<<"\n"; continue; }
} }
Standard_Integer ill, nbl = list->Length(); Standard_Integer ill, nbl = list->Length();
@ -209,17 +239,17 @@ static Standard_Integer stepread (Draw_Interpretor& di/*theCommands*/, Standard_
Message_ProgressSentry PSentry ( progress, "Root", 0, nbl, 1 ); Message_ProgressSentry PSentry ( progress, "Root", 0, nbl, 1 );
for (ill = 1; ill <= nbl && PSentry.More(); ill ++, PSentry.Next()) { for (ill = 1; ill <= nbl && PSentry.More(); ill ++, PSentry.Next()) {
num = sr.Model()->Number(list->Value(ill)); num = sr.Model()->Number(list->Value(ill));
if (num == 0) continue; if (num == 0) continue;
if (!sr.TransferOne(num)) di<<"Transfer entity n0 "<<num<<" : no result"<<"\n"; if (!sr.TransferOne(num)) di<<"Transfer entity n0 "<<num<<" : no result"<<"\n";
else { else {
nbs = sr.NbShapes(); nbs = sr.NbShapes();
char shname[30]; sprintf (shname,"%s_%d",rnom.ToCString(),nbs); char shname[30]; sprintf (shname,"%s_%d",rnom.ToCString(),nbs);
di<<"Transfer entity n0 "<<num<<" OK -> DRAW Shape: "<<shname<<"\n"; di<<"Transfer entity n0 "<<num<<" OK -> DRAW Shape: "<<shname<<"\n";
di<<"Now, "<<nbs<<" Shapes produced"<<"\n"; di<<"Now, "<<nbs<<" Shapes produced"<<"\n";
TopoDS_Shape sh = sr.Shape(nbs); TopoDS_Shape sh = sr.Shape(nbs);
DBRep::Set (shname,sh); DBRep::Set (shname,sh);
} }
} }
sr.WS()->MapReader()->SetProgress ( 0 ); sr.WS()->MapReader()->SetProgress ( 0 );
progress->EndScope(); progress->EndScope();
@ -512,7 +542,7 @@ void XSDRAWSTEP::InitCommands (Draw_Interpretor& theCommands)
XSDRAW::LoadDraw(theCommands); XSDRAW::LoadDraw(theCommands);
theCommands.Add("stepwrite" , "stepwrite mode[0-4 afsmw] shape", __FILE__, stepwrite, g); theCommands.Add("stepwrite" , "stepwrite mode[0-4 afsmw] shape", __FILE__, stepwrite, g);
theCommands.Add("testwritestep", "testwritestep filename.stp shape", __FILE__, testwrite, g); theCommands.Add("testwritestep", "testwritestep filename.stp shape", __FILE__, testwrite, g);
theCommands.Add("stepread", "stepread [file]", __FILE__, stepread, g); theCommands.Add("stepread", "stepread [file] [f or r (type of model full or reduced)]",__FILE__, stepread, g);
theCommands.Add("testreadstep", "testreadstep [file] [name DRAW]", __FILE__, testread, g); theCommands.Add("testreadstep", "testreadstep [file] [name DRAW]", __FILE__, testread, g);
theCommands.Add("steptrans", "steptrans shape stepax1 stepax2", __FILE__, steptrans, g); theCommands.Add("steptrans", "steptrans shape stepax1 stepax2", __FILE__, steptrans, g);
theCommands.Add("countexpected","TEST", __FILE__, countexpected, g); theCommands.Add("countexpected","TEST", __FILE__, countexpected, g);