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 "mitkCone.h"
00020 #include "vtkLinearTransform.h"
00021 #include "mitkVector.h"
00022 #include "vtkConeSource.h"
00023
00024 mitk::Cone::Cone()
00025 : BoundingObject()
00026 {
00027
00028 vtkConeSource* cone = vtkConeSource::New();
00029 cone->SetRadius(1.0);
00030 cone->SetHeight(2.0);
00031 cone->SetDirection(0.0, -1.0, 0.0);
00032 cone->SetCenter(0.0, 0.0, 0.0);
00033 cone->SetResolution(20);
00034 cone->CappingOn();
00035 cone->Update();
00036 SetVtkPolyData(cone->GetOutput());
00037 cone->Delete();
00038 }
00039
00040 mitk::Cone::~Cone()
00041 {
00042 }
00043
00044 bool mitk::Cone::IsInside(const Point3D& worldPoint) const
00045 {
00046
00047 ScalarType p[4];
00048 p[0] = worldPoint[0];
00049 p[1] = worldPoint[1];
00050 p[2] = worldPoint[2];
00051 p[3] = 1;
00052
00053 GetGeometry()->GetVtkTransform()->GetInverse()->TransformPoint(p, p);
00054
00055 p[1] += 1;
00056 return (sqrt(p[0] * p[0] + p[2] * p[2]) <= p[1] * 0.5) && (p[1] <= 2);
00057 }
00058
00059 mitk::ScalarType mitk::Cone::GetVolume()
00060 {
00061 Geometry3D* geometry = GetTimeSlicedGeometry();
00062 return geometry->GetExtentInMM(0) * 0.5
00063 * geometry->GetExtentInMM(2) * 0.5
00064 * vnl_math::pi / 3.0
00065 * geometry->GetExtentInMM(1);
00066 }