CFx SDK Documentation  2023 SP0
Public Member Functions | Protected Member Functions | Friends | List of all members
OdDbGraph Class Reference

#include <DbGraph.h>

Inheritance diagram for OdDbGraph:
OdDbObjectIdGraph OdDbXrefGraph

Public Member Functions

 OdDbGraph ()
 
virtual ~OdDbGraph ()
 
OdDbGraphNodenode (int nodeIndex) const
 
OdDbGraphNoderootNode () const
 
int numNodes () const
 
bool isEmpty () const
 
void addNode (OdDbGraphNode *pNode)
 
void addEdge (OdDbGraphNode *pFrom, OdDbGraphNode *pTo)
 
void delNode (OdDbGraphNode *pNode)
 
void reset ()
 
void clearAll (OdUInt8 flags)
 
void getOutgoing (OdDbGraphNodeArray &outgoing)
 
virtual bool findCycles (OdDbGraphNode *pStart=0)
 
void breakCycleEdge (OdDbGraphNode *pFrom, OdDbGraphNode *pTo)
 

Protected Member Functions

void clearAllCycles ()
 

Friends

class OdDbGraphNode
 

Detailed Description

This class implements generic graph objects.

Remarks
A graph consists of a collection of nodes bi-directionally linked by directional edges.

An edge connected to a node is represented as a pointer or reference to the node at the other end of the edge.

References are classified as either incoming or outgoing. Every incoming reference has a corresponding outgoing reference and vice versa.

Each GraphNode object can have any number of references associated with it, enabling the implementation of any graph structure.

See also
OdDbGraphNode OdDbGraphStack OdDbXrefGraph OdDbXrefGraphNode

Corresponding C++ library: TD_Db <group OdDb_Classes>

Definition at line 501 of file DbGraph.h.

Constructor & Destructor Documentation

◆ OdDbGraph()

OdDbGraph::OdDbGraph ( )
inline

Definition at line 505 of file DbGraph.h.

◆ ~OdDbGraph()

virtual OdDbGraph::~OdDbGraph ( )
virtual

Member Function Documentation

◆ addEdge()

void OdDbGraph::addEdge ( OdDbGraphNode pFrom,
OdDbGraphNode pTo 
)

Adds the specified edge to this Graph object.

Parameters
pFrom[in] Pointer to the GraphNode at the start of the edge.
pTo[in] Pointer to the GraphNode at the end of the edge.
Remarks
Creates an outgoing reference to *pTo in *pFrom, and an incoming reference to *pFrom in *pTo.

Throws: OdError(eInvalidOwnerObject) if the specified GraphNode objects are not in the same Graph object.

◆ addNode()

void OdDbGraph::addNode ( OdDbGraphNode pNode)

Adds the specifed GraphNode object to this Graph object.

Parameters
pNode[in] Pointer to the GraphNode object.
Remarks
pNode must be created with new(), and should not be deleted once added to this Graph object; This Graph object will delete the GraphNode when it is no longer needed.

Throws: OdError(eInvalidOwnerObject) if the specified GraphNode object already has an owner.

◆ breakCycleEdge()

void OdDbGraph::breakCycleEdge ( OdDbGraphNode pFrom,
OdDbGraphNode pTo 
)
Remarks
Removes the specified edge, and updates the cyclical information for this Graph object.
Parameters
pFrom[in] Pointer to the GraphNode at the start of the edge.
pTo[in] Pointer to the GraphNode at the end of the edge.

◆ clearAll()

void OdDbGraph::clearAll ( OdUInt8  flags)

Clears the specified set flag bits in the GraphNode objects of this Graph object.

Parameters
flags[in] Flag bits.
Remarks
flags must be a combination of one or more of the following:

Value Description OdDbGraphNode::kNone 0x00 None. OdDbGraphNode::kVisited 0x01 Used internally by OdDbGraph::findCycles() and while traversing a graphs with cycles. OdDbGraphNode::kOutsideRefed 0x02 Used internally by Xref detach. OdDbGraphNode::kSelected 0x04 User selection. Set by getOutgoing. OdDbGraphNode::kInList 0x08 Is in list. Set by getOutgoing. OdDbGraphNode::kListAll 0x0E Used to clear kSelected, kInList, kOutsideRefed. OdDbGraphNode::kFirstLevel 0x10 The node is connected to the root node. Read Only. OdDbGraphNode::kUnresTree 0x20 The tree is unresolved. OdDbGraphNode::kAll 0x2F Used to clear all but kFirstLevel.

OdDbGraphNode::kListAll and OdDbGraphNode::kAll are intended to be used with this function.

◆ clearAllCycles()

void OdDbGraph::clearAllCycles ( )
protected

Removes all cyclical information determined by findCycles.

\ewmarks This function does not remove cyclical edges, and is intended only for error cleanup.

See also
breakCycleEdge

◆ delNode()

void OdDbGraph::delNode ( OdDbGraphNode pNode)

Removes the specified node from this GraphNode object, and all references to it.

Parameters
pNode[in] Pointer to the GraphNode object.

◆ findCycles()

virtual bool OdDbGraph::findCycles ( OdDbGraphNode pStart = 0)
virtual

Finds the cyclical nodes for this Graph object.

Parameters
pStart[in] Pointer to the starting node from which to search. Usually defaulted.
Returns
Returns true if and only if there are any cyclical GraphNodes.
Remarks
This function must be called with no intervening changes to the graph, prior to querying cycle information.

◆ getOutgoing()

void OdDbGraph::getOutgoing ( OdDbGraphNodeArray outgoing)

Adds to the specified array, the nested outgoing GraphNode objects from the specified GraphNode objects.

Parameters
outgoing[in/out] Array of GraphNode objects.
Remarks
The user must clear the kListAll flags with OdDbGraph::clearAll() or OdDbGraphNode::clear() when done with them.

◆ isEmpty()

bool OdDbGraph::isEmpty ( ) const
inline

Returns true if and only if this Graph object is empty.

Definition at line 534 of file DbGraph.h.

◆ node()

OdDbGraphNode* OdDbGraph::node ( int  nodeIndex) const
inline

Returns the specified GraphNode object of this Graph object.

Parameters
nodeIndex[in] Node index.

Definition at line 513 of file DbGraph.h.

◆ numNodes()

int OdDbGraph::numNodes ( ) const
inline

Returns the specified incoming reference of this Graph object.

Parameters
refIndex[in] Reference index.

Definition at line 529 of file DbGraph.h.

◆ reset()

void OdDbGraph::reset ( )

Removes all nodes and cycle nodes from this Graph object.

Remarks
Always called by ~OdDbGraph().

◆ rootNode()

OdDbGraphNode* OdDbGraph::rootNode ( ) const

Returns the root (first) GraphNode object of this Graph object.

Remarks
Returns a null pointer if isEmpty().

Friends And Related Function Documentation

◆ OdDbGraphNode

friend class OdDbGraphNode
friend

Definition at line 503 of file DbGraph.h.


The documentation for this class was generated from the following file: