Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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,
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 "mitkCuboid.h"
18 #include "mitkNumericTypes.h"
19 #include "vtkCubeSource.h"
20 #include "vtkLinearTransform.h"
21 
22 #include <vtkSTLReader.h>
23 
25 {
26  vtkCubeSource *cube = vtkCubeSource::New();
27  cube->SetXLength(2.0);
28  cube->SetYLength(2.0);
29  cube->SetZLength(2.0);
30  cube->Update();
31  SetVtkPolyData(cube->GetOutput());
32  cube->Delete();
33 }
34 
36 {
37 }
38 
39 bool mitk::Cuboid::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  return (p[0] >= -1) && (p[0] <= 1) && (p[1] >= -1) && (p[1] <= 1) && (p[2] >= -1) && (p[2] <= 1);
51 }
52 
54 {
55  TimeGeometry *geometry = GetTimeGeometry();
56  return geometry->GetExtentInWorld(0) * geometry->GetExtentInWorld(1) * geometry->GetExtentInWorld(2);
57 }
virtual mitk::ScalarType GetVolume() override
Definition: mitkCuboid.cpp:53
double ScalarType
virtual ~Cuboid()
Definition: mitkCuboid.cpp:35
superclass of all bounding objects (cylinder, cuboid,...)
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.
virtual bool IsInside(const Point3D &p) const override
Definition: mitkCuboid.cpp:39
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.