Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkCone.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 "mitkCone.h"
18 #include "mitkNumericTypes.h"
19 #include "vtkConeSource.h"
20 #include "vtkLinearTransform.h"
21 
23 {
24  // Set up Cone Surface. Radius 1.0, height 2.0, , centered around the origin
25  vtkConeSource *cone = vtkConeSource::New();
26  cone->SetRadius(1.0);
27  cone->SetHeight(2.0);
28  cone->SetDirection(0.0, -1.0, 0.0);
29  cone->SetCenter(0.0, 0.0, 0.0);
30  cone->SetResolution(20);
31  cone->CappingOn();
32  cone->Update();
33  SetVtkPolyData(cone->GetOutput());
34  cone->Delete();
35 }
36 
38 {
39 }
40 
41 bool mitk::Cone::IsInside(const Point3D &worldPoint) const
42 {
43  // transform point from world to object coordinates
44  ScalarType p[4];
45  p[0] = worldPoint[0];
46  p[1] = worldPoint[1];
47  p[2] = worldPoint[2];
48  p[3] = 1;
49 
50  GetGeometry()->GetVtkTransform()->GetInverse()->TransformPoint(p, p);
51 
52  p[1] += 1; // translate point, so that it fits to the formula below, which describes a cone that has its cone vertex
53  // at the origin
54  return (sqrt(p[0] * p[0] + p[2] * p[2]) <= p[1] * 0.5) && (p[1] <= 2); // formula to calculate if a given point is
55  // inside a cone that has its cone vertex at
56  // the origin, is aligned on the second axis,
57  // has a radius of one an a height of two
58 }
59 
61 {
62  TimeGeometry *geometry = GetTimeGeometry();
63  return geometry->GetExtentInWorld(0) * 0.5 * geometry->GetExtentInWorld(2) * 0.5 * vnl_math::pi / 3.0 *
64  geometry->GetExtentInWorld(1);
65 }
virtual ~Cone()
Definition: mitkCone.cpp:37
double ScalarType
virtual mitk::ScalarType GetVolume() override
Definition: mitkCone.cpp:60
superclass of all bounding objects (cylinder, cuboid,...)
virtual void SetVtkPolyData(vtkPolyData *polydata, unsigned int t=0)
virtual bool IsInside(const Point3D &p) const override
Definition: mitkCone.cpp:41
ScalarType GetExtentInWorld(unsigned int direction) const
Returns the Extend of the bounding in the given direction.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.