20 #include "mitkVtkAbstractTransformPlaneGeometry.h"
22 #include <vtkSphericalTransform.h>
24 #include <vnl/vnl_quaternion.h>
25 #include <vnl/vnl_quaternion.txx>
36 std::cout <<
"Initializing an x-/y-plane (xyPlane) as parameter plane by InitializeStandardPlane(rightVector, "
37 "downVector, spacing = NULL): "
48 xyPlane->InitializeStandardPlane(right, bottom);
49 xyPlane->SetOrigin(origin);
50 xyPlane->SetSizeInUnits(width, height);
52 std::cout <<
"Creating VtkAbstractTransformPlaneGeometry: " << std::endl;
55 std::cout <<
"Setting xyPlane as parameter plane of VtkAbstractTransformPlaneGeometry: " << std::endl;
56 abstractgeometry->SetPlane(xyPlane);
58 std::cout <<
"Testing whether the bounds of xyPlane and the parametric bounds of VtkAbstractTransformPlaneGeometry "
60 if ((
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->GetMinimum(),
61 const_cast<mitk::BoundingBox *
>(xyPlane->GetBoundingBox())->GetMinimum()) ==
false) ||
62 (
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->GetMaximum(),
63 const_cast<mitk::BoundingBox *
>(xyPlane->GetBoundingBox())->GetMaximum()) ==
false))
65 std::cout <<
"[FAILED]" << std::endl;
68 std::cout <<
"[PASSED]" << std::endl;
70 std::cout <<
"Testing whether the parametic bounds of VtkAbstractTransformPlaneGeometry and the bounds of the plane "
71 "accessed from there are equal: ";
72 if ((
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->GetMinimum(),
73 const_cast<mitk::BoundingBox *
>(abstractgeometry->GetPlane()->GetBoundingBox())->GetMinimum()) ==
75 (
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->GetMaximum(),
76 const_cast<mitk::BoundingBox *
>(abstractgeometry->GetPlane()->GetBoundingBox())->GetMaximum()) ==
79 std::cout <<
"[FAILED]" << std::endl;
82 std::cout <<
"[PASSED]" << std::endl;
84 std::cout <<
"Change parametic bounds of VtkAbstractTransformPlaneGeometry and test whether they are equal to the "
85 "bounds of the plane accessed from there: "
89 abstractgeometry->SetParametricBounds(bounds);
90 if ((
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->GetMinimum(),
91 const_cast<mitk::BoundingBox *
>(abstractgeometry->GetPlane()->GetBoundingBox())->GetMinimum()) ==
93 (
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->GetMaximum(),
94 const_cast<mitk::BoundingBox *
>(abstractgeometry->GetPlane()->GetBoundingBox())->GetMaximum()) ==
97 std::cout <<
"[FAILED]" << std::endl;
100 std::cout <<
"[PASSED]" << std::endl;
102 std::cout <<
"Initializing an phi-/theta-plane (sphereParameterPlane) as parameter plane by "
103 "InitializeStandardPlane(rightVector, downVector, spacing = NULL): "
107 widthInMM = 2 * vnl_math::pi;
109 heightInMM = vnl_math::pi;
115 sphereParameterPlane->InitializeStandardPlane(right, bottom);
116 sphereParameterPlane->SetOrigin(origin);
117 sphereParameterPlane->SetSizeInUnits(width, height);
119 std::cout <<
"Creating an vtkSphericalTransform (sphericalTransform) to use with sphereParameterPlane: " << std::endl;
122 std::cout <<
"Setting sphereParameterPlane as parameter plane and sphericalTransform as transform of "
123 "VtkAbstractTransformPlaneGeometry: "
125 abstractgeometry->SetPlane(sphereParameterPlane);
126 abstractgeometry->SetVtkAbstractTransform(sphericalTransform);
128 std::cout <<
"Testing whether the bounds of sphereParameterPlane and the parametric bounds of "
129 "VtkAbstractTransformPlaneGeometry are equal: ";
130 if ((
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->GetMinimum(),
131 const_cast<mitk::BoundingBox *
>(sphereParameterPlane->GetBoundingBox())->GetMinimum()) ==
false) ||
132 (
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->GetMaximum(),
133 const_cast<mitk::BoundingBox *
>(sphereParameterPlane->GetBoundingBox())->GetMaximum()) ==
false))
135 std::cout <<
"[FAILED]" << std::endl;
138 std::cout <<
"[PASSED]" << std::endl;
140 std::cout <<
"Testing whether the parametic bounds of VtkAbstractTransformPlaneGeometry and the bounds of the plane "
141 "accessed from there are equal: ";
142 if ((
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->GetMinimum(),
143 const_cast<mitk::BoundingBox *
>(abstractgeometry->GetPlane()->GetBoundingBox())->GetMinimum()) ==
145 (
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->GetMaximum(),
146 const_cast<mitk::BoundingBox *
>(abstractgeometry->GetPlane()->GetBoundingBox())->GetMaximum()) ==
149 std::cout <<
"[FAILED]" << std::endl;
152 std::cout <<
"[PASSED]" << std::endl;
154 std::cout <<
"Testing mapping Map(pt2d_mm(phi=Pi,theta=Pi/2.0), pt3d_mm) and compare with expected (-radius, 0, 0): ";
157 pt2d_mm[0] = vnl_math::pi;
158 pt2d_mm[1] = vnl_math::pi_over_2;
160 abstractgeometry->Map(pt2d_mm, pt3d_mm);
161 if (
mitk::Equal(pt3d_mm, expected_pt3d_mm) ==
false)
163 std::cout <<
"[FAILED]" << std::endl;
166 std::cout <<
"[PASSED]" << std::endl;
168 std::cout <<
"Testing mapping Map(pt3d_mm, pt2d_mm) and compare with expected: ";
170 abstractgeometry->Map(pt3d_mm, testpt2d_mm);
173 std::cout <<
"[FAILED]" << std::endl;
176 std::cout <<
"[PASSED]" << std::endl;
178 std::cout <<
"Testing IndexToWorld(pt2d_units, pt2d_mm) and compare with expected: ";
180 pt2d_units[0] = width / 2.0;
181 pt2d_units[1] = height / 2.0;
182 pt2d_mm[0] = widthInMM / 2.0;
183 pt2d_mm[1] = heightInMM / 2.0;
184 abstractgeometry->IndexToWorld(pt2d_units, testpt2d_mm);
187 std::cout <<
"[FAILED]" << std::endl;
190 std::cout <<
"[PASSED]" << std::endl;
192 std::cout <<
"Change parametic bounds of VtkAbstractTransformPlaneGeometry and test whether they are equal to the "
193 "bounds of the plane accessed from there: "
197 abstractgeometry->SetParametricBounds(bounds);
198 if ((
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->GetMinimum(),
199 const_cast<mitk::BoundingBox *
>(abstractgeometry->GetPlane()->GetBoundingBox())->GetMinimum()) ==
201 (
mitk::Equal(const_cast<mitk::BoundingBox *>(abstractgeometry->GetParametricBoundingBox())->GetMaximum(),
202 const_cast<mitk::BoundingBox *
>(abstractgeometry->GetPlane()->GetBoundingBox())->GetMaximum()) ==
205 std::cout <<
"[FAILED]" << std::endl;
208 std::cout <<
"[PASSED]" << std::endl;
210 std::cout <<
"Testing IndexToWorld(pt2d_units, pt2d_mm) and compare with expected: ";
211 pt2d_units[0] = width / 2.0;
212 pt2d_units[1] = height / 2.0;
213 pt2d_mm[0] = widthInMM / 2.0;
214 pt2d_mm[1] = heightInMM / 2.0;
215 abstractgeometry->IndexToWorld(pt2d_units, testpt2d_mm);
218 std::cout <<
"[FAILED]" << std::endl;
221 std::cout <<
"[PASSED]" << std::endl;
244 std::cout <<
"[TEST DONE]" << std::endl;
itk::BoundingBox< unsigned long, 3, ScalarType > BoundingBox
Standard 3D-BoundingBox typedef.
itk::SmartPointer< Self > Pointer
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.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.