Fraxinus  18.10
An IGT application
cxBranch.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 #include "cxBranch.h"
12 
13 namespace cx
14 {
15 
17  mParentBranch(BranchPtr())
18 {
19  // TODO Auto-generated constructor stub
20 
21 }
22 
23 void Branch::setPositions(Eigen::MatrixXd pos)
24 {
25  mPositions = pos;
26 }
27 
28 Eigen::MatrixXd Branch::getPositions()
29 {
30  return mPositions;
31 }
32 
33 void Branch::setOrientations(Eigen::MatrixXd orient)
34 {
35  mOrientations = orient;
36 }
37 
38 Eigen::MatrixXd Branch::getOrientations()
39 {
40  return mOrientations;
41 }
42 
44 {
45  mChildBranches.push_back(child);
46 }
47 
49 {
50  mChildBranches = children;
51 }
52 
54 {
55  mChildBranches.clear();
56 }
57 
59 {
60  return mChildBranches;
61 }
62 
64 {
65  mParentBranch = parent;
66 }
68 {
69  return mParentBranch;
70 }
71 
83 {
84  for(size_t i = 0; i < bv.size(); ++i)
85  {
86  if(bv[i] == mParentBranch)
87  return static_cast<int>(i);
88  }
89 
90  return -1;
91 }
92 
94 {
95  int generationNumber = 1;
96 
97  BranchPtr parentBranchPtr = this->getParentBranch();
98  while (parentBranchPtr)
99  {
100  if (parentBranchPtr->getChildBranches().size() > 1) // Do not count generation if it is not a real division
101  generationNumber = generationNumber + 1;
102 
103  parentBranchPtr = parentBranchPtr->getParentBranch();
104 
105  if (generationNumber > 23) //maximum possible generations - avoiding infinite loop
106  break;
107  }
108 
109  return generationNumber;
110 }
111 
113 {
114  int generationNumber = this->findGenerationNumber();
115 
116  if (generationNumber == 1)
117  return 8;
118  if (generationNumber == 2)
119  return 6;
120  if (generationNumber == 3)
121  return 4;
122  if (generationNumber == 4)
123  return 3;
124  if (generationNumber == 5)
125  return 2.5;
126  else
127  return 2;
128 }
129 
130 
132 {
133 
134 }
135 
136 }//namespace cx
void deleteChildBranches()
Definition: cxBranch.cpp:53
void addChildBranch(BranchPtr child)
Definition: cxBranch.cpp:43
void setPositions(Eigen::MatrixXd pos)
Definition: cxBranch.cpp:23
branchVector getChildBranches()
Definition: cxBranch.cpp:58
double findBranchRadius()
Definition: cxBranch.cpp:112
int findGenerationNumber()
Definition: cxBranch.cpp:93
boost::shared_ptr< class Branch > BranchPtr
Eigen::MatrixXd getOrientations()
Definition: cxBranch.cpp:38
virtual ~Branch()
Definition: cxBranch.cpp:131
int findParentIndex(branchVector bv) const
Branch::findParentIndex Given a vector of branches, find this branch&#39;s parent branch in that vector...
Definition: cxBranch.cpp:82
BranchPtr getParentBranch()
Definition: cxBranch.cpp:67
void setOrientations(Eigen::MatrixXd orient)
Definition: cxBranch.cpp:33
Eigen::MatrixXd getPositions()
Definition: cxBranch.cpp:28
void setChildBranches(branchVector children)
Definition: cxBranch.cpp:48
void setParentBranch(BranchPtr parent)
Definition: cxBranch.cpp:63
std::vector< BranchPtr > branchVector
Definition: cxBranch.h:28
Namespace for all CustusX production code.