13 #include "mitkExternAbstractTransformGeometry.h" 18 #include <vtkSphericalTransform.h> 29 std::cout <<
"Initializing an x-/y-plane (xyPlane) as parameter plane by InitializeStandardPlane(rightVector, " 30 "downVector, spacing = nullptr): " 41 xyPlane->InitializeStandardPlane(right, bottom);
42 xyPlane->SetOrigin(origin);
43 xyPlane->SetSizeInUnits(width, height);
45 std::cout <<
"Creating AbstractTransformGeometry: " << std::endl;
46 mitk::ExternAbstractTransformGeometry::Pointer abstractgeometry = mitk::ExternAbstractTransformGeometry::New();
48 std::cout <<
"Setting xyPlane as parameter plane of AbstractTransformGeometry: " << std::endl;
49 abstractgeometry->SetPlane(xyPlane);
52 <<
"Testing whether the bounds of xyPlane and the parametric bounds of AbstractTransformGeometry are equal: ";
53 if ((
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->
GetMinimum(),
55 (
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->GetMaximum(),
56 const_cast<mitk::BoundingBox *
>(xyPlane->GetBoundingBox())->GetMaximum()) ==
false))
58 std::cout <<
"[FAILED]" << std::endl;
61 std::cout <<
"[PASSED]" << std::endl;
63 std::cout <<
"Testing whether the parametic bounds of AbstractTransformGeometry and the bounds of the plane accessed " 64 "from there are equal: ";
65 if ((
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->
GetMinimum(),
68 (
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->GetMaximum(),
69 const_cast<mitk::BoundingBox *
>(abstractgeometry->GetPlane()->GetBoundingBox())->GetMaximum()) ==
72 std::cout <<
"[FAILED]" << std::endl;
75 std::cout <<
"[PASSED]" << std::endl;
77 std::cout <<
"Change parametic bounds of AbstractTransformGeometry and test whether they are equal to the bounds of " 78 "the plane accessed from there: " 82 abstractgeometry->SetParametricBounds(bounds);
83 if ((
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->
GetMinimum(),
86 (
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->GetMaximum(),
87 const_cast<mitk::BoundingBox *
>(abstractgeometry->GetPlane()->GetBoundingBox())->GetMaximum()) ==
90 std::cout <<
"[FAILED]" << std::endl;
93 std::cout <<
"[PASSED]" << std::endl;
95 std::cout <<
"Initializing an phi-/theta-plane (sphereParameterPlane) as parameter plane by " 96 "InitializeStandardPlane(rightVector, downVector, spacing = nullptr): " 100 widthInMM = 2 * vnl_math::pi;
102 heightInMM = vnl_math::pi;
108 sphereParameterPlane->InitializeStandardPlane(right, bottom);
109 sphereParameterPlane->SetOrigin(origin);
110 sphereParameterPlane->SetSizeInUnits(width, height);
112 std::cout <<
"Creating an vtkSphericalTransform (sphericalTransform) to use with sphereParameterPlane: " << std::endl;
113 vtkSphericalTransform *sphericalTransform = vtkSphericalTransform::New();
115 std::cout <<
"Setting sphereParameterPlane as parameter plane and sphericalTransform as transform of " 116 "AbstractTransformGeometry: " 118 abstractgeometry->SetPlane(sphereParameterPlane);
119 abstractgeometry->SetVtkAbstractTransform(sphericalTransform);
121 std::cout <<
"Testing whether the bounds of sphereParameterPlane and the parametric bounds of " 122 "AbstractTransformGeometry are equal: ";
123 if ((
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->
GetMinimum(),
125 (
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->GetMaximum(),
126 const_cast<mitk::BoundingBox *
>(sphereParameterPlane->GetBoundingBox())->GetMaximum()) ==
false))
128 std::cout <<
"[FAILED]" << std::endl;
131 std::cout <<
"[PASSED]" << std::endl;
133 std::cout <<
"Testing whether the parametic bounds of AbstractTransformGeometry and the bounds of the plane accessed " 134 "from there are equal: ";
135 if ((
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->
GetMinimum(),
138 (
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->GetMaximum(),
139 const_cast<mitk::BoundingBox *
>(abstractgeometry->GetPlane()->GetBoundingBox())->GetMaximum()) ==
142 std::cout <<
"[FAILED]" << std::endl;
145 std::cout <<
"[PASSED]" << std::endl;
147 std::cout <<
"Testing mapping Map(pt2d_mm(phi=Pi,theta=Pi/2.0), pt3d_mm) and compare with expected (-radius, 0, 0): ";
150 pt2d_mm[0] = vnl_math::pi;
151 pt2d_mm[1] = vnl_math::pi_over_2;
153 abstractgeometry->Map(pt2d_mm, pt3d_mm);
154 if (
mitk::Equal(pt3d_mm, expected_pt3d_mm) ==
false)
156 std::cout <<
"[FAILED]" << std::endl;
159 std::cout <<
"[PASSED]" << std::endl;
161 std::cout <<
"Testing mapping Map(pt3d_mm, pt2d_mm) and compare with expected: ";
163 abstractgeometry->Map(pt3d_mm, testpt2d_mm);
166 std::cout <<
"[FAILED]" << std::endl;
169 std::cout <<
"[PASSED]" << std::endl;
171 std::cout <<
"Testing IndexToWorld(pt2d_units, pt2d_mm) and compare with expected: ";
173 pt2d_units[0] = width / 2.0;
174 pt2d_units[1] = height / 2.0;
175 pt2d_mm[0] = widthInMM / 2.0;
176 pt2d_mm[1] = heightInMM / 2.0;
177 abstractgeometry->IndexToWorld(pt2d_units, testpt2d_mm);
180 std::cout <<
"[FAILED]" << std::endl;
183 std::cout <<
"[PASSED]" << std::endl;
185 std::cout <<
"Change parametic bounds of AbstractTransformGeometry and test whether they are equal to the bounds of " 186 "the plane accessed from there: " 190 abstractgeometry->SetParametricBounds(bounds);
191 if ((
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->
GetMinimum(),
194 (
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->GetMaximum(),
195 const_cast<mitk::BoundingBox *
>(abstractgeometry->GetPlane()->GetBoundingBox())->GetMaximum()) ==
198 std::cout <<
"[FAILED]" << std::endl;
201 std::cout <<
"[PASSED]" << std::endl;
203 std::cout <<
"Testing IndexToWorld(pt2d_units, pt2d_mm) and compare with expected: ";
204 pt2d_units[0] = width / 2.0;
205 pt2d_units[1] = height / 2.0;
206 pt2d_mm[0] = widthInMM / 2.0;
207 pt2d_mm[1] = heightInMM / 2.0;
208 abstractgeometry->IndexToWorld(pt2d_units, testpt2d_mm);
211 std::cout <<
"[FAILED]" << std::endl;
214 std::cout <<
"[PASSED]" << std::endl;
237 sphericalTransform->Delete();
239 std::cout <<
"[TEST DONE]" << std::endl;
itk::BoundingBox< unsigned long, 3, ScalarType > BoundingBox
Standard 3D-BoundingBox typedef.
void GetMinimum(itk::Image< TPixel, VImageDimension > *itkImage, double &minimum)
void FillVector3D(Tout &out, mitk::ScalarType x, mitk::ScalarType y, mitk::ScalarType z)
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.