GraphBase< NODE, EDGE > Class Template Reference

#include <graphbase.h>

详细描述

template<typename NODE, typename EDGE>
class maxon::GraphBase< NODE, EDGE >

Basic undirected graph template.

Template Parameters
NODE The node type in the graph.
EDGE The edge type in the graph.

Public Types

typedef GraphBase < NODE, EDGE >  Super
typedef NODE  NodeType
typedef EDGE  EdgeType

公共成员函数

  GraphBase ()
  ~GraphBase ()
  GraphBase ( GraphBase && src )
Result < void >  CopyFrom (const GraphBase & src )
Result < void >  AppendGraph (const GraphBase & src )
GRAPH_TYPE   GetType () const
void  SetType ( GRAPH_TYPE type)
Int   GetNodesCount ( Bool subPoint=false) const
Int   GetEdgesCount () const
NODE *  GetFirstNode ()
NODE *  GetLastNode ()
NODE *  FindNodeByPosition (const 向量 &position, Float tolerance=0.0)
const NODE *  FindNodeByPosition (const 向量 &position, Float tolerance=0.0) const
Result < NODE * >  GetNode ( Int idx)
Result < const NODE * >  GetNode ( Int idx) const
Result < NODE * >  GetSuccessor (NODE *node)
Result < NODE * >  GetPredecessor (NODE *node)
Result < EDGE * >  GetSuccessorEdge (NODE *node)
Result < EDGE * >  GetPredecessorEdge (NODE *node)
Int   FindNode (NODE *node)
Result < EDGE * >  GetEdge ( Int idx)
Result < const EDGE * >  GetEdge ( Int idx) const
Int   FindEdge (EDGE *edge)
Result < EDGE * >  GetEdgeByPoints ( NodeType *p1, NodeType *p2) const
Result < NODE * >  AddNode (const NodeType &node, Int pos= NOTOK )
Result < EDGE * >  AddEdge ( NodeType *p1, NodeType *p2, Int pos= NOTOK )
Result < NODE * >  SplitEdge (const NODE &node, EdgeType *edge)
Result < EDGE * >  SplitEdge ( NodeType *node, EdgeType *edge)
Result < void >  DeleteNode ( NodeType *node, Bool replaceEdge=true)
Result < void >  DeleteNode ( Int pos, Bool replaceEdge=true)
Result < void >  DeleteEdge ( EdgeType *edge, Bool nodes=false)
Result < void >  DeleteEdge ( Int pos, Bool nodes=false)
Result < void >  WeldNodes ( NodeType *p1, NodeType *p2)
Result < void >  MeltEdge ( EdgeType *edge)
Result < void >  MeltEdge ( Int pos)
void  重置 ()

Protected Attributes

GRAPH_TYPE   _type
PointerArray < NODE >  _nodes
PointerArray < EDGE >  _edges

Member Typedef Documentation

◆  Super

typedef GraphBase <NODE, EDGE> Super

◆  NodeType

typedef NODE NodeType

◆  EdgeType

typedef EDGE EdgeType

构造函数 & 析构函数文档编制

◆  GraphBase() [1/2]

GraphBase ( )
explicit

◆  ~GraphBase()

~ GraphBase ( )

◆  GraphBase() [2/2]

GraphBase ( GraphBase < NODE, EDGE > &&  src )

成员函数文档编制

◆  CopyFrom()

Result <void> CopyFrom ( const GraphBase < NODE, EDGE > &  src )

◆  AppendGraph()

Result <void> AppendGraph ( const GraphBase < NODE, EDGE > &  src )

Append src graph t this graph, the existing graph is mantained.

参数
[in] src The graph to append.
返回
OK on success.

◆  GetType()

GRAPH_TYPE GetType ( ) const

Get The graph type.

返回
The graph type.

◆  SetType()

void SetType ( GRAPH_TYPE   type )

Set The graph type.

参数
[in] type The new graph type.

◆  GetNodesCount()

Int GetNodesCount ( Bool   subPoint = false ) const

Get All nodes count in the graph.

返回
The main point count in the graph.

◆  GetEdgesCount()

Int GetEdgesCount ( ) const

Get All edge count in the graph.

返回
The stroke count in the graph.

◆  GetFirstNode()

NODE* GetFirstNode ( )

Get a pointer to the first node.

返回
A pointer to the first node.

◆  GetLastNode()

NODE* GetLastNode ( )

Get a pointer to the last node.

返回
A pointer to the last node.

◆  FindNodeByPosition() [1/2]

NODE* FindNodeByPosition ( const 向量 position ,
Float   tolerance = 0.0  
)

Serch a node with at passed position.

参数
[in] position The 3d position where search the node.
[in] tolerance Search can be tolerat if passed value is != 0.
返回
A pointer to the node if found at position otherwise false.

◆  FindNodeByPosition() [2/2]

const NODE* FindNodeByPosition ( const 向量 position ,
Float   tolerance = 0.0  
) const

Serch a node with at passed position.

参数
[in] position The 3d position where search the node.
[in] tolerance Search can be tolerat if passed value is != 0.
返回
A pointer to the node if found at position otherwise false.

◆  GetNode() [1/2]

Result <NODE*> GetNode ( Int   idx )

Get a node in the list.

参数
[in] idx The node index in the list.
返回
A pointer to the entry in the list otherwise error.

◆  GetNode() [2/2]

Result <const NODE*> GetNode ( Int   idx ) const

Get a node in the list.

参数
[in] idx The node index in the list.
返回
A pointer to the entry in the list otherwise error.

◆  GetSuccessor()

Result <NODE*> GetSuccessor ( NODE *  node )

Get the successor node, valid only in continuos graph case.

