Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "mitkPlane.h"
00020 #include "mitkVector.h"
00021
00022 #include <vtkLinearTransform.h>
00023 #include <vtkPlaneSource.h>
00024 #include <vtkDoubleArray.h>
00025 #include <vtkPointData.h>
00026
00027
00028 namespace mitk
00029 {
00030
00031 Plane::Plane()
00032 : BoundingObject()
00033 {
00034
00035 m_PlaneSource = vtkPlaneSource::New();
00036 m_PlaneSource->SetOrigin( -32.0, -32.0, 0.0 );
00037 m_PlaneSource->SetPoint1( 32.0, -32.0, 0.0 );
00038 m_PlaneSource->SetPoint2( -32.0, 32.0, 0.0 );
00039 m_PlaneSource->SetResolution( 128, 128 );
00040 m_PlaneSource->Update();
00041
00042 m_PlaneNormal = vtkDoubleArray::New();
00043 m_PlaneNormal->SetNumberOfComponents( 3 );
00044 m_PlaneNormal->SetNumberOfTuples( m_PlaneSource->GetOutput()->GetNumberOfPoints() );
00045 m_PlaneNormal->SetTuple3( 0, 0.0, 0.0, 1.0 );
00046 m_PlaneNormal->SetName( "planeNormal" );
00047
00048 m_Plane = vtkPolyData::New();
00049 m_Plane->DeepCopy( m_PlaneSource->GetOutput() );
00050 m_Plane->GetPointData()->SetVectors( m_PlaneNormal );
00051
00052 this->SetVtkPolyData( m_Plane );
00053 }
00054
00055
00056 Plane::~Plane()
00057 {
00058 m_PlaneSource->Delete();
00059 m_Plane->Delete();
00060 m_PlaneNormal->Delete();
00061 }
00062
00063
00064 void Plane::SetExtent( const double x, const double y )
00065 {
00066 m_PlaneSource->SetOrigin( -x / 2.0, -y / 2.0, 0.0 );
00067 m_PlaneSource->SetPoint1( x / 2.0, -y / 2.0, 0.0 );
00068 m_PlaneSource->SetPoint2( -x / 2.0, y / 2.0, 0.0 );
00069 m_PlaneSource->Update();
00070
00071 m_Plane->DeepCopy( m_PlaneSource->GetOutput() );
00072 m_Plane->GetPointData()->SetVectors( m_PlaneNormal );
00073
00074 this->Modified();
00075 }
00076
00077 void Plane::GetExtent( double &x, double &y ) const
00078 {
00079 x = m_PlaneSource->GetPoint1()[0] - m_PlaneSource->GetOrigin()[0];
00080 y = m_PlaneSource->GetPoint2()[1] - m_PlaneSource->GetOrigin()[1];
00081 }
00082
00083 void Plane::SetResolution( const int xR, const int yR )
00084 {
00085 m_PlaneSource->SetResolution( xR, yR );
00086 m_PlaneSource->Update();
00087
00088 m_Plane->DeepCopy( m_PlaneSource->GetOutput() );
00089 m_Plane->GetPointData()->SetVectors( m_PlaneNormal );
00090
00091 this->Modified();
00092 }
00093
00094
00095 void Plane::GetResolution( int &xR, int &yR ) const
00096 {
00097 m_PlaneSource->GetResolution( xR, yR );
00098 }
00099
00100
00101 bool Plane::IsInside( const Point3D & ) const
00102 {
00103
00104 return false;
00105 }
00106
00107
00108 ScalarType Plane::GetVolume()
00109 {
00110
00111 return 0.0;
00112 }
00113
00114 }