1
0
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:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

61
src/GraphDS/GraphDS.cdl Executable file
View File

@@ -0,0 +1,61 @@
-- File: GraphDS.cdl
-- Created: Fri Aug 6 16:39:11 1993
-- Author: Denis PASCAL
-- <dp@phobox>
---Copyright: Matra Datavision 1993
package GraphDS
---Purpose: This package <GraphDS> provides generic classes to
-- describe transient graph data structure.
uses Standard,
MMgt,
TCollection,
TColStd
is
enumeration EntityRole is
OnlyInput,
OnlyOutput,
InputAndOutput
end EntityRole;
enumeration RelationRole is
OnlyFront,
OnlyBack,
FrontAndBack
end RelationRole;
class EntityRoleMap instantiates DataMap from TCollection
(Transient from Standard,
EntityRole from GraphDS,
MapTransientHasher from TColStd);
generic class DirectedGraph,
Vertex,
Edge,
VerticesIterator,
EdgesIterator;
generic class RelationGraph,
Entity,
Relation,
EntitiesIterator,
IncidentEntitiesIterator,
RelationsIterator,
IncidentRelationsIterator;
end GraphDS;

View File

@@ -0,0 +1,376 @@
-- File: DirectedGraph.cdl
-- Created: Wed Apr 24 16:53:50 1991
-- Author: Denis PASCAL
-- <dp@topsn2>
generic class DirectedGraph from GraphDS
(GraphDS_Item as any ;
GraphDS_Attribute as any)
---Purpose: This class describes a structure which contains a
-- list of Vertices and a list of Edges. The vertex
-- (also called a Node), is the basic element of the
-- graph, it contains an Item. Each edge (also called
-- an Arc) defines an oriented link between two
-- vertices. it contains an Attribute. In the scheme
-- A->B, vertex A is called the SOURCE of the link, B
-- its DESTINATION, and B is ADJACENT to A. If there is
-- no edge which destinates to a vertex, this vertex is
-- a ROOT of the graph. If there is no edge which
-- originates from a vertex, this vertex is a LEAF of
-- the graph.
-- Keywords: SOURCE vertex, DESTINATION Vertex, ROOT vertex, LEAF
-- vertex, ADJACENT vertex. Depth-first search, breadth
-- first Search.
-- References: Software Components with ADA (The Benjamin/Cummings
-- Company, Inc. 1986).
uses MapOfTransient from TColStd
raises NoSuchObject from Standard,
DomainError from Standard
class Vertex inherits TShared from MMgt
---Purpose: nested public class vertex (composed of an
-- associated Item).
uses MapOfTransient from TColStd
raises NoSuchObject from Standard
is
Create (value : GraphDS_Item)
returns mutable Vertex from GraphDS;
--is private;
GetItem (me)
returns any GraphDS_Item;
---Purpose: returns item associated to <me>.
---C++: return const &
---Level: Internal
SetItem (me : mutable; value : GraphDS_Item);
---Purpose: Associates a new item to <me>.
---Level: Internal
Contains (me; E : Edge)
returns Boolean from Standard;
IsFront (me; E : Edge)
returns Boolean from Standard;
IsBack (me; E : Edge)
returns Boolean from Standard;
IsRoot (me; ignoreselfloop : Boolean from Standard = Standard_True)
---Purpose: Returns TRUE if NbBackEdges = 0.
---Level: Internal
returns Boolean from Standard;
IsLeaf (me; ignoreselfloop : Boolean from Standard = Standard_True)
---Purpose: Returns TRUE if NbFrontEdges = 0.
---Level: Internal
returns Boolean from Standard;
AddEdge (me : mutable; E : Edge)
returns Boolean from Standard
is private;
RemoveEdge (me : mutable; anEdge : Edge)
raises NoSuchObject from Standard
is private;
GetEdges (me)
returns MapOfTransient from TColStd
---C++: return const&
---Purpose: Returns <myEdges> field for Iterator;
---Level: Internal
is private;
fields
myItem : GraphDS_Item;
myEdges : MapOfTransient from TColStd;
friends
class DirectedGraph from GraphDS,
class Edge from GraphDS,
class VerticesIterator from GraphDS,
class EdgesIterator from GraphDS
end;
class Edge inherits TShared from MMgt
---Purpose: Nested public class Edge (composed of an
-- associated attribute) An Edge is an oriented link
-- between two vertices.
raises NoMoreObject from Standard ,
NoSuchObject from Standard
is
Create (source,destination : Vertex; value : GraphDS_Attribute)
returns mutable Edge;
--is private;
GetAttribute (me)
---Purpose: returns attribute associated to <me>.
---C++: return const &
---Level: Internal
returns any GraphDS_Attribute;
SetAttribute (me : mutable; Value : GraphDS_Attribute);
---Purpose: To associate a new attribute to <me>.
---Level: Internal
Contains (me; V : Vertex)
returns Boolean from Standard;
Source (me)
---C++: return const&
---Purpose: Returns the vertex which originates from <me>.
---Level: Internal
returns mutable Vertex;
Destination (me)
---C++: return const&
---Purpose: Returns the vertex which destinates to <me>.
---Level: Internal
returns mutable Vertex;
Reverse (me : mutable);
---Purpose: Reverse the orientation of <me>. the source
-- vertex becomes the destination vertex. And
-- the destination the source.
---Level: Internal
IsLoop (me)
returns Boolean from Standard;
---Purpose: Returns True if the source and destination vertices
-- are equal.
---Level: Internal
fields
myAttribute : GraphDS_Attribute;
mySource : Vertex from GraphDS;
myDestination : Vertex from GraphDS;
friends
class DirectedGraph from GraphDS,
class Vertex from GraphDS,
class VerticesIterator from GraphDS,
class EdgesIterator from GraphDS
end;
class VerticesIterator
---Purpose: basic tool to iterate on vertices.
-- 1 - vertices member of a DirectedGraph.
-- 2 - adjacent vertices of a given one.
uses MapOfTransient from TColStd,
MapIteratorOfMapOfTransient from TColStd
raises NoMoreObject from Standard,
NoSuchObject from Standard
is
Create
returns VerticesIterator from GraphDS;
Create (G : DirectedGraph from GraphDS)
returns VerticesIterator from GraphDS;
Create (G : DirectedGraph from GraphDS;
V : Vertex from GraphDS)
returns VerticesIterator from GraphDS;
Initialize (me : in out; G : DirectedGraph from GraphDS);
---Level: Public
Initialize (me : in out; G : DirectedGraph from GraphDS;
V : Vertex from GraphDS);
---Level: Public
More (me)
returns Boolean from Standard;
---Level: Public
Next (me : in out)
raises NoMoreObject from Standard;
---Level: Public
Value (me)
---C++: return const&
---Level: Public
returns Vertex
raises NoSuchObject from Standard;
fields
myMap : MapOfTransient from TColStd;
myVertices : MapIteratorOfMapOfTransient from TColStd;
end;
class EdgesIterator
---Purpose: basic tool to iterate on edges :
-- 1 - edges member of a DirectedGraph.
-- 2 - edges referenced by a given vertex.
uses MapIteratorOfMapOfTransient from TColStd
raises NoMoreObject from Standard ,
NoSuchObject from Standard
is
Create
returns EdgesIterator from GraphDS;
Create (G : DirectedGraph from GraphDS)
returns EdgesIterator from GraphDS;
Create (G : DirectedGraph from GraphDS;
V : Vertex from GraphDS)
returns EdgesIterator from GraphDS;
Initialize (me : in out; G : DirectedGraph from GraphDS);
---Level: Public
Initialize (me : in out; G : DirectedGraph from GraphDS;
V : Vertex from GraphDS);
---Level: Public
More (me)
returns Boolean from Standard;
---Level: Public
Next (me : in out)
raises NoMoreObject from Standard;
---Level: Public
Value (me)
---C++: return const&
---Level: Public
returns Edge
raises NoSuchObject from Standard;
fields
myEdges : MapIteratorOfMapOfTransient from TColStd;
end;
is
Create
returns DirectedGraph from GraphDS;
---Purpose: Create an empty Directed Graph.
IsEmpty (me)
returns Boolean from Standard;
---Level: Public
NbVertices (me)
returns Integer from Standard;
---Level: Public
NbEdges (me)
returns Integer from Standard;
---Level: Public
Clear (me : in out);
---Purpose: removes all edges and vertices of <me>.
---Level: Public
Contains (me; E : Edge)
returns Boolean from Standard;
---Level: Public
Contains (me; V : Vertex)
returns Boolean from Standard;
---Level: Public
IsRoot (me; V : Vertex; ignoreselfloop : Boolean from Standard = Standard_True)
returns Boolean from Standard;
---Level: Public
IsLeaf (me; V : Vertex; ignoreselfloop : Boolean from Standard = Standard_True)
returns Boolean from Standard;
---Level: Public
Add (me : in out; value : GraphDS_Item)
---Purpose: Creates a vertex, with a given Item <value>, and
-- Adds it to <me>. Of course this new Vertex
-- (returned by the method) is a "root" and "leaf"
-- vertex of <me>.
---Level: Public
returns mutable Vertex;
Remove (me : in out; V : Vertex)
---Purpose: Removes <V> from <me>. <NoSuchObject> is raised
-- if <V> is not member of <me>. <DomainError> is
-- raised if <V> is used by at least one edge of <me>
---Level: Public
raises NoSuchObject from Standard,
DomainError from Standard;
Add (me : in out; source : mutable Vertex;
destination : mutable Vertex;
value : GraphDS_Attribute)
---Purpose: Creates an Edge, with a given Attribute <value>,
-- from <source> to <destination>, and Adds it to
-- <me>. This new edge is returned by the method.
-- <NoSuchObject> is raised if <source> and/or
-- <destination> are not members of <me>.
---Level: Public
returns mutable Edge
raises NoSuchObject from Standard;
Remove (me : in out; E : Edge)
---Purpose: Removes <E> from <me>. <NoSuchObject> is raised if
-- <E> is not member of <me>.
---Level: Public
raises NoSuchObject from Standard;
fields
myVertices : MapOfTransient from TColStd;
myEdges : MapOfTransient from TColStd;
friends
class VerticesIterator from GraphDS,
class EdgesIterator from GraphDS
end;

