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