13 #ifndef mitkPlaneClipping_h
14 #define mitkPlaneClipping_h
18 #include <vtkPoints.h>
19 #include <vtkSmartPointer.h>
20 #include <vtkTransform.h>
25 namespace PlaneClipping
43 points->GetPoint(p1, point1);
44 points->GetPoint(p2, point2);
46 if ((point1[2] * point2[2] <= 0.0) && (point1[2] != point2[2]))
49 x = (point1[0] * point2[2] - point1[2] * point2[0]) / (point2[2] - point1[2]);
50 y = (point1[1] * point2[2] - point1[2] * point2[1]) / (point2[2] - point1[2]);
68 bounds[4] = bounds[5] = 0.0;
98 mitk::BoundingBox::PointType bbMin = boundingBox->GetMinimum();
99 mitk::BoundingBox::PointType bbMax = boundingBox->GetMaximum();
104 points->InsertPoint(0, bbMin[0] - 0.5, bbMin[1] - 0.5, bbMin[2] - 0.5);
105 points->InsertPoint(1, bbMin[0] - 0.5, bbMin[1] - 0.5, bbMax[2] - 0.5);
106 points->InsertPoint(2, bbMin[0] - 0.5, bbMax[1] - 0.5, bbMax[2] - 0.5);
107 points->InsertPoint(3, bbMin[0] - 0.5, bbMax[1] - 0.5, bbMin[2] - 0.5);
108 points->InsertPoint(4, bbMax[0] - 0.5, bbMin[1] - 0.5, bbMin[2] - 0.5);
109 points->InsertPoint(5, bbMax[0] - 0.5, bbMin[1] - 0.5, bbMax[2] - 0.5);
110 points->InsertPoint(6, bbMax[0] - 0.5, bbMax[1] - 0.5, bbMax[2] - 0.5);
111 points->InsertPoint(7, bbMax[0] - 0.5, bbMax[1] - 0.5, bbMin[2] - 0.5);
115 points->InsertPoint(0, bbMin[0], bbMin[1], bbMin[2]);
116 points->InsertPoint(1, bbMin[0], bbMin[1], bbMax[2]);
117 points->InsertPoint(2, bbMin[0], bbMax[1], bbMax[2]);
118 points->InsertPoint(3, bbMin[0], bbMax[1], bbMin[2]);
119 points->InsertPoint(4, bbMax[0], bbMin[1], bbMin[2]);
120 points->InsertPoint(5, bbMax[0], bbMin[1], bbMax[2]);
121 points->InsertPoint(6, bbMax[0], bbMax[1], bbMax[2]);
122 points->InsertPoint(7, bbMax[0], bbMax[1], bbMin[2]);
128 transform->Identity();
129 transform->Concatenate(planeGeometry->
GetVtkTransform()->GetLinearInverse());
133 transform->TransformPoints(points, newPoints);
135 bounds[0] = bounds[2] = 10000000.0;
136 bounds[1] = bounds[3] = -10000000.0;
137 bounds[4] = bounds[5] = 0.0;
152 if ((bounds[0] > 9999999.0) || (bounds[2] > 9999999.0) || (bounds[1] < -9999999.0) || (bounds[3] < -9999999.0))
161 bounds[0] *= planeSpacing[0];
162 bounds[1] *= planeSpacing[0];
163 bounds[2] *= planeSpacing[1];
164 bounds[3] *= planeSpacing[1];
165 bounds[4] *= planeSpacing[2];
166 bounds[5] *= planeSpacing[2];
Abstract base class describing the geometry of a data object.
virtual const BoundingBoxType * GetBoundingBox()
Get the bounding box in index/unit coordinates.
mitk::Vector3D GetSpacing() const
Get the spacing (voxel size) in mm per unit for each axis.
vtkLinearTransform * GetVtkTransform() const
Get the IndexToWorldTransform as a vtkLinearTransform.
virtual bool GetImageGeometry() const
Query whether this geometry refers to an image.
Describes the geometry of a plane object.
static bool CalculateClippedPlaneBounds(const BaseGeometry *boundingGeometry, const PlaneGeometry *planeGeometry, double *bounds)
Calculate the bounding box of the resliced image.
static bool LineIntersectZero(vtkPoints *points, int p1, int p2, double *bounds)
Internal helper method for intersection testing used only in CalculateClippedPlaneBounds().
Find image slices visible on a given plane.
itk::BoundingBox< unsigned long, 3, ScalarType > BoundingBox
Standard 3D bounding box type.