View File

@@ -0,0 +1,174 @@
// File: GraphDS_DirectedGraph.gxx
// Created: Tue Mar 16 14:12:08 1993
// Author: Denis PASCAL
// <dp@bravox>
#include <Standard_NoSuchObject.hxx>
#include <Standard_DomainError.hxx>
//=======================================================================
//function : GraphDS_DirectedGraph
//purpose :
//=======================================================================
GraphDS_DirectedGraph::GraphDS_DirectedGraph ()
{
}
//=======================================================================
//function : NbVertices
//purpose :
//=======================================================================
Standard_Integer GraphDS_DirectedGraph::NbVertices () const
{
return myVertices.Extent();
}
//=======================================================================
//function : NbEdges
//purpose :
//=======================================================================
Standard_Integer GraphDS_DirectedGraph::NbEdges () const
{
return myEdges.Extent();
}
//=======================================================================
//function : IsEmpty
//purpose :
//=======================================================================
Standard_Boolean GraphDS_DirectedGraph::IsEmpty () const
{
return (myVertices.IsEmpty());
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void GraphDS_DirectedGraph::Clear ()
{
myVertices.Clear();
myEdges.Clear();
}
//=======================================================================
//function : Contains
//purpose :
//=======================================================================
Standard_Boolean GraphDS_DirectedGraph::Contains
(const Handle(GraphDS_Vertex)& V) const
{
return myVertices.Contains(V);
}
//=======================================================================
//function : IsRoot
//purpose :
//=======================================================================
Standard_Boolean GraphDS_DirectedGraph::IsRoot
(const Handle(GraphDS_Vertex)& V,
const Standard_Boolean ignoreselfloop) const
{
return V->IsRoot(ignoreselfloop);
}
//=======================================================================
//function : IsLeaf
//purpose :
//=======================================================================
Standard_Boolean GraphDS_DirectedGraph::IsLeaf
(const Handle(GraphDS_Vertex)& V,
const Standard_Boolean ignoreselfloop) const
{
return V->IsLeaf(ignoreselfloop);
}
//=======================================================================
//function : Contains
//purpose :
//=======================================================================
Standard_Boolean GraphDS_DirectedGraph::Contains
(const Handle(GraphDS_Edge)& E) const
{
return myEdges.Contains(E);
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
Handle(GraphDS_Vertex) GraphDS_DirectedGraph::Add
(const GraphDS_Item& value)
{
Handle(GraphDS_Vertex) V = new GraphDS_Vertex (value);
myVertices.Add(V);
return V;
}
//=======================================================================
//function : Remove
//purpose :
//=======================================================================
void GraphDS_DirectedGraph::Remove (const Handle(GraphDS_Vertex)& V)
{
if (!V->GetEdges().IsEmpty()) Standard_DomainError::Raise();
myVertices.Remove(V);
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
Handle(GraphDS_Edge) GraphDS_DirectedGraph::Add
(const Handle(GraphDS_Vertex)& source,
const Handle(GraphDS_Vertex)& destination,
const GraphDS_Attribute& A)
{
Handle(GraphDS_Edge) E = new GraphDS_Edge (source,destination,A);
source->AddEdge (E);
destination->AddEdge(E);
myEdges.Add(E);
return E;
}
//=======================================================================
//function : Remove
//purpose :
//=======================================================================
void GraphDS_DirectedGraph::Remove (const Handle(GraphDS_Edge)& E)
{
E->Source()->RemoveEdge(E);
E->Destination()->RemoveEdge(E);
myEdges.Remove(E);
}

110
src/GraphDS/GraphDS_Edge.gxx Executable file
View File

@@ -0,0 +1,110 @@
// File: GraphDS_Edge.gxx
// Created: Tue Mar 16 15:37:56 1993
// Author: Denis PASCAL
// <dp@bravox>
#include <Standard_NoMoreObject.hxx>
#include <Standard_NoSuchObject.hxx>
//=======================================================================
//function : GraphDS_Edge
//purpose :
//=======================================================================
GraphDS_Edge::GraphDS_Edge
(const Handle(GraphDS_Vertex)& source,
const Handle(GraphDS_Vertex)& destination,
const GraphDS_Attribute& value) : myAttribute (value)
{
mySource = source;
myDestination = destination;
}
//=======================================================================
//function : GetAttribute
//purpose :
//=======================================================================
const GraphDS_Attribute& GraphDS_Edge::GetAttribute () const
{
return myAttribute;
}
//=======================================================================
//function : SetAttribute
//purpose :
//=======================================================================
void GraphDS_Edge::SetAttribute (const GraphDS_Attribute& Value)
{
myAttribute = Value;
}
//=======================================================================
//function : Contains
//purpose :
//=======================================================================
Standard_Boolean GraphDS_Edge::Contains (const Handle(GraphDS_Vertex)& V) const
{
return (mySource == V || myDestination == V);
}
//=======================================================================
//function : Source
//purpose :
//=======================================================================
const Handle(GraphDS_Vertex)& GraphDS_Edge::Source () const
{
return mySource;
}
//=======================================================================
//function : Destination
//purpose :
//=======================================================================
const Handle(GraphDS_Vertex)& GraphDS_Edge::Destination () const
{
return myDestination;
}
//=======================================================================
//function : Reverse
//purpose :
//=======================================================================
void GraphDS_Edge::Reverse ()
{
Handle (GraphDS_Vertex) temp = myDestination;
myDestination = mySource;
mySource = temp;
}
//=======================================================================
//function : IsLoop
//purpose :
//=======================================================================
Standard_Boolean GraphDS_Edge::IsLoop () const
{
return (myDestination == mySource);
}

View File

@@ -0,0 +1,108 @@
// File: GraphDS_EdgesIterator.gxx
// Created: Tue Mar 16 15:48:48 1993
// Author: Denis PASCAL
// <dp@bravox>
#include <Standard_NoMoreObject.hxx>
#include <Standard_NoSuchObject.hxx>
//=======================================================================
//function : GraphDS_EdgesIterator
//purpose :
//=======================================================================
GraphDS_EdgesIterator::GraphDS_EdgesIterator ()
{
}
//=======================================================================
//function : GraphDS_EdgesIterator
//purpose :
//=======================================================================
GraphDS_EdgesIterator::GraphDS_EdgesIterator
(const GraphDS_DirectedGraph& G)
{
Initialize (G);
}
//=======================================================================
//function : GraphDS_EdgesIterator
//purpose :
//=======================================================================
GraphDS_EdgesIterator::GraphDS_EdgesIterator
(const GraphDS_DirectedGraph& G,
const Handle(GraphDS_Vertex)& V)
{
Initialize (G,V);
}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
void GraphDS_EdgesIterator::Initialize
(const GraphDS_DirectedGraph& G)
{
myEdges.Initialize(G.myEdges);
}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
void GraphDS_EdgesIterator::Initialize
(const GraphDS_DirectedGraph&,
const Handle(GraphDS_Vertex)& V)
{
myEdges.Initialize(V->GetEdges());
}
//=======================================================================
//function : More
//purpose :
//=======================================================================
Standard_Boolean GraphDS_EdgesIterator::More () const
{
return myEdges.More();
}
//=======================================================================
//function : Next
//purpose :
//=======================================================================
void GraphDS_EdgesIterator::Next ()
{
myEdges.Next();
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
const Handle(GraphDS_Edge)& GraphDS_EdgesIterator::Value () const
{
return *((Handle(GraphDS_Edge)*)& myEdges.Key());
//return Handle(GraphDS_Edge)::DownCast(myEdges.Key());
}

View File

@@ -0,0 +1,153 @@
// Copyright: Matra-Datavision 1991
// File: GraphDS_EntitiesIterator.cxx
// Created: Tue Sep 10 17:01:56 1991
// Author: Denis PASCAL
// <dp>
#include <Standard_NoSuchObject.hxx>
#include <Standard_NoMoreObject.hxx>
#include <GraphDS_DataMapIteratorOfEntityRoleMap.hxx>
//=======================================================================
//function : GraphDS_EntitiesIterator
//purpose :
//=======================================================================
GraphDS_EntitiesIterator::GraphDS_EntitiesIterator ()
{
}
//=======================================================================
//function : GraphDS_EntitiesIterator
//purpose :
//=======================================================================
GraphDS_EntitiesIterator::GraphDS_EntitiesIterator
(const GraphDS_RelationGraph& G)
{
Initialize (G);
}
//=======================================================================
//function : GraphDS_EntitiesIterator
//purpose :
//=======================================================================
GraphDS_EntitiesIterator::GraphDS_EntitiesIterator
(const GraphDS_RelationGraph& G,
const Handle(GraphDS_Entity)& E)
{
Initialize (G,E);
}
//=======================================================================
//function : GraphDS_EntitiesIterator
//purpose :
//=======================================================================
GraphDS_EntitiesIterator::GraphDS_EntitiesIterator
(const GraphDS_RelationGraph& G,
const Handle(GraphDS_Relation)& R)
{
Initialize (G,R);
}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
void GraphDS_EntitiesIterator::Initialize
(const GraphDS_RelationGraph& G)
{
myEntities.Initialize(G.myEntities);
}
//=======================================================================
//function : Initialize
//purpose : adjacent entities search
//=======================================================================
void GraphDS_EntitiesIterator::Initialize
(const GraphDS_RelationGraph&,
const Handle(GraphDS_Entity)& E)
{
myMap.Clear();
Handle(GraphDS_Relation) REL;
GraphDS_DataMapIteratorOfEntityRoleMap itv;
TColStd_MapIteratorOfMapOfTransient itr;
for (itr.Initialize(E->GetRelations());itr.More();itr.Next()) {
REL = Handle(GraphDS_Relation)::DownCast(itr.Key());
if (REL->IsInput(E)) {
for (itv.Initialize(REL->GetEntities());itv.More();itv.Next()) {
if (itv.Value() != GraphDS_OnlyInput) {
myMap.Add(itv.Key());
}
}
}
}
myEntities.Initialize(myMap);
}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
void GraphDS_EntitiesIterator::Initialize
(const GraphDS_RelationGraph&,
const Handle(GraphDS_Relation)& R)
{
myMap.Clear();
GraphDS_DataMapIteratorOfEntityRoleMap itv;
for (itv.Initialize(R->GetEntities());itv.More();itv.Next()) {
myMap.Add(itv.Key());
}
myEntities.Initialize(myMap);
}
//=======================================================================
//function : More
//purpose :
//=======================================================================
Standard_Boolean GraphDS_EntitiesIterator::More () const
{
return myEntities.More();
}
//=======================================================================
//function : Next
//purpose :
//=======================================================================
void GraphDS_EntitiesIterator::Next ()
{
myEntities.Next();
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
const Handle(GraphDS_Entity)& GraphDS_EntitiesIterator::Value () const
{
return *((Handle(GraphDS_Entity)*)& myEntities.Key());
//return Handle(GraphDS_Entity)::DownCast(myEntities.Key());
}

142
src/GraphDS/GraphDS_Entity.gxx Executable file
View File

@@ -0,0 +1,142 @@
// Copyright: Matra-Datavision 1991
// File: GraphDS_Entity.gxx
// Created: Tue Sep 10 10:37:41 1991
// Author: Denis PASCAL
// <dp>
# include <Standard_NoSuchObject.hxx>
# include <Standard_DomainError.hxx>
//=======================================================================
//function : GraphDS_Entity
//purpose :
//=======================================================================
GraphDS_Entity::GraphDS_Entity
(const GraphDS_Item& item) : myItem(item)
{
}
//=======================================================================
//function : GetItem
//purpose :
//=======================================================================
const GraphDS_Item& GraphDS_Entity::GetItem() const
{
return myItem;
}
//=======================================================================
//function : Contains
//purpose :
//=======================================================================
Standard_Boolean GraphDS_Entity::Contains
(const Handle(GraphDS_Relation)& R) const
{
return myRelations.Contains(R);
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void GraphDS_Entity::Add (const Handle(GraphDS_Relation)& R)
{
myRelations.Add(R);
}
//=======================================================================
//function : Remove
//purpose :
//=======================================================================
void GraphDS_Entity::Remove (const Handle(GraphDS_Relation)& R)
{
myRelations.Remove(R);
}
//=======================================================================
//function : HasRelation
//purpose :
//=======================================================================
Standard_Boolean GraphDS_Entity::HasRelation () const
{
return !myRelations.IsEmpty();
}
//=======================================================================
//function : GetRole
//purpose :
//=======================================================================
GraphDS_RelationRole GraphDS_Entity::GetRole
(const Handle(GraphDS_Relation)& R) const
{
GraphDS_RelationRole RR;
Handle(GraphDS_Entity) me = this;
GraphDS_EntityRole ER = R->GetRole(me);
switch(ER) {
case GraphDS_OnlyInput:
RR = GraphDS_OnlyFront;
break;
case GraphDS_OnlyOutput:
RR = GraphDS_OnlyBack;
break;
case GraphDS_InputAndOutput:
RR = GraphDS_FrontAndBack;
break;
}
return RR;
}
//=======================================================================
//function : IsFront
//purpose :
//=======================================================================
Standard_Boolean GraphDS_Entity::IsFront
(const Handle(GraphDS_Relation)& R) const
{
Handle(GraphDS_Entity) me = this;
return R->IsInput(me);
}
//=======================================================================
//function : IsBack
//purpose :
//=======================================================================
Standard_Boolean GraphDS_Entity::IsBack
(const Handle(GraphDS_Relation)& R) const
{
Handle(GraphDS_Entity) me = this;
return R->IsOutput(me);
}
//=======================================================================
//function : GetRelations
//purpose :
//=======================================================================
const TColStd_MapOfTransient& GraphDS_Entity::GetRelations() const
{
return myRelations;
}

View File

@@ -0,0 +1,314 @@
// Copyright: Matra-Datavision 1991
// File: GraphDS_IncidentEntitiesIterator.cxx
// Created: Tue Oct 15 14:57:30 1991
// Author: Denis PASCAL
// <dp>
#include <Standard_NoMoreObject.hxx>
#include <Standard_NoSuchObject.hxx>
#include <GraphDS_DataMapIteratorOfEntityRoleMap.hxx>
//=======================================================================
//function : Create
//purpose :
//=======================================================================
GraphDS_IncidentEntitiesIterator::GraphDS_IncidentEntitiesIterator ()
{
}
//=======================================================================
//function : Create
//purpose :
//=======================================================================
GraphDS_IncidentEntitiesIterator::GraphDS_IncidentEntitiesIterator
(const GraphDS_RelationGraph& G,
const Handle(GraphDS_Entity)& V)
{
Initialize (G,V);
}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
void GraphDS_IncidentEntitiesIterator::Initialize
(const GraphDS_RelationGraph&,
const Handle(GraphDS_Entity)& E)
{
myMap.Clear();
Handle(GraphDS_Relation) REL;
GraphDS_DataMapIteratorOfEntityRoleMap itv;
TColStd_MapIteratorOfMapOfTransient itr;
for (itr.Initialize(E->GetRelations());itr.More();itr.Next()) {
REL = Handle(GraphDS_Relation)::DownCast(itr.Key());
if (REL->IsOutput(E)) {
for (itv.Initialize(REL->GetEntities());itv.More();itv.Next()) {
if (itv.Value() != GraphDS_OnlyOutput) {
myMap.Add(itv.Key());
}
}
}
}
myEntities.Initialize(myMap);
}
//=======================================================================
//function : More
//purpose :
//=======================================================================
Standard_Boolean GraphDS_IncidentEntitiesIterator::More () const
{
return myEntities.More();
}
//=======================================================================
//function : Next
//purpose :
//=======================================================================
void GraphDS_IncidentEntitiesIterator::Next ()
{
myEntities.Next();
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
const Handle(GraphDS_Entity)& GraphDS_IncidentEntitiesIterator::Value () const
{
return *((Handle(GraphDS_Entity)*)& myEntities.Key());
// return Handle(GraphDS_Entity)::DownCast(myEntities.Key());
}

View File

@@ -0,0 +1,103 @@
// Copyright: Matra-Datavision 1991
// File: GraphDS_IncidentRelationsIterator.gxx
// Created: Tue Sep 10 17:01:38 1991
// Author: Denis PASCAL
// <dp>
#include <Standard_NoMoreObject.hxx>
#include <Standard_NoSuchObject.hxx>
#include <GraphDS_DataMapIteratorOfEntityRoleMap.hxx>
//=======================================================================
//function : GraphDS_IncidentRelationsIterator
//purpose :
//=======================================================================
GraphDS_IncidentRelationsIterator::GraphDS_IncidentRelationsIterator ()
{
}
//=======================================================================
//function : GraphDS_IncidentRelationsIterator
//purpose :
//=======================================================================
GraphDS_IncidentRelationsIterator::GraphDS_IncidentRelationsIterator
(const GraphDS_RelationGraph& G,
const Handle(GraphDS_Relation)& R)
{
Initialize (G,R);
}
//=======================================================================
//function : GraphDS_Initialize
//purpose :
//=======================================================================
void GraphDS_IncidentRelationsIterator::Initialize
(const GraphDS_RelationGraph&,
const Handle(GraphDS_Relation)& R)
{
myMap.Clear();
Handle(GraphDS_Entity) ENT;
Handle(GraphDS_Relation) REL;
GraphDS_DataMapIteratorOfEntityRoleMap itv;
TColStd_MapIteratorOfMapOfTransient itr;
for (itv.Initialize(R->GetEntities());itv.More();itv.Next()) {
ENT = Handle(GraphDS_Entity)::DownCast(itv.Key());
if (itv.Value() != GraphDS_OnlyOutput) {
for (itr.Initialize(ENT->GetRelations()); itr.More(); itr.Next()) {
REL = Handle(GraphDS_Relation)::DownCast(itr.Key());
if (REL->IsOutput(ENT)) myMap.Add(REL);
}
}
}
myRelations.Initialize(myMap);
}
//=======================================================================
//function : More
//purpose :
//=======================================================================
Standard_Boolean GraphDS_IncidentRelationsIterator::More () const
{
return myRelations.More();
}
//=======================================================================
//function : Next
//purpose :
//=======================================================================
void GraphDS_IncidentRelationsIterator::Next ()
{
myRelations.Next();
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
const Handle(GraphDS_Relation)& GraphDS_IncidentRelationsIterator::Value () const
{
return *((Handle(GraphDS_Relation)*)& myRelations.Key());
//return Handle(GraphDS_Relation)::DownCast(myRelations.Key());
}

197
src/GraphDS/GraphDS_Relation.gxx Executable file
View File

@@ -0,0 +1,197 @@
// Copyright: Matra-Datavision 1991
// File: GraphDS_Relation.cxx
// Created: Fri Oct 11 18:03:55 1991
// Author: Denis PASCAL
// <dp>
# include <Standard_NoSuchObject.hxx>
# include <Standard_DomainError.hxx>
//=======================================================================
//function : GraphDS_Relation
//purpose :
//=======================================================================
GraphDS_Relation::GraphDS_Relation
(const GraphDS_Attribute& att) : myAttribute(att)
{
}
//=======================================================================
//function : GetAttribute
//purpose :
//=======================================================================
const GraphDS_Attribute& GraphDS_Relation::GetAttribute () const
{
return myAttribute;
}
//=======================================================================
//function : Contains
//purpose :
//=======================================================================
Standard_Boolean GraphDS_Relation::Contains
(const Handle(GraphDS_Entity)& E) const
{
return myEntities.IsBound(E);
}
//=======================================================================
//function : IsEmpty
//purpose :
//=======================================================================
Standard_Boolean GraphDS_Relation::IsEmpty () const
{
return myEntities.IsEmpty();
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void GraphDS_Relation::Add
(const Handle(GraphDS_Entity)& E, const GraphDS_EntityRole R)
{
myEntities.Bind(E,R);
}
//=======================================================================
//function : SetRole
//purpose :
//=======================================================================
void GraphDS_Relation::SetRole
(const Handle(GraphDS_Entity)& E, const GraphDS_EntityRole R)
{
myEntities(E) = R;
}
//=======================================================================
//function : Remove
//purpose :
//=======================================================================
void GraphDS_Relation::Remove (const Handle(GraphDS_Entity)& E)
{
myEntities.UnBind(E);
}
//=======================================================================
//function : GetRole
//purpose :
//=======================================================================
GraphDS_EntityRole GraphDS_Relation::GetRole
(const Handle(GraphDS_Entity)& E) const
{
return myEntities(E);
}
//=======================================================================
//function : IsInput
//purpose :
//=======================================================================
Standard_Boolean GraphDS_Relation::IsInput
(const Handle(GraphDS_Entity)& E) const
{
return (myEntities(E) != GraphDS_OnlyOutput);
}
//=======================================================================
//function : IsOutput
//purpose :
//=======================================================================
Standard_Boolean GraphDS_Relation::IsOutput
(const Handle(GraphDS_Entity)& E) const
{
return (myEntities(E) != GraphDS_OnlyInput);
}
//=======================================================================
//function : GetEntities
//purpose :
//=======================================================================
const GraphDS_EntityRoleMap& GraphDS_Relation::GetEntities() const
{
return myEntities;
}

View File

@@ -0,0 +1,514 @@
-- File: GraphDS_RelationGraph.cdl
-- Created: Fri Sep 6 11:00:25 1991
-- Author: Denis PASCAL
-- <dp@topsn2>
---Copyright: Matra Datavision 1991
generic class RelationGraph from GraphDS
(GraphDS_Item as any;
GraphDS_Attribute as any)
---Purpose: This generic class describe a network (or graph) of
-- Relations between Entities. an Item can be associated
-- to the Entity and respectively an Attribute to the
-- Relation. This class can be compared to the
-- DirectedGraph of this package. But here the Relation
-- (compared to the Edge) can describe links between more
-- than two Entities. Each link can be described as
-- oriented or not. Nested classes permit to edit and
-- visit that structure. Interface of visiting tools are
-- done as iterators.
uses TShared from MMgt,
MapOfTransient from TColStd,
EntityRole from GraphDS
raises NoSuchObject from Standard,
NoMoreObject from Standard,
DomainError from Standard
class Entity from GraphDS inherits TShared from MMgt
uses RelationRole from GraphDS,
MapOfTransient from TColStd
is
Create (value : GraphDS_Item)
returns mutable Entity from GraphDS;
GetItem (me)
---Level: Internal
---C++ : return const&
returns any GraphDS_Item;
Contains (me; R : Relation from GraphDS)
---Level: Internal
returns Boolean from Standard;
HasRelation (me)
---Level: Internal
returns Boolean from Standard;
GetRole (me; R : Relation from GraphDS)
---Level: Internal
returns RelationRole from GraphDS;
IsFront (me; R : Relation from GraphDS)
---Level: Internal
returns Boolean from Standard;
IsBack (me; R : Relation from GraphDS)
---Level: Internal
returns Boolean from Standard;
Add (me : mutable; R : Relation from GraphDS)
is private;
Remove (me : mutable; R : Relation from GraphDS)
is private;
GetRelations (me)
---C++: return const&
returns MapOfTransient from TColStd
is private;
fields
myItem : GraphDS_Item;
myRelations : MapOfTransient from TColStd;
friends
class RelationGraph from GraphDS,
class EntitiesIterator from GraphDS,
class IncidentEntitiesIterator from GraphDS,
class RelationsIterator from GraphDS,
class IncidentRelationsIterator from GraphDS
end Entity from GraphDS;
class Relation inherits TShared from MMgt
uses EntityRole from GraphDS,
EntityRoleMap from GraphDS
is
Create (value : GraphDS_Attribute)
returns mutable Relation;
GetAttribute (me)
---Level: Internal
---C++: return const&
returns any GraphDS_Attribute;
Contains (me; E : Entity from GraphDS)
---Level: Internal
returns Boolean from Standard;
IsEmpty (me)
---Level: Internal
returns Boolean from Standard;
GetRole (me; E : Entity from GraphDS)
---Level: Internal
returns EntityRole from GraphDS;
IsInput (me; E : Entity from GraphDS)
---Level: Internal
returns Boolean from Standard;
IsOutput (me; E : Entity from GraphDS)
---Level: Internal
returns Boolean from Standard;
Remove (me : mutable; E : Entity from GraphDS)
is private;
Add (me : mutable; E : Entity from GraphDS;
R : EntityRole from GraphDS)
is private;
SetRole (me : mutable; E : Entity from GraphDS;
R : EntityRole from GraphDS)
is private;
GetEntities (me)
---C++: return const&
returns EntityRoleMap from GraphDS
is private;
fields
myAttribute : GraphDS_Attribute;
myEntities : EntityRoleMap from GraphDS;
friends
class RelationGraph from GraphDS,
class EntitiesIterator from GraphDS,
class IncidentEntitiesIterator from GraphDS,
class RelationsIterator from GraphDS,
class IncidentRelationsIterator from GraphDS
end Relation;
class EntitiesIterator from GraphDS
---Purpose: Public nested class which defines an iterator to
-- visit each Entity member of a given RelationGraph.
uses MapOfTransient from TColStd,
MapIteratorOfMapOfTransient from TColStd
raises NoMoreObject from Standard,
NoSuchObject from Standard
is
Create
returns EntitiesIterator from GraphDS;
Create (G : RelationGraph from GraphDS)
returns EntitiesIterator from GraphDS;
Create (G : RelationGraph from GraphDS;
E : Entity from GraphDS)
returns EntitiesIterator from GraphDS;
Create (G : RelationGraph from GraphDS;
E : Relation from GraphDS)
returns EntitiesIterator from GraphDS;
Initialize (me : in out; G : RelationGraph from GraphDS);
---Level: Public
Initialize (me : in out; G : RelationGraph from GraphDS;
E : Entity from GraphDS);
---Level: Public
Initialize (me : in out; G : RelationGraph from GraphDS;
R : Relation from GraphDS);
---Level: Public
More (me)
---Level: Public
returns Boolean from Standard;
Next (me : in out)
---Level: Public
raises NoMoreObject from Standard;
Value (me)
---C++: return const&
---Level: Public
returns Entity from GraphDS
raises NoSuchObject from Standard;
fields
myMap : MapOfTransient from TColStd;
myEntities : MapIteratorOfMapOfTransient from TColStd;
end EntitiesIterator;
class RelationsIterator from GraphDS
---Purpose: Public nested class which defines an iterator to
-- visit each Relation member of a given
-- RelationGraph.
uses MapOfTransient from TColStd,
MapIteratorOfMapOfTransient from TColStd
raises NoMoreObject from Standard,
NoSuchObject from Standard
is
Create
returns RelationsIterator from GraphDS;
Create (G : RelationGraph from GraphDS)
returns RelationsIterator from GraphDS;
Create (G : RelationGraph from GraphDS;
R : Relation from GraphDS)
returns RelationsIterator from GraphDS;
Create (G : RelationGraph from GraphDS;
E : Entity from GraphDS)
returns RelationsIterator from GraphDS;
Initialize (me : in out; G : RelationGraph from GraphDS);
---Level: Public
Initialize (me : in out; G : RelationGraph from GraphDS;
R : Relation from GraphDS);
---Level: Public
Initialize (me : in out; G : RelationGraph from GraphDS;
E : Entity from GraphDS);
---Level: Public
More (me)
returns Boolean from Standard;
---Level: Public
Next (me : in out)
raises NoMoreObject from Standard;
---Level: Public
Value (me)
---C++: return const&
returns Relation from GraphDS
raises NoSuchObject from Standard;
---Level: Public
fields
myMap : MapOfTransient from TColStd;
myRelations : MapIteratorOfMapOfTransient from TColStd;
end RelationsIterator;
class IncidentEntitiesIterator from GraphDS
uses MapOfTransient from TColStd,
MapIteratorOfMapOfTransient from TColStd
raises NoMoreObject from Standard,
NoSuchObject from Standard
is
Create
returns IncidentEntitiesIterator from GraphDS;
Create (G : RelationGraph from GraphDS;
E : Entity from GraphDS)
returns IncidentEntitiesIterator from GraphDS;
Initialize (me : in out; G : RelationGraph from GraphDS;
E : Entity from GraphDS);
---Level: Public
More (me)
---Level: Public
returns Boolean from Standard;
Next (me : in out)
---Level: Public
raises NoMoreObject from Standard;
Value (me)
---C++: return const&
---Level: Public
returns Entity from GraphDS
raises NoSuchObject from Standard;
fields
myMap : MapOfTransient from TColStd;
myEntities : MapIteratorOfMapOfTransient from TColStd;
end IncidentEntitiesIterator;
class IncidentRelationsIterator from GraphDS
uses MapOfTransient from TColStd,
MapIteratorOfMapOfTransient from TColStd
raises NoMoreObject from Standard,
NoSuchObject from Standard
is
Create
returns IncidentRelationsIterator from GraphDS;
Create (G : RelationGraph from GraphDS;
R : Relation from GraphDS)
returns IncidentRelationsIterator from GraphDS;
Initialize (me : in out; G : RelationGraph from GraphDS;
R : Relation from GraphDS);
---Level: Public
More (me)
---Level: Public
returns Boolean from Standard;
Next (me : in out)
---Level: Public
raises NoMoreObject from Standard;
Value (me)
---C++: return const&
---Level: Public
returns Relation from GraphDS
raises NoSuchObject from Standard;
fields
myMap : MapOfTransient from TColStd;
myRelations : MapIteratorOfMapOfTransient from TColStd;
end IncidentRelationsIterator;
is
Create
returns RelationGraph from GraphDS;
---Purpose: Creates an empty relation graph.
Create (other : RelationGraph from GraphDS)
returns RelationGraph from GraphDS;
IsEmpty (me)
---Purpose: tests if <me> contains any Entity.
---Level: Public
returns Boolean from Standard;
Clear (me : in out);
---Purpose: Removes all the Entities and all the relations of
-- <me>.
---Level: Public
Contains (me; E : Entity from GraphDS)
---Purpose: tests if <me> contains <E>.
---Level: Public
returns Boolean from Standard;
Contains (me; R : Relation from GraphDS)
---Purpose: tests if <me> contains <rel>.
---Level: Public
returns Boolean from Standard;
NbEntities (me)
---Purpose: returns the number of Entity of me.
---Level: Public
returns Integer from Standard;
NbRelations (me)
---Purpose: returns the number of Relations of <me>.
---Level: Public
returns Integer from Standard;
IsInRelation (me; E : Entity from GraphDS)
---Purpose: To Know if <E> is in relation (as input,output
-- or both as well) with others Entities of <me>.
---Level: Public
returns Boolean from Standard
raises NoSuchObject from Standard;
IsInput (me; E : Entity from GraphDS)
returns Boolean from Standard
---Purpose: returns True if <E>
---Level: Public
raises NoSuchObject from Standard;
IsOutput (me; E : Entity from GraphDS)
returns Boolean from Standard
---Purpose: returns True if <E> is at least output of one of
-- its relation.
---Level: Public
raises NoSuchObject from Standard;
IsDependent (me; E : Entity from GraphDS)
returns Boolean from Standard
---Purpose: returns True if <E> is not input of one of its
-- relation.
---Level: Public
raises NoSuchObject from Standard;
AddEntity (me : in out; value : GraphDS_Item)
---Purpose: Creates an adds a new Entity (which contains item)
-- to <me>.
---Level: Public
returns Entity from GraphDS;
RemoveEntity (me : in out; E : Entity from GraphDS)
---Purpose: Removes a Entity <E> of <me>. Be carefull than an
-- exception is raised if <E> is still member of any
-- relation of <me>.
---Level: Public
raises NoSuchObject from Standard,
DomainError from Standard;
AddRelation (me : in out; value : GraphDS_Attribute)
---Purpose: Creates an adds a new Relation (which contains
-- attribute) to <me>.
---Level: Public
returns Relation from GraphDS;
RemoveRelation (me : in out; R : Relation from GraphDS)
---Purpose: Removes a relation <R> of <me>.
---Level: Public
raises NoSuchObject from Standard;
---Purpose: relation editing function
IsEmpty (me; R : Relation)
---Purpose: returns TRUE if noone entity is member of <R>.
---Level: Public
returns Boolean from Standard
raises NoSuchObject from Standard;
Add (me : in out; R : Relation; E : Entity)
---Purpose: add an InputAndOutput entity <E> to <R>
---Level: Public
raises NoSuchObject from Standard;
AddInput (me : in out; R : Relation; E : Entity)
---Purpose: add OnlyInput entity <E> to <R>.
---Level: Public
raises NoSuchObject from Standard;
AddOutput (me : in out; R : Relation; E : Entity)
---Purpose: add an OnlyOutput entity <E> to <R>.
---Level: Public
raises NoSuchObject from Standard;
Add (me : in out; R : Relation;
E : Entity;
role : EntityRole from GraphDS)
---Purpose: add an entity <E> to <R> with role <role>.
---Level: Public
raises NoSuchObject from Standard;
SetRole (me : in out; R : Relation;
E : Entity;
role : EntityRole from GraphDS)
---Purpose: set a new role <role> for the entity <E> member of <R>.
---Level: Public
raises NoSuchObject from Standard;
Remove (me : in out; R : Relation; E : Entity)
---Purpose: remove the entity <E> member of <R>.
---Level: Public
raises NoSuchObject from Standard;
fields
myEntities : MapOfTransient from TColStd;
myRelations : MapOfTransient from TColStd;
friends
class EntitiesIterator from GraphDS,
class RelationsIterator from GraphDS
end RelationGraph;

View File

@@ -0,0 +1,313 @@
// Copyright: Matra-Datavision 1991
// File: GraphDS_RelationGraph.gxx
// Created: Mon Sep 9 14:43:52 1991
// Author: Denis PASCAL
// <dp>
#include <Standard_NoSuchObject.hxx>
#include <Standard_DomainError.hxx>
#include <TColStd_MapIteratorOfMapOfTransient.hxx>
#include <GraphDS_DataMapIteratorOfEntityRoleMap.hxx>
//=======================================================================
//function : GraphDS_RelationGraph
//purpose :
//=======================================================================
GraphDS_RelationGraph::GraphDS_RelationGraph ()
{
}
//=======================================================================
//function : GraphDS_RelationGraph
//purpose :
//=======================================================================
GraphDS_RelationGraph::GraphDS_RelationGraph
(const GraphDS_RelationGraph& other)
{
myEntities = other.myEntities;
myRelations = other.myRelations;
}
//=======================================================================
//function : IsEmpty
//purpose :
//=======================================================================
Standard_Boolean GraphDS_RelationGraph::IsEmpty () const
{
return myEntities.Extent() ==0;
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void GraphDS_RelationGraph::Clear ()
{
myEntities.Clear();
myRelations.Clear();
}
//=======================================================================
//function : Contains
//purpose :
//=======================================================================
Standard_Boolean GraphDS_RelationGraph::Contains
(const Handle(GraphDS_Entity)& V) const
{
return myEntities.Contains(V);
}
//=======================================================================
//function : IsInRelation
//purpose :
//=======================================================================
Standard_Boolean GraphDS_RelationGraph::IsInRelation
(const Handle(GraphDS_Entity)& V) const
{
return (V->HasRelation());
}
//=======================================================================
//function : IsInput
//purpose :
//=======================================================================
Standard_Boolean GraphDS_RelationGraph::IsInput
(const Handle(GraphDS_Entity)& V) const
{
return !IsDependent(V);
}
//=======================================================================
//function : IsOutput
//purpose :
//=======================================================================
Standard_Boolean GraphDS_RelationGraph::IsOutput
(const Handle(GraphDS_Entity)& V) const
{
if (V->GetRelations().IsEmpty()) return Standard_True;
TColStd_MapIteratorOfMapOfTransient it (V->GetRelations());
for (;it.More();it.Next()) {
if (Handle(GraphDS_Relation)::DownCast(it.Key())->IsOutput(V)) return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : IsDependent
//purpose : il est seulement sortie d'une au moins de ses relations
//=======================================================================
Standard_Boolean GraphDS_RelationGraph::IsDependent
(const Handle(GraphDS_Entity)& E) const
{
if (E->GetRelations().IsEmpty()) return Standard_False;
TColStd_MapIteratorOfMapOfTransient it (E->GetRelations());
for (;it.More();it.Next()) {
if (Handle(GraphDS_Relation)::DownCast(it.Key())->IsOutput(E)) {
if (!Handle(GraphDS_Relation)::DownCast(it.Key())->IsInput(E))return Standard_True;
}
}
return Standard_False;
}
//=======================================================================
//function : Contains
//purpose :
//=======================================================================
Standard_Boolean GraphDS_RelationGraph::Contains
(const Handle(GraphDS_Relation)& R) const
{
return (myRelations.Contains(R));
}
//=======================================================================
//function : NbEntities
//purpose :
//=======================================================================
Standard_Integer GraphDS_RelationGraph::NbEntities() const
{
return myEntities.Extent();
}
//=======================================================================
//function : NbRelations
//purpose :
//=======================================================================
Standard_Integer GraphDS_RelationGraph::NbRelations() const
{
return myRelations.Extent();
}
//=======================================================================
//function : AddEntity
//purpose :
//=======================================================================
Handle(GraphDS_Entity) GraphDS_RelationGraph::AddEntity
(const GraphDS_Item& item)
{
Handle(GraphDS_Entity) entity = new GraphDS_Entity(item);
myEntities.Add(entity);
return entity;
}
//=======================================================================
//function : RemoveEntity
//purpose : Removes an Entity of the relation graph
//=======================================================================
void GraphDS_RelationGraph::RemoveEntity
(const Handle(GraphDS_Entity)& E)
{
if (E->HasRelation()) Standard_DomainError::Raise();
myEntities.Remove(E);
}
//=======================================================================
//function : AddRelation
//purpose :
//=======================================================================
Handle(GraphDS_Relation) GraphDS_RelationGraph::AddRelation
(const GraphDS_Attribute& att)
{
Handle(GraphDS_Relation) newrel = new GraphDS_Relation(att);
myRelations.Add(newrel);
return newrel;
}
//=======================================================================
//function : IsEmpty
//purpose :
//=======================================================================
Standard_Boolean GraphDS_RelationGraph::IsEmpty
(const Handle(GraphDS_Relation)& R) const
{
return R->IsEmpty();
}
//=======================================================================
//function : Add
//purpose : InputAndOutput
//=======================================================================
void GraphDS_RelationGraph::Add
(const Handle(GraphDS_Relation)& R,
const Handle(GraphDS_Entity)& E)
{
Add (R,E,GraphDS_InputAndOutput);
}
//=======================================================================
//function : AddInput
//purpose : OnlyInput
//=======================================================================
void GraphDS_RelationGraph::AddInput
(const Handle(GraphDS_Relation)& R,
const Handle(GraphDS_Entity)& E)
{
Add (R,E,GraphDS_OnlyInput);
}
//=======================================================================
//function : AddOutput
//purpose : OnlyOutput
//=======================================================================
void GraphDS_RelationGraph::AddOutput
(const Handle(GraphDS_Relation)& R,
const Handle(GraphDS_Entity)& E)
{
Add (R,E,GraphDS_OnlyOutput);
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void GraphDS_RelationGraph::Add
(const Handle(GraphDS_Relation)& R,
const Handle(GraphDS_Entity)& E,
const GraphDS_EntityRole role)
{
R->Add(E,role);
E->Add(R);
}
//=======================================================================
//function : SetRole
//purpose :
//=======================================================================
void GraphDS_RelationGraph::SetRole
(const Handle(GraphDS_Relation)& R,
const Handle(GraphDS_Entity)& E,
const GraphDS_EntityRole role)
{
R->SetRole(E,role);
}
//=======================================================================
//function : Remove
//purpose :
//=======================================================================
void GraphDS_RelationGraph::Remove
(const Handle(GraphDS_Relation)& R,
const Handle(GraphDS_Entity)& E)
{
R->Remove(E);
E->Remove(R);
}
//=======================================================================
//function : RemoveRelation
//purpose : Removes a relation of the relation graph
//=======================================================================
void GraphDS_RelationGraph::RemoveRelation
(const Handle(GraphDS_Relation)& R)
{
Handle(GraphDS_Entity) ENT;
GraphDS_DataMapIteratorOfEntityRoleMap it;
for (it.Initialize(R->GetEntities());it.More();it.Next()) {
ENT = Handle(GraphDS_Entity)::DownCast(it.Key());
ENT->Remove(R);
}
myRelations.Remove(R);
}

View File

@@ -0,0 +1,144 @@
// Copyright: Matra-Datavision 1991
// File: GraphDS_RelationsIterator.gxx
// Created: Tue Sep 10 17:01:38 1991
// Author: Denis PASCAL
// <dp>
#include <Standard_NoMoreObject.hxx>
#include <Standard_NoSuchObject.hxx>
#include <GraphDS_DataMapIteratorOfEntityRoleMap.hxx>
//=======================================================================
//function : GraphDS_RelationsIterator
//purpose :
//=======================================================================
GraphDS_RelationsIterator::GraphDS_RelationsIterator ()
{
}
//=======================================================================
//function : GraphDS_RelationsIterator
//purpose :
//=======================================================================
GraphDS_RelationsIterator::GraphDS_RelationsIterator
(const GraphDS_RelationGraph& G)
{
Initialize (G);
}
//=======================================================================
//function : GraphDS_RelationsIterator
//purpose :
//=======================================================================
GraphDS_RelationsIterator::GraphDS_RelationsIterator
(const GraphDS_RelationGraph& G,
const Handle(GraphDS_Entity)& E)
{
Initialize(G,E);
}
//=======================================================================
//function : GraphDS_RelationsIterator
//purpose :
//=======================================================================
GraphDS_RelationsIterator::GraphDS_RelationsIterator
(const GraphDS_RelationGraph& G,
const Handle(GraphDS_Relation)& R)
{
Initialize(G,R);
}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
void GraphDS_RelationsIterator::Initialize
(const GraphDS_RelationGraph& G)
{
myRelations.Initialize(G.myRelations);
}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
void GraphDS_RelationsIterator::Initialize
(const GraphDS_RelationGraph&,
const Handle(GraphDS_Entity)& E)
{
myRelations.Initialize(E->GetRelations());
}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
void GraphDS_RelationsIterator::Initialize
(const GraphDS_RelationGraph&,
const Handle(GraphDS_Relation)& R)
{
myMap.Clear();
Handle(GraphDS_Entity) ENT;
Handle(GraphDS_Relation) REL;
GraphDS_DataMapIteratorOfEntityRoleMap itv;
TColStd_MapIteratorOfMapOfTransient itr;
for (itv.Initialize(R->GetEntities());itv.More();itv.Next()) {
ENT = Handle(GraphDS_Entity)::DownCast(itv.Key());
if (itv.Value() != GraphDS_OnlyInput) {
for (itr.Initialize(ENT->GetRelations()); itr.More(); itr.Next()) {
REL = Handle(GraphDS_Relation)::DownCast(itr.Key());
if (REL->IsInput(ENT)) myMap.Add(REL);
}
}
}
myRelations.Initialize(myMap);
}
//=======================================================================
//function : More
//purpose :
//=======================================================================
Standard_Boolean GraphDS_RelationsIterator::More () const
{
return myRelations.More();
}
//=======================================================================
//function : Next
//purpose :
//=======================================================================
void GraphDS_RelationsIterator::Next ()
{
myRelations.Next();
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
const Handle(GraphDS_Relation)& GraphDS_RelationsIterator::Value () const
{
return *((Handle(GraphDS_Relation)*)& myRelations.Key());
//return Handle(GraphDS_Relation)::DownCast(myRelations.Key());
}

145
src/GraphDS/GraphDS_Vertex.gxx Executable file
View File

@@ -0,0 +1,145 @@
// File: GraphDS_Vertex.gxx
// Created: Tue Mar 16 15:26:55 1993
// Author: Denis PASCAL
// <dp@bravox>
#include <Standard_NoSuchObject.hxx>
#include <Standard_NoMoreObject.hxx>
#include <Standard_DomainError.hxx>
#include <Standard_NotImplemented.hxx>
//=======================================================================
//function : GraphDS_Vertex
//purpose :
//=======================================================================
GraphDS_Vertex::GraphDS_Vertex (const GraphDS_Item& value) : myItem(value)
{
}
//=======================================================================
//function : GetItem
//purpose :
//=======================================================================
const GraphDS_Item& GraphDS_Vertex::GetItem () const
{
return myItem;
}
//=======================================================================
//function : SetItem
//purpose :
//=======================================================================
void GraphDS_Vertex::SetItem (const GraphDS_Item& Value)
{
myItem = Value;
}
//=======================================================================
//function : Contains
//purpose :
//=======================================================================
Standard_Boolean GraphDS_Vertex::Contains (const Handle(GraphDS_Edge)& E) const
{
return myEdges.Contains(E);
}
Standard_Boolean GraphDS_Vertex::IsFront (const Handle(GraphDS_Edge)& ) const
{
Standard_NotImplemented::Raise();
return Standard_False;
}
Standard_Boolean GraphDS_Vertex::IsBack (const Handle(GraphDS_Edge)& ) const
{
Standard_NotImplemented::Raise();
return Standard_False;
}
//=======================================================================
//function : IsRoot
//purpose : never destination of an edge
//=======================================================================
Standard_Boolean GraphDS_Vertex::IsRoot (const Standard_Boolean ignoreselfloop) const
{
Handle(GraphDS_Vertex) me = this;
Handle(GraphDS_Edge) E;
TColStd_MapIteratorOfMapOfTransient it;
for (it.Initialize(myEdges); it.More(); it.Next()) {
E = Handle(GraphDS_Edge)::DownCast(it.Key());
if (ignoreselfloop && E->IsLoop()) continue;
if (E->Destination() == me) return Standard_False;
}
return Standard_True;
}
//=======================================================================
//function : IsLeaf
//purpose : never source of an edge
//=======================================================================
Standard_Boolean GraphDS_Vertex::IsLeaf (const Standard_Boolean ignoreselfloop) const
{
Handle(GraphDS_Vertex) me = this;
Handle(GraphDS_Edge) E;
TColStd_MapIteratorOfMapOfTransient it;
for (it.Initialize(myEdges); it.More(); it.Next()) {
E = Handle(GraphDS_Edge)::DownCast(it.Key());
if (ignoreselfloop && E->IsLoop()) continue;
if (E->Source() == me) return Standard_False;
}
return Standard_True;
}
//=======================================================================
//function : AddEdge
//purpose : private
//=======================================================================
Standard_Boolean GraphDS_Vertex::AddEdge (const Handle(GraphDS_Edge)& E)
{
return myEdges.Add(E);
}
//=======================================================================
//function : RemoveEdge
//purpose : private
//=======================================================================
void GraphDS_Vertex::RemoveEdge (const Handle(GraphDS_Edge)& E)
{
myEdges.Remove(E);
}
//=======================================================================
//function : GetEdges
//purpose : private
//=======================================================================
const TColStd_MapOfTransient& GraphDS_Vertex::GetEdges () const
{
return myEdges;
}

View File

@@ -0,0 +1,117 @@
// File: GraphDS_VerticesIterator.gxx
// Created: Tue Mar 16 15:43:39 1993
// Author: Denis PASCAL
// <dp@bravox>
#include <Standard_NoMoreObject.hxx>
#include <Standard_NoSuchObject.hxx>
//=======================================================================
//function : GraphDS_VerticesIterator
//purpose :
//=======================================================================
GraphDS_VerticesIterator::GraphDS_VerticesIterator ()
{
}
//=======================================================================
//function : GraphDS_VerticesIterator
//purpose :
//=======================================================================
GraphDS_VerticesIterator::GraphDS_VerticesIterator
(const GraphDS_DirectedGraph& DG)
{
Initialize (DG);
}
//=======================================================================
//function : GraphDS_VerticesIterator
//purpose :
//=======================================================================
GraphDS_VerticesIterator::GraphDS_VerticesIterator
(const GraphDS_DirectedGraph& DG,
const Handle(GraphDS_Vertex)& V)
{
Initialize (DG,V);
}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
void GraphDS_VerticesIterator::Initialize (const GraphDS_DirectedGraph& DG)
{
myVertices.Initialize(DG.myVertices);
}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
void GraphDS_VerticesIterator::Initialize
(const GraphDS_DirectedGraph& DG,
const Handle(GraphDS_Vertex)& V)
{
myMap.Clear();
Handle(GraphDS_Edge) E;
TColStd_MapIteratorOfMapOfTransient it(V->GetEdges());
for (;it.More();it.Next()) {
E = Handle(GraphDS_Edge)::DownCast(it.Key());
if (E->Source() == V) myMap.Add(E->Destination());
}
myVertices.Initialize(myMap);
}
//=======================================================================
//function : More
//purpose :
//=======================================================================
Standard_Boolean GraphDS_VerticesIterator::More () const
{
return myVertices.More();
}
//=======================================================================
//function : Next
//purpose :
//=======================================================================
void GraphDS_VerticesIterator::Next ()
{
myVertices.Next();
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
const Handle(GraphDS_Vertex)& GraphDS_VerticesIterator::Value () const
{
return *((Handle(GraphDS_Vertex)*)& myVertices.Key());
//return Handle(GraphDS_Vertex)::DownCast(myVertices.Key());
}