ALBA
Classes | Public Member Functions | Static Public Attributes | List of all members
albaPolylineGraph Class Reference

#include <albaPolylineGraph.h>

Classes

class  Branch
 
class  Edge
 
class  Vertex
 

Public Member Functions

 albaPolylineGraph ()
 
 ~albaPolylineGraph ()
 
int GetNumberOfVertices () const
 
int GetNumberOfEdges () const
 
int GetNumberOfBranches () const
 
vtkIdType GetMaxVertexId () const
 
vtkIdType GetMaxEdgeId () const
 
vtkIdType GetMaxBranchId () const
 
void GetVertexCoords (vtkIdType v, double *coords) const
 
void SetVertexCoords (vtkIdType v, const double *coords)
 
const char * GetBranchName (vtkIdType b) const
 
void SetBranchName (vtkIdType b, const char *name)
 
void UnsetBranchName (vtkIdType b)
 
vtkIdType FindBranchName (const char *name) const
 
double GetBranchLength (vtkIdType b) const
 
double GetBranchIntervalLength (vtkIdType b, vtkIdType startVertexId, vtkIdType endVertexId) const
 
bool IsEdgeDirected (vtkIdType e) const
 
void SetEdgeDirected (vtkIdType e, bool directed)
 
void ReverseEdge (vtkIdType e)
 
double GetEdgeWeight (vtkIdType e) const
 
void SetEdgeWeight (vtkIdType e, double wt)
 
bool AddNewEdge (vtkIdType v0, vtkIdType v1)
 
void AddNewVertex (double *coords=NULL)
 
bool AddNewVertex (vtkIdType v0, double *coords=NULL)
 
void AddNewBranch (const char *name=NULL)
 
bool AddNewBranch (vtkIdType v0, const char *name=NULL)
 
bool CopyFromPolydata (vtkPolyData *polydata)
 
bool CopyToPolydata (vtkPolyData *polydata)
 
void GetOutputCellCorrespondingToEdge (vtkIdType edgeid, vtkIdType *cellid, vtkIdType *index) const
 
vtkIdType GetEdgeCorrespondingToOutputCell (vtkIdType cellid, vtkIdType index) const
 
void GetOutputCellCorrespondingToBranch (vtkIdType branchid, vtkIdType *cellid) const
 
vtkIdType GetBranchCorrespondingToOutputCell (vtkIdType cellid) const
 
bool SplitBranchAtEdge (vtkIdType b, vtkIdType e)
 
bool SplitBranchAtVertex (vtkIdType b, vtkIdType v)
 
void AddNewVertexToBranch (vtkIdType b, double *coords=NULL)
 
bool AddExistingVertexToBranch (vtkIdType b, vtkIdType v, vtkIdType e=m_UndefinedId)
 
bool AddExistingEdgeToBranch (vtkIdType b, vtkIdType e)
 
void ReverseBranch (vtkIdType b)
 
bool DeleteEdge (vtkIdType i)
 
bool DeleteVertex (vtkIdType i)
 
bool DeleteBranch (vtkIdType i)
 
bool MergeBranches (vtkIdType b1, vtkIdType b2)
 
bool MergeSimpleJoinedBranchesAtVertex (vtkIdType v)
 
void MergeSimpleJoinedBranches ()
 
bool IsConnected () const
 
bool IsConnectedTree () const
 
void Clear ()
 
bool SelfCheck () const
 
void PrintSelf (std::ostream &os, const int tabs) const
 
const VertexGetConstVertexPtr (vtkIdType i) const
 
const EdgeGetConstEdgePtr (vtkIdType i) const
 
const BranchGetConstBranchPtr (vtkIdType i) const
 

Static Public Attributes

static const vtkIdType m_UndefinedId
 
static const int m_UndefinedInt
 
static const char * m_UndefinedName
 

Detailed Description

albaPolylineGraph class

albaPolylineGraph is a class for navigating and editing polyline data.

