18 #define _USE_MATH_DEFINES
34 image->Initialize(mitk::MakePixelType<int, int, 1>(), *(geometry3D.GetPointer()));
48 planeOnSliceZero->InitializePlane(origin, normal);
50 calculator->
SetInput(planeOnSliceZero, image);
56 MITK_TEST_CONDITION(minMax.first == 0 && minMax.second == 0,
"Check if plane is on slice 0");
62 planeOnSliceThree->InitializePlane(origin, normal);
63 planeOnSliceThree->SetImageGeometry(
false);
65 calculator->
SetInput(planeOnSliceThree, image);
71 MITK_TEST_CONDITION(minMax.first == 3 && minMax.second == 3,
"Check if plane is on slice 3");
77 planeOnSliceSeventeen->InitializePlane(origin, normal);
79 calculator->
SetInput(planeOnSliceSeventeen, image);
85 MITK_TEST_CONDITION(minMax.first == 17 && minMax.second == 17,
"Check if plane is on slice 17");
91 planeOnSliceTwenty->InitializePlane(origin, normal);
93 calculator->
SetInput(planeOnSliceTwenty, image);
99 MITK_TEST_CONDITION(minMax.first == 19 && minMax.second == 19,
"Check if plane is on slice 19");
110 image->Initialize(mitk::MakePixelType<int, int, 1>(), *(geometry3D.GetPointer()));
123 planeSagittalOne->InitializePlane(origin, normal);
125 calculator->
SetInput(planeSagittalOne, image);
129 MITK_TEST_CONDITION(minMax.first == 0 && minMax.second == 19,
"Check if plane is from slice 0 to slice 19");
137 planeSagittalTwo->InitializePlane(origin, normal);
139 MITK_INFO <<
"PlaneNormal: " << planeSagittalTwo->GetNormal();
140 MITK_INFO <<
"PlaneOrigin: " << planeSagittalTwo->GetOrigin();
142 calculator->
SetInput(planeSagittalTwo, image);
146 MITK_INFO <<
"min: " << minMax.first <<
" max: " << minMax.second;
148 MITK_TEST_CONDITION(minMax.first == 0 && minMax.second == 19,
"Check if plane is from slice 0 to slice 19");
154 planeOnSliceSeventeen->InitializePlane(origin, normal);
156 calculator->
SetInput(planeOnSliceSeventeen, image);
160 MITK_TEST_CONDITION(minMax.first == 0 && minMax.second == 19,
"Check if plane is from slice 0 to slice 19");
172 planeCrookedOne->InitializePlane(origin, normal);
174 calculator->
SetInput(planeCrookedOne, image);
178 MITK_INFO <<
"min: " << minMax.first <<
" max: " << minMax.second;
181 "Check if plane is from slice 0 to slice 5 with inclined plane");
188 planeCrookedTwo->InitializePlane(origin, normal);
190 calculator->
SetInput(planeCrookedTwo, image);
194 MITK_INFO <<
"min: " << minMax.first <<
" max: " << minMax.second;
197 "Check if plane is from slice 16 to slice 19 with inclined plane");
207 planeCrookedThree->InitializePlane(origin, normal);
209 calculator->
SetInput(planeCrookedThree, image);
213 MITK_INFO <<
"min: " << minMax.first <<
" max: " << minMax.second;
216 "Check if plane is from slice 0 to slice 19 with inclined plane");
227 image->Initialize(mitk::MakePixelType<int, int, 1>(), *(geometry3D.GetPointer()));
239 planeInFront->InitializePlane(origin, normal);
241 calculator->
SetInput(planeInFront, image);
253 planeBehind->InitializePlane(origin, normal);
255 calculator->
SetInput(planeBehind, image);
269 planeAbove->InitializePlane(origin, normal);
271 calculator->
SetInput(planeAbove, image);
283 planeBelow->InitializePlane(origin, normal);
285 calculator->
SetInput(planeBelow, image);
299 planeLeftSide->InitializePlane(origin, normal);
301 calculator->
SetInput(planeLeftSide, image);
313 planeRightSide->InitializePlane(origin, normal);
315 calculator->
SetInput(planeRightSide, image);
331 firstImage->Initialize(mitk::MakePixelType<int, int, 1>(), *(firstGeometry3D.GetPointer()));
333 calculator->
SetInput(secondGeometry3D, firstImage);
337 MITK_INFO <<
"min: " << minMax.first <<
" max: " << minMax.second;
339 MITK_TEST_CONDITION(minMax.first == 0 && minMax.second == 19,
"Check if plane is from slice 0 to slice 19");
348 image->Initialize(mitk::MakePixelType<int, int, 1>(), *(geometry3D.GetPointer()));
360 pointlist.push_back(pnt1);
361 pointlist.push_back(pnt2);
364 calculator.
SetInput(pointlist, image);
369 "Check if points span from slice 3 to slice 8 in axial");
373 "Check if points span from slice 3 to slice 5 in sagittal");
382 pointlist.push_back(pnt1);
383 pointlist.push_back(pnt2);
386 calculator.
SetInput(pointlist, image);
391 "Check if points are correctly clipped to slice 0 and slice 19 in axial");
395 "Check if points are correctly clipped to slice 0 and slice 511 in sagittal");
404 origin3[1] = -113.22;
420 planeGeometry3->InitializePlane(origin3, normal3);
421 planeGeometry3->SetSpacing(spacing);
430 planeGeometry3->SetBounds(moreBounds);
434 rotatedSlicedGeometry3D->InitializeEvenlySpaced(dynamic_cast<mitk::PlaneGeometry *>(planeGeometry3.GetPointer()), 25);
435 rotatedSlicedGeometry3D->SetImageGeometry(
true);
438 mitk::AffineTransform3D::MatrixType matrix;
440 matrix[0][1] = -0.01;
441 matrix[0][2] = -0.02;
445 matrix[2][2] = -0.18;
450 geom->SetMatrix(matrix);
454 image->Initialize(mitk::MakePixelType<int, int, 1>(), *(rotatedSlicedGeometry3D.GetPointer()));
474 planeOnSliceZero->InitializePlane(origin, normal);
475 planeOnSliceZero->SetSpacing(spacing);
477 calculator->
SetInput(planeOnSliceZero, image);
483 MITK_TEST_CONDITION(minMax.first == 24 && minMax.second == 24,
"Check if plane is on slice 24");
502 planeOnSliceZero->InitializePlane(origin, normal);
503 planeOnSliceZero->SetSpacing(spacing);
505 calculator->
SetInput(planeOnSliceZero, image);
511 MITK_TEST_CONDITION(minMax.first == 0 && minMax.second == 24,
"Check if plane is on slices 0-24");
538 planeGeometry3->InitializePlane(origin3, normal3);
539 planeGeometry3->SetSpacing(spacing);
548 planeGeometry3->SetBounds(moreBounds);
552 rotatedSlicedGeometry3D->InitializeEvenlySpaced(dynamic_cast<mitk::PlaneGeometry *>(planeGeometry3.GetPointer()), 50);
553 rotatedSlicedGeometry3D->SetImageGeometry(
true);
558 mitk::AffineTransform3D::MatrixType matrix;
559 matrix[0][0] = spacing[0];
564 matrix[1][1] = spacing[1];
569 matrix[2][2] = spacing[2];
570 geom->SetMatrix(matrix);
574 image->Initialize(mitk::MakePixelType<int, int, 1>(), *(rotatedSlicedGeometry3D.GetPointer()));
580 originFirstSlice[0] = 0.0;
581 originFirstSlice[1] = -1.0;
582 originFirstSlice[2] = 0.0;
588 spacingFirstSlice[0] = 1.0;
589 spacingFirstSlice[1] = 1.0;
590 spacingFirstSlice[2] = 1.0;
593 planeOnFirstSlice->InitializePlane(originFirstSlice, normalFitrstSlice);
594 planeOnFirstSlice->SetSpacing(spacingFirstSlice);
598 originLastSlice[0] = 0.0;
599 originLastSlice[1] = 99.0;
600 originLastSlice[2] = 0.0;
606 spacingLastSlice[0] = 1.0;
607 spacingLastSlice[1] = 1.0;
608 spacingLastSlice[2] = 1.0;
611 planeOnLastSlice->InitializePlane(originLastSlice, normalLastSlice);
612 planeOnLastSlice->SetSpacing(spacingLastSlice);
615 calculator->
SetInput(planeOnLastSlice, image);
621 MITK_TEST_CONDITION(minMax.first == 49 && minMax.second == 49,
"Check if plane is on slice 49");
622 MITK_INFO <<
"min: " << minMax.first <<
" max: " << minMax.second;
625 calculator->
SetInput(planeOnFirstSlice, image);
631 MITK_TEST_CONDITION(minMax.first == 0 && minMax.second == 0,
"Check if plane is on slice 0");
632 MITK_INFO <<
"min: " << minMax.first <<
" max: " << minMax.second;
636 double angleInDegrees = 270 *
M_PI / 180;
638 mitk::AffineTransform3D::MatrixType matrix2;
639 matrix2[0][0] = cos(angleInDegrees);
640 matrix2[0][1] = -sin(angleInDegrees);
643 matrix2[1][0] = sin(angleInDegrees);
644 matrix2[1][1] = cos(angleInDegrees);
652 mitk::AffineTransform3D::MatrixType TransformationMatrix = matrix2 * matrix;
655 geom->SetMatrix(TransformationMatrix);
656 image->Initialize(mitk::MakePixelType<int, int, 1>(), *(rotatedSlicedGeometry3D.GetPointer()));
661 originFirstSlice[0] = -1.0;
662 originFirstSlice[1] = 0.0;
663 originFirstSlice[2] = 0.0;
669 spacingFirstSlice[0] = 1.0;
670 spacingFirstSlice[1] = 1.0;
671 spacingFirstSlice[2] = 1.0;
674 planeOnFirstSlice->InitializePlane(originFirstSlice, normalFitrstSlice);
675 planeOnFirstSlice->SetSpacing(spacingFirstSlice);
679 originLastSlice[0] = 99.0;
680 originLastSlice[1] = 0.0;
681 originLastSlice[2] = 0.0;
687 spacingLastSlice[0] = 1.0;
688 spacingLastSlice[1] = 1.0;
689 spacingLastSlice[2] = 1.0;
692 planeOnLastSlice->InitializePlane(originLastSlice, normalLastSlice);
693 planeOnLastSlice->SetSpacing(spacingLastSlice);
695 calculator->
SetInput(planeOnLastSlice, image);
701 MITK_TEST_CONDITION(minMax.first == 49 && minMax.second == 49,
"Check if plane is on slice 49");
702 MITK_INFO <<
"min: " << minMax.first <<
" max: " << minMax.second;
704 calculator->
SetInput(planeOnFirstSlice, image);
710 MITK_TEST_CONDITION(minMax.first == 0 && minMax.second == 0,
"Check if plane is on slice 0");
711 MITK_INFO <<
"min: " << minMax.first <<
" max: " << minMax.second;
748 planeGeometry->InitializePlane(origin, normal);
758 planeGeometry->SetBounds(bounds);
762 slicedGeometry3D->InitializeEvenlySpaced(dynamic_cast<mitk::PlaneGeometry *>(planeGeometry.GetPointer()), 20);
764 geometry3D->SetImageGeometry(
true);
778 planeGeometry2->InitializePlane(origin2, normal2);
782 secondSlicedGeometry3D->InitializeEvenlySpaced(dynamic_cast<mitk::PlaneGeometry *>(planeGeometry2.GetPointer()), 20);
785 secondGeometry3D->SetImageGeometry(
true);
OutputType GetMinMaxSpatialDirectionZ()
What Z coordinates (slice indices) are cut/visible in given plane.
static void CheckIntersectionWithRotatedGeometry()
void SetInput(const mitk::PlaneGeometry *geometry, mitk::Image *image)
void Update()
Request calculation.
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
static void CheckPlanesInsideBoundingBox(mitk::BaseGeometry::Pointer geometry3D)
void FillVector3D(Tout &out, mitk::ScalarType x, mitk::ScalarType y, mitk::ScalarType z)
static void CheckIntersectionWithPointCloud(mitk::BaseGeometry::Pointer geometry3D)
#define MITK_TEST_CONDITION(COND, MSG)
static void CheckPlanesOutsideOfBoundingBox(mitk::BaseGeometry::Pointer geometry3D)
std::vector< mitk::Point3D > PointListType
itk::AffineGeometryFrame< ScalarType, 3 >::TransformType AffineTransform3D
static void CheckIntersectionWithRotatedGeometry90()
int mitkClippedSurfaceBoundsCalculatorTest(int, char *[])
OutputType GetMinMaxSpatialDirectionY()
What Y coordinates (slice indices) are cut/visible in given plane.
static void CheckPlanesInsideBoundingBoxOnlyOnOneSlice(mitk::BaseGeometry::Pointer geometry3D)
OutputType GetMinMaxSpatialDirectionX()
What X coordinates (slice indices) are cut/visible in given plane.
BaseGeometry Describes the geometry of a data object.
std::pair< int, int > OutputType
Minimum (first) and maximum (second) slice index.
BoundingBoxType::BoundsArrayType BoundsArrayType
static void CheckIntersectionPointsOfTwoGeometry3D(mitk::BaseGeometry::Pointer firstGeometry3D, mitk::BaseGeometry::Pointer secondGeometry3D)