Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "mitkEllipsoid.h"
14 #include "mitkNumericTypes.h"
15 #include "vtkLinearTransform.h"
16 #include <vtkSphereSource.h>
17 
19 {
20  auto sphere = vtkSmartPointer<vtkSphereSource>::New();
21  sphere->SetRadius(1.0);
22  sphere->SetThetaResolution(20);
23  sphere->SetPhiResolution(20);
24  sphere->Update();
25  SetVtkPolyData(sphere->GetOutput());
26 }
27 
29 {
30 }
31 
32 bool mitk::Ellipsoid::IsInside(const Point3D &worldPoint) const
33 {
34  // transform point from world to object coordinates
35  ScalarType p[4];
36  p[0] = worldPoint[0];
37  p[1] = worldPoint[1];
38  p[2] = worldPoint[2];
39  p[3] = 1;
40 
41  GetGeometry()->GetVtkTransform()->GetInverse()->TransformPoint(p, p);
42 
43  return (pow(p[0], 2) + pow(p[1], 2) + pow(p[2], 2) <= 1);
44 }
45 
47 {
48  return GetGeometry()->GetExtentInMM(0) * 0.5 * GetGeometry()->GetExtentInMM(1) * 0.5 *
49  GetGeometry()->GetExtentInMM(2) * 0.5 * vnl_math::pi * 4.0 / 3.0;
50 }
double ScalarType
vtkLinearTransform * GetVtkTransform() const
Get the m_IndexToWorldTransform as a vtkLinearTransform.
~Ellipsoid() override
bool IsInside(const Point3D &p) const override
ScalarType GetExtentInMM(int direction) const
Get the extent of the bounding-box in the specified direction in mm.
superclass of all bounding objects (cylinder, cuboid,...)
mitk::ScalarType GetVolume() override
virtual void SetVtkPolyData(vtkPolyData *polydata, unsigned int t=0)
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
Definition: mitkBaseData.h:138