It consists of a list of vertices, edges and branches. Vertices are points. Edges connect pairs of vertices. Branches are named sequences of connected vertices and edges.

The graph can read from and write to vtkPolydata. Navigation and editing is much simpler with this class than vtkPolydata.

albaPolylineGraph provides top-level methods which always leave a self-consistent graph, ie SelfCheck() = true. There is also public read-only access to the vertices, edges and branches using: albaPolylineGraph->GetConstVertexPtr() albaPolylineGraph->GetConstEdgePtr() albaPolylineGraph->GetConstBranchPtr()

Eg to get the degree of vertex i: Graph->GetConstVertexPtr(i)->GetDegree() ;

Keeping track of object ids: This scheme causes the least inconvenience to the user and the programmer: Methods which create new vertices, edges and branches do so at the end of the id list, so you can easily get the id of the new object with Graph->GetMaxVertexId() etc. Methods which delete objects overwrite them from the end of the list, and delete the end of the list. Eg Graph->DeleteBranch(i) moves branch(idmax) to branch(i), and deletes branch(idmax).

Branches: adding and removing edges You can only add and remove edges and vertices from a branch by editing the branch. To remove an edge from a branch you have to split the branch. Edges and vertices can only be added to the end of the branch. Adding and deleting items from branches has no effect on the graph connectivity.

Definition at line 69 of file albaPolylineGraph.h.

Constructor & Destructor Documentation

◆ albaPolylineGraph()

albaPolylineGraph::albaPolylineGraph ( )

constructor: empty graph

◆ ~albaPolylineGraph()

albaPolylineGraph::~albaPolylineGraph ( )

destructor

Member Function Documentation

◆ GetNumberOfVertices()

int albaPolylineGraph::GetNumberOfVertices ( ) const

get no. of vertices

◆ GetNumberOfEdges()

int albaPolylineGraph::GetNumberOfEdges ( ) const

get no. of edges

◆ GetNumberOfBranches()

int albaPolylineGraph::GetNumberOfBranches ( ) const

get no. of branches

◆ GetMaxVertexId()

vtkIdType albaPolylineGraph::GetMaxVertexId ( ) const

get index of last vertex in graph

◆ GetMaxEdgeId()

vtkIdType albaPolylineGraph::GetMaxEdgeId ( ) const

get index of last edge in graph

◆ GetMaxBranchId()

vtkIdType albaPolylineGraph::GetMaxBranchId ( ) const

get index of last branch in graph

◆ GetVertexCoords()

void albaPolylineGraph::GetVertexCoords ( vtkIdType  v,
double *  coords 
) const

get coords of vertex

◆ SetVertexCoords()

void albaPolylineGraph::SetVertexCoords ( vtkIdType  v,
const double *  coords 
)

set coords of vertex

◆ GetBranchName()

const char * albaPolylineGraph::GetBranchName ( vtkIdType  b) const

get name of branch

◆ SetBranchName()

void albaPolylineGraph::SetBranchName ( vtkIdType  b,
const char *  name 
)

set name of branch

◆ UnsetBranchName()

void albaPolylineGraph::UnsetBranchName ( vtkIdType  b)

unset name of branch to undefined

◆ FindBranchName()

vtkIdType albaPolylineGraph::FindBranchName ( const char *  name) const

find branch with name

◆ GetBranchLength()

double albaPolylineGraph::GetBranchLength ( vtkIdType  b) const

return the length of the branch

◆ GetBranchIntervalLength()

double albaPolylineGraph::GetBranchIntervalLength ( vtkIdType  b,
vtkIdType  startVertexId,
vtkIdType  endVertexId 
) const

◆ IsEdgeDirected()

bool albaPolylineGraph::IsEdgeDirected ( vtkIdType  e) const

get directed property of edge

◆ SetEdgeDirected()

void albaPolylineGraph::SetEdgeDirected ( vtkIdType  e,
bool  directed 
)

set directed property of edge

◆ ReverseEdge()

