19 #include "vtkPolyData.h" 23 template <
typename TScalarType>
30 for (i = 0; i < 6; ++i)
32 if (
mitk::Equal(bounds[i], expectedIndexBounds[i]) ==
false)
34 std::cout <<
"[FAILED]" << std::endl;
38 std::cout <<
"[PASSED]" << std::endl;
42 template <
typename TScalarType>
49 for (i = 0; i < 6; ++i)
51 if (
mitk::Equal(bounds[i], expectedAxisParallelBounds[i]) ==
false)
53 std::cout <<
"[FAILED]" << std::endl;
57 std::cout <<
"[PASSED]" << std::endl;
63 std::cout <<
" Testing surface contents: ";
64 if ((surface ==
nullptr) || (surface->
GetVtkPolyData() ==
nullptr) ||
67 std::cout <<
"[FAILED]" << std::endl;
72 std::cout <<
"[PASSED]" << std::endl;
75 double bounds[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
78 polys->ComputeBounds();
79 polys->GetBounds(bounds);
81 if (expectIdentityTransform ==
false)
84 geometry->SetFloatBounds(bounds);
87 for (
int i = 0; i < 6; ++i)
91 std::cout <<
" Testing GetBoundingBox() ";
94 std::cout <<
"[FAILED]" << std::endl;
97 std::cout <<
"[PASSED]" << std::endl;
105 bool expectIdentityTransform)
109 std::cout <<
"Testing SetRequestedRegionToLargestPossibleRegion(): ";
111 std::cout <<
"[PASSED]" << std::endl;
113 std::cout <<
"Testing UpdateOutputInformation(): ";
114 geometryToSurfaceFilter->UpdateOutputInformation();
115 std::cout <<
"[PASSED]" << std::endl;
117 std::cout <<
"Testing correctness of bounding-box after UpdateOutputInformation(): ";
119 expectedIndexBounds)) != EXIT_SUCCESS)
124 std::cout <<
"Testing correctness of axis-parallel bounding-box after UpdateOutputInformation(): ";
126 expectedAxisParallelBounds)) != EXIT_SUCCESS)
131 std::cout <<
"Testing Update(): ";
132 geometryToSurfaceFilter->Update();
133 std::cout <<
"[PASSED]" << std::endl;
135 std::cout <<
"Testing correctness of bounding-box after Update(): ";
137 expectedIndexBounds)) != EXIT_SUCCESS)
142 std::cout <<
"Testing correctness of axis-parallel bounding-box after UpdateOutputInformation(): ";
144 expectedAxisParallelBounds)) != EXIT_SUCCESS)
149 std::cout <<
"Testing bounding-box consistency: " << std::endl;
153 std::cout <<
"[FAILED]" << std::endl;
158 std::cout <<
"[PASSED]" << std::endl;
167 std::cout <<
"Testing mitk::PlaneGeometryDataToSurfaceFilter: " << std::endl;
170 std::cout <<
"Testing PlaneGeometryDataToSurfaceFilter::New(): ";
172 if (geometryToSurfaceFilter.IsNull())
174 std::cout <<
"[FAILED]" << std::endl;
179 std::cout <<
"[PASSED]" << std::endl;
184 plane->InitializeStandardPlane(50, 100);
186 plane->SetOrigin(origin);
189 geometryData->SetPlaneGeometry(plane);
191 std::cout <<
"Testing SetInput(): ";
192 geometryToSurfaceFilter->SetInput(geometryData);
193 std::cout <<
"[PASSED]" << std::endl;
195 std::cout <<
"Testing GetInput(): ";
196 if (geometryToSurfaceFilter->GetInput() != geometryData)
198 std::cout <<
"[FAILED]" << std::endl;
203 std::cout <<
"[PASSED]" << std::endl;
206 std::cout <<
"Testing default of PlaneGeometryDataToSurfaceFilter::m_PlaceByGeometry (expected is false): ";
207 if (geometryToSurfaceFilter->GetPlaceByGeometry() !=
false)
209 std::cout <<
"[FAILED]" << std::endl;
214 std::cout <<
"[PASSED]" << std::endl;
218 mitk::ScalarType expectedBoundsFinal[6] = {1.0, 51.0, 2.0, 102.0, 3.0, 3.0};
220 geometryToSurfaceFilter, expectedBoundsFinal, expectedBoundsFinal,
true)) != EXIT_SUCCESS)
225 std::cout <<
"Testing PlaneGeometryDataToSurfaceFilter::SetPlaceByGeometry(true): ";
226 geometryToSurfaceFilter->SetPlaceByGeometry(
true);
227 if (geometryToSurfaceFilter->GetPlaceByGeometry() !=
true)
229 std::cout <<
"[FAILED]" << std::endl;
234 std::cout <<
"[PASSED]" << std::endl;
238 mitk::ScalarType expectedIndexBounds[6] = {0.0, 50.0, 0.0, 100.0, 0.0, 0.0};
239 mitk::ScalarType expectedAxisParallelBounds[6] = {1.0, 51.0, 2.0, 102.0, 3.0, 3.0};
241 geometryToSurfaceFilter, expectedIndexBounds, expectedAxisParallelBounds,
true)) != EXIT_SUCCESS)
247 mitk::BoundingBox::Pointer boundingBox = mitk::BoundingBox::New();
252 mitk::BoundingBox::PointsContainer::Pointer pointsContainer = mitk::BoundingBox::PointsContainer::New();
253 pointsContainer->InsertElement(0, bbMin);
254 pointsContainer->InsertElement(1, bbMax);
255 boundingBox->SetPoints(pointsContainer);
256 boundingBox->ComputeBoundingBox();
258 geometryToSurfaceFilter->SetPlaceByGeometry(
true);
259 geometryToSurfaceFilter->SetBoundingBox(boundingBox);
260 mitk::ScalarType expectedIndexBoundsWithBB[6] = {9.0, 39.0, 8.0, 88.0, 0.0, 0.0};
261 mitk::ScalarType expectedAxisParallelBoundsWithBB[6] = {10.0, 40.0, 10.0, 90.0, 3.0, 3.0};
263 geometryToSurfaceFilter, expectedIndexBoundsWithBB, expectedAxisParallelBoundsWithBB,
true)) != EXIT_SUCCESS)
268 std::cout <<
"[TEST DONE]" << std::endl;
Class for storing surfaces (vtkPolyData).
itk::BoundingBox< unsigned long, 3, ScalarType > BoundingBox
Standard 3D-BoundingBox typedef.
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])
void SetRequestedRegionToLargestPossibleRegion() override=0
Set the RequestedRegion to the LargestPossibleRegion.
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])
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...
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()