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 "mitkEllipsoid.h"
00020 #include "vtkLinearTransform.h"
00021 #include "mitkVector.h"
00022 #include "vtkSphereSource.h"
00023
00024
00025 mitk::Ellipsoid::Ellipsoid()
00026 : BoundingObject()
00027 {
00028 vtkSphereSource* sphere = vtkSphereSource::New();
00029 sphere->SetRadius(1.0);
00030 sphere->SetThetaResolution(20);
00031 sphere->SetPhiResolution(20);
00032 sphere->Update();
00033 SetVtkPolyData(sphere->GetOutput());
00034 sphere->Delete();
00035 }
00036
00037
00038
00039 mitk::Ellipsoid::~Ellipsoid()
00040 {
00041 }
00042
00043
00044 bool mitk::Ellipsoid::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 return (pow(p[0], 2) + pow(p[1], 2) + pow(p[2], 2) <= 1);
00056 }
00057
00058
00059 mitk::ScalarType mitk::Ellipsoid::GetVolume()
00060 {
00061 return GetGeometry()->GetExtentInMM(0) * 0.5
00062 * GetGeometry()->GetExtentInMM(1) * 0.5
00063 * GetGeometry()->GetExtentInMM(2) * 0.5
00064 * vnl_math::pi * 4.0/3.0;
00065 }