void albaPolylineGraph::ReverseEdge ( vtkIdType  e)

reverse direction of edge (swap end vertices)

◆ GetEdgeWeight()

double albaPolylineGraph::GetEdgeWeight ( vtkIdType  e) const

get weight of edge

◆ SetEdgeWeight()

void albaPolylineGraph::SetEdgeWeight ( vtkIdType  e,
double  wt 
)

set weight of edge

◆ AddNewEdge()

bool albaPolylineGraph::AddNewEdge ( vtkIdType  v0,
vtkIdType  v1 
)

Add new edge between existing vertices.

◆ AddNewVertex() [1/2]

void albaPolylineGraph::AddNewVertex ( double *  coords = NULL)

Add new vertex to graph.

The vertex can be empty or it can connect to an existing vertex with a new edge You can optionally specify the coords of the vertex add new empty vertex

◆ AddNewVertex() [2/2]

bool albaPolylineGraph::AddNewVertex ( vtkIdType  v0,
double *  coords = NULL 
)

add new vertex, connecting to existing vertex

◆ AddNewBranch() [1/2]

void albaPolylineGraph::AddNewBranch ( const char *  name = NULL)

Add new branch to graph.

add new empty branch with optional name

◆ AddNewBranch() [2/2]

bool albaPolylineGraph::AddNewBranch ( vtkIdType  v0,
const char *  name = NULL 
)

add new branch with start vertex and optional name

◆ CopyFromPolydata()

bool albaPolylineGraph::CopyFromPolydata ( vtkPolyData *  polydata)

Read graph from vtkPolyData (polyline only).

Each polydata point becomes a graph vertex. Each polydata cell (line or polyline) becomes a graph branch. Each polydata line or line segment becomes a graph edge. The points stay in the same order: point i in the graph is the same as point i in the polydata.

◆ CopyToPolydata()

bool albaPolylineGraph::CopyToPolydata ( vtkPolyData *  polydata)

Write polyline graph to vtkPolyData.

Each graph vertex becomes a polydata point. Each graph branch becomes a line or polyline. Edges which are not members of branches become lines. The points stay in the same order: point i in the polydata is the same as point i in the graph. This also sets the mapping between the graph edges and the cells in the output polydata.

◆ GetOutputCellCorrespondingToEdge()

void albaPolylineGraph::GetOutputCellCorrespondingToEdge ( vtkIdType  edgeid,
vtkIdType *  cellid,
vtkIdType *  index 
) const

◆ GetEdgeCorrespondingToOutputCell()

vtkIdType albaPolylineGraph::GetEdgeCorrespondingToOutputCell ( vtkIdType  cellid,
vtkIdType  index 
) const

◆ GetOutputCellCorrespondingToBranch()

void albaPolylineGraph::GetOutputCellCorrespondingToBranch ( vtkIdType  branchid,
vtkIdType *  cellid 
) const

◆ GetBranchCorrespondingToOutputCell()

vtkIdType albaPolylineGraph::GetBranchCorrespondingToOutputCell ( vtkIdType  cellid) const

◆ SplitBranchAtEdge()

bool albaPolylineGraph::SplitBranchAtEdge ( vtkIdType  b,
vtkIdType  e 
)

Split branch by finding and removing edge.

A new branch is created at the end of the list. The front section of the split gets the name.

◆ SplitBranchAtVertex()

bool albaPolylineGraph::SplitBranchAtVertex ( vtkIdType  b,
vtkIdType  v 
)

Split branch at vertex v.

A new branch is created at the end of the list. The front section of the split gets the name.

◆ AddNewVertexToBranch()

void albaPolylineGraph::AddNewVertexToBranch ( vtkIdType  b,
double *  coords = NULL 
)

Add new vertex to end of branch.

If the branch is empty, this adds creates a new vertex and adds it to the branch. If the branch is not empty, it creates a new vertex and edge and adds them.

◆ AddExistingVertexToBranch()

