Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkBoundingObject.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 "mitkBoundingObject.h"
18 #include "mitkBaseProcess.h"
19 
21 {
22  // Initialize(1);
23 
24  /* bounding box around the unscaled bounding object */
25  ScalarType bounds[6] = {-1, 1, -1, 1, -1, 1}; //{xmin,x_max, ymin,y_max,zmin,z_max}
26  GetGeometry()->SetBounds(bounds);
28 }
29 
31 {
32 }
33 
35 {
36  return 0.0;
37 }
38 
40 {
41  // Adjusted this function to fix
42  // BUG 6951 - Image Cropper - Bounding Box is strange
43  // Still, the behavior of the BoundingObject is really strange.
44  // One would think that writing "setGeometry(aGeometry3D)" here would do the job.
45  // But apparently the boundingObject can only be handled correctly, when it's
46  // indexBounds are from -1 to 1 in all axis (so it is only 2x2x2 Pixels big) and the spacing
47  // specifies it's actual bounds. This behavior needs to be analyzed and maybe changed.
48  // Check also BUG 11406
49 
50  GetGeometry()->SetIdentity();
51  GetGeometry()->Compose(aGeometry3D->GetIndexToWorldTransform());
52  GetGeometry()->SetOrigin(aGeometry3D->GetCenter());
53 
54  mitk::Vector3D size;
55  for (unsigned int i = 0; i < 3; ++i)
56  size[i] = (aGeometry3D->GetExtentInMM(i) / 2.0);
57  GetGeometry()->SetSpacing(size);
58  GetTimeGeometry()->Update();
59 }
Class for storing surfaces (vtkPolyData).
Definition: mitkSurface.h:32
double ScalarType
virtual mitk::ScalarType GetVolume()
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
Definition: mitkBaseData.h:52
Point3D GetCenter() const
Get the center of the bounding-box in mm.
virtual void FitGeometry(BaseGeometry *aGeometry3D)
Sets the Geometry3D of the bounding object to fit the given geometry.
void SetBounds(const BoundsArrayType &bounds)
Set the bounding box (in index/unit coordinates)
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
Definition: mitkBaseData.h:129
void Update()
Updates the geometry.
ScalarType GetExtentInMM(int direction) const
Get the extent of the bounding-box in the specified direction in mm.
BaseGeometry Describes the geometry of a data object.
mitk::AffineTransform3D * GetIndexToWorldTransform()
Get the transformation used to convert from index to world coordinates.