forked from DIDSR/breastPhantom
-
Notifications
You must be signed in to change notification settings - Fork 1
/
artery.hxx
259 lines (232 loc) · 6.53 KB
/
artery.hxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
/*! \file artery.hxx
* \brief breastPhantom artery header file
* \author Christian G. Graff
* \version 1.0
* \date 2018
*
* \copyright To the extent possible under law, the author(s) have
* dedicated all copyright and related and neighboring rights to this
* software to the public domain worldwide. This software is
* distributed without any warranty. You should have received a copy
* of the CC0 Public Domain Dedication along with this software.
* If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
*
*/
#ifndef ARTERY_HXX_
#define ARTERY_HXX_
#ifndef __CMATH__
#define __CMATH__
#include <cmath>
#endif
#ifndef __OMP__
#define __OMP__
#include <omp.h>
#endif
#ifndef __ALGORITHM__
#define __ALGORITHM__
#include <algorithm>
#endif
#ifndef __VTKIMAGEDATA__
#define __VTKIMAGEDATA__
#include <vtkImageData.h>
#endif
#ifndef __VTKMATH__
#define __VTKMATH__
#include <vtkMath.h>
#endif
#ifndef __BOOST__
#define __BOOST__
#include <boost/random.hpp>
#include <boost/math/distributions/beta.hpp>
#include <boost/program_options.hpp>
#endif
#ifndef __TISSUESTRUCT__
#define __TISSUESTRUCT__
#include "tissueStruct.hxx"
#endif
// forward declaration
class arterySeg;
class arteryBr;
/**********************************************
*
* structure for arteryTree initialization
*
**********************************************/
struct arteryTreeInit{
// random number generator seed
int seed;
// pointer to bound box
int *boundBox;
// tissue values
tissueStruct* tissue;
// FOV
double startPos[3];
double endPos[3];
// preferential direction of growth (same as startDir)
double nipplePos[3];
// size of arrays
unsigned int nVox[3];
unsigned int nFill[3];
// pointer to breast
vtkImageData* breast;
};
/**********************************************
*
* Class for an artery tree
*
**********************************************/
class arteryTree {
friend class arteryBr;
friend class arterySeg;
typedef boost::mt19937 rgenType;
// random number generator - constructor should set seed!!
rgenType randGen;
// pointer to configuration
boost::program_options::variables_map opt;
public:
// pointer to breast bound box
int *boundBox;
// tissue values
tissueStruct* tissue;
// maximum number of branches
unsigned int maxBranch;
// base length of initial branch
double baseLength;
// fill map giving distance to tree in roi
// initial value is distance to base of tree
vtkImageData* fill;
// artery tree count
static unsigned int num;
// uniform [0,1) distribution
boost::uniform_01<rgenType> u01;
// beta distribution for segment length
boost::math::beta_distribution<> lengthDist;
// beta distribution for radius of curvature
boost::math::beta_distribution<> radiusDist;
// artery tree id number
unsigned int id;
// keep track of number of branches in tree
unsigned int numBranch;
// pointer to main branch
arteryBr* head;
// pointer to breast
vtkImageData* breast;
// preferential growth direction
double nipplePos[3];
// save to file function
// constructor
arteryTree(boost::program_options::variables_map, arteryTreeInit*);
// destructor
~arteryTree();
};
/**********************************************
*
* Class for a artery branch
*
**********************************************/
class arteryBr {
// this is one branch of a tree
// sType refers to segment type (equivalent to tree type)
friend class arterySeg;
friend class arteryTree;
// start and end position of branch
double startPos[3];
double endPos[3];
// start and end radius (mm)
double startRad, endRad;
// start and end direction (unit vector)
double startDir[3];
double endDir[3];
// rotation angle from parent
double azimuth;
// length of branch and current length (mm)
double length, curLength;
// pointer to first segment of branch
arterySeg* firstSeg;
// pointer to last segment of branch
arterySeg* lastSeg;
// pointer to parent branch
arteryBr* parent;
// pointer to first child branch
arteryBr* firstChild;
// pointer to second child branch
arteryBr* secondChild;
// pointer to sibling branch
arteryBr* sibBranch;
// branch id number
unsigned int id;
// number of child branches
unsigned int nChild;
// pointer to tree instance
arteryTree* myTree;
// level in network, 0 == main branch
unsigned int level;
// generation of branch, 0 == root
unsigned int gen;
// function to set length of branch
double setLength(void);
// function to set number of children
unsigned int setChild(void);
// function to pick starting radii of child branches
void setRadiiThetas(double*,double*);
// function to pick starting direction based on parent direction
void setDir(double*,double);
public:
// constructor for first branch (the root)
arteryBr(double*, double*, double, arteryTree*);
// constructor for first child branch of a parent branch
arteryBr(arteryBr*, unsigned int, unsigned int, double, double);
// constructor for other branches
arteryBr(arteryBr*, arteryBr*, unsigned int, unsigned int, double, double);
// destructor that deletes all child branches as well
~arteryBr();
};
/**********************************************
*
* Class for a segment (of a artery branch)
*
**********************************************/
class arterySeg {
// this is one segment of a branch
friend class arteryBr;
friend class arteryTree;
// start and end position of segment
double startPos[3];
double endPos[3];
// start and end radius rate of change
double startDeriv, endDeriv;
// center of curvature
double centerCurv[3];
// start and end direction (unit vector)
double startDir[3];
double endDir[3];
// radius of curvature
double radCurv;
// pointer to previous segment of branch
arterySeg* prevSeg;
// pointer to owning branch
arteryBr* myBranch;
// cubic spline coefficients
double shape[4];
public:
// start and end radius (mm)
double startRad, endRad;
// length of segment (mm)
double length;
// pointer to next segment of branch
arterySeg* nextSeg;
// make a first segment - determines endPos, endRad
// centerCurv, length, endDir
void makeSeg(void);
// make shape
void setShape(void);
// get segment radius
double getRadius(double);
// update voxel-based map of artery tree - this edits breast data
void updateMap(void);
// constructor for first segment
arterySeg(arteryBr*);
// constructor for subsequent segments
arterySeg(arterySeg*);
};
#endif /* ARTERY_HXX_ */