Medical Imaging Interaction Toolkit  2018.4.99-f51274ea
Medical Imaging Interaction Toolkit
mitkPAVesselTree.cpp
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 #include "mitkPAVesselTree.h"
14 #include "thread"
15 
16 mitk::pa::VesselTree::VesselTree(VesselProperties::Pointer initialProperties)
17 {
18  m_CurrentSubvessels = new std::vector<Vessel::Pointer>();
19  Vessel::Pointer tmpVessel = Vessel::New(initialProperties);
20  m_CurrentSubvessels->push_back(tmpVessel);
21 }
22 
24 {
25  m_CurrentSubvessels->clear();
26  delete m_CurrentSubvessels;
27  m_CurrentSubvessels = nullptr;
28 }
29 
30 void mitk::pa::VesselTree::Step(mitk::pa::InSilicoTissueVolume::Pointer volume,
31  Vessel::CalculateNewVesselPositionCallback calculateNewPosition, double bendingFactor, std::mt19937* rng)
32 {
33  std::vector<Vessel::Pointer> newVessels;
34 
35  for (unsigned int vesselTreeIndex = 0; vesselTreeIndex < m_CurrentSubvessels->size(); vesselTreeIndex++)
36  {
37  Vessel::Pointer currentVessel = m_CurrentSubvessels->at(vesselTreeIndex);
38  if (!currentVessel->IsFinished())
39  {
40  currentVessel->ExpandVessel(volume, calculateNewPosition, bendingFactor, rng);
41  if (currentVessel->CanBifurcate())
42  {
43  newVessels.push_back(currentVessel->Bifurcate(rng));
44  }
45  }
46  }
47 
48  for (unsigned int newVesselsIndex = 0; newVesselsIndex < newVessels.size(); newVesselsIndex++)
49  {
50  m_CurrentSubvessels->push_back(newVessels.at(newVesselsIndex));
51  }
52 }
53 
55 {
56  for (unsigned int vesselTreeIndex = 0; vesselTreeIndex < m_CurrentSubvessels->size(); vesselTreeIndex++)
57  {
58  if (!m_CurrentSubvessels->at(vesselTreeIndex)->IsFinished())
59  return false;
60  }
61  return true;
62 }
63 
64 bool mitk::pa::Equal(const VesselTree::Pointer leftHandSide, const VesselTree::Pointer rightHandSide, double eps, bool verbose)
65 {
66  MITK_INFO(verbose) << "=== mitk::pa::Vessel Equal ===";
67 
68  if (rightHandSide.IsNull() || leftHandSide.IsNull())
69  {
70  MITK_INFO(verbose) << "Cannot compare nullpointers";
71  return false;
72  }
73 
74  if (leftHandSide->IsFinished() != rightHandSide->IsFinished())
75  {
76  MITK_INFO(verbose) << "Not same finished state.";
77  return false;
78  }
79 
80  if (leftHandSide->GetCurrentSubvessels()->size() != rightHandSide->GetCurrentSubvessels()->size())
81  {
82  MITK_INFO(verbose) << "Not same number of subvessels in the vesseltree.";
83  return false;
84  }
85 
86  for (unsigned int vesselIdx = 0, numVessels = leftHandSide->GetCurrentSubvessels()->size(); vesselIdx < numVessels; ++vesselIdx)
87  {
88  if (!Equal(leftHandSide->GetCurrentSubvessels()->at(vesselIdx), rightHandSide->GetCurrentSubvessels()->at(vesselIdx), eps, verbose))
89  {
90  MITK_INFO(verbose) << "At least one vessel was not equal or the vessel list were not in order.";
91  return false;
92  }
93  }
94 
95  return true;
96 }
#define MITK_INFO
Definition: mitkLogMacros.h:18
VesselTree(VesselProperties::Pointer initialProperties)
MITKPHOTOACOUSTICSLIB_EXPORT bool Equal(const MonteCarloThreadHandler::Pointer leftHandSide, const MonteCarloThreadHandler::Pointer rightHandSide, double eps, bool verbose)
Equal A function comparing two thread handlers for beeing equal.
bool verbose(false)
MITKCORE_EXPORT const ScalarType eps
bool IsFinished()
IsFinished.
void Step(InSilicoTissueVolume::Pointer volume, Vessel::CalculateNewVesselPositionCallback calculateNewPosition, double bendingFactor, std::mt19937 *rng)
Step Performs a simulation step, in which all subvessels of this VesselTree are expanded.
void(VesselMeanderStrategy::* CalculateNewVesselPositionCallback)(Vector::Pointer, double, std::mt19937 *)
Definition: mitkPAVessel.h:41