23 #include "vtkPolyData.h"
27 template <
typename TScalarType>
34 for (i = 0; i < 6; ++i)
36 if (
mitk::Equal(bounds[i], expectedIndexBounds[i]) ==
false)
38 std::cout <<
"[FAILED]" << std::endl;
42 std::cout <<
"[PASSED]" << std::endl;
46 template <
typename TScalarType>
53 for (i = 0; i < 6; ++i)
55 if (
mitk::Equal(bounds[i], expectedAxisParallelBounds[i]) ==
false)
57 std::cout <<
"[FAILED]" << std::endl;
61 std::cout <<
"[PASSED]" << std::endl;
68 std::cout <<
" Testing surface contents: ";
69 if ((surface ==
nullptr) || (surface->
GetVtkPolyData() ==
nullptr) ||
72 std::cout <<
"[FAILED]" << std::endl;
77 std::cout <<
"[PASSED]" << std::endl;
80 double bounds[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
83 polys->ComputeBounds();
84 polys->GetBounds(bounds);
86 if (expectIdentityTransform ==
false)
89 geometry->SetFloatBounds(bounds);
92 for (
int i = 0; i < 6; ++i)
96 std::cout <<
" Testing GetBoundingBox() ";
99 std::cout <<
"[FAILED]" << std::endl;
102 std::cout <<
"[PASSED]" << std::endl;
110 bool expectIdentityTransform)
114 std::cout <<
"Testing SetRequestedRegionToLargestPossibleRegion(): ";
116 std::cout <<
"[PASSED]" << std::endl;
118 std::cout <<
"Testing UpdateOutputInformation(): ";
119 geometryToSurfaceFilter->UpdateOutputInformation();
120 std::cout <<
"[PASSED]" << std::endl;
122 std::cout <<
"Testing correctness of bounding-box after UpdateOutputInformation(): ";
124 expectedIndexBounds)) != EXIT_SUCCESS)
129 std::cout <<
"Testing correctness of axis-parallel bounding-box after UpdateOutputInformation(): ";
131 expectedAxisParallelBounds)) != EXIT_SUCCESS)
136 std::cout <<
"Testing Update(): ";
137 geometryToSurfaceFilter->Update();
138 std::cout <<
"[PASSED]" << std::endl;
140 std::cout <<
"Testing correctness of bounding-box after Update(): ";
142 expectedIndexBounds)) != EXIT_SUCCESS)
147 std::cout <<
"Testing correctness of axis-parallel bounding-box after UpdateOutputInformation(): ";
149 expectedAxisParallelBounds)) != EXIT_SUCCESS)
154 std::cout <<
"Testing bounding-box consistency: " << std::endl;
158 std::cout <<
"[FAILED]" << std::endl;
163 std::cout <<
"[PASSED]" << std::endl;
172 std::cout <<
"Testing mitk::PlaneGeometryDataToSurfaceFilter: " << std::endl;
175 std::cout <<
"Testing PlaneGeometryDataToSurfaceFilter::New(): ";
177 if (geometryToSurfaceFilter.IsNull())
179 std::cout <<
"[FAILED]" << std::endl;
184 std::cout <<
"[PASSED]" << std::endl;
189 plane->InitializeStandardPlane(50, 100);
191 plane->SetOrigin(origin);
194 geometryData->SetPlaneGeometry(plane);
196 std::cout <<
"Testing SetInput(): ";
197 geometryToSurfaceFilter->SetInput(geometryData);
198 std::cout <<
"[PASSED]" << std::endl;
200 std::cout <<
"Testing GetInput(): ";
201 if (geometryToSurfaceFilter->GetInput() != geometryData)
203 std::cout <<
"[FAILED]" << std::endl;
208 std::cout <<
"[PASSED]" << std::endl;
211 std::cout <<
"Testing default of PlaneGeometryDataToSurfaceFilter::m_PlaceByGeometry (expected is false): ";
212 if (geometryToSurfaceFilter->GetPlaceByGeometry() !=
false)
214 std::cout <<
"[FAILED]" << std::endl;
219 std::cout <<
"[PASSED]" << std::endl;
223 mitk::ScalarType expectedBoundsFinal[6] = {1.0, 51.0, 2.0, 102.0, 3.0, 3.0};
225 geometryToSurfaceFilter, expectedBoundsFinal, expectedBoundsFinal,
true)) != EXIT_SUCCESS)
230 std::cout <<
"Testing PlaneGeometryDataToSurfaceFilter::SetPlaceByGeometry(true): ";
231 geometryToSurfaceFilter->SetPlaceByGeometry(
true);
232 if (geometryToSurfaceFilter->GetPlaceByGeometry() !=
true)
234 std::cout <<
"[FAILED]" << std::endl;
239 std::cout <<
"[PASSED]" << std::endl;
243 mitk::ScalarType expectedIndexBounds[6] = {0.0, 50.0, 0.0, 100.0, 0.0, 0.0};
244 mitk::ScalarType expectedAxisParallelBounds[6] = {1.0, 51.0, 2.0, 102.0, 3.0, 3.0};
246 geometryToSurfaceFilter, expectedIndexBounds, expectedAxisParallelBounds,
true)) != EXIT_SUCCESS)
258 pointsContainer->InsertElement(0, bbMin);
259 pointsContainer->InsertElement(1, bbMax);
260 boundingBox->SetPoints(pointsContainer);
261 boundingBox->ComputeBoundingBox();
263 geometryToSurfaceFilter->SetPlaceByGeometry(
true);
264 geometryToSurfaceFilter->SetBoundingBox(boundingBox);
265 mitk::ScalarType expectedIndexBoundsWithBB[6] = {9.0, 39.0, 8.0, 88.0, 0.0, 0.0};
266 mitk::ScalarType expectedAxisParallelBoundsWithBB[6] = {10.0, 40.0, 10.0, 90.0, 3.0, 3.0};
268 geometryToSurfaceFilter, expectedIndexBoundsWithBB, expectedAxisParallelBoundsWithBB,
true)) != EXIT_SUCCESS)
273 std::cout <<
"[TEST DONE]" << std::endl;
Class for storing surfaces (vtkPolyData).
itk::BoundingBox< unsigned long, 3, ScalarType > BoundingBox
Standard 3D-BoundingBox typedef.
itk::SmartPointer< Self > Pointer
virtual vtkPolyData * GetVtkPolyData(unsigned int t=0) const
Superclass of all classes having a PlaneGeometryData as input and generating Images as output...
int testSurfaceBoundingBoxConsistency(mitk::Surface *surface, bool expectIdentityTransform)
void FillVector3D(Tout &out, mitk::ScalarType x, mitk::ScalarType y, mitk::ScalarType z)
int mitkGeometryDataToSurfaceFilterTest(int, char *[])
int testExpectedAxisParallelBoundingBox(mitk::BaseGeometry *geometry, TScalarType expectedAxisParallelBounds[6])
mitk::BoundingBox::Pointer CalculateBoundingBoxRelativeToTransform(const mitk::AffineTransform3D *transform) const
Calculates a bounding-box around the geometry relative to a coordinate system defined by a transform...
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.
int testExpectedIndexBoundingBox(mitk::BaseGeometry *geometry, TScalarType expectedIndexBounds[6])
virtual void SetRequestedRegionToLargestPossibleRegion() override=0
Set the RequestedRegion to the LargestPossibleRegion.
int testGeometryDataToSurfaceFilter(mitk::PlaneGeometryDataToSurfaceFilter *geometryToSurfaceFilter, mitk::ScalarType expectedIndexBounds[6], mitk::ScalarType expectedAxisParallelBounds[6], bool expectIdentityTransform)
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
BaseGeometry Describes the geometry of a data object.
mitk::AffineTransform3D * GetIndexToWorldTransform()
Get the transformation used to convert from index to world coordinates.
BoundingBoxType::BoundsArrayType BoundsArrayType
virtual const BoundingBoxType * GetBoundingBox()
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.