14#ifndef __albaPolylineGraph_h
15#define __albaPolylineGraph_h
21#include "vtkPolydata.h"
197#pragma region BES April 2008
217 void PrintSelf(std::ostream& os,
const int tabs)
const ;
255 void PrintSelf(std::ostream& os,
const int tabs)
const ;
258 std::vector<vtkIdType> m_EdgeId ;
259 std::vector<vtkIdType> m_VertexId ;
272 Edge(vtkIdType v0, vtkIdType v1) ;
293 void PrintSelf(std::ostream& os,
const int tabs)
const ;
295 vtkIdType m_VertexId[2] ;
298 vtkIdType m_BranchId ;
300 vtkIdType m_OutputPolydataCell ;
301 vtkIdType m_OutputPolydataCellIndex ;
315 explicit Branch(vtkIdType startvertex,
const char* name = NULL) ;
344 void PrintSelf(std::ostream& os,
const int tabs)
const ;
350 std::vector<vtkIdType> m_VertexId ;
351 std::vector<vtkIdType> m_EdgeId ;
353 vtkIdType m_OutputPolydataCell ;
369 void AllocateVertices(
int nv) ;
370 void AllocateEdges(
int ne) ;
371 void AllocateBranches(
int ne) ;
373 bool SwapVertexIndices(vtkIdType i, vtkIdType j) ;
374 bool SwapEdgeIndices(vtkIdType i, vtkIdType j) ;
375 bool SwapBranchIndices(vtkIdType i, vtkIdType j) ;
379 bool DeleteLastEdge() ;
384 bool DeleteLastVertex() ;
387 bool DeleteLastBranch() ;
395 Vertex* GetVertexPtr(vtkIdType i) ;
396 Edge* GetEdgePtr(vtkIdType i) ;
397 Branch* GetBranchPtr(vtkIdType i) ;
402 std::vector<Vertex> m_Vertex ;
403 std::vector<Edge> m_Edge ;
404 std::vector<Branch> m_Branch ;
Nested Branch class A branch is a connected sequence of vertex id's.
void Clear()
clear data from branch
void PrintSelf(std::ostream &os, const int tabs) const
print self
int FindEdgeId(vtkIdType e) const
find position (0..ne-1) of this edge id in the list, return -1 if invalid
void SetMappingToOutputPolydata(vtkIdType cellid)
set mapping from branch to output cell
Branch(const Branch &src)
int GetNumberOfEdges() const
get number of edges (should be vertices - 1)
void ReverseDirection()
reverse branch direction
void AddVertexId(vtkIdType v)
add new vertex to end of list
void InsertVertexId(int i, vtkIdType v)
insert vertex at position i in list
int FindVertexId(vtkIdType v) const
find position (0..nv-1) of this vertex id in the list, return -1 if invalid
void AddEdgeId(vtkIdType e)
add edge to end of list
void SetEdgeId(int i, vtkIdType e)
set ith edge
void GetName(char *name) const
get name of branch
void DeleteLastVertex()
delete last vertex and edge from end of list
int GetNumberOfVertices() const
get number of vertices
void SetName(const char *name)
set name of branch
void GetVerticesIdList(vtkIdList *idlist) const
return vertices as a vtkIdlist
vtkIdType GetLastEdgeId() const
get id of last edge
Branch(vtkIdType startvertex, const char *name=NULL)
constructor: branch with initial vertex and optional name
vtkIdType GetMappingToOutputPolydata() const
get mapping from branch to output cell
vtkIdType GetLastVertexId() const
get id of last vertex
vtkIdType GetVertexId(int i) const
get index of ith vertex
Branch & operator=(const Branch &src)
const char * GetName() const
get name of branch
void SetVertexId(int i, vtkIdType v)
set ith vertex
void InsertEdgeId(int i, vtkIdType e)
insert edge
vtkIdType GetEdgeId(int i) const
get index of ith edge
Branch(const char *name=NULL)
constructor: empty branch with optional name
void UnsetName()
unset name of branch to undefined
bool SelfCheck() const
check self consistency (empty branches are allowed)
Nested Edge class This is a vertex pair.
bool SelfCheck() const
check self consistency
void SetDirected(bool directed)
set directed property
void ReverseDirection()
exchange vertices 0 and 1
void PrintSelf(std::ostream &os, const int tabs) const
print self
vtkIdType GetVertexId(int i) const
get index of vertex i, where i = 0 or 1
double GetWeight() const
get weight
void SetVertexIds(vtkIdType v0, vtkIdType v1)
set indices of vertices
vtkIdType GetOtherEndVertexId(vtkIdType v) const
get the vertex id at the other end of the edge
vtkIdType GetBranchId() const
get branch which edge belongs to
bool IsVertexPair(vtkIdType v0, vtkIdType v1) const
is the edge equal to these vertices (order doesn't matter)
bool IsVertexPairOrdered(vtkIdType v0, vtkIdType v1) const
is the edge equal to these vertices in this order
void GetMappingToOutputPolydata(vtkIdType *cellid, vtkIdType *index) const
get mapping from edge to location in output
void SetWeight(double w)
set weight
void SetBranchId(vtkIdType b)
set branch which edge belongs to
bool IsDirected() const
is edge directed
void SetVertexId(int i, vtkIdType v)
set index of vertex, where i = 0 or 1
Edge & operator=(const Edge &e)
assignment operator
Edge(vtkIdType v0, vtkIdType v1)
constructor with end vertices
void SetMappingToOutputPolydata(vtkIdType cellid, vtkIdType index)
set mapping from edge to location in output
Edge(const Edge &e)
copy constructor (because array member doesn't deep copy)
void GetVerticesIdList(vtkIdList *idlist) const
return vertices as a vtkIdlist
** Logs messages. Formatted */
bool DeleteVertexId(vtkIdType v)
delete this vertex and assoc. edge from the vertex
void AddVertexId(vtkIdType v)
add new vertex id to end of list
vtkIdType GetEdgeId(int i) const
get index of ith edge
int GetDegree() const
return degree of vertex
bool DeleteEdgeId(vtkIdType e)
delete this edge and assoc. vertex from the vertex
int FindEdgeId(vtkIdType e) const
find position (0..deg-1) of this edge id in the list, return -1 if invalid
vtkIdType GetVertexId(int i) const
get index of ith vertex neighbour
void AddEdgeId(vtkIdType e)
add new edge id to end of list
bool SelfCheck() const
check self consistency
Vertex(double *coords)
constructor
void Clear()
clear data from vertex
void SetEdgeId(int i, vtkIdType e)
set ith edge
void SetCoords(const double *coords)
set coords of vertex
void GetCoords(double *coords) const
get coords of vertex
void GetVerticesIdList(vtkIdList *idlist) const
return vertices as a vtkIdlist
void PrintSelf(std::ostream &os, const int tabs) const
print self
int FindVertexId(vtkIdType v) const
find position (0..deg-1) of this vertex id in the list, return undefinedInt if invalid
void SetVertexId(int i, vtkIdType v)
set ith vertex neighbour
void GetOutputCellCorrespondingToEdge(vtkIdType edgeid, vtkIdType *cellid, vtkIdType *index) const
void SetVertexCoords(vtkIdType v, const double *coords)
set coords of vertex
int GetNumberOfBranches() const
get no. of branches
vtkIdType GetMaxEdgeId() const
get index of last edge in graph
bool IsConnectedTree() const
is graph a connected tree
bool CopyFromPolydata(vtkPolyData *polydata)
Read graph from vtkPolyData (polyline only).
bool IsEdgeDirected(vtkIdType e) const
get directed property of edge
void MergeSimpleJoinedBranches()
Merges all branches in the graph connected in vertices of order 2 Be careful: this leads to reindex...
void AddNewVertex(double *coords=NULL)
Add new vertex to graph.
bool IsConnected() const
is graph connected
bool SplitBranchAtVertex(vtkIdType b, vtkIdType v)
Split branch at vertex v.
vtkIdType GetEdgeCorrespondingToOutputCell(vtkIdType cellid, vtkIdType index) const
int GetNumberOfVertices() const
get no. of vertices
int GetNumberOfEdges() const
get no. of edges
bool SelfCheck() const
check internal consistency
bool AddNewVertex(vtkIdType v0, double *coords=NULL)
add new vertex, connecting to existing vertex
void AddNewBranch(const char *name=NULL)
Add new branch to graph.
vtkIdType GetMaxVertexId() const
get index of last vertex in graph
double GetBranchIntervalLength(vtkIdType b, vtkIdType startVertexId, vtkIdType endVertexId) const
const Edge * GetConstEdgePtr(vtkIdType i) const
return read-only pointer to edge, return NULL if index out of range
bool AddExistingEdgeToBranch(vtkIdType b, vtkIdType e)
Add existing edge to end of branch.
bool AddNewBranch(vtkIdType v0, const char *name=NULL)
add new branch with start vertex and optional name
void GetOutputCellCorrespondingToBranch(vtkIdType branchid, vtkIdType *cellid) const
void SetBranchName(vtkIdType b, const char *name)
set name of branch
const Branch * GetConstBranchPtr(vtkIdType i) const
return read-only pointer to branch, return NULL if index out of range
bool AddNewEdge(vtkIdType v0, vtkIdType v1)
Add new edge between existing vertices.
bool SplitBranchAtEdge(vtkIdType b, vtkIdType e)
Split branch by finding and removing edge.
albaPolylineGraph()
constructor: empty graph
bool MergeBranches(vtkIdType b1, vtkIdType b2)
Merges two branches.
void ReverseEdge(vtkIdType e)
reverse direction of edge (swap end vertices)
const char * GetBranchName(vtkIdType b) const
get name of branch
bool DeleteVertex(vtkIdType i)
Delete vertex from the graph.
bool DeleteEdge(vtkIdType i)
Delete edge from graph If the edge was a member of a branch, the branch will be split.
void SetEdgeWeight(vtkIdType e, double wt)
set weight of edge
void AddNewVertexToBranch(vtkIdType b, double *coords=NULL)
Add new vertex to end of branch.
void SetEdgeDirected(vtkIdType e, bool directed)
set directed property of edge
bool DeleteBranch(vtkIdType i)
Delete branch from the graph.
void GetVertexCoords(vtkIdType v, double *coords) const
get coords of vertex
bool AddExistingVertexToBranch(vtkIdType b, vtkIdType v, vtkIdType e=m_UndefinedId)
Add existing vertex to end of branch.
static const char * m_UndefinedName
void PrintSelf(std::ostream &os, const int tabs) const
print self
~albaPolylineGraph()
destructor
bool MergeSimpleJoinedBranchesAtVertex(vtkIdType v)
Merges two branches connected at the given vertex.
void UnsetBranchName(vtkIdType b)
unset name of branch to undefined
vtkIdType GetMaxBranchId() const
get index of last branch in graph
bool CopyToPolydata(vtkPolyData *polydata)
Write polyline graph to vtkPolyData.
vtkIdType GetBranchCorrespondingToOutputCell(vtkIdType cellid) const
const Vertex * GetConstVertexPtr(vtkIdType i) const
return read-only pointer to vertex, return NULL if index out of range
static const int m_UndefinedInt
double GetBranchLength(vtkIdType b) const
return the length of the branch
void ReverseBranch(vtkIdType b)
Reverse direction of branch This is useful if you want to add items at the front end of the branch.
double GetEdgeWeight(vtkIdType e) const
get weight of edge
vtkIdType FindBranchName(const char *name) const
find branch with name
static const vtkIdType m_UndefinedId
consts for undefined index values