Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkPlane.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "mitkPlane.h"
18 #include "mitkNumericTypes.h"
19 
20 #include <vtkDoubleArray.h>
21 #include <vtkLinearTransform.h>
22 #include <vtkPlaneSource.h>
23 #include <vtkPointData.h>
24 
25 namespace mitk
26 {
28  {
29  // Set up Plane Surface.
31  m_PlaneSource->SetOrigin(-32.0, -32.0, 0.0);
32  m_PlaneSource->SetPoint1(32.0, -32.0, 0.0);
33  m_PlaneSource->SetPoint2(-32.0, 32.0, 0.0);
34  m_PlaneSource->SetResolution(128, 128);
35  m_PlaneSource->Update();
36 
38  m_PlaneNormal->SetNumberOfComponents(3);
39  m_PlaneNormal->SetNumberOfTuples(m_PlaneSource->GetOutput()->GetNumberOfPoints());
40  m_PlaneNormal->SetTuple3(0, 0.0, 0.0, 1.0);
41  m_PlaneNormal->SetName("planeNormal");
42 
44  m_Plane->DeepCopy(m_PlaneSource->GetOutput());
45  m_Plane->GetPointData()->SetVectors(m_PlaneNormal);
46 
47  this->SetVtkPolyData(m_Plane);
48  }
49 
51  {
52  m_PlaneSource->Delete();
53  m_Plane->Delete();
54  m_PlaneNormal->Delete();
55  }
56 
57  void Plane::SetExtent(const double x, const double y)
58  {
59  m_PlaneSource->SetOrigin(-x / 2.0, -y / 2.0, 0.0);
60  m_PlaneSource->SetPoint1(x / 2.0, -y / 2.0, 0.0);
61  m_PlaneSource->SetPoint2(-x / 2.0, y / 2.0, 0.0);
62  m_PlaneSource->Update();
63 
64  m_Plane->DeepCopy(m_PlaneSource->GetOutput());
65  m_Plane->GetPointData()->SetVectors(m_PlaneNormal);
66 
67  this->Modified();
68  }
69 
70  void Plane::GetExtent(double &x, double &y) const
71  {
72  x = m_PlaneSource->GetPoint1()[0] - m_PlaneSource->GetOrigin()[0];
73  y = m_PlaneSource->GetPoint2()[1] - m_PlaneSource->GetOrigin()[1];
74  }
75 
76  void Plane::SetResolution(const int xR, const int yR)
77  {
78  m_PlaneSource->SetResolution(xR, yR);
79  m_PlaneSource->Update();
80 
81  m_Plane->DeepCopy(m_PlaneSource->GetOutput());
82  m_Plane->GetPointData()->SetVectors(m_PlaneNormal);
83 
84  this->Modified();
85  }
86 
87  void Plane::GetResolution(int &xR, int &yR) const { m_PlaneSource->GetResolution(xR, yR); }
88  bool Plane::IsInside(const Point3D & /*worldPoint*/) const
89  {
90  // Plane does not have a volume
91  return false;
92  }
93 
95  {
96  // Plane does not have a volume
97  return 0.0;
98  }
99 }
void GetExtent(double &x, double &y) const
Definition: mitkPlane.cpp:70
double ScalarType
void GetResolution(int &xR, int &yR) const
Definition: mitkPlane.cpp:87
virtual mitk::ScalarType GetVolume() override
Definition: mitkPlane.cpp:94
DataCollection - Class to facilitate loading/accessing structured data.
vtkPlaneSource * m_PlaneSource
Definition: mitkPlane.h:54
vtkDoubleArray * m_PlaneNormal
Definition: mitkPlane.h:58
superclass of all bounding objects (cylinder, cuboid,...)
virtual void SetVtkPolyData(vtkPolyData *polydata, unsigned int t=0)
virtual bool IsInside(const Point3D &p) const override
Definition: mitkPlane.cpp:88
void SetExtent(const double x, const double y)
Definition: mitkPlane.cpp:57
vtkPolyData * m_Plane
Definition: mitkPlane.h:56
virtual ~Plane()
Definition: mitkPlane.cpp:50
void SetResolution(const int xR, const int yR)
Definition: mitkPlane.cpp:76
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.