forked from DIDSR/breastPhantom
-
Notifications
You must be signed in to change notification settings - Fork 1
/
vein.hxx
258 lines (230 loc) · 6.26 KB
/
vein.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
/*! \file vein.hxx
* \brief breastPhantom vein 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 VEIN_HXX_
#define VEIN_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 veinSeg;
class veinBr;
/**********************************************
*
* structure for veinTree initialization
*
**********************************************/
struct veinTreeInit{
// 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 vein tree
*
**********************************************/
class veinTree {
friend class veinBr;
friend class veinSeg;
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;
// length of base branch
double baseLength;
// fill map giving distance to tree in roi
// initial value is distance to base of tree
vtkImageData* fill;
// vein tree count
static unsigned int num;
// uniform [0,1) distribution
boost::uniform_01<rgenType> u01;
// beta distribution for radius of curvature
boost::math::beta_distribution<> radiusDist;
// vein tree id number
unsigned int id;
// keep track of number of branches in tree
unsigned int numBranch;
// pointer to main branch
veinBr* head;
// pointer to breast
vtkImageData* breast;
// preferential growth direction
double nipplePos[3];
// save to file function
// constructor
veinTree(boost::program_options::variables_map, veinTreeInit*);
// destructor
~veinTree();
};
/**********************************************
*
* Class for a vein branch
*
**********************************************/
class veinBr {
// this is one branch of a tree
// sType refers to segment type (equivalent to tree type)
friend class veinSeg;
friend class veinTree;
// 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];
// length of branch and current length (mm)
double length, curLength;
// rotation angle from parent
double azimuth;
// pointer to first segment of branch
veinSeg* firstSeg;
// pointer to last segment of branch
veinSeg* lastSeg;
// pointer to parent branch
veinBr* parent;
// pointer to first child branch
veinBr* firstChild;
// pointer to second child branch
veinBr* secondChild;
// pointer to sibling branch
veinBr* sibBranch;
// branch id number
unsigned int id;
// number of child branches
unsigned int nChild;
// pointer to tree instance
veinTree* 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 and angles 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)
veinBr(double*, double*, double, veinTree*);
// constructor for first child branch of a parent branch
veinBr(veinBr*, unsigned int, unsigned int, double, double);
// constructor for other branches
veinBr(veinBr*, veinBr*, unsigned int, unsigned int, double, double);
// destructor that deletes all child branches as well
~veinBr();
};
/**********************************************
*
* Class for a segment (of a vein branch)
*
**********************************************/
class veinSeg {
// this is one segment of a branch
friend class veinBr;
friend class veinTree;
// 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
veinSeg* prevSeg;
// pointer to owning branch
veinBr* 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
veinSeg* 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 vein tree - this edits breast data
void updateMap(void);
// constructor for first segment
veinSeg(veinBr*);
// constructor for subsequent segments
veinSeg(veinSeg*);
};
#endif /* VEIN_HXX_ */