ALBA
|
#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 Vertex * | GetConstVertexPtr (vtkIdType i) const |
const Edge * | GetConstEdgePtr (vtkIdType i) const |
const Branch * | GetConstBranchPtr (vtkIdType i) const |
Static Public Attributes | |
static const vtkIdType | m_UndefinedId |
static const int | m_UndefinedInt |
static const char * | m_UndefinedName |
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.
albaPolylineGraph::albaPolylineGraph | ( | ) |
constructor: empty graph
albaPolylineGraph::~albaPolylineGraph | ( | ) |
destructor
int albaPolylineGraph::GetNumberOfVertices | ( | ) | const |
get no. of vertices
int albaPolylineGraph::GetNumberOfEdges | ( | ) | const |
get no. of edges
int albaPolylineGraph::GetNumberOfBranches | ( | ) | const |
get no. of branches
vtkIdType albaPolylineGraph::GetMaxVertexId | ( | ) | const |
get index of last vertex in graph
vtkIdType albaPolylineGraph::GetMaxEdgeId | ( | ) | const |
get index of last edge in graph
vtkIdType albaPolylineGraph::GetMaxBranchId | ( | ) | const |
get index of last branch in graph
void albaPolylineGraph::GetVertexCoords | ( | vtkIdType | v, |
double * | coords | ||
) | const |
get coords of vertex
void albaPolylineGraph::SetVertexCoords | ( | vtkIdType | v, |
const double * | coords | ||
) |
set coords of vertex
const char * albaPolylineGraph::GetBranchName | ( | vtkIdType | b | ) | const |
get name of branch
void albaPolylineGraph::SetBranchName | ( | vtkIdType | b, |
const char * | name | ||
) |
set name of branch
void albaPolylineGraph::UnsetBranchName | ( | vtkIdType | b | ) |
unset name of branch to undefined
vtkIdType albaPolylineGraph::FindBranchName | ( | const char * | name | ) | const |
find branch with name
double albaPolylineGraph::GetBranchLength | ( | vtkIdType | b | ) | const |
return the length of the branch
double albaPolylineGraph::GetBranchIntervalLength | ( | vtkIdType | b, |
vtkIdType | startVertexId, | ||
vtkIdType | endVertexId | ||
) | const |
bool albaPolylineGraph::IsEdgeDirected | ( | vtkIdType | e | ) | const |
get directed property of edge
void albaPolylineGraph::SetEdgeDirected | ( | vtkIdType | e, |
bool | directed | ||
) |
set directed property of edge
void albaPolylineGraph::ReverseEdge | ( | vtkIdType | e | ) |
reverse direction of edge (swap end vertices)
double albaPolylineGraph::GetEdgeWeight | ( | vtkIdType | e | ) | const |
get weight of edge
void albaPolylineGraph::SetEdgeWeight | ( | vtkIdType | e, |
double | wt | ||
) |
set weight of edge
bool albaPolylineGraph::AddNewEdge | ( | vtkIdType | v0, |
vtkIdType | v1 | ||
) |
Add new edge between existing vertices.
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
bool albaPolylineGraph::AddNewVertex | ( | vtkIdType | v0, |
double * | coords = NULL |
||
) |
add new vertex, connecting to existing vertex
void albaPolylineGraph::AddNewBranch | ( | const char * | name = NULL | ) |
Add new branch to graph.
add new empty branch with optional name
bool albaPolylineGraph::AddNewBranch | ( | vtkIdType | v0, |
const char * | name = NULL |
||
) |
add new branch with start vertex and optional name
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.
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.
void albaPolylineGraph::GetOutputCellCorrespondingToEdge | ( | vtkIdType | edgeid, |
vtkIdType * | cellid, | ||
vtkIdType * | index | ||
) | const |
vtkIdType albaPolylineGraph::GetEdgeCorrespondingToOutputCell | ( | vtkIdType | cellid, |
vtkIdType | index | ||
) | const |
void albaPolylineGraph::GetOutputCellCorrespondingToBranch | ( | vtkIdType | branchid, |
vtkIdType * | cellid | ||
) | const |
vtkIdType albaPolylineGraph::GetBranchCorrespondingToOutputCell | ( | vtkIdType | cellid | ) | const |
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
void albaPolylineGraph::MergeSimpleJoinedBranches | ( | ) |
Merges all branches in the graph connected in vertices of order 2
Be careful: this leads to reindexing of branches.
bool albaPolylineGraph::IsConnected | ( | ) | const |
is graph connected
bool albaPolylineGraph::IsConnectedTree | ( | ) | const |
is graph a connected tree
void albaPolylineGraph::Clear | ( | ) |
clear graph
bool albaPolylineGraph::SelfCheck | ( | ) | const |
check internal consistency
void albaPolylineGraph::PrintSelf | ( | std::ostream & | os, |
const int | tabs | ||
) | const |
print self
const Vertex * albaPolylineGraph::GetConstVertexPtr | ( | vtkIdType | i | ) | const |
return read-only pointer to vertex, return NULL if index out of range
const Edge * albaPolylineGraph::GetConstEdgePtr | ( | vtkIdType | i | ) | const |
return read-only pointer to edge, return NULL if index out of range
const Branch * albaPolylineGraph::GetConstBranchPtr | ( | vtkIdType | i | ) | const |
return read-only pointer to branch, return NULL if index out of range
|
static |
consts for undefined index values
Definition at line 73 of file albaPolylineGraph.h.
|
static |
Definition at line 74 of file albaPolylineGraph.h.
|
static |
Definition at line 75 of file albaPolylineGraph.h.