-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathduct.hxx
287 lines (256 loc) · 6.92 KB
/
duct.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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
/*! \file duct.hxx
* \brief breastPhantom duct 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 DUCT_HXX_
#define DUCT_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 __VTKPOINTS__
#define __VTKPOINTS__
#include <vtkPoints.h>
#endif
#ifndef __VTKDOUBLEARRAY__
#define __VTKDOUBLEARRAY__
#include <vtkDoubleArray.h>
#endif
#ifndef __VTKMATH__
#define __VTKMATH__
#include <vtkMath.h>
#endif
#ifndef __VTKVECTOR__
#define __VTKVECTOR__
#include <vtkVector.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 ductSeg;
class ductBr;
/**********************************************
*
* structure for duct tree initialization
*
**********************************************/
struct ductTreeInit{
// random number generator seed
int seed;
// pointer to bound box
int *boundBox;
// compartment id
unsigned char compartmentId;
// segmentation tissue values
tissueStruct* tissue;
// FOV
double startPos[3];
double endPos[3];
// preferential direction of growth (same as startDir)
double prefDir[3];
// size of arrays
unsigned int nVox[3];
unsigned int nFill[3];
// pointer to breast
vtkImageData* breast;
// pointer to TDLU locations
vtkPoints* TDLUloc;
// pointer to TDLU attributes
vtkDoubleArray* TDLUattr;
};
/**********************************************
*
* Class for a duct tree
*
**********************************************/
class ductTree{
friend class ductBr;
friend class ductSeg;
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;
// compartment id
unsigned char compartmentId;
// 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;
// duct 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;
// duct tree id number
unsigned int id;
// keep track of number of branches in tree
unsigned int numBranch;
// pointer to main branch
ductBr* head;
// pointer to breast
vtkImageData* breast;
// pointer to TDLU locations
vtkPoints* TDLUloc;
// pointer to TDLU attributes
vtkDoubleArray* TDLUattr;
// preferential growth direction
double prefDir[3];
// save to file function
// constructor
ductTree(boost::program_options::variables_map, ductTreeInit*);
// destructor
~ductTree();
};
/**********************************************
*
* Class for a duct branch
*
**********************************************/
class ductBr {
// this is one branch of a tree
// sType refers to segment type (equivalent to tree type)
friend class ductSeg;
friend class ductTree;
// 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
ductSeg* firstSeg;
// pointer to last segment of branch
ductSeg* lastSeg;
// pointer to parent branch
ductBr* parent;
// pointer to first child branch
ductBr* firstChild;
// pointer to second child branch
ductBr* secondChild;
// pointer to sibling branch
ductBr* sibBranch;
// branch id number
unsigned int id;
// number of child branches (0 or 2)
unsigned int nChild;
// pointer to tree instance
ductTree* 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)
ductBr(double*, double*, double, ductTree*);
// constructor for first child branch of a parent branch
ductBr(ductBr*, unsigned int, unsigned int, double, double);
// constructor for second child branch
ductBr(ductBr*, ductBr*, unsigned int, unsigned int, double, double);
// destructor that deletes all child branches as well
~ductBr();
};
/**********************************************
*
* Class for a segment (of a duct branch)
*
**********************************************/
class ductSeg {
// this is one segment of a branch
friend class ductBr;
friend class ductTree;
// 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
ductSeg* prevSeg;
// pointer to owning branch
ductBr* 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
ductSeg* 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 duct tree - this edits breast data
void updateMap(void);
// constructor for first segment
ductSeg(ductBr*);
// constructor for subsequent segments
ductSeg(ductSeg*);
};
#endif /* DUCT_HXX_ */