mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
44
src/IFGraph/IFGraph.cdl
Executable file
44
src/IFGraph/IFGraph.cdl
Executable file
@@ -0,0 +1,44 @@
|
||||
-- File: IFGraph.cdl
|
||||
-- Created: Tue Sep 22 18:15:48 1992
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@phobox>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
package IFGraph
|
||||
|
||||
---Purpose : Provides tools to operate on an InterfaceModel and its
|
||||
-- Entities as on a Graph. These Tools are based on classes
|
||||
-- Graph and GraphContent from Interface
|
||||
|
||||
uses Interface, GraphTools, TColStd, Standard
|
||||
|
||||
is
|
||||
|
||||
-- (sub-classes of GraphContent from Interface)
|
||||
class AllShared;
|
||||
class AllConnected;
|
||||
class Cumulate;
|
||||
class Compare;
|
||||
class ExternalSources;
|
||||
|
||||
class Articulations;
|
||||
|
||||
class SubPartsIterator; -- result as several subsets
|
||||
class ConnectedComponants;
|
||||
class StrongComponants;
|
||||
class Cycles;
|
||||
class SCRoots;
|
||||
|
||||
-- class SortedStrongsFrom instantiates SortedStrgCmptsFromIterator from GraphTools
|
||||
-- (Graph from Interface,Transient,
|
||||
-- MapTransientHasher from TColStd,GraphContent from Interface);
|
||||
|
||||
-- class SortedStrongs instantiates SortedStrgCmptsIterator from GraphTools
|
||||
-- (Graph from Interface,Transient,
|
||||
-- GraphContent from Interface,SortedStrongsFrom from IFGraph);
|
||||
|
||||
-- class SortedStrongs instantiates SortedStrgCmptsIterator
|
||||
-- (Graph,Transient,GraphContent,GraphContent);
|
||||
|
||||
end IFGraph;
|
49
src/IFGraph/IFGraph_AllConnected.cdl
Executable file
49
src/IFGraph/IFGraph_AllConnected.cdl
Executable file
@@ -0,0 +1,49 @@
|
||||
-- File: AllConnected.cdl
|
||||
-- Created: Fri Oct 2 09:54:44 1992
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@sdsun1>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
class AllConnected from IFGraph inherits GraphContent
|
||||
|
||||
---Purpose : this class gives content of the CONNECTED COMPONANT(S)
|
||||
-- which include specific Entity(ies)
|
||||
|
||||
uses Transient, EntityIterator, Graph
|
||||
|
||||
is
|
||||
|
||||
Create (agraph : Graph) returns AllConnected;
|
||||
---Purpose : creates an AllConnected from a graph, empty ready to be filled
|
||||
|
||||
Create (agraph : Graph; ent : any Transient)
|
||||
returns AllConnected;
|
||||
---Purpose : creates an AllConnected which memorizes Entities Connected to
|
||||
-- a given one, at any level : that is, itself, all Entities
|
||||
-- Shared by it and Sharing it, and so on.
|
||||
-- In other terms, this is the content of the CONNECTED COMPONANT
|
||||
-- which include a specific Entity
|
||||
|
||||
GetFromEntity (me : in out; ent : any Transient);
|
||||
---Purpose : adds an entity and its Connected ones to the list (allows to
|
||||
-- cumulate all Entities Connected by some ones)
|
||||
-- Note that if "ent" is in the already computed list,, no entity
|
||||
-- will be added, but if "ent" is not already in the list, a new
|
||||
-- Connected Componant will be cumulated
|
||||
|
||||
ResetData (me : in out);
|
||||
---Purpose : Allows to restart on a new data set
|
||||
|
||||
-- -- Results -- --
|
||||
-- More-Next-Value give all entities noted in Connected Componant,
|
||||
-- including the entities given for construction or to GetFromEntity
|
||||
|
||||
Evaluate (me : in out) is redefined;
|
||||
---Purpose : does the specific evaluation (Connected entities atall levels)
|
||||
|
||||
fields
|
||||
|
||||
thegraph : Graph;
|
||||
|
||||
end AllConnected;
|
40
src/IFGraph/IFGraph_AllConnected.cxx
Executable file
40
src/IFGraph/IFGraph_AllConnected.cxx
Executable file
@@ -0,0 +1,40 @@
|
||||
#include <IFGraph_AllConnected.ixx>
|
||||
|
||||
|
||||
|
||||
// AllConnected prend toutes les Entites connectees a une Entite donnee
|
||||
// c-a-d toutes les "Shared" + toutes les "Sharings" et on recommence
|
||||
// Autrement dit le contenu du "Composant Connexe" du graphe d'ensemble
|
||||
// qui contient cette entite
|
||||
// Le calcul est effectue par GetFromEntity (Evaluate n'a rien a faire)
|
||||
|
||||
|
||||
IFGraph_AllConnected::IFGraph_AllConnected (const Interface_Graph& agraph)
|
||||
: thegraph (agraph) { }
|
||||
|
||||
|
||||
IFGraph_AllConnected::IFGraph_AllConnected
|
||||
(const Interface_Graph& agraph, const Handle(Standard_Transient)& ent)
|
||||
: thegraph (agraph)
|
||||
{ GetFromEntity(ent); }
|
||||
|
||||
void IFGraph_AllConnected::GetFromEntity
|
||||
(const Handle(Standard_Transient)& ent)
|
||||
{
|
||||
if (!thegraph.IsPresent(thegraph.EntityNumber(ent))) return;
|
||||
thegraph.GetFromEntity(ent,Standard_False);
|
||||
|
||||
for (Interface_EntityIterator shareds = thegraph.Shareds(ent);
|
||||
shareds.More(); shareds.Next())
|
||||
GetFromEntity(shareds.Value());
|
||||
|
||||
for (Interface_EntityIterator sharings = thegraph.Sharings(ent);
|
||||
sharings.More(); sharings.Next())
|
||||
GetFromEntity(sharings.Value());
|
||||
}
|
||||
|
||||
void IFGraph_AllConnected::ResetData ()
|
||||
{ Reset(); thegraph.Reset(); }
|
||||
|
||||
void IFGraph_AllConnected::Evaluate()
|
||||
{ GetFromGraph(thegraph); } // GetFromEntity a tout fait
|
48
src/IFGraph/IFGraph_AllShared.cdl
Executable file
48
src/IFGraph/IFGraph_AllShared.cdl
Executable file
@@ -0,0 +1,48 @@
|
||||
-- File: AllShared.cdl
|
||||
-- Created: Wed Sep 30 18:30:42 1992
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@phobox>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
class AllShared from IFGraph inherits GraphContent
|
||||
|
||||
---Purpose : this class determines all Entities shared by some specific
|
||||
-- ones, at any level (those which will be lead in a Transfer
|
||||
-- for instance)
|
||||
|
||||
uses Transient, EntityIterator, Graph
|
||||
|
||||
is
|
||||
|
||||
Create (agraph : Graph) returns AllShared;
|
||||
---Purpose : creates an AllShared from a graph, empty ready to be filled
|
||||
|
||||
Create (agraph : Graph; ent : any Transient)
|
||||
returns AllShared;
|
||||
---Purpose : creates an AllShared which memrizes Entities shared by a given
|
||||
-- one, at any level, including itself
|
||||
|
||||
GetFromEntity (me : in out; ent : any Transient);
|
||||
---Purpose : adds an entity and its shared ones to the list (allows to
|
||||
-- cumulate all Entities shared by some ones)
|
||||
|
||||
GetFromIter (me : in out; iter : EntityIterator);
|
||||
---Purpose : Adds Entities from an EntityIterator and all their shared
|
||||
-- ones at any level
|
||||
|
||||
ResetData (me : in out);
|
||||
---Purpose : Allows to restart on a new data set
|
||||
|
||||
-- -- Results -- --
|
||||
-- More-Next-Value give all entities noted as shared,
|
||||
-- including the entities given for construction or to GetFromEntity
|
||||
|
||||
Evaluate (me : in out) is redefined;
|
||||
---Purpose : does the specific evaluation (shared entities atall levels)
|
||||
|
||||
fields
|
||||
|
||||
thegraph : Graph;
|
||||
|
||||
end AllShared;
|
31
src/IFGraph/IFGraph_AllShared.cxx
Executable file
31
src/IFGraph/IFGraph_AllShared.cxx
Executable file
@@ -0,0 +1,31 @@
|
||||
#include <IFGraph_AllShared.ixx>
|
||||
#include <Interface_InterfaceModel.hxx>
|
||||
|
||||
|
||||
IFGraph_AllShared::IFGraph_AllShared (const Interface_Graph& agraph)
|
||||
: thegraph (agraph) { }
|
||||
|
||||
|
||||
IFGraph_AllShared::IFGraph_AllShared
|
||||
(const Interface_Graph& agraph, const Handle(Standard_Transient)& ent)
|
||||
: thegraph (agraph)
|
||||
{
|
||||
if (!agraph.Model()->Contains(ent)) return;
|
||||
GetFromEntity(ent);
|
||||
}
|
||||
|
||||
void IFGraph_AllShared::GetFromEntity
|
||||
(const Handle(Standard_Transient)& ent)
|
||||
{ thegraph.GetFromEntity(ent,Standard_True); } // le fait pour nous
|
||||
|
||||
void IFGraph_AllShared::GetFromIter (const Interface_EntityIterator& iter)
|
||||
{
|
||||
for (iter.Start(); iter.More(); iter.Next())
|
||||
thegraph.GetFromEntity(iter.Value(),Standard_True);
|
||||
}
|
||||
|
||||
void IFGraph_AllShared::ResetData ()
|
||||
{ Reset(); thegraph.Reset(); }
|
||||
|
||||
void IFGraph_AllShared::Evaluate()
|
||||
{ Reset(); GetFromGraph(thegraph); }
|
51
src/IFGraph/IFGraph_Articulations.cdl
Executable file
51
src/IFGraph/IFGraph_Articulations.cdl
Executable file
@@ -0,0 +1,51 @@
|
||||
-- File: Articulations.cdl
|
||||
-- Created: Wed Sep 23 11:19:31 1992
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@phobox>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
class Articulations from IFGraph inherits GraphContent
|
||||
|
||||
---Purpose : this class gives entities which are Articulation points
|
||||
-- in a whole Model or in a sub-part
|
||||
-- An Articulation Point divides the graph in two (or more)
|
||||
-- disconnected sub-graphs
|
||||
-- Identifying Articulation Points allows improving
|
||||
-- efficiency of spliting a set of Entities into sub-sets
|
||||
|
||||
uses Transient, HSequenceOfInteger, EntityIterator, Graph
|
||||
|
||||
is
|
||||
|
||||
Create (agraph : Graph; whole : Boolean) returns Articulations;
|
||||
---Purpose : creates Articulations to evaluate a Graph
|
||||
-- whole True : works on the whole Model
|
||||
-- whole False : remains empty, ready to work on a sub-part
|
||||
|
||||
GetFromEntity (me : in out; ent : any Transient);
|
||||
---Purpose : adds an entity and its shared ones to the list
|
||||
|
||||
GetFromIter (me : in out; iter : EntityIterator);
|
||||
---Purpose : adds a list of entities (as an iterator)
|
||||
|
||||
ResetData (me : in out);
|
||||
---Purpose : Allows to restart on a new data set
|
||||
|
||||
-- -- Results -- --
|
||||
-- More-Next-Value give Articulation points
|
||||
|
||||
Evaluate (me : in out) is redefined;
|
||||
---Purpose : Evaluates the list of Articulation points
|
||||
|
||||
Visit (me : in out; num : Integer) returns Integer is private;
|
||||
---Purpose : basic routine of computation
|
||||
-- (see book Sedgewick "Algorithms", p 392)
|
||||
|
||||
fields
|
||||
|
||||
thegraph : Graph;
|
||||
thenow : Integer; -- for Visit algorithm
|
||||
thelist : HSequenceOfInteger; -- results from Visiting
|
||||
|
||||
end Articulations;
|
69
src/IFGraph/IFGraph_Articulations.cxx
Executable file
69
src/IFGraph/IFGraph_Articulations.cxx
Executable file
@@ -0,0 +1,69 @@
|
||||
#include <IFGraph_Articulations.ixx>
|
||||
#include <Interface_InterfaceModel.hxx>
|
||||
|
||||
|
||||
|
||||
// Points d'Articulation d'un Graphe : ce sont les "passages obliges" du graphe
|
||||
// Algorithme tire du Sedgewick, p 392
|
||||
|
||||
IFGraph_Articulations::IFGraph_Articulations
|
||||
(const Interface_Graph& agraph, const Standard_Boolean whole)
|
||||
: thegraph (agraph)
|
||||
{ if (whole) thegraph.GetFromModel(); }
|
||||
|
||||
|
||||
void IFGraph_Articulations::GetFromEntity
|
||||
(const Handle(Standard_Transient)& ent)
|
||||
{ thegraph.GetFromEntity(ent,Standard_True); }
|
||||
|
||||
void IFGraph_Articulations::GetFromIter(const Interface_EntityIterator& iter)
|
||||
{ thegraph.GetFromIter(iter,0); }
|
||||
|
||||
|
||||
void IFGraph_Articulations::ResetData ()
|
||||
{ Reset(); thegraph.Reset(); thelist = new TColStd_HSequenceOfInteger(); }
|
||||
|
||||
void IFGraph_Articulations::Evaluate ()
|
||||
{
|
||||
// Algorithme, cf Sedgewick "Algorithms", p 392
|
||||
thelist = new TColStd_HSequenceOfInteger();
|
||||
// Utilisation de Visit
|
||||
Standard_Integer nb = thegraph.Size();
|
||||
for (Standard_Integer i = 1; i <= nb; i ++) {
|
||||
Standard_Integer visited;
|
||||
thenow = 0;
|
||||
if (thegraph.IsPresent(i)) visited = Visit(i);
|
||||
}
|
||||
// Resultat dans thelist
|
||||
Reset();
|
||||
Standard_Integer nbres = thelist->Length();
|
||||
for (Standard_Integer ires = 1; ires <= nbres; ires ++) {
|
||||
Standard_Integer num = thelist->Value(ires);
|
||||
GetOneItem(thegraph.Model()->Value(num));
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Integer IFGraph_Articulations::Visit (const Standard_Integer num)
|
||||
{
|
||||
thenow ++;
|
||||
thegraph.SetStatus(num,thenow);
|
||||
Standard_Integer min = thenow;
|
||||
|
||||
for (Interface_EntityIterator iter = thegraph.Shareds(thegraph.Entity(num));
|
||||
iter.More(); iter.Next()) {
|
||||
Handle(Standard_Transient) ent = iter.Value();
|
||||
Standard_Integer nument = thegraph.EntityNumber(ent);
|
||||
if (!thegraph.IsPresent(num)) {
|
||||
thegraph.GetFromEntity(ent,Standard_False);
|
||||
nument = thegraph.EntityNumber(ent);
|
||||
}
|
||||
Standard_Integer statent = thegraph.Status(nument); // pas reevalue
|
||||
if (statent == 0) {
|
||||
Standard_Integer mm = Visit(nument);
|
||||
if (mm < min) min = mm;
|
||||
if (mm > thegraph.Status(num)) thelist->Append(num); // ON EN A UN : num
|
||||
}
|
||||
else if (statent < min) min = statent;
|
||||
}
|
||||
return min;
|
||||
}
|
68
src/IFGraph/IFGraph_Compare.cdl
Executable file
68
src/IFGraph/IFGraph_Compare.cdl
Executable file
@@ -0,0 +1,68 @@
|
||||
-- File: Compare.cdl
|
||||
-- Created: Wed Sep 23 10:52:07 1992
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@phobox>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
class Compare from IFGraph inherits GraphContent
|
||||
|
||||
---Purpose : this class evaluates effect of two compared sub-parts :
|
||||
-- cumulation (union), common part (intersection-overlapping)
|
||||
-- part specific to first sub-part or to the second one
|
||||
-- Results are kept in a Graph, several question can be set
|
||||
-- Basic Iteration gives Cumulation (union)
|
||||
|
||||
uses Transient, EntityIterator, Graph
|
||||
|
||||
is
|
||||
|
||||
Create (agraph : Graph) returns Compare;
|
||||
---Purpose : creates empty Compare, ready to work
|
||||
|
||||
GetFromEntity (me : in out; ent : any Transient; first : Boolean);
|
||||
---Purpose : adds an entity and its shared ones to the list :
|
||||
-- first True means adds to the first sub-list, else to the 2nd
|
||||
|
||||
GetFromIter (me : in out; iter : EntityIterator; first : Boolean);
|
||||
---Purpose : adds a list of entities (as an iterator) as such, that is,
|
||||
-- their shared entities are not considered (use AllShared to
|
||||
-- have them)
|
||||
-- first True means adds to the first sub-list, else to the 2nd
|
||||
|
||||
Merge (me : in out);
|
||||
---Purpose : merges the second list into the first one, hence the second
|
||||
-- list is empty
|
||||
|
||||
RemoveSecond (me : in out);
|
||||
---Purpose : Removes the contents of second list
|
||||
|
||||
KeepCommon (me : in out);
|
||||
---Purpose : Keeps only Common part, sets it as First list and clears
|
||||
-- second list
|
||||
|
||||
ResetData (me : in out);
|
||||
---Purpose : Allows to restart on a new data set
|
||||
|
||||
-- -- Results -- --
|
||||
-- More-Next-Value-Entity give all entities taken into the Cumulation
|
||||
-- other informations are provided, as EntityIterator : hence they
|
||||
-- are available for other evaluations
|
||||
|
||||
Evaluate (me : in out) is redefined;
|
||||
---Purpose : Recomputes result of comparing to sub-parts
|
||||
|
||||
Common (me) returns EntityIterator;
|
||||
---Purpose : returns entities common to the both parts
|
||||
|
||||
FirstOnly (me) returns EntityIterator;
|
||||
---Purpose : returns entities which are exclusively in the first list
|
||||
|
||||
SecondOnly (me) returns EntityIterator;
|
||||
---Purpose : returns entities which are exclusively in the second part
|
||||
|
||||
fields
|
||||
|
||||
thegraph : Graph;
|
||||
|
||||
end Compare;
|
64
src/IFGraph/IFGraph_Compare.cxx
Executable file
64
src/IFGraph/IFGraph_Compare.cxx
Executable file
@@ -0,0 +1,64 @@
|
||||
#include <IFGraph_Compare.ixx>
|
||||
#include <IFGraph_AllShared.hxx>
|
||||
|
||||
|
||||
|
||||
// Comparateur de deux sous-ensembles d un Modele
|
||||
// Au premier sous-ensemble, est attribue le Status 1
|
||||
// Au deuxieme sous-ensemble, est attribue le Status 2
|
||||
// La partie commune se voit attribuer le Status 3
|
||||
|
||||
IFGraph_Compare::IFGraph_Compare (const Interface_Graph& agraph)
|
||||
: thegraph (agraph) { }
|
||||
|
||||
void IFGraph_Compare::GetFromEntity
|
||||
(const Handle(Standard_Transient)& ent, const Standard_Boolean first)
|
||||
{
|
||||
IFGraph_AllShared iter(thegraph.Model(),ent);
|
||||
GetFromIter(iter,first);
|
||||
}
|
||||
|
||||
void IFGraph_Compare::GetFromIter
|
||||
(const Interface_EntityIterator& iter, const Standard_Boolean first)
|
||||
{
|
||||
Standard_Integer stat = 2;
|
||||
if (first) stat = 1;
|
||||
thegraph.GetFromIter(iter,stat,3,Standard_False);
|
||||
}
|
||||
|
||||
|
||||
void IFGraph_Compare::Merge ()
|
||||
{
|
||||
thegraph.ChangeStatus (2,1);
|
||||
thegraph.ChangeStatus (3,1);
|
||||
}
|
||||
|
||||
void IFGraph_Compare::RemoveSecond ()
|
||||
{
|
||||
thegraph.ChangeStatus (3,1);
|
||||
thegraph.RemoveStatus (2);
|
||||
}
|
||||
|
||||
void IFGraph_Compare::KeepCommon ()
|
||||
{
|
||||
thegraph.RemoveStatus (1);
|
||||
thegraph.RemoveStatus (2);
|
||||
thegraph.ChangeStatus (3,1);
|
||||
}
|
||||
|
||||
void IFGraph_Compare::ResetData ()
|
||||
{ Reset(); thegraph.Reset(); }
|
||||
|
||||
void IFGraph_Compare::Evaluate ()
|
||||
{
|
||||
Reset(); GetFromGraph(thegraph); // Evaluation deja faite par le graphe
|
||||
}
|
||||
|
||||
Interface_EntityIterator IFGraph_Compare::Common () const
|
||||
{ return Interface_GraphContent(thegraph,3); }
|
||||
|
||||
Interface_EntityIterator IFGraph_Compare::FirstOnly () const
|
||||
{ return Interface_GraphContent(thegraph,1); }
|
||||
|
||||
Interface_EntityIterator IFGraph_Compare::SecondOnly () const
|
||||
{ return Interface_GraphContent(thegraph,2); }
|
27
src/IFGraph/IFGraph_ConnectedComponants.cdl
Executable file
27
src/IFGraph/IFGraph_ConnectedComponants.cdl
Executable file
@@ -0,0 +1,27 @@
|
||||
-- File: ConnectedComponants.cdl
|
||||
-- Created: Wed Sep 23 14:19:57 1992
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@phobox>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
class ConnectedComponants from IFGraph inherits SubPartsIterator
|
||||
|
||||
---Purpose : determines Connected Componants in a Graph. They define
|
||||
-- disjoined sets of Entities
|
||||
|
||||
uses Graph
|
||||
|
||||
is
|
||||
|
||||
Create (agraph : Graph; whole : Boolean) returns ConnectedComponants;
|
||||
---Purpose : creates with a Graph, and will analyse :
|
||||
-- whole True : all the contents of the Model
|
||||
-- whole False : sub-parts which will be given later
|
||||
|
||||
Evaluate (me : in out) is redefined;
|
||||
---Purpose : does the computation
|
||||
|
||||
-- -- Iteration : More-Next-etc... will give the Connected Componants
|
||||
|
||||
end ConnectedComponants;
|
35
src/IFGraph/IFGraph_ConnectedComponants.cxx
Executable file
35
src/IFGraph/IFGraph_ConnectedComponants.cxx
Executable file
@@ -0,0 +1,35 @@
|
||||
#include <IFGraph_ConnectedComponants.ixx>
|
||||
#include <IFGraph_AllConnected.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
|
||||
|
||||
|
||||
// Pour travailler, ConnectedComponants exploite AllConnected :
|
||||
// On prend un 1er Vertex, on determine ses AllConnected -> voila un 1er
|
||||
// Connected Componant
|
||||
// On recommence jusqu'a ce qu'il n'y ait plus de Vertex libre
|
||||
|
||||
|
||||
// Honnetement, si ca ne marche pas, cf classe ConnectedVerticesIterator
|
||||
// de GraphTools qui fait en principe la meme chose
|
||||
|
||||
|
||||
IFGraph_ConnectedComponants::IFGraph_ConnectedComponants
|
||||
(const Interface_Graph& agraph, const Standard_Boolean whole)
|
||||
: IFGraph_SubPartsIterator (agraph, whole) { }
|
||||
|
||||
void IFGraph_ConnectedComponants::Evaluate()
|
||||
{
|
||||
// On part des "loaded"
|
||||
// Pour chacun : s il est note dans le graphe, on passe
|
||||
// Sinon, on ajoute les AllConnected en tant que sub-part
|
||||
Interface_EntityIterator loaded = Loaded();
|
||||
Reset();
|
||||
for (loaded.Start(); loaded.More(); loaded.Next()) {
|
||||
Handle(Standard_Transient) ent = loaded.Value();
|
||||
if (IsInPart(ent)) continue;
|
||||
IFGraph_AllConnected connect(Model(),ent);
|
||||
AddPart();
|
||||
GetFromIter (connect);
|
||||
}
|
||||
}
|
62
src/IFGraph/IFGraph_Cumulate.cdl
Executable file
62
src/IFGraph/IFGraph_Cumulate.cdl
Executable file
@@ -0,0 +1,62 @@
|
||||
-- File: Cumulate.cdl
|
||||
-- Created: Wed Sep 23 10:36:04 1992
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@phobox>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
class Cumulate from IFGraph inherits GraphContent
|
||||
|
||||
---Purpose : this class evaluates effect of cumulated sub-parts :
|
||||
-- overlapping, forgotten entities
|
||||
-- Results are kept in a Graph, several question can be set
|
||||
-- Basic Iteration gives entities which are part of Cumulation
|
||||
|
||||
uses Transient, EntityIterator, Graph
|
||||
|
||||
is
|
||||
|
||||
Create (agraph : Graph) returns Cumulate;
|
||||
---Purpose : creates empty Cumulate, ready to work
|
||||
|
||||
GetFromEntity (me : in out; ent : any Transient);
|
||||
---Purpose : adds an entity and its shared ones to the list
|
||||
|
||||
GetFromIter (me : in out; iter : EntityIterator);
|
||||
---Purpose : adds a list of entities (as an iterator) as such, that is,
|
||||
-- without their shared entities (use AllShared to have them)
|
||||
|
||||
ResetData (me : in out);
|
||||
---Purpose : Allows to restart on a new data set
|
||||
|
||||
-- -- Results -- --
|
||||
-- More-Next-Value-Entity give all entities taken into the Cumulation
|
||||
-- other informations are provided, as EntityIterator : hence they
|
||||
-- are available for other evaluations
|
||||
|
||||
Evaluate (me : in out) is redefined;
|
||||
---Purpose : Evaluates the result of cumulation
|
||||
|
||||
Overlapped (me) returns EntityIterator;
|
||||
---Purpose : returns entities which are taken several times
|
||||
|
||||
Forgotten (me) returns EntityIterator;
|
||||
---Purpose : returns entities which are not taken
|
||||
|
||||
PerCount (me; count : Integer = 1) returns EntityIterator;
|
||||
---Purpose : Returns entities taken a given count of times
|
||||
-- (0 : same as Forgotten, 1 : same as no Overlap : default)
|
||||
|
||||
NbTimes (me; ent : Transient) returns Integer;
|
||||
---Purpose : returns number of times an Entity has been counted
|
||||
-- (0 means forgotten, more than 1 means overlap, 1 is normal)
|
||||
|
||||
HighestNbTimes (me) returns Integer;
|
||||
---Purpose : Returns the highest number of times recorded for every Entity
|
||||
-- (0 means empty, 1 means no overlap)
|
||||
|
||||
fields
|
||||
|
||||
thegraph : Graph;
|
||||
|
||||
end Cumulate;
|
93
src/IFGraph/IFGraph_Cumulate.cxx
Executable file
93
src/IFGraph/IFGraph_Cumulate.cxx
Executable file
@@ -0,0 +1,93 @@
|
||||
#include <IFGraph_Cumulate.ixx>
|
||||
#include <IFGraph_AllShared.hxx>
|
||||
#include <Interface_InterfaceModel.hxx>
|
||||
|
||||
|
||||
|
||||
// Calcul de cumul
|
||||
// Tres simple, on note les entites demandees, et a la fin
|
||||
// on a le cumul lui-meme, et comme infos derivees, les doubles et les oublis
|
||||
// Chaque recouvrement correspond a une augmentation de UN du status
|
||||
// Les status demarrent a 2, ainsi a l ajout d une entite, on distingue bien
|
||||
// entre les entites nouvelles, liees a cet appel (statut temporaire 1) et les
|
||||
// autres (statut superieur ou egal a 2)
|
||||
|
||||
IFGraph_Cumulate::IFGraph_Cumulate (const Interface_Graph& agraph)
|
||||
: thegraph (agraph) { }
|
||||
|
||||
void IFGraph_Cumulate::GetFromEntity
|
||||
(const Handle(Standard_Transient)& ent)
|
||||
{
|
||||
IFGraph_AllShared iter(thegraph.Model(),ent);
|
||||
GetFromIter (iter);
|
||||
}
|
||||
|
||||
void IFGraph_Cumulate::ResetData ()
|
||||
{ Reset(); thegraph.Reset(); }
|
||||
|
||||
void IFGraph_Cumulate::GetFromIter (const Interface_EntityIterator& iter)
|
||||
{
|
||||
thegraph.GetFromIter(iter,1,1,Standard_True);
|
||||
thegraph.ChangeStatus (1,2); // une fois le calcul fait
|
||||
}
|
||||
|
||||
void IFGraph_Cumulate::Evaluate ()
|
||||
{
|
||||
Reset(); GetFromGraph(thegraph); // evaluation deja faite dans le graphe
|
||||
}
|
||||
|
||||
Interface_EntityIterator IFGraph_Cumulate::Overlapped () const
|
||||
{
|
||||
Interface_EntityIterator iter;
|
||||
Standard_Integer nb = thegraph.Size();
|
||||
for (Standard_Integer i = 1; i <= nb; i ++) {
|
||||
if (thegraph.IsPresent(i) && thegraph.Status(i) > 2)
|
||||
iter.GetOneItem(thegraph.Entity(i));
|
||||
}
|
||||
return iter;
|
||||
}
|
||||
|
||||
Interface_EntityIterator IFGraph_Cumulate::Forgotten () const
|
||||
{
|
||||
Interface_EntityIterator iter;
|
||||
Standard_Integer nb = thegraph.Size();
|
||||
for (Standard_Integer i = 1; i <= nb; i ++) {
|
||||
if (!thegraph.IsPresent(i))
|
||||
iter.GetOneItem(thegraph.Model()->Value(i));
|
||||
}
|
||||
return iter;
|
||||
}
|
||||
|
||||
Interface_EntityIterator IFGraph_Cumulate::PerCount
|
||||
(const Standard_Integer count) const
|
||||
{
|
||||
Interface_EntityIterator iter;
|
||||
Standard_Integer nb = thegraph.Size();
|
||||
for (Standard_Integer i = 1; i <= nb; i ++) {
|
||||
if (thegraph.IsPresent(i) && thegraph.Status(i) == (count + 1))
|
||||
iter.GetOneItem(thegraph.Model()->Value(i));
|
||||
}
|
||||
return iter;
|
||||
}
|
||||
|
||||
|
||||
Standard_Integer IFGraph_Cumulate::NbTimes
|
||||
(const Handle(Standard_Transient)& ent) const
|
||||
{
|
||||
Standard_Integer num = thegraph.EntityNumber(ent);
|
||||
if (num == 0) return 0;
|
||||
Standard_Integer stat = thegraph.Status(num);
|
||||
return stat-1;
|
||||
}
|
||||
|
||||
Standard_Integer IFGraph_Cumulate::HighestNbTimes () const
|
||||
{
|
||||
Standard_Integer max = 0;
|
||||
Standard_Integer nb = thegraph.Size();
|
||||
for (Standard_Integer i = 1; i <= nb; i ++) {
|
||||
if (!thegraph.IsPresent(i)) continue;
|
||||
Standard_Integer count = thegraph.Status(i) - 1;
|
||||
if (count > max) max = count;
|
||||
}
|
||||
return max;
|
||||
}
|
30
src/IFGraph/IFGraph_Cycles.cdl
Executable file
30
src/IFGraph/IFGraph_Cycles.cdl
Executable file
@@ -0,0 +1,30 @@
|
||||
-- File: Cycles.cdl
|
||||
-- Created: Wed Sep 23 14:28:44 1992
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@phobox>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
class Cycles from IFGraph inherits SubPartsIterator
|
||||
|
||||
---Purpose : determines strong componants in a graph which are Cycles
|
||||
|
||||
uses Graph, StrongComponants
|
||||
|
||||
is
|
||||
|
||||
Create (agraph : Graph; whole : Boolean) returns Cycles;
|
||||
---Purpose : creates with a Graph, and will analyse :
|
||||
-- whole True : all the contents of the Model
|
||||
-- whole False : sub-parts which will be given later
|
||||
|
||||
Create (subparts : in out StrongComponants);
|
||||
---Purpose : creates from a StrongComponants which was already computed
|
||||
|
||||
Evaluate (me : in out) is redefined;
|
||||
---Purpose : does the computation. Cycles are StrongComponants which are
|
||||
-- not Single
|
||||
|
||||
-- -- Iteration : More-Next-etc... will give Cycles
|
||||
|
||||
end Cycles;
|
28
src/IFGraph/IFGraph_Cycles.cxx
Executable file
28
src/IFGraph/IFGraph_Cycles.cxx
Executable file
@@ -0,0 +1,28 @@
|
||||
#include <IFGraph_Cycles.ixx>
|
||||
#include <Interface_GraphContent.hxx>
|
||||
#include <IFGraph_StrongComponants.hxx>
|
||||
|
||||
|
||||
|
||||
// Cycles utilise les services de StrongComponants :
|
||||
// Il retient les Strong Componants qui ne sont pas Single
|
||||
|
||||
|
||||
IFGraph_Cycles::IFGraph_Cycles
|
||||
(const Interface_Graph& agraph, const Standard_Boolean whole)
|
||||
: IFGraph_SubPartsIterator (agraph,whole) { }
|
||||
|
||||
IFGraph_Cycles::IFGraph_Cycles (IFGraph_StrongComponants& subparts)
|
||||
: IFGraph_SubPartsIterator (subparts) { }
|
||||
|
||||
|
||||
void IFGraph_Cycles::Evaluate ()
|
||||
{
|
||||
IFGraph_StrongComponants complist(Model(),Standard_False);
|
||||
complist.GetFromIter(Loaded());
|
||||
for (complist.Start(); complist.More(); complist.Next()) {
|
||||
if (complist.IsSingle()) continue;
|
||||
AddPart();
|
||||
GetFromIter(complist.Entities());
|
||||
}
|
||||
}
|
44
src/IFGraph/IFGraph_ExternalSources.cdl
Executable file
44
src/IFGraph/IFGraph_ExternalSources.cdl
Executable file
@@ -0,0 +1,44 @@
|
||||
-- File: ExternalSources.cdl
|
||||
-- Created: Wed Sep 23 11:10:40 1992
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@phobox>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
class ExternalSources from IFGraph inherits GraphContent
|
||||
|
||||
---Purpose : this class gives entities which are Source of entities of
|
||||
-- a sub-part, but are not contained by this sub-part
|
||||
|
||||
uses Transient, EntityIterator, Graph
|
||||
|
||||
is
|
||||
|
||||
Create (agraph : Graph) returns ExternalSources;
|
||||
---Purpose : creates empty ExternalSources, ready to work
|
||||
|
||||
GetFromEntity (me : in out; ent : any Transient);
|
||||
---Purpose : adds an entity and its shared ones to the list
|
||||
|
||||
GetFromIter (me : in out; iter : EntityIterator);
|
||||
---Purpose : adds a list of entities (as an iterator) with shared ones
|
||||
|
||||
ResetData (me : in out);
|
||||
---Purpose : Allows to restart on a new data set
|
||||
|
||||
-- -- Results -- --
|
||||
-- More-Next-Value give External Source entities
|
||||
|
||||
Evaluate (me : in out) is redefined;
|
||||
---Purpose : Evaluates external sources of a set of entities
|
||||
|
||||
IsEmpty(me : in out) returns Boolean;
|
||||
---Purpose : Returns True if no External Source are found
|
||||
-- It means that we have a "root" set
|
||||
-- (performs an Evaluation as necessary)
|
||||
|
||||
fields
|
||||
|
||||
thegraph : Graph;
|
||||
|
||||
end ExternalSources;
|
51
src/IFGraph/IFGraph_ExternalSources.cxx
Executable file
51
src/IFGraph/IFGraph_ExternalSources.cxx
Executable file
@@ -0,0 +1,51 @@
|
||||
#include <IFGraph_ExternalSources.ixx>
|
||||
|
||||
|
||||
|
||||
// ExternalSources exploite les resultats stockes dans le Graphe sur Sharings
|
||||
// Soit les "Sharings" des entites notees par GetFromEntity et GetFromIter
|
||||
// Celles des "Sharings" qui n etaient pas deja notees sont ExternalSources
|
||||
// Les status :
|
||||
// - Les entites de depart sont au Status 0
|
||||
// - Les entites Sharing NOUVELLES (ExternalSources) sont au Status 1
|
||||
|
||||
|
||||
IFGraph_ExternalSources::IFGraph_ExternalSources
|
||||
(const Interface_Graph& agraph)
|
||||
: thegraph (agraph) { }
|
||||
|
||||
|
||||
void IFGraph_ExternalSources::GetFromEntity
|
||||
(const Handle(Standard_Transient)& ent)
|
||||
{ thegraph.GetFromEntity(ent,Standard_True); }
|
||||
|
||||
void IFGraph_ExternalSources::GetFromIter
|
||||
(const Interface_EntityIterator& iter)
|
||||
{ thegraph.GetFromIter(iter,0); }
|
||||
|
||||
void IFGraph_ExternalSources::ResetData ()
|
||||
{ Reset(); thegraph.Reset(); }
|
||||
|
||||
|
||||
void IFGraph_ExternalSources::Evaluate ()
|
||||
{
|
||||
Reset();
|
||||
thegraph.RemoveStatus(1);
|
||||
Standard_Integer nb = thegraph.Size();
|
||||
for (Standard_Integer i = 1; i <= nb; i ++) {
|
||||
if (thegraph.IsPresent(i) && thegraph.Status(i) == 0)
|
||||
thegraph.GetFromIter ( thegraph.Sharings(thegraph.Entity(i)), 1 );
|
||||
}
|
||||
GetFromGraph(thegraph,1);
|
||||
}
|
||||
|
||||
Standard_Boolean IFGraph_ExternalSources::IsEmpty ()
|
||||
{
|
||||
Evaluate();
|
||||
Standard_Integer nb = thegraph.Size();
|
||||
for (Standard_Integer i = 1; i <= nb; i ++) {
|
||||
if (thegraph.IsPresent(i) || thegraph.Status(i) == 1)
|
||||
return Standard_False;
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
29
src/IFGraph/IFGraph_SCRoots.cdl
Executable file
29
src/IFGraph/IFGraph_SCRoots.cdl
Executable file
@@ -0,0 +1,29 @@
|
||||
-- File: SCRoots.cdl
|
||||
-- Created: Wed Sep 23 14:34:25 1992
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@phobox>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
class SCRoots from IFGraph inherits StrongComponants
|
||||
|
||||
---Purpose : determines strong componants in a graph which are Roots
|
||||
|
||||
uses Graph
|
||||
|
||||
is
|
||||
|
||||
Create (agraph : Graph; whole : Boolean) returns SCRoots;
|
||||
---Purpose : creates with a Graph, and will analyse :
|
||||
-- whole True : all the contents of the Model
|
||||
-- whole False : sub-parts which will be given later
|
||||
|
||||
Create (subparts : in out StrongComponants);
|
||||
---Purpose : creates from a StrongComponants which was already computed
|
||||
|
||||
Evaluate (me : in out) is redefined;
|
||||
---Purpose : does the computation
|
||||
|
||||
-- -- Iteration : More-Next-etc... gives Roots (either Loop or not)
|
||||
|
||||
end SCRoots;
|
57
src/IFGraph/IFGraph_SCRoots.cxx
Executable file
57
src/IFGraph/IFGraph_SCRoots.cxx
Executable file
@@ -0,0 +1,57 @@
|
||||
#include <IFGraph_SCRoots.ixx>
|
||||
//#include <Interface_GraphContent.hxx>
|
||||
#include <IFGraph_StrongComponants.hxx>
|
||||
#include <IFGraph_ExternalSources.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
|
||||
//#define PRINTDEB
|
||||
|
||||
|
||||
IFGraph_SCRoots::IFGraph_SCRoots
|
||||
(const Interface_Graph& agraph, const Standard_Boolean whole)
|
||||
: IFGraph_StrongComponants (agraph,whole) { }
|
||||
|
||||
IFGraph_SCRoots::IFGraph_SCRoots (IFGraph_StrongComponants& subparts)
|
||||
: IFGraph_StrongComponants (subparts) { }
|
||||
|
||||
// StrongComponants racines d un ensemble donne
|
||||
// On ne tient pas compte du reste eventuel (c est un autre probleme)
|
||||
// On part du fait que StrongComponants donne les Composants dans l ordre de
|
||||
// dependance, le premier ne dependant de rien (les autres, on ne sait pas ...)
|
||||
|
||||
void IFGraph_SCRoots::Evaluate ()
|
||||
{
|
||||
IFGraph_StrongComponants complist (Model(),Standard_False);
|
||||
complist.GetFromIter(Loaded());
|
||||
// Interface_Graph G(Model());
|
||||
Interface_Graph G(thegraph);
|
||||
#ifdef PRINTDEB
|
||||
cout<<" SCRoots:"<<endl;
|
||||
#endif
|
||||
G.ResetStatus();
|
||||
for (complist.Start(); complist.More(); complist.Next()) {
|
||||
Handle(Standard_Transient) ent = complist.FirstEntity();
|
||||
Standard_Integer num = G.EntityNumber(ent);
|
||||
#ifdef PRINTDEB
|
||||
cout<<" Iteration,num="<<num<<(G.IsPresent(num) ? " Pris" : " A prendre")<<endl;
|
||||
#endif
|
||||
if (!G.IsPresent(num)) { // enregistrer pour suivants
|
||||
G.GetFromEntity(ent,Standard_True);
|
||||
Interface_EntityIterator list = complist.Entities();
|
||||
AddPart();
|
||||
GetFromIter(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ce qui suit, c etait autre chose : les SC qui n ont pas d ExternalSource
|
||||
Interface_EntityIterator list = complist.Entities();
|
||||
IFGraph_ExternalSources eval (Model());
|
||||
eval.GetFromIter(list);
|
||||
if (eval.IsEmpty()) {
|
||||
AddPart();
|
||||
GetFromIter(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
27
src/IFGraph/IFGraph_StrongComponants.cdl
Executable file
27
src/IFGraph/IFGraph_StrongComponants.cdl
Executable file
@@ -0,0 +1,27 @@
|
||||
-- File: StrongComponants.cdl
|
||||
-- Created: Wed Sep 23 14:26:23 1992
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@phobox>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
class StrongComponants from IFGraph inherits SubPartsIterator
|
||||
|
||||
---Purpose : determines strong componants of a graph, that is
|
||||
-- isolated entities (single componants) or loops
|
||||
|
||||
uses Graph
|
||||
|
||||
is
|
||||
|
||||
Create (agraph : Graph; whole : Boolean) returns StrongComponants;
|
||||
---Purpose : creates with a Graph, and will analyse :
|
||||
-- whole True : all the contents of the Model
|
||||
-- whole False : sub-parts which will be given later
|
||||
|
||||
Evaluate (me : in out) is redefined;
|
||||
---Purpose : does the computation
|
||||
|
||||
-- -- Iteration : More-Next-etc... will give strong componants
|
||||
|
||||
end StrongComponants;
|
49
src/IFGraph/IFGraph_StrongComponants.cxx
Executable file
49
src/IFGraph/IFGraph_StrongComponants.cxx
Executable file
@@ -0,0 +1,49 @@
|
||||
#include <IFGraph_StrongComponants.ixx>
|
||||
//#include <IFGraph_SortedStrongs.hxx>
|
||||
#include <Interface_Graph.hxx>
|
||||
#include <Interface_GraphContent.hxx>
|
||||
|
||||
//#define PRINTDEB
|
||||
#define pbgraphtool
|
||||
|
||||
|
||||
IFGraph_StrongComponants::IFGraph_StrongComponants
|
||||
(const Interface_Graph& agraph, const Standard_Boolean whole)
|
||||
: IFGraph_SubPartsIterator (agraph, whole) { }
|
||||
|
||||
void IFGraph_StrongComponants::Evaluate ()
|
||||
{
|
||||
Interface_GraphContent iter = Loaded();
|
||||
Interface_Graph G(thegraph); G.GetFromIter(iter,0);
|
||||
#ifdef pbgraphtool
|
||||
Standard_Integer nb = G.Size();
|
||||
for (Standard_Integer i = 1; i <= nb; i ++) {
|
||||
if (!G.IsPresent(i)) continue;
|
||||
AddPart();
|
||||
GetFromEntity (G.Entity(i),Standard_False);
|
||||
}
|
||||
#else
|
||||
#ifdef PRINTDEB
|
||||
cout<<"StrongComponants :"<<endl;
|
||||
#endif
|
||||
for (IFGraph_SortedStrongs res(G); res.More(); res.Next()) {
|
||||
Standard_Integer nb = res.NbVertices();
|
||||
#ifdef PRINTDEB
|
||||
cout<<" Iteration, Vertices:"<<nb<<" :";
|
||||
#endif
|
||||
if (nb == 0) continue;
|
||||
AddPart();
|
||||
for (Standard_Integer i = 1; i <= nb; i ++)
|
||||
#ifdef PRINTDEB
|
||||
{
|
||||
Handle(Standard_Transient) oneres = res.Value(i);
|
||||
cout<<" "<<G.EntityNumber(oneres);
|
||||
GetFromEntity(oneres,Standard_False);
|
||||
}
|
||||
cout<<endl;
|
||||
#else
|
||||
GetFromEntity(res.Value(i),Standard_False);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
146
src/IFGraph/IFGraph_SubPartsIterator.cdl
Executable file
146
src/IFGraph/IFGraph_SubPartsIterator.cdl
Executable file
@@ -0,0 +1,146 @@
|
||||
-- File: SubPartsIterator.cdl
|
||||
-- Created: Wed Sep 23 11:27:17 1992
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@phobox>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
class SubPartsIterator from IFGraph
|
||||
|
||||
---Purpose : defines general form for graph classes of which result is
|
||||
-- not a single iteration on Entities, but a nested one :
|
||||
-- External iteration works on sub-parts, identified by each
|
||||
-- class (according to its algorithm)
|
||||
-- Internal Iteration concerns Entities of a sub-part
|
||||
-- Sub-Parts are assumed to be disjoined; if they are not,
|
||||
-- the first one has priority
|
||||
--
|
||||
-- A SubPartsIterator can work in two steps : first, load
|
||||
-- entities which have to be processed
|
||||
-- then, analyse to set those entities into sub-parts
|
||||
|
||||
uses Transient, HSequenceOfInteger, InterfaceModel, EntityIterator,
|
||||
Graph, GraphContent
|
||||
|
||||
raises OutOfRange, NoSuchObject, InterfaceError
|
||||
|
||||
is
|
||||
|
||||
Create (agraph : Graph; whole : Boolean) returns SubPartsIterator;
|
||||
---Purpose : Creates with a Graph, whole or parts of it
|
||||
-- whole True : works on the entire Model
|
||||
-- whole False : empty, ready to be filled
|
||||
-- SubPartIterator is set to load entities
|
||||
|
||||
Create (other : in out SubPartsIterator) returns SubPartsIterator;
|
||||
---Purpose : Creates a SubPartIterator from another one and gets its Data
|
||||
-- Note that only non-empty sub-parts are taken into account
|
||||
-- PartNum is set to the last one
|
||||
|
||||
GetParts (me : in out; other : in out SubPartsIterator)
|
||||
raises InterfaceError;
|
||||
---Purpose : Gets Parts from another SubPartsIterator (in addition to the
|
||||
-- ones already recorded)
|
||||
-- Error if both SubPartsIterators are not based on the same Model
|
||||
|
||||
Graph (me) returns Graph is private;
|
||||
---Purpose : Returns the Graph used by <me>. Used to create another
|
||||
-- SubPartsIterator from <me>
|
||||
---C++ : return const &
|
||||
|
||||
Model (me) returns InterfaceModel;
|
||||
---Purpose : Returns the Model with which this Iterator was created
|
||||
|
||||
AddPart (me : in out);
|
||||
---Purpose : Adds an empty part and sets it to receive entities
|
||||
|
||||
NbParts (me) returns Integer;
|
||||
---Purpose : Returns count of registered parts
|
||||
|
||||
PartNum (me) returns Integer;
|
||||
---Purpose : Returns numero of part which currently receives entities
|
||||
-- (0 at load time)
|
||||
|
||||
SetLoad (me : in out);
|
||||
---Purpose : Sets SubPartIterator to get Entities (by GetFromEntity &
|
||||
-- GetFromIter) into load status, to be analysed later
|
||||
|
||||
SetPartNum (me : in out; num : Integer) raises OutOfRange;
|
||||
---Purpose : Sets numero of receiving part to a new value
|
||||
-- Error if not in range (1-NbParts)
|
||||
|
||||
GetFromEntity (me : in out; ent : any Transient; shared : Boolean);
|
||||
---Purpose : Adds an Entity : into load status if in Load mode, to the
|
||||
-- current part if there is one. If shared is True, adds
|
||||
-- also its shared ones (shared at all levels)
|
||||
|
||||
GetFromIter (me : in out; iter : EntityIterator);
|
||||
---Purpose : Adds a list of Entities (into Load mode or to a Part),
|
||||
-- given as an Iterator
|
||||
|
||||
Reset (me : in out);
|
||||
---Purpose : Erases data (parts, entities) : "me" becomes empty and in
|
||||
-- load status
|
||||
|
||||
Evaluate (me : in out) is virtual;
|
||||
---Purpose : Called by Clear, this method allows evaluation just before
|
||||
-- iteration; its default is doing nothing, it is designed to
|
||||
-- be redefined
|
||||
|
||||
Loaded (me) returns GraphContent;
|
||||
---Purpose : Returns entities which where loaded (not set into a sub-part)
|
||||
|
||||
LoadedGraph (me) returns Graph;
|
||||
---Purpose : Same as above, but under the form of a Graph
|
||||
|
||||
IsLoaded (me; ent : Transient) returns Boolean;
|
||||
---Purpose : Returns True if an Entity is loaded (either set into a
|
||||
-- sub-part or not)
|
||||
|
||||
IsInPart (me; ent : Transient) returns Boolean;
|
||||
---Purpose : Returns True if an Entity is Present in a sub-part
|
||||
|
||||
EntityPartNum (me; ent : Transient) returns Integer;
|
||||
---Purpose : Returns number of the sub-part in which an Entity has been set
|
||||
-- if it is not in a sub-part (or not loaded at all), Returns 0
|
||||
|
||||
-- -- Iteration -- --
|
||||
|
||||
Start (me : in out);
|
||||
---Purpose : Sets iteration to its beginning; calls Evaluate
|
||||
|
||||
More (me : in out) returns Boolean;
|
||||
---Purpose : Returns True if there are more sub-parts to iterate on
|
||||
-- Note : an empty sub-part is not taken in account by Iteration
|
||||
|
||||
Next (me : in out);
|
||||
---Purpose : Sets iteration to the next sub-part
|
||||
-- if there is not, IsSingle-Entities will raises an exception
|
||||
|
||||
IsSingle (me) returns Boolean raises NoSuchObject;
|
||||
---Purpose : Returns True if current sub-part is single (has only one Entity)
|
||||
-- Error if there is no sub-part to iterate now
|
||||
|
||||
FirstEntity (me) returns Transient raises NoSuchObject;
|
||||
---Purpose : Returns the first entity of current sub-part, that is for a
|
||||
-- Single one, the only one it contains
|
||||
-- Error : same as above (end of iteration)
|
||||
|
||||
Entities (me) returns EntityIterator raises NoSuchObject;
|
||||
---Purpose : Returns current sub-part, not as a "Value", but as an Iterator
|
||||
-- on Entities it contains
|
||||
-- Error : same as above (end of iteration)
|
||||
|
||||
Delete (me:out) is virtual;
|
||||
---C++: alias "Standard_EXPORT virtual ~IFGraph_SubPartsIterator() { Delete(); }"
|
||||
|
||||
fields
|
||||
|
||||
thegraph : Graph is protected; -- graph of entities + stores the model
|
||||
-- protected : allows sub-classes to create a Graph Tool directly with it
|
||||
theparts : HSequenceOfInteger; -- for each part, its count of entities
|
||||
thefirsts : HSequenceOfInteger; -- ... number of its first Entity
|
||||
thepart : Integer; -- Part receiving entities (GetFromEntity,GetFromIter)
|
||||
thecurr : Integer; -- Part to be iterated
|
||||
|
||||
end SubPartsIterator;
|
244
src/IFGraph/IFGraph_SubPartsIterator.cxx
Executable file
244
src/IFGraph/IFGraph_SubPartsIterator.cxx
Executable file
@@ -0,0 +1,244 @@
|
||||
#include <IFGraph_SubPartsIterator.ixx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <Interface_InterfaceError.hxx>
|
||||
#include <Standard_NoSuchObject.hxx>
|
||||
|
||||
|
||||
|
||||
// SubPartsIterator permet de regrouper les entites en plusieurs sous-parties
|
||||
// A chaque sous-partie est attache un Status : la 1re a 1, la 2e a 2, etc...
|
||||
// (consequence, les sous-parties sont necessairement disjointes)
|
||||
|
||||
IFGraph_SubPartsIterator::IFGraph_SubPartsIterator
|
||||
(const Interface_Graph& agraph, const Standard_Boolean whole)
|
||||
: thegraph (agraph)
|
||||
{
|
||||
if (whole) thegraph.GetFromModel();
|
||||
theparts = new TColStd_HSequenceOfInteger();
|
||||
thefirsts = new TColStd_HSequenceOfInteger();
|
||||
thepart = 0;
|
||||
thecurr = 0;
|
||||
}
|
||||
|
||||
IFGraph_SubPartsIterator::IFGraph_SubPartsIterator
|
||||
(IFGraph_SubPartsIterator& other)
|
||||
: thegraph (other.Graph())
|
||||
{
|
||||
Standard_Integer nb = thegraph.Size();
|
||||
theparts = new TColStd_HSequenceOfInteger();
|
||||
thepart = 0;
|
||||
for (other.Start(); other.More(); other.Next()) {
|
||||
thepart ++;
|
||||
Standard_Integer nbent = 0;
|
||||
GetFromIter (other.Entities());
|
||||
for (Standard_Integer i = 1; i <= nb; i ++) {
|
||||
if (thegraph.Status(i) == thepart) nbent ++;
|
||||
}
|
||||
theparts->Append(nbent); // compte vide
|
||||
}
|
||||
thepart = 0;
|
||||
thecurr = 1;
|
||||
}
|
||||
|
||||
void IFGraph_SubPartsIterator::GetParts
|
||||
(IFGraph_SubPartsIterator& other)
|
||||
{
|
||||
if (Model() != other.Model()) Interface_InterfaceError::Raise
|
||||
("SubPartsIterator : GetParts");
|
||||
// On AJOUTE les Parts de other, sans perdre les siennes propres
|
||||
// (meme principe que le constructeur ci-dessus)
|
||||
Standard_Integer nb = thegraph.Size();
|
||||
thepart = theparts->Length();
|
||||
for (other.Start(); other.More(); other.Next()) {
|
||||
thepart ++;
|
||||
Standard_Integer nbent = 0;
|
||||
GetFromIter (other.Entities());
|
||||
for (Standard_Integer i = 1; i <= nb; i ++) {
|
||||
if (thegraph.Status(i) == thepart) nbent ++;
|
||||
}
|
||||
theparts->Append(nbent); // compte vide
|
||||
}
|
||||
}
|
||||
|
||||
const Interface_Graph& IFGraph_SubPartsIterator::Graph () const
|
||||
{ return thegraph; }
|
||||
|
||||
// .... Gestion Interne (remplissage, etc...) .... //
|
||||
|
||||
Handle(Interface_InterfaceModel) IFGraph_SubPartsIterator::Model() const
|
||||
{ return thegraph.Model(); }
|
||||
|
||||
void IFGraph_SubPartsIterator::AddPart ()
|
||||
{
|
||||
theparts->Append( Standard_Integer(0) );
|
||||
thepart = theparts->Length();
|
||||
}
|
||||
|
||||
Standard_Integer IFGraph_SubPartsIterator::NbParts () const
|
||||
{ return theparts->Length(); }
|
||||
|
||||
Standard_Integer IFGraph_SubPartsIterator::PartNum () const
|
||||
{ return thepart; }
|
||||
|
||||
void IFGraph_SubPartsIterator::SetLoad ()
|
||||
{ thepart = 0; }
|
||||
|
||||
void IFGraph_SubPartsIterator::SetPartNum (const Standard_Integer num)
|
||||
{
|
||||
if (num <= 0 || num > theparts->Length()) Standard_OutOfRange::Raise
|
||||
("IFGraph_SubPartsIterator : SetPartNum");
|
||||
thepart = num;
|
||||
}
|
||||
|
||||
void IFGraph_SubPartsIterator::GetFromEntity
|
||||
(const Handle(Standard_Transient)& ent, const Standard_Boolean shared)
|
||||
{
|
||||
thegraph.GetFromEntity(ent,shared, thepart,thepart,Standard_False);
|
||||
}
|
||||
|
||||
void IFGraph_SubPartsIterator::GetFromIter (const Interface_EntityIterator& iter)
|
||||
{
|
||||
thegraph.GetFromIter(iter, thepart,thepart, Standard_False);
|
||||
}
|
||||
|
||||
void IFGraph_SubPartsIterator::Reset ()
|
||||
{
|
||||
thegraph.Reset();
|
||||
theparts->Clear();
|
||||
thepart = 0;
|
||||
thecurr = 0;
|
||||
}
|
||||
|
||||
|
||||
// .... Resultat (Evaluation, Iterations) .... //
|
||||
|
||||
void IFGraph_SubPartsIterator::Evaluate ()
|
||||
{ } // par defaut, ne fait rien; redefinie par les sous-classes
|
||||
|
||||
Interface_GraphContent IFGraph_SubPartsIterator::Loaded () const
|
||||
{
|
||||
Interface_EntityIterator iter;
|
||||
// Standard_Integer nb = thegraph.Size();
|
||||
return Interface_GraphContent(thegraph,0);
|
||||
}
|
||||
|
||||
Interface_Graph IFGraph_SubPartsIterator::LoadedGraph () const
|
||||
{
|
||||
Interface_Graph G(Model());
|
||||
Standard_Integer nb = thegraph.Size();
|
||||
for (Standard_Integer i = 1; i <= nb; i ++) {
|
||||
if (thegraph.IsPresent(i) && thegraph.Status(i) == 0)
|
||||
G.GetFromEntity(thegraph.Entity(i),Standard_False);
|
||||
}
|
||||
return G;
|
||||
}
|
||||
|
||||
|
||||
Standard_Boolean IFGraph_SubPartsIterator::IsLoaded
|
||||
(const Handle(Standard_Transient)& ent) const
|
||||
{ return thegraph.IsPresent(thegraph.EntityNumber(ent)); }
|
||||
|
||||
Standard_Boolean IFGraph_SubPartsIterator::IsInPart
|
||||
(const Handle(Standard_Transient)& ent) const
|
||||
{
|
||||
Standard_Integer num = thegraph.EntityNumber(ent);
|
||||
if (!thegraph.IsPresent(num)) return Standard_False;
|
||||
return (thegraph.Status(num) != 0);
|
||||
}
|
||||
|
||||
Standard_Integer IFGraph_SubPartsIterator::EntityPartNum
|
||||
(const Handle(Standard_Transient)& ent) const
|
||||
{
|
||||
Standard_Integer num = thegraph.EntityNumber(ent);
|
||||
if (!thegraph.IsPresent(num)) return 0;
|
||||
return thegraph.Status(num);
|
||||
}
|
||||
|
||||
|
||||
void IFGraph_SubPartsIterator::Start ()
|
||||
{
|
||||
Evaluate();
|
||||
// On evalue les tailles des contenus des Parts
|
||||
Standard_Integer nb = thegraph.Size();
|
||||
Standard_Integer nbp = theparts->Length();
|
||||
if (thepart > nbp) thepart = nbp;
|
||||
if (nbp == 0) { thecurr = 1; return; } // L Iteration s arrete de suite
|
||||
|
||||
// - On fait les comptes (via tableaux pour performances)
|
||||
TColStd_Array1OfInteger partcounts (1,nbp); partcounts.Init(0);
|
||||
TColStd_Array1OfInteger partfirsts (1,nbp); partfirsts.Init(0);
|
||||
for (Standard_Integer i = 1; i <= nb; i ++) {
|
||||
if (!thegraph.IsPresent(i)) continue;
|
||||
Standard_Integer nump = thegraph.Status(i);
|
||||
if (nump < 1 || nump > nbp) continue;
|
||||
Standard_Integer nbent = partcounts.Value(nump);
|
||||
partcounts.SetValue(nump,nbent+1);
|
||||
if (nbent == 0) partfirsts.SetValue(nump,i);
|
||||
}
|
||||
// - On les met en forme (c-a-d dans les sequences)
|
||||
theparts->Clear(); thefirsts->Clear();
|
||||
Standard_Integer lastp = 0;
|
||||
for (Standard_Integer np = 1; np <= nbp; np ++) {
|
||||
Standard_Integer nbent = partcounts.Value(np);
|
||||
if (np != 0) lastp = np;
|
||||
theparts->Append (nbent);
|
||||
thefirsts->Append (partfirsts.Value(np));
|
||||
}
|
||||
if (lastp < nbp) theparts->Remove(lastp+1,nbp);
|
||||
// Enfin, on se prepare a iterer
|
||||
thecurr = 1;
|
||||
}
|
||||
|
||||
Standard_Boolean IFGraph_SubPartsIterator::More ()
|
||||
{
|
||||
if (thecurr == 0) Start();
|
||||
return (thecurr <= theparts->Length());
|
||||
}
|
||||
|
||||
void IFGraph_SubPartsIterator::Next ()
|
||||
{
|
||||
thecurr ++; if (thecurr > theparts->Length()) return;
|
||||
if (theparts->Value(thecurr) == 0) Next(); // sauter parties vides
|
||||
}
|
||||
|
||||
Standard_Boolean IFGraph_SubPartsIterator::IsSingle () const
|
||||
{
|
||||
if (thecurr < 1 || thecurr > theparts->Length()) Standard_NoSuchObject::Raise
|
||||
("IFGraph_SubPartsIterator : IsSingle");
|
||||
return (theparts->Value(thecurr) == 1);
|
||||
}
|
||||
|
||||
Handle(Standard_Transient) IFGraph_SubPartsIterator::FirstEntity
|
||||
() const
|
||||
{
|
||||
if (thecurr < 1 || thecurr > theparts->Length()) Standard_NoSuchObject::Raise
|
||||
("IFGraph_SubPartsIterator : FirstEntity");
|
||||
Standard_Integer nument = thefirsts->Value(thecurr);
|
||||
if (nument == 0) Standard_NoSuchObject::Raise
|
||||
("IFGraph_SubPartsIterator : FirstEntity (current part is empty)");
|
||||
return thegraph.Entity(nument);
|
||||
}
|
||||
|
||||
Interface_EntityIterator IFGraph_SubPartsIterator::Entities () const
|
||||
{
|
||||
if (thecurr < 1 || thecurr > theparts->Length()) Standard_NoSuchObject::Raise
|
||||
("IFGraph_SubPartsIterator : Entities");
|
||||
Interface_EntityIterator iter;
|
||||
Standard_Integer nb = thegraph.Size();
|
||||
Standard_Integer nument = thefirsts->Value(thecurr);
|
||||
if (nument == 0) return iter;
|
||||
if (theparts->Value(thecurr) == 1) nb = nument; // evident : 1 seule Entite
|
||||
for (Standard_Integer i = nument; i <= nb; i ++) {
|
||||
if (thegraph.Status(i) == thecurr && thegraph.IsPresent(i))
|
||||
iter.GetOneItem(thegraph.Entity(i));
|
||||
}
|
||||
return iter;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Delete
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void IFGraph_SubPartsIterator::Delete()
|
||||
{}
|
Reference in New Issue
Block a user