13 #ifndef mitkPlaneClipping_h
14 #define mitkPlaneClipping_h
18 #include <vtkPoints.h>
19 #include <vtkSmartPointer.h>
20 #include <vtkTransform.h>
24 namespace PlaneClipping
31 points->GetPoint(p1, point1);
32 points->GetPoint(p2, point2);
34 if ((point1[2] * point2[2] <= 0.0) && (point1[2] != point2[2]))
37 x = (point1[0] * point2[2] - point1[2] * point2[0]) / (point2[2] - point1[2]);
38 y = (point1[1] * point2[2] - point1[2] * point2[1]) / (point2[2] - point1[2]);
56 bounds[4] = bounds[5] = 0.0;
76 mitk::BoundingBox::PointType bbMin = boundingBox->GetMinimum();
77 mitk::BoundingBox::PointType bbMax = boundingBox->GetMaximum();
79 vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
82 points->InsertPoint(0, bbMin[0] - 0.5, bbMin[1] - 0.5, bbMin[2] - 0.5);
83 points->InsertPoint(1, bbMin[0] - 0.5, bbMin[1] - 0.5, bbMax[2] - 0.5);
84 points->InsertPoint(2, bbMin[0] - 0.5, bbMax[1] - 0.5, bbMax[2] - 0.5);
85 points->InsertPoint(3, bbMin[0] - 0.5, bbMax[1] - 0.5, bbMin[2] - 0.5);
86 points->InsertPoint(4, bbMax[0] - 0.5, bbMin[1] - 0.5, bbMin[2] - 0.5);
87 points->InsertPoint(5, bbMax[0] - 0.5, bbMin[1] - 0.5, bbMax[2] - 0.5);
88 points->InsertPoint(6, bbMax[0] - 0.5, bbMax[1] - 0.5, bbMax[2] - 0.5);
89 points->InsertPoint(7, bbMax[0] - 0.5, bbMax[1] - 0.5, bbMin[2] - 0.5);
93 points->InsertPoint(0, bbMin[0], bbMin[1], bbMin[2]);
94 points->InsertPoint(1, bbMin[0], bbMin[1], bbMax[2]);
95 points->InsertPoint(2, bbMin[0], bbMax[1], bbMax[2]);
96 points->InsertPoint(3, bbMin[0], bbMax[1], bbMin[2]);
97 points->InsertPoint(4, bbMax[0], bbMin[1], bbMin[2]);
98 points->InsertPoint(5, bbMax[0], bbMin[1], bbMax[2]);
99 points->InsertPoint(6, bbMax[0], bbMax[1], bbMax[2]);
100 points->InsertPoint(7, bbMax[0], bbMax[1], bbMin[2]);
103 vtkSmartPointer<vtkPoints> newPoints = vtkSmartPointer<vtkPoints>::New();
105 vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New();
106 transform->Identity();
107 transform->Concatenate(planeGeometry->
GetVtkTransform()->GetLinearInverse());
111 transform->TransformPoints(points, newPoints);
113 bounds[0] = bounds[2] = 10000000.0;
114 bounds[1] = bounds[3] = -10000000.0;
115 bounds[4] = bounds[5] = 0.0;
130 if ((bounds[0] > 9999999.0) || (bounds[2] > 9999999.0) || (bounds[1] < -9999999.0) || (bounds[3] < -9999999.0))
139 bounds[0] *= planeSpacing[0];
140 bounds[1] *= planeSpacing[0];
141 bounds[2] *= planeSpacing[1];
142 bounds[3] *= planeSpacing[1];
143 bounds[4] *= planeSpacing[2];
144 bounds[5] *= planeSpacing[2];