Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
mitkEllipsoid.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 "mitkEllipsoid.h"
18 #include "mitkNumericTypes.h"
19 #include "vtkLinearTransform.h"
20 #include "vtkSphereSource.h"
21 
23 {
24  vtkSphereSource *sphere = vtkSphereSource::New();
25  sphere->SetRadius(1.0);
26  sphere->SetThetaResolution(20);
27  sphere->SetPhiResolution(20);
28  sphere->Update();
29  SetVtkPolyData(sphere->GetOutput());
30  sphere->Delete();
31 }
32 
34 {
35 }
36 
37 bool mitk::Ellipsoid::IsInside(const Point3D &worldPoint) const
38 {
39  // transform point from world to object coordinates
40  ScalarType p[4];
41  p[0] = worldPoint[0];
42  p[1] = worldPoint[1];
43  p[2] = worldPoint[2];
44  p[3] = 1;
45 
46  GetGeometry()->GetVtkTransform()->GetInverse()->TransformPoint(p, p);
47 
48  return (pow(p[0], 2) + pow(p[1], 2) + pow(p[2], 2) <= 1);
49 }
50 
52 {
53  return GetGeometry()->GetExtentInMM(0) * 0.5 * GetGeometry()->GetExtentInMM(1) * 0.5 *
54  GetGeometry()->GetExtentInMM(2) * 0.5 * vnl_math::pi * 4.0 / 3.0;
55 }
double ScalarType
virtual ~Ellipsoid()
virtual bool IsInside(const Point3D &p) const override
superclass of all bounding objects (cylinder, cuboid,...)
virtual mitk::ScalarType GetVolume() override
virtual void SetVtkPolyData(vtkPolyData *polydata, unsigned int t=0)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.