Fraxinus  17.12
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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 #include "cxBranch.h"
33 
34 namespace cx
35 {
36 
38  mParentBranch(BranchPtr())
39 {
40  // TODO Auto-generated constructor stub
41 
42 }
43 
44 void Branch::setPositions(Eigen::MatrixXd pos)
45 {
46  mPositions = pos;
47 }
48 
49 Eigen::MatrixXd Branch::getPositions()
50 {
51  return mPositions;
52 }
53 
54 void Branch::setOrientations(Eigen::MatrixXd orient)
55 {
56  mOrientations = orient;
57 }
58 
59 Eigen::MatrixXd Branch::getOrientations()
60 {
61  return mOrientations;
62 }
63 
65 {
66  mChildBranches.push_back(child);
67 }
68 
70 {
71  mChildBranches = children;
72 }
73 
75 {
76  mChildBranches.clear();
77 }
78 
80 {
81  return mChildBranches;
82 }
83 
85 {
86  mParentBranch = parent;
87 }
89 {
90  return mParentBranch;
91 }
92 
104 {
105  for(size_t i = 0; i < bv.size(); ++i)
106  {
107  if(bv[i] == mParentBranch)
108  return static_cast<int>(i);
109  }
110 
111  return -1;
112 }
113 
115 {
116  int generationNumber = 1;
117 
118  BranchPtr parentBranchPtr = this->getParentBranch();
119  while (parentBranchPtr)
120  {
121  generationNumber = generationNumber + 1;
122  parentBranchPtr = parentBranchPtr->getParentBranch();
123  }
124 
125  return generationNumber;
126 }
127 
129 {
130  int generationNumber = this->findGenerationNumber();
131 
132  if (generationNumber == 1)
133  return 6;
134  if (generationNumber == 2)
135  return 4;
136  if (generationNumber == 3)
137  return 3;
138  if (generationNumber == 4)
139  return 2.5;
140  if (generationNumber == 5)
141  return 2;
142  else
143  return 2;
144 }
145 
146 
148 {
149 
150 }
151 
152 }//namespace cx
void deleteChildBranches()
Definition: cxBranch.cpp:74
void addChildBranch(BranchPtr child)
Definition: cxBranch.cpp:64
void setPositions(Eigen::MatrixXd pos)
Definition: cxBranch.cpp:44
branchVector getChildBranches()
Definition: cxBranch.cpp:79
double findBranchRadius()
Definition: cxBranch.cpp:128
int findGenerationNumber()
Definition: cxBranch.cpp:114
boost::shared_ptr< class Branch > BranchPtr
Eigen::MatrixXd getOrientations()
Definition: cxBranch.cpp:59
virtual ~Branch()
Definition: cxBranch.cpp:147
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:103
BranchPtr getParentBranch()
Definition: cxBranch.cpp:88
void setOrientations(Eigen::MatrixXd orient)
Definition: cxBranch.cpp:54
Eigen::MatrixXd getPositions()
Definition: cxBranch.cpp:49
void setChildBranches(branchVector children)
Definition: cxBranch.cpp:69
void setParentBranch(BranchPtr parent)
Definition: cxBranch.cpp:84
std::vector< BranchPtr > branchVector
Definition: cxBranch.h:49
Namespace for all CustusX production code.