Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkCylinder.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 "mitkCylinder.h"
18 #include "mitkNumericTypes.h"
19 #include "vtkCylinderSource.h"
20 #include "vtkLinearTransform.h"
21 
23 {
24  vtkCylinderSource *cylinder = vtkCylinderSource::New();
25  cylinder->SetRadius(1.0);
26  cylinder->SetHeight(2.0);
27  cylinder->SetCenter(0.0, 0.0, 0.0);
28  cylinder->SetResolution(100);
29  cylinder->CappingOn();
30  cylinder->Update();
31  SetVtkPolyData(cylinder->GetOutput());
32  cylinder->Delete();
33 }
34 
36 {
37 }
38 
39 bool mitk::Cylinder::IsInside(const Point3D &worldPoint) const
40 {
41  // transform point from world to object coordinates
42  ScalarType p[4];
43  p[0] = worldPoint[0];
44  p[1] = worldPoint[1];
45  p[2] = worldPoint[2];
46  p[3] = 1;
47 
48  GetGeometry()->GetVtkTransform()->GetInverse()->TransformPoint(p, p);
49 
50  mitk::ScalarType v = pow(p[0], 2) + pow(p[2], 2);
51  bool retval = (v <= 1) && (p[1] >= -1) && (p[1] <= 1);
52  return retval;
53 }
54 
56 {
57  TimeGeometry *geometry = GetTimeGeometry();
58  return geometry->GetExtentInWorld(0) * 0.5 * geometry->GetExtentInWorld(2) * 0.5 * vnl_math::pi *
59  geometry->GetExtentInWorld(1);
60 }
virtual bool IsInside(const Point3D &p) const override
double ScalarType
superclass of all bounding objects (cylinder, cuboid,...)
virtual void SetVtkPolyData(vtkPolyData *polydata, unsigned int t=0)
virtual mitk::ScalarType GetVolume() override
ScalarType GetExtentInWorld(unsigned int direction) const
Returns the Extend of the bounding in the given direction.
virtual ~Cylinder()
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.