Developer documentation
Version 3.0.3-105-gd3941f44
particle.h
Go to the documentation of this file.
1
/* Copyright (c) 2008-2022 the MRtrix3 contributors.
2
*
3
* This Source Code Form is subject to the terms of the Mozilla Public
4
* License, v. 2.0. If a copy of the MPL was not distributed with this
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
*
7
* Covered Software is provided under this License on an "as is"
8
* basis, without warranty of any kind, either expressed, implied, or
9
* statutory, including, without limitation, warranties that the
10
* Covered Software is free of defects, merchantable, fit for a
11
* particular purpose or non-infringing.
12
* See the Mozilla Public License v. 2.0 for more details.
13
*
14
* For more details, see http://www.mrtrix.org/.
15
*/
16
17
#ifndef __gt_particle_h__
18
#define __gt_particle_h__
19
20
#include "types.h"
21
22
23
24
namespace
MR
{
25
namespace
DWI {
26
namespace
Tractography {
27
namespace
GT {
28
29
using
Point_t
= Eigen::Vector3f;
30
34
class
Particle
35
{
MEMALIGN
(
Particle
)
36
public
:
37
38
// Particle length
39
static
float
L;
40
41
// Constructors and destructor --------------------------------------------------
42
43
Particle
()
44
{
45
predecessor
=
nullptr
;
46
successor
=
nullptr
;
47
visited
=
false
;
48
alive
=
false
;
49
}
50
51
Particle
(
const
Point_t
& p,
const
Point_t
& d)
52
{
53
init(p, d);
54
}
55
56
~Particle
()
57
{
58
finalize();
59
}
60
61
inline
void
init(
const
Point_t
& p,
const
Point_t
& d)
62
{
63
setPosition(p);
64
setDirection(d);
65
predecessor
=
nullptr
;
66
successor
=
nullptr
;
67
visited
=
false
;
68
alive
=
true
;
69
}
70
71
inline
void
finalize()
72
{
73
if
(
predecessor
)
74
removePredecessor();
75
if
(
successor
)
76
removeSuccessor();
77
alive
=
false
;
78
}
79
80
// disable copy and assignment
81
Particle
(
const
Particle
&) =
delete
;
82
Particle
& operator=(
const
Particle
&) =
delete
;
83
84
// default move constructor and assignment
85
Particle
(
Particle
&&) =
default
;
86
Particle
& operator=(
Particle
&&) =
default
;
87
88
89
// Getters and setters ----------------------------------------------------------
90
91
Point_t
getPosition()
const
92
{
93
return
pos
;
94
}
95
96
void
setPosition(
const
Point_t
& p)
97
{
98
pos
= p;
99
}
100
101
Point_t
getDirection()
const
102
{
103
return
dir
;
104
}
105
106
void
setDirection(
const
Point_t
& d)
107
{
108
dir
= d;
109
dir
.normalize();
110
}
111
112
Point_t
getEndPoint(
const
int
a)
const
113
{
114
return
(
pos
+ a*L*
dir
);
115
}
116
117
bool
hasPredecessor()
const
118
{
119
return
(
predecessor
!=
nullptr
);
120
}
121
122
Particle
* getPredecessor()
const
123
{
124
return
predecessor
;
125
}
126
127
void
connectPredecessor(
Particle
* p1,
const
int
a1)
128
{
129
assert(p1 !=
nullptr
);
130
setPredecessor
(p1);
131
if
(a1 == 1)
132
p1->
setSuccessor
(
this
);
133
if
(a1 == -1)
134
p1->
setPredecessor
(
this
);
135
}
136
137
void
removePredecessor()
138
{
139
assert(
predecessor
!=
nullptr
);
140
assert(
predecessor
->
predecessor
==
this
||
predecessor
->
successor
==
this
);
141
if
(
predecessor
->
predecessor
==
this
)
142
predecessor
->
predecessor
=
nullptr
;
143
if
(
predecessor
->
successor
==
this
)
144
predecessor
->
successor
=
nullptr
;
145
predecessor
=
nullptr
;
146
}
147
148
bool
hasSuccessor()
const
149
{
150
return
(
successor
!=
nullptr
);
151
}
152
153
Particle
* getSuccessor()
const
154
{
155
return
successor
;
156
}
157
158
void
connectSuccessor(
Particle
* p1,
const
int
a1)
159
{
160
assert(p1 !=
nullptr
);
161
setSuccessor
(p1);
162
if
(a1 == 1)
163
p1->
setSuccessor
(
this
);
164
if
(a1 == -1)
165
p1->
setPredecessor
(
this
);
166
}
167
168
void
removeSuccessor()
169
{
170
assert(
successor
!=
nullptr
);
171
assert(
successor
->
predecessor
==
this
||
successor
->
successor
==
this
);
172
if
(
successor
->
predecessor
==
this
)
173
successor
->
predecessor
=
nullptr
;
174
if
(
successor
->
successor
==
this
)
175
successor
->
successor
=
nullptr
;
176
successor
=
nullptr
;
177
}
178
179
bool
isVisited()
const
180
{
181
return
visited
;
182
}
183
184
void
setVisited(
const
bool
v)
185
{
186
visited
= v;
187
}
188
189
bool
isAlive()
const
190
{
191
return
alive
;
192
}
193
194
195
protected
:
196
197
Point_t
pos
,
dir
;
198
Particle
*
predecessor
;
199
Particle
*
successor
;
200
bool
visited
;
201
bool
alive
;
202
203
void
setPredecessor
(
Particle
* p1)
204
{
205
if
(
predecessor
)
206
removePredecessor();
207
predecessor
= p1;
208
}
209
210
void
setSuccessor
(
Particle
* p1)
211
{
212
if
(
successor
)
213
removeSuccessor();
214
successor
= p1;
215
}
216
217
};
218
219
220
226
struct
ParticleEnd
227
{
MEMALIGN
(
ParticleEnd
)
228
Particle
* par;
229
int
alpha
;
230
float
e_conn
;
231
double
p_suc
;
232
};
233
234
235
236
}
237
}
238
}
239
}
240
241
#endif
// __gt_particle_h__
MR::DWI::Tractography::GT::Particle
Definition:
particle.h:35
MR::DWI::Tractography::GT::Particle::alive
bool alive
Definition:
particle.h:201
MR::DWI::Tractography::GT::Particle::visited
bool visited
Definition:
particle.h:200
MR::DWI::Tractography::GT::Particle::predecessor
Particle * predecessor
Definition:
particle.h:198
MR::DWI::Tractography::GT::Particle::successor
Particle * successor
Definition:
particle.h:199
MR::DWI::Tractography::GT::Particle::setPredecessor
void setPredecessor(Particle *p1)
Definition:
particle.h:203
MR::DWI::Tractography::GT::Particle::dir
Point_t dir
Definition:
particle.h:197
MR::DWI::Tractography::GT::Particle::pos
Point_t pos
Definition:
particle.h:197
MR::DWI::Tractography::GT::Particle::setSuccessor
void setSuccessor(Particle *p1)
Definition:
particle.h:210
MR::DWI::Tractography::GT::Point_t
Eigen::Vector3f Point_t
Definition:
particle.h:29
MR
Definition:
base.h:24
MEMALIGN
#define MEMALIGN(...)
Definition:
types.h:185
MR::DWI::Tractography::GT::ParticleEnd
Definition:
particle.h:227
MR::DWI::Tractography::GT::ParticleEnd::MEMALIGN
MEMALIGN(ParticleEnd) Particle *par
MR::DWI::Tractography::GT::ParticleEnd::alpha
int alpha
Definition:
particle.h:229
MR::DWI::Tractography::GT::ParticleEnd::e_conn
float e_conn
Definition:
particle.h:230
MR::DWI::Tractography::GT::ParticleEnd::p_suc
double p_suc
Definition:
particle.h:231
src
dwi
tractography
GT
particle.h
Generated on Mon Jul 4 2022 08:00:07 for MRtrix by
1.9.3