bool albaPolylineGraph::AddExistingVertexToBranch ( vtkIdType  b,
vtkIdType  v,
vtkIdType  e = m_UndefinedId 
)

Add existing vertex to end of branch.

You can optionally specify the edge required to make the join. If the edge is omitted, it will be found automatically.

◆ AddExistingEdgeToBranch()

bool albaPolylineGraph::AddExistingEdgeToBranch ( vtkIdType  b,
vtkIdType  e 
)

Add existing edge to end of branch.

The edge must share a vertex with the end of the branch, and must not already belong to a branch. The branch must not be empty.

◆ ReverseBranch()

void albaPolylineGraph::ReverseBranch ( vtkIdType  b)

Reverse direction of branch This is useful if you want to add items at the front end of the branch.

◆ DeleteEdge()

bool albaPolylineGraph::DeleteEdge ( vtkIdType  i)

Delete edge from graph If the edge was a member of a branch, the branch will be split.

Be careful: this also moves the edge at the end of the list to index i.

◆ DeleteVertex()

bool albaPolylineGraph::DeleteVertex ( vtkIdType  i)

Delete vertex from the graph.


The vertex must be degree zero, so you have to remove any edges first. Any branches containing this vertex will be left empty. Be careful: this also moves the vertex at the end of the list to index i.

◆ DeleteBranch()

bool albaPolylineGraph::DeleteBranch ( vtkIdType  i)

Delete branch from the graph.


Be careful: this also moves the branch at the end of the list to index i.

◆ MergeBranches()

bool albaPolylineGraph::MergeBranches ( vtkIdType  b1,
vtkIdType  b2 
)

Merges two branches.

Both branches (identified by b1 and b2) must share common endpoint. Be careful: this also moves the branch at the end of the list to index b2.

◆ MergeSimpleJoinedBranchesAtVertex()

bool albaPolylineGraph::MergeSimpleJoinedBranchesAtVertex ( vtkIdType  v)

Merges two branches connected at the given vertex.

The vertex may not be at a bifurcation, i.e., it must be of order 2 Be careful: this also moves the branch at the end of the list to index b1.

◆ MergeSimpleJoinedBranches()

void albaPolylineGraph::MergeSimpleJoinedBranches ( )

Merges all branches in the graph connected in vertices of order 2
Be careful: this leads to reindexing of branches.

◆ IsConnected()

bool albaPolylineGraph::IsConnected ( ) const

is graph connected

◆ IsConnectedTree()

bool albaPolylineGraph::IsConnectedTree ( ) const

is graph a connected tree

◆ Clear()

void albaPolylineGraph::Clear ( )

clear graph

◆ SelfCheck()

bool albaPolylineGraph::SelfCheck ( ) const

check internal consistency

◆ PrintSelf()

void albaPolylineGraph::PrintSelf ( std::ostream &  os,
const int  tabs 
) const

print self

◆ GetConstVertexPtr()

const Vertex * albaPolylineGraph::GetConstVertexPtr ( vtkIdType  i) const

return read-only pointer to vertex, return NULL if index out of range

◆ GetConstEdgePtr()

const Edge * albaPolylineGraph::GetConstEdgePtr ( vtkIdType  i) const

return read-only pointer to edge, return NULL if index out of range

◆ GetConstBranchPtr()

const Branch * albaPolylineGraph::GetConstBranchPtr ( vtkIdType  i) const

return read-only pointer to branch, return NULL if index out of range

Member Data Documentation

◆ m_UndefinedId

const vtkIdType albaPolylineGraph::m_UndefinedId
static

consts for undefined index values

Definition at line 73 of file albaPolylineGraph.h.

◆ m_UndefinedInt

const int albaPolylineGraph::m_UndefinedInt
static

Definition at line 74 of file albaPolylineGraph.h.

◆ m_UndefinedName

const char* albaPolylineGraph::m_UndefinedName
static

Definition at line 75 of file albaPolylineGraph.h.


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