18 #define _USE_MATH_DEFINES
33 #include <itkImageDuplicator.h>
34 #include <itkResampleImageFilter.h>
35 #include <itkTimeProbe.h>
36 #include <itkMersenneTwisterRandomVariateGenerator.h>
57 randGen->SetSeed((
unsigned int)0);
65 case FiberGenerationParameters::DISTRIBUTE_GAUSSIAN:
70 p[0] = randGen->GetUniformVariate(-1, 1);
71 p[1] = randGen->GetUniformVariate(-1, 1);
74 if (sqrt(p[0]*p[0]+p[1]*p[1]) <= 1)
87 itkExceptionMacro(
"At least 2 fiducials needed per fiber bundle!");
96 vector< unsigned int > fliplist;
100 fliplist.resize(bundle.size(), 0);
101 if (fliplist.size()<bundle.size())
102 fliplist.resize(bundle.size(), 0);
114 double r1 = p0.EuclideanDistanceTo(p1);
115 double r2 = p0.EuclideanDistanceTo(p2);
120 vnl_matrix_fixed<double, 2, 2> tRot;
121 tRot[0][0] = tDir[0];
122 tRot[1][1] = tRot[0][0];
123 tRot[1][0] = sin(acos(tRot[0][0]));
124 tRot[0][1] = -tRot[1][0];
126 tRot.inplace_transpose();
130 vnl_vector_fixed< double, 2 > newP;
133 double alpha = acos(eDir[0]);
135 alpha = 2*
M_PI-alpha;
136 vnl_matrix_fixed<double, 2, 2> eRot;
137 eRot[0][0] = cos(alpha);
138 eRot[1][1] = eRot[0][0];
139 eRot[1][0] = sin(alpha);
140 eRot[0][1] = -eRot[1][0];
144 newP = eRot.transpose()*newP;
152 planeGeo->
Map(p0, w);
154 wc = figure->GetWorldControlPoint(0);
156 vtkIdType
id = m_VtkPoints->InsertNextPoint(w.GetDataPointer());
157 container->GetPointIds()->InsertNextId(
id);
159 vnl_vector_fixed< double, 3 > n = planeGeo->
GetNormalVnl();
161 for (
unsigned int k=1; k<bundle.size(); k++)
163 figure = bundle.at(k);
164 p0 = figure->GetControlPoint(0);
165 p1 = figure->GetControlPoint(1);
166 p2 = figure->GetControlPoint(2);
167 p3 = figure->GetControlPoint(3);
168 r1 = p0.EuclideanDistanceTo(p1);
169 r2 = p0.EuclideanDistanceTo(p2);
171 eDir = p1-p0; eDir.Normalize();
173 mitk::Vector2D temp; temp.SetVnlVector(tRot.transpose() * tDir2.GetVnlVector());
176 tRot[0][0] = tDir[0]*tDir2[0] + tDir[1]*tDir2[1];
177 tRot[1][1] = tRot[0][0];
178 tRot[1][0] = sin(acos(tRot[0][0]));
179 tRot[0][1] = -tRot[1][0];
181 tRot.inplace_transpose();
192 vnl_vector_fixed< double, 3 > n2 = planeGeo->
GetNormalVnl();
193 wc = figure->GetWorldControlPoint(0);
196 if (dot_product(perp.GetVnlVector(),n2)>0 && dot_product(n,n2)<=0.00001)
198 if (fliplist.at(k)>0)
202 alpha = acos(eDir[0]);
204 alpha = 2*
M_PI-alpha;
205 eRot[0][0] = cos(alpha);
206 eRot[1][1] = eRot[0][0];
207 eRot[1][0] = sin(alpha);
208 eRot[0][1] = -eRot[1][0];
212 newP = eRot.transpose()*newP;
218 planeGeo->
Map(p0, w);
221 vtkIdType
id = m_VtkPoints->InsertNextPoint(w.GetDataPointer());
222 container->GetPointIds()->InsertNextId(
id);
225 m_VtkCellArray->InsertNextCell(container);
229 fiberPolyData->SetPoints(m_VtkPoints);
230 fiberPolyData->SetLines(m_VtkCellArray);
itk::SmartPointer< Self > Pointer
virtual bool Map(const mitk::Point3D &pt3d_mm, mitk::Point2D &pt2d_mm) const
Project a 3D point given in mm (pt3d_mm) onto the 2D geometry. The result is a 2D point in mm (pt2d_m...
Constants for most interaction classes, due to the generic StateMachines.
VnlVector GetNormalVnl() const
Normal of the plane as VnlVector.
FlipListType m_FlipList
contains flags indicating a flip of the 2D fiber x-coordinates (needed to resolve some unwanted fiber...
Point3D ProjectPointOntoPlane(const Point3D &pt) const
Returns the lot from the point to the plane.
Describes a two-dimensional, rectangular plane.
FiducialListType m_Fiducials
container of the planar ellipses used as fiducials for the fiber generation process ...
FiberDistribution m_Distribution
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.