Medical Imaging Interaction Toolkit  2023.04.00
Medical Imaging Interaction Toolkit
mitkTubeGraph.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkTubeGraph_h
14 #define mitkTubeGraph_h
15 
16 #include <MitkTubeGraphExports.h>
17 
18 #include "mitkTubeGraphEdge.h"
19 #include "mitkTubeGraphVertex.h"
20 #include "mitkUndirectedGraph.h"
21 
22 #ifdef _MSC_VER
23 # pragma warning(push)
24 # pragma warning(disable: 4172) // boost/graph/named_function_params.hpp(240): returning address of local variable or temporary
25 #endif
26 
27 #include <boost/graph/undirected_dfs.hpp>
28 #include <boost/graph/visitors.hpp>
29 #include <boost/property_map/property_map.hpp>
30 
31 #include <boost/graph/breadth_first_search.hpp>
32 #include <boost/pending/property.hpp>
33 
34 #ifdef _MSC_VER
35 # pragma warning(pop)
36 #endif
37 
38 namespace mitk
39 {
43  class MITKTUBEGRAPH_EXPORT TubeGraph : public UndirectedGraph<TubeGraphVertex, TubeGraphEdge>
44  {
45  public:
49  typedef std::pair<VertexDescriptorType, VertexDescriptorType> TubeDescriptorType;
50 
51  typedef boost::adjacency_list<boost::vecS,
52  boost::vecS,
53  boost::directedS // directed graph
54  >
56 
62 
63  //--- Macros ---//
65  itkNewMacro(Self);
66 
70  std::vector<TubeDescriptorType> SearchShortestPath(
71  const TubeDescriptorType &startTube, const TubeDescriptorType &endTube /*, std::vector<unsigned long> barrier*/);
72 
76  std::vector<TubeDescriptorType> SearchAllPathBetweenVertices(
77  const TubeDescriptorType &startTube, const TubeDescriptorType &endTube /*, std::vector<unsigned long> barrier*/);
78  std::vector<TubeDescriptorType> SearchPathToPeriphery(
79  const TubeDescriptorType &startTube /*, std::vector<unsigned long> barrier*/);
80 
84  TubeDescriptorType GetThickestTube();
85 
89  DirectedGraphType GetDirectedGraph(VertexDescriptorType startVertex);
90 
94  TubeGraph::Pointer CreateSubGraph(std::vector<TubeDescriptorType> subGraphTubes);
95 
100  void RemoveSubGraph(std::vector<TubeDescriptorType> deletedTubes);
101 
102  void SetRootTube(const TubeDescriptorType &root);
103  void SetRoot(const VertexDescriptorType &root);
104  TubeDescriptorType GetRootTube();
105  VertexDescriptorType GetRootVertex();
106 
107  protected:
108  TubeGraph();
109  TubeGraph(const TubeGraph &graph);
110  ~TubeGraph() override;
111 
112  TubeGraph &operator=(const TubeGraph &rhs);
113 
114  private:
115  TubeDescriptorType m_RootTube;
116  VertexDescriptorType m_Root;
117 
118  void GetOutEdgesOfAVertex(VertexDescriptorType vertex,
119  DirectedGraphType &directedGraph,
120  std::vector<TubeDescriptorType> &pathToPeriphery);
121  };
122 
127  class DirectedGraphBfsVisitor : public boost::default_bfs_visitor
128  {
129  public:
131  : m_OrignialGraph(oldGraph), m_DirectedGraph(newGraph)
132  {
133  }
134 
136  {
137  unsigned int numberSource = boost::source(e, g);
138  unsigned int numberTarget = boost::target(e, g);
139  boost::graph_traits<TubeGraph::DirectedGraphType>::vertex_descriptor source = numberSource;
140  boost::graph_traits<TubeGraph::DirectedGraphType>::vertex_descriptor target = numberTarget;
141 
142  boost::add_edge(source, target, m_DirectedGraph);
143  }
144 
145  private:
146  TubeGraph::Pointer m_OrignialGraph;
147  TubeGraph::DirectedGraphType &m_DirectedGraph;
148  };
149 
150 } // namespace mitk
151 
152 #endif
mitkTubeGraphVertex.h
mitk::TubeGraph::ErrorId
static const TubeDescriptorType ErrorId
Definition: mitkTubeGraph.h:61
mitk::TubeGraph::TubeDescriptorType
std::pair< VertexDescriptorType, VertexDescriptorType > TubeDescriptorType
Definition: mitkTubeGraph.h:49
MITKTUBEGRAPH_EXPORT
#define MITKTUBEGRAPH_EXPORT
Definition: MitkTubeGraphExports.h:15
mitk::UndirectedGraph
Template class for undirected graphs.Paramters should be the vertex and edge classes,...
Definition: mitkUndirectedGraph.h:45
mitk::TubeGraph
Base Class for Tube Graphs.
Definition: mitkTubeGraph.h:43
itk::SmartPointer< Self >
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitk::TubeGraph::DirectedGraphType
boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS > DirectedGraphType
Definition: mitkTubeGraph.h:55
mitk::DirectedGraphBfsVisitor
Definition: mitkTubeGraph.h:127
mitk::UndirectedGraph< TubeGraphVertex, TubeGraphEdge >::EdgeDescriptorType
boost::graph_traits< GraphType >::edge_descriptor EdgeDescriptorType
Definition: mitkUndirectedGraph.h:69
mitkUndirectedGraph.h
mitk::UndirectedGraph< TubeGraphVertex, TubeGraphEdge >::GraphType
boost::adjacency_list< boost::listS, boost::vecS, boost::undirectedS, boost::property< vertex_properties_t, VertexType >, boost::property< edge_properties_t, EdgeType > > GraphType
Definition: mitkUndirectedGraph.h:65
mitk::BaseData::Superclass
itk::DataObject Superclass
Definition: mitkBaseData.h:46
mitk::BaseData
Base of all data objects.
Definition: mitkBaseData.h:42
mitkTubeGraphEdge.h
mitk::DirectedGraphBfsVisitor::DirectedGraphBfsVisitor
DirectedGraphBfsVisitor(TubeGraph *oldGraph, TubeGraph::DirectedGraphType &newGraph)
Definition: mitkTubeGraph.h:130
mitk::DirectedGraphBfsVisitor::tree_edge
void tree_edge(TubeGraph::EdgeDescriptorType e, const TubeGraph::GraphType &g)
Definition: mitkTubeGraph.h:135
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
MitkTubeGraphExports.h