24 #include <vtkPlaneSource.h>
25 #include <vtkPolyData.h>
26 #include <vtkTransformPolyDataFilter.h>
29 #include <vtkClipPolyData.h>
30 #include <vtkCubeSource.h>
31 #include <vtkCutter.h>
32 #include <vtkGeneralTransform.h>
33 #include <vtkPPolyDataNormals.h>
35 #include <vtkStripper.h>
36 #include <vtkTextureMapToPlane.h>
37 #include <vtkTransform.h>
38 #include <vtkTransformPolyDataFilter.h>
39 #include <vtkTriangleFilter.h>
42 : m_UseGeometryParametricBounds(true),
45 m_PlaceByGeometry(false),
46 m_UseBoundingBox(false)
71 m_PlaneSource->Delete();
72 m_Transform->Delete();
74 m_CubeSource->Delete();
75 m_PolyDataTransformer->Delete();
78 m_PlaneCutter->Delete();
79 m_PlaneStripper->Delete();
80 m_PlanePolyData->Delete();
81 m_NormalsUpdater->Delete();
82 m_PlaneTriangler->Delete();
83 m_TextureMapToPlane->Delete();
86 m_PlaneClipper->Delete();
88 m_VtkTransformPlaneFilter->Delete();
96 if (input.IsNull() || (input->GetPlaneGeometry() ==
nullptr) || (input->GetPlaneGeometry()->IsValid() ==
false) ||
97 (m_UseBoundingBox && (m_BoundingBox.IsNull() || (m_BoundingBox->GetDiagonalLength2() <
mitk::eps))))
105 vtkPolyData *planeSurface =
nullptr;
109 dynamic_cast<AbstractTransformGeometry *>(input->GetPlaneGeometry()))
116 origin = abstractGeometry->GetPlane()->GetOrigin();
117 right = origin + abstractGeometry->GetPlane()->GetAxisVector(0);
118 bottom = origin + abstractGeometry->GetPlane()->GetAxisVector(1);
121 m_PlaneSource->SetOrigin(origin[0], origin[1], origin[2]);
122 m_PlaneSource->SetPoint1(right[0], right[1], right[2]);
123 m_PlaneSource->SetPoint2(bottom[0], bottom[1], bottom[2]);
128 if (m_UseGeometryParametricBounds)
130 m_PlaneSource->SetXResolution((
int)abstractGeometry->GetParametricExtent(0));
131 m_PlaneSource->SetYResolution((
int)abstractGeometry->GetParametricExtent(1));
135 m_PlaneSource->SetXResolution(m_XResolution);
136 m_PlaneSource->SetYResolution(m_YResolution);
138 if (m_PlaceByGeometry)
149 composedResliceTransform->Identity();
150 composedResliceTransform->Concatenate(abstractGeometry->GetVtkTransform()->GetLinearInverse());
151 composedResliceTransform->Concatenate(abstractGeometry->GetVtkAbstractTransform());
153 m_VtkTransformPlaneFilter->SetTransform(composedResliceTransform);
158 m_VtkTransformPlaneFilter->SetTransform(abstractGeometry->GetVtkAbstractTransform());
161 if (m_UseBoundingBox)
167 m_Box->SetXMin(boundingBoxMin[0], boundingBoxMin[1], boundingBoxMin[2]);
168 m_Box->SetXMax(boundingBoxMax[0], boundingBoxMax[1], boundingBoxMax[2]);
173 m_Box->SetXMin(-10000.0, -10000.0, -10000.0);
174 m_Box->SetXMax(10000.0, 10000.0, 10000.0);
177 m_Transform->Identity();
178 m_Transform->Concatenate(input->GetPlaneGeometry()->GetVtkTransform());
179 m_Transform->PreMultiply();
181 m_Box->SetTransform(m_Transform);
183 m_PlaneClipper->SetInputConnection(m_VtkTransformPlaneFilter->GetOutputPort());
184 m_PlaneClipper->SetClipFunction(m_Box);
185 m_PlaneClipper->GenerateClippedOutputOff();
186 m_PlaneClipper->InsideOutOn();
187 m_PlaneClipper->SetValue(0.0);
188 m_PlaneClipper->Update();
190 planeSurface = m_PlaneClipper->GetOutput();
193 else if (dynamic_cast<PlaneGeometry *>(input->GetPlaneGeometry()) !=
nullptr)
197 if (m_PlaceByGeometry)
208 if (!m_UseBoundingBox)
212 if (m_PlaceByGeometry)
229 m_PlaneSource->SetXResolution(1);
230 m_PlaneSource->SetYResolution(1);
232 m_PlaneSource->SetOrigin(origin[0], origin[1], origin[2]);
233 m_PlaneSource->SetPoint1(right[0], right[1], right[2]);
234 m_PlaneSource->SetPoint2(bottom[0], bottom[1], bottom[2]);
236 m_PlaneSource->Update();
237 planeSurface = m_PlaneSource->GetOutput();
253 m_CubeSource->SetXLength(boundingBoxMax[0] - boundingBoxMin[0]);
254 m_CubeSource->SetYLength(boundingBoxMax[1] - boundingBoxMin[1]);
255 m_CubeSource->SetZLength(boundingBoxMax[2] - boundingBoxMin[2]);
256 m_CubeSource->SetCenter(boundingBoxCenter[0], boundingBoxCenter[1], boundingBoxCenter[2]);
263 m_Transform->Identity();
264 m_Transform->Concatenate(planeGeometry->
GetVtkTransform()->GetLinearInverse());
267 if (referenceGeometry)
273 m_PolyDataTransformer->SetInputConnection(m_CubeSource->GetOutputPort());
274 m_PolyDataTransformer->SetTransform(m_Transform);
278 m_Plane->SetNormal(0.0, 0.0, 1.0);
281 m_PlaneCutter->SetInputConnection(m_PolyDataTransformer->GetOutputPort());
282 m_PlaneCutter->SetCutFunction(m_Plane);
285 m_PlaneStripper->SetInputConnection(m_PlaneCutter->GetOutputPort());
286 m_PlaneStripper->Update();
288 if (m_PlaneStripper->GetOutput()->GetNumberOfPoints() < 3)
293 m_PlanePolyData->SetPoints(m_PlaneStripper->GetOutput()->GetPoints());
294 m_PlanePolyData->SetPolys(m_PlaneStripper->GetOutput()->GetLines());
296 m_PlaneTriangler->SetInputData(m_PlanePolyData);
300 m_PlaneTriangler->Update();
301 m_PlaneTriangler->GetOutput()->ComputeBounds();
302 double *surfaceBounds = m_PlaneTriangler->GetOutput()->GetBounds();
304 origin[0] = surfaceBounds[0];
305 origin[1] = surfaceBounds[2];
306 origin[2] = surfaceBounds[4];
308 right[0] = surfaceBounds[1];
309 right[1] = surfaceBounds[2];
310 right[2] = surfaceBounds[4];
312 bottom[0] = surfaceBounds[0];
313 bottom[1] = surfaceBounds[3];
314 bottom[2] = surfaceBounds[4];
318 m_TextureMapToPlane->SetInputConnection(m_PlaneTriangler->GetOutputPort());
319 m_TextureMapToPlane->AutomaticPlaneGenerationOn();
320 m_TextureMapToPlane->SetOrigin(origin[0], origin[1], origin[2]);
321 m_TextureMapToPlane->SetPoint1(right[0], right[1], right[2]);
322 m_TextureMapToPlane->SetPoint2(bottom[0], bottom[1], bottom[2]);
326 m_TextureMapToPlane->Update();
329 planeSurface =
dynamic_cast<vtkPolyData *
>(m_TextureMapToPlane->GetOutput());
333 m_NormalsUpdater->SetInputData(planeSurface);
334 m_NormalsUpdater->AutoOrientNormalsOn();
336 m_NormalsUpdater->ComputePointNormalsOn();
337 m_NormalsUpdater->Update();
339 output->SetVtkPolyData(m_NormalsUpdater->GetOutput());
340 output->CalculateBoundingBox();
349 if (output->GetVtkPolyData() ==
nullptr)
357 if (this->GetNumberOfInputs() < 1)
373 this->ProcessObject::SetNthInput(0, const_cast<mitk::PlaneGeometryData *>(input));
378 if (index + 1 > this->GetNumberOfInputs())
380 this->SetNumberOfRequiredInputs(index + 1);
383 this->ProcessObject::SetNthInput(index, const_cast<mitk::PlaneGeometryData *>(input));
388 m_BoundingBox = boundingBox;
389 this->UseBoundingBoxOn();
394 return m_BoundingBox.GetPointer();
ScalarType GetExtent(unsigned int direction) const
Set the time bounds (in ms)
const Point3D GetOrigin() const
Get the origin, e.g. the upper-left corner of the plane.
itk::BoundingBox< unsigned long, 3, ScalarType > BoundingBox
Standard 3D-BoundingBox typedef.
void SetIndexToWorldTransform(mitk::AffineTransform3D *transform)
const PlaneGeometryData * GetInput(void)
virtual void GenerateOutputInformation() override
virtual void SetInput(const PlaneGeometryData *image)
virtual void GenerateData() override
GeometryTransformHolder::TransformType TransformType
virtual ~PlaneGeometryDataToSurfaceFilter()
vtkClipPolyData * m_PlaneClipper
void FillVector3D(Tout &out, mitk::ScalarType x, mitk::ScalarType y, mitk::ScalarType z)
PlaneGeometryDataToSurfaceFilter()
vtkPPolyDataNormals * m_NormalsUpdater
vtkTextureMapToPlane * m_TextureMapToPlane
void SetBoundingBox(const BoundingBox *boundingBox)
vtkTriangleFilter * m_PlaneTriangler
const BoundingBox * GetBoundingBox() const
void SetOrigin(const Point3D &origin)
Set the origin, i.e. the upper-left corner of the plane.
vtkTransform * m_Transform
vtkPolyData * m_PlanePolyData
Data class containing PlaneGeometry objects.
Point3D GetCornerPoint(int id) const
Get the position of the corner number id (in world coordinates)
vtkCubeSource * m_CubeSource
const BaseGeometry * GetReferenceGeometry() const
Get the geometrical frame of reference for this PlaneGeometry.
vtkPlaneSource * m_PlaneSource
Source to create the vtk-representation of the parameter space rectangle of the PlaneGeometry.
vtkCutter * m_PlaneCutter
vtkTransformPolyDataFilter * m_PolyDataTransformer
virtual BaseGeometry::Pointer GetGeometryForTimeStep(TimeStepType timeStep) const =0
Returns the geometry which corresponds to the given time step.
vtkTransformPolyDataFilter * m_VtkTransformPlaneFilter
Filter to create the vtk-representation of the PlaneGeometry, which is a transformation of the m_Plan...
MITKCORE_EXPORT const ScalarType eps
Describes a two-dimensional, rectangular plane.
vtkLinearTransform * GetVtkTransform() const
Get the m_IndexToWorldTransform as a vtkLinearTransform.
vtkStripper * m_PlaneStripper
BaseGeometry Describes the geometry of a data object.
mitk::AffineTransform3D * GetIndexToWorldTransform()
Get the transformation used to convert from index to world coordinates.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.