Medical Imaging Interaction Toolkit  2018.4.99-08619e4f
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 (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 "mitkCylinder.h"
14 #include "mitkNumericTypes.h"
15 #include "vtkCylinderSource.h"
16 #include "vtkLinearTransform.h"
17 
19 {
20  vtkCylinderSource *cylinder = vtkCylinderSource::New();
21  cylinder->SetRadius(1.0);
22  cylinder->SetHeight(2.0);
23  cylinder->SetCenter(0.0, 0.0, 0.0);
24  cylinder->SetResolution(100);
25  cylinder->CappingOn();
26  cylinder->Update();
27  SetVtkPolyData(cylinder->GetOutput());
28  cylinder->Delete();
29 }
30 
32 {
33 }
34 
35 bool mitk::Cylinder::IsInside(const Point3D &worldPoint) const
36 {
37  // transform point from world to object coordinates
38  ScalarType p[4];
39  p[0] = worldPoint[0];
40  p[1] = worldPoint[1];
41  p[2] = worldPoint[2];
42  p[3] = 1;
43 
44  GetGeometry()->GetVtkTransform()->GetInverse()->TransformPoint(p, p);
45 
46  mitk::ScalarType v = pow(p[0], 2) + pow(p[2], 2);
47  bool retval = (v <= 1) && (p[1] >= -1) && (p[1] <= 1);
48  return retval;
49 }
50 
52 {
53  TimeGeometry *geometry = GetTimeGeometry();
54  return geometry->GetExtentInWorld(0) * 0.5 * geometry->GetExtentInWorld(2) * 0.5 * vnl_math::pi *
55  geometry->GetExtentInWorld(1);
56 }
bool IsInside(const Point3D &p) const override
double ScalarType
vtkLinearTransform * GetVtkTransform() const
Get the m_IndexToWorldTransform as a vtkLinearTransform.
~Cylinder() override
superclass of all bounding objects (cylinder, cuboid,...)
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
Definition: mitkBaseData.h:66
virtual void SetVtkPolyData(vtkPolyData *polydata, unsigned int t=0)
mitk::ScalarType GetVolume() override
ScalarType GetExtentInWorld(unsigned int direction) const
Returns the Extend of the bounding in the given direction.
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
Definition: mitkBaseData.h:143