Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkCuboid.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 "mitkCuboid.h"
14 #include "mitkNumericTypes.h"
15 #include "vtkCubeSource.h"
16 #include "vtkLinearTransform.h"
17 
18 #include <vtkSTLReader.h>
19 
21 {
22  vtkCubeSource *cube = vtkCubeSource::New();
23  cube->SetXLength(2.0);
24  cube->SetYLength(2.0);
25  cube->SetZLength(2.0);
26  cube->Update();
27  SetVtkPolyData(cube->GetOutput());
28  cube->Delete();
29 }
30 
32 {
33 }
34 
35 bool mitk::Cuboid::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  return (p[0] >= -1) && (p[0] <= 1) && (p[1] >= -1) && (p[1] <= 1) && (p[2] >= -1) && (p[2] <= 1);
47 }
48 
50 {
51  TimeGeometry *geometry = GetTimeGeometry();
52  return geometry->GetExtentInWorld(0) * geometry->GetExtentInWorld(1) * geometry->GetExtentInWorld(2);
53 }
mitk::ScalarType GetVolume() override
Definition: mitkCuboid.cpp:49
double ScalarType
vtkLinearTransform * GetVtkTransform() const
Get the m_IndexToWorldTransform as a vtkLinearTransform.
superclass of all bounding objects (cylinder, cuboid,...)
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
Definition: mitkBaseData.h:61
~Cuboid() override
Definition: mitkCuboid.cpp:31
virtual void SetVtkPolyData(vtkPolyData *polydata, unsigned int t=0)
ScalarType GetExtentInWorld(unsigned int direction) const
Returns the Extend of the bounding in the given direction.
bool IsInside(const Point3D &p) const override
Definition: mitkCuboid.cpp:35
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