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 "mitkCuboid.h"
00020 #include "vtkLinearTransform.h"
00021 #include "mitkVector.h"
00022 #include "vtkCubeSource.h"
00023
00024 #include <vtkSTLReader.h>
00025
00026 mitk::Cuboid::Cuboid()
00027 : BoundingObject()
00028 {
00029 vtkCubeSource* cube = vtkCubeSource::New();
00030 cube->SetXLength(2.0);
00031 cube->SetYLength(2.0);
00032 cube->SetZLength(2.0);
00033 cube->Update();
00034 SetVtkPolyData(cube->GetOutput());
00035 cube->Delete();
00036 }
00037
00038 mitk::Cuboid::~Cuboid()
00039 {
00040
00041 }
00042
00043 bool mitk::Cuboid::IsInside(const Point3D& worldPoint) const
00044 {
00045
00046 ScalarType p[4];
00047 p[0] = worldPoint[0];
00048 p[1] = worldPoint[1];
00049 p[2] = worldPoint[2];
00050 p[3] = 1;
00051
00052 GetGeometry()->GetVtkTransform()->GetInverse()->TransformPoint(p, p);
00053
00054 return (p[0] >= -1) && (p[0] <= 1)
00055 && (p[1] >= -1) && (p[1] <= 1)
00056 && (p[2] >= -1) && (p[2] <= 1);
00057 }
00058
00059 mitk::ScalarType mitk::Cuboid::GetVolume()
00060 {
00061 Geometry3D* geometry = GetTimeSlicedGeometry();
00062 return geometry->GetExtentInMM(0)
00063 * geometry->GetExtentInMM(1)
00064 * geometry->GetExtentInMM(2);
00065 }