参数
[in] node The node.
返回
A pointer to the successor node otherwise an error.

◆  GetPredecessor()

Result <NODE*> GetPredecessor ( NODE *  node )

Get the predecessor node, valid only in continuos graph case.

参数
[in] node The node.
返回
A pointer to the Predecessor node otherwise an error.

◆  GetSuccessorEdge()

Result <EDGE*> GetSuccessorEdge ( NODE *  node )

Get the successor edge, valid only in continuos graph case.

参数
[in] node The node.
返回
A pointer to the successor edge otherwise an error.

◆  GetPredecessorEdge()

Result <EDGE*> GetPredecessorEdge ( NODE *  node )

Get the predecessor edge, valid only in continuos graph case.

参数
[in] node The node.
返回
A pointer to the Predecessor edge otherwise an error.

◆  FindNode()

Int FindNode ( NODE *  node )

Check if node exist in the node list and return the index.

参数
[in] node The node to check for.
返回
The node index if found or NOTOK if the node is not in to the list.

◆  GetEdge() [1/2]

Result <EDGE*> GetEdge ( Int   idx )

Get a edge at idx in the list.

参数
[in] idx The edge index in the list.
返回
A pointer to the entry in the list otherwise error.

◆  GetEdge() [2/2]

Result <const EDGE*> GetEdge ( Int   idx ) const

Get a edge at idx in the list.

参数
[in] idx The edge index in the list.
返回
A pointer to the entry in the list otherwise error.

◆  FindEdge()

Int FindEdge ( EDGE *  edge )

Check if edge exist in the edge list and return the index.

参数
[in] edge The edge to check for.
返回
The edge index if found or NOTOK if the edge is not in to the list.

◆  GetEdgeByPoints()

Result <EDGE*> GetEdgeByPoints ( NodeType p1 ,
NodeType p2  
) const

Check if exist a edge in between p1 and p2, if yes return the pointer.

参数
[in] p1 First edge point.
[in] p2 Second edge point.
返回
A pointer to the edge otherwise error.

◆  AddNode()

Result <NODE*> AddNode ( const NodeType node ,
Int   pos = NOTOK  
)

Add a new node to the list.

参数
[in] node The new pen node to add.
[in] pos Optional position in to the array if NOTOK or not passed the point is added at the end of the list.
返回
A pointer to the added entry otherwise error.

◆  AddEdge()

Result <EDGE*> AddEdge ( NodeType p1 ,
NodeType p2 ,
Int   pos = NOTOK  
)

Add a new edge in between p1 and p2 with type and initialize it. Automatically map the stoke to the points list.

参数
[in] p1 First edge node.
[in] p2 Second edge node.
[in] pos If not NOTOK new stroke will be inserted at pos in the list.
返回
A pointer to the new stroke added to the list otherwise error.

◆  SplitEdge() [1/2]

Result <NODE*> SplitEdge ( const NODE &  node ,
EdgeType edge  
)

Split edge in 2 parts by adding the new node.

参数
[in] node The new node to insert in to the list.
[in] edge The edge to split.
返回
A pointer to the new created node otherwise error.

◆  SplitEdge() [2/2]

Result <EDGE*> SplitEdge ( NodeType node ,
EdgeType edge  
)

Split edge in 2 parts by attaching it to an existing node.

参数
[in] node The node to attach the strokes.
[in] edge The edge to split.
返回
The new added edge pointer otherwise error.

◆  DeleteNode() [1/2]

Result <void> DeleteNode ( NodeType node ,
Bool   replaceEdge = true  
)

Remove node and the connected edges.

参数
[in] node The node to be removed.
[in] replaceEdge If true a new edge will be added to fill the gap, just if the graph is not sparse (max 2 edges per node).
返回
OK on success.

◆  DeleteNode() [2/2]

Result <void> DeleteNode ( Int   pos ,
Bool   replaceEdge = true  
)

Remove node at pos and the connected edges.

参数
[in] pos The index position of node to be removed.
[in] replaceEdge If true a new edge will be added to fill the gap, just if the graph is not sparse (max 2 edges per node).
返回
OK on success.

◆  DeleteEdge() [1/2]

Result <void> DeleteEdge ( EdgeType edge ,
Bool   nodes = false  
)

Remove the edge and adjust the nodes<->edges mapping.

参数
[in] edge The edge to be removed.
[in] nodes If True also node will be deleted if any other edge use it.
返回
OK on success.

◆  DeleteEdge() [2/2]

Result <void> DeleteEdge ( Int   pos ,
Bool   nodes = false  
)

Remove the edge and adjust the nodes<->edges mapping.

参数
[in] pos The position in to edge list.
[in] nodes If True also nodes will be deleted if any other edge use it.
返回
OK on success.

◆  WeldNodes()

Result <void> WeldNodes ( NodeType p1 ,
NodeType p2  
)

Weld disconnected nodes.

参数
[in] p1 First node, this node will be stay alive.
[in] p2 Second node.
返回
OK on success.

◆  MeltEdge() [1/2]

Result <void> MeltEdge ( EdgeType edge )

Shrink edge to a single node and refresh the graph.

参数
[in] edge The edge to be removed.
返回
OK on success.

◆  MeltEdge() [2/2]

Result <void> MeltEdge ( Int   pos )

Shrink edge at pos to a single node and refresh the graph.

参数
[in] pos The position in to edge list.
返回
OK on success.

◆  Reset()

void Reset ( )

Free memory and reset all values.

Member Data Documentation

◆  _type

GRAPH_TYPE _type
protected

◆  _nodes

PointerArray <NODE> _nodes
protected

◆  _edges

PointerArray <EDGE> _edges
protected