Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkTubeGraph.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 Copyright (c) German Cancer Research Center,
5 Division of Medical and Biological Informatics.
6 All rights reserved.
7 
8 This software is distributed WITHOUT ANY WARRANTY; without
9 even the implied warranty of MERCHANTABILITY or FITNESS FOR
10 A PARTICULAR PURPOSE.
11 
12 See LICENSE.txt or http://www.mitk.org for details.
13 
14 ===================================================================*/
15 
16 #ifndef _mitk_TubeGraph_h
17 #define _mitk_TubeGraph_h
18 
19 #include <MitkTubeGraphExports.h>
20 
21 #include "mitkTubeGraphEdge.h"
22 #include "mitkTubeGraphVertex.h"
23 #include "mitkUndirectedGraph.h"
24 
25 #include <boost/graph/undirected_dfs.hpp>
26 #include <boost/graph/visitors.hpp>
27 #include <boost/property_map/property_map.hpp>
28 
29 #include <boost/graph/breadth_first_search.hpp>
30 #include <boost/pending/property.hpp>
31 
32 namespace mitk
33 {
37  class MITKTUBEGRAPH_EXPORT TubeGraph : public UndirectedGraph<TubeGraphVertex, TubeGraphEdge>
38  {
39  public:
43  typedef std::pair<VertexDescriptorType, VertexDescriptorType> TubeDescriptorType;
44 
45  typedef boost::adjacency_list<boost::vecS,
46  boost::vecS,
47  boost::directedS // directed graph
48  >
50 
55  static const TubeDescriptorType ErrorId;
56 
57  //--- Macros ---//
59  itkNewMacro(Self);
60 
64  std::vector<TubeDescriptorType> SearchShortestPath(
65  const TubeDescriptorType &startTube, const TubeDescriptorType &endTube /*, std::vector<unsigned long> barrier*/);
66 
70  std::vector<TubeDescriptorType> SearchAllPathBetweenVertices(
71  const TubeDescriptorType &startTube, const TubeDescriptorType &endTube /*, std::vector<unsigned long> barrier*/);
72  std::vector<TubeDescriptorType> SearchPathToPeriphery(
73  const TubeDescriptorType &startTube /*, std::vector<unsigned long> barrier*/);
74 
78  TubeDescriptorType GetThickestTube();
79 
83  DirectedGraphType GetDirectedGraph(VertexDescriptorType startVertex);
84 
88  TubeGraph::Pointer CreateSubGraph(std::vector<TubeDescriptorType> subGraphTubes);
89 
94  void RemoveSubGraph(std::vector<TubeDescriptorType> deletedTubes);
95 
96  void SetRootTube(const TubeDescriptorType &root);
97  void SetRoot(const VertexDescriptorType &root);
98  TubeDescriptorType GetRootTube();
99  VertexDescriptorType GetRootVertex();
100 
101  protected:
102  TubeGraph();
103  TubeGraph(const TubeGraph &graph);
104  virtual ~TubeGraph();
105 
106  TubeGraph &operator=(const TubeGraph &rhs);
107 
108  private:
109  TubeDescriptorType m_RootTube;
110  VertexDescriptorType m_Root;
111 
112  void GetOutEdgesOfAVertex(VertexDescriptorType vertex,
113  DirectedGraphType &directedGraph,
114  std::vector<TubeDescriptorType> &pathToPeriphery);
115  };
116 
121  class DirectedGraphBfsVisitor : public boost::default_bfs_visitor
122  {
123  public:
125  : m_OrignialGraph(oldGraph), m_DirectedGraph(newGraph)
126  {
127  }
128 
130  {
131  unsigned int numberSource = boost::source(e, g);
132  unsigned int numberTarget = boost::target(e, g);
133  boost::graph_traits<TubeGraph::DirectedGraphType>::vertex_descriptor source = numberSource;
134  boost::graph_traits<TubeGraph::DirectedGraphType>::vertex_descriptor target = numberTarget;
135 
136  boost::add_edge(source, target, m_DirectedGraph);
137  }
138 
139  private:
140  TubeGraph::Pointer m_OrignialGraph;
141  TubeGraph::DirectedGraphType &m_DirectedGraph;
142  };
143 
144 } // namespace mitk
145 
146 #endif /* _mitk_TubeGraph_h */
boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS > DirectedGraphType
Definition: mitkTubeGraph.h:49
#define MITKTUBEGRAPH_EXPORT
static const TubeDescriptorType ErrorId
Definition: mitkTubeGraph.h:55
Base of all data objects.
Definition: mitkBaseData.h:39
Base Class for Tube Graphs.
Definition: mitkTubeGraph.h:37
DataCollection - Class to facilitate loading/accessing structured data.
DirectedGraphBfsVisitor(TubeGraph *oldGraph, TubeGraph::DirectedGraphType &newGraph)
itk::DataObject Superclass
Definition: mitkBaseData.h:42
boost::graph_traits< GraphType >::edge_descriptor EdgeDescriptorType
std::pair< VertexDescriptorType, VertexDescriptorType > TubeDescriptorType
Definition: mitkTubeGraph.h:43
boost::adjacency_list< boost::listS, boost::vecS, boost::undirectedS, boost::property< vertex_properties_t, VertexType >, boost::property< edge_properties_t, EdgeType > > GraphType
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:44
void tree_edge(TubeGraph::EdgeDescriptorType e, const TubeGraph::GraphType &g)
Template class for undirected graphs.Paramters should be the vertex and edge classes, which contains the information.
boost::graph_traits< GraphType >::vertex_descriptor VertexDescriptorType