13 #ifndef mitkBaseGeometry_h
14 #define mitkBaseGeometry_h
20 #include "itkScalableAffineTransform.h"
22 #include <itkBoundingBox.h>
24 #include <itkQuaternionRigidTransform.h>
28 #include <vtkTransform.h>
31 class vtkMatrixToLinearTransform;
32 class vtkLinearTransform;
40 typedef itk::BoundingBox<unsigned long, 3, ScalarType>
BoundingBox;
140 itkGetConstMacro(FrameOfReferenceID,
unsigned int);
144 itkSetMacro(FrameOfReferenceID,
unsigned int);
146 itkGetConstMacro(IndexToWorldTransformLastModified,
unsigned long);
237 void Compose(
const vtkMatrix4x4 *vtkmatrix,
bool pre =
false);
265 template <
unsigned int VIndexDimension>
268 typedef itk::Index<VIndexDimension> IndexType;
270 this->WorldToIndex(pt_mm, pt_units);
271 int i, dim = index.GetIndexDimension();
277 for (i = 0; i < dim; ++i)
279 index[i] = itk::Math::RoundHalfIntegerUp<typename IndexType::IndexValueType>(pt_units[i]);
297 template <
unsigned int VIndexDimension>
302 int i, dim = index.GetIndexDimension();
307 for (i = 0; i < dim; ++i)
309 pt_units[i] = index[i];
312 IndexToWorld(pt_units, pt_mm);
337 template <
class TCoordRep>
359 template <
class TCoordRep>
419 ScalarType GetExtent(
unsigned int direction)
const;
491 template <
unsigned int VIndexDimension>
494 int i, dim = index.GetIndexDimension();
497 for (i = 0; i < dim; ++i)
499 pt_index[i] = index[i];
501 return IsIndexInside(pt_index);
529 itkGetConstMacro(ImageGeometry,
bool)
543 itkSetMacro(ImageGeometry,
bool);
544 itkBooleanMacro(ImageGeometry);
557 void MapAxesToOrientations(
int axes[]) const;
565 itk::LightObject::Pointer InternalClone() const override = 0;
567 void PrintSelf(std::ostream &os,
itk::Indent indent) const override;
569 static const std::
string GetTransformAsString(
TransformType *transformType);
571 itkGetConstMacro(NDimensions,
unsigned int);
573 bool IsBoundingBoxNull() const;
575 bool IsIndexToWorldTransformNull() const;
577 void SetVtkMatrixDeepCopy(vtkTransform *vtktransform);
579 void _SetSpacing(const
mitk::
Vector3D &aSpacing,
bool enforceSetSpacing = false);
610 void InitializeGeometryTransformHolder(
const BaseGeometry *otherGeometry);
615 BoundingBoxPointer m_BoundingBox;
617 unsigned int m_FrameOfReferenceID;
621 static const unsigned int m_NDimensions = 3;
623 mutable TransformType::Pointer m_InvertedTransform;
625 mutable unsigned long m_IndexToWorldTransformLastModified;
627 bool m_ImageGeometry;
634 bool m_ModifiedLockFlag;
641 mutable bool m_ModifiedCalledFlag;
671 bool verbose =
false);
690 bool verbose =
false);
755 bool verbose =
false);
773 bool verbose =
false);
BaseGeometry Describes the geometry of a data object.
VnlVector GetMatrixColumn(unsigned int direction) const
Get a VnlVector along bounding-box in the specified direction, length is spacing.
mitk::BoundingBox::Pointer CalculateBoundingBoxRelativeToTransform(const mitk::AffineTransform3D *transform) const
Calculates a bounding-box around the geometry relative to a coordinate system defined by a transform.
void SetFloatBounds(const double bounds[6])
Set the bounding box (in index/unit coordinates) via a double array.
bool IsIndexInside(const itk::Index< VIndexDimension > &index) const
Convenience method for working with ITK indices.
virtual bool IsValid() const
Is this BaseGeometry in a state that is valid?
void IndexToWorld(const mitk::Point3D &pt_units, mitk::Point3D &pt_mm) const
Convert (continuous or discrete) index coordinates of a point to world coordinates (in mm) For furthe...
void Compose(const TransformType *other, bool pre=false)
Compose new IndexToWorldTransform with a given transform.
mitk::Vector3D GetSpacing() const
Get the spacing (size of a pixel).
vtkMatrix4x4 * GetVtkMatrix()
bool IsIndexInside(const mitk::Point3D &index) const
Test whether the point p ((continuous!)index coordinates in units) is inside the bounding box.
void ExecuteOperation(Operation *operation) override
executes affine operations (translate, rotate, scale)
void WorldToIndex(const mitk::Point3D &pt_mm, itk::Index< VIndexDimension > &index) const
Convert world coordinates (in mm) of a point to (discrete!) index coordinates. This method rounds to ...
const mitk::AffineTransform3D * GetIndexToWorldTransform() const
Get the transformation used to convert from index to world coordinates.
bool IsInside(const mitk::Point3D &p) const
Test whether the point p (world coordinates in mm) is inside the bounding box.
VnlVector GetOriginVnl() const
Get the origin as VnlVector.
void InitializeGeometry(Self *newGeometry) const
BoundingBoxType::Pointer BoundingBoxPointer
Point3D GetOrigin() const
Get the origin, e.g. the upper-left corner of the plane.
virtual void CheckBounds(const BoundsArrayType &)
CheckBounds.
void ItkPhysicalPointToWorld(const itk::Point< TCoordRep, 3 > &itkPhysicalPoint, mitk::Point3D &pt_mm) const
Deprecated for use with ITK version 3.10 or newer. Convert ITK physical coordinates of a point (in mm...
void Translate(const Vector3D &vector)
Translate the origin by a vector.
virtual bool Is2DConvertable()
Checks, if the given geometry can be converted to 2D without information loss e.g....
mitkClassMacroItkParent(BaseGeometry, itk::Object)
void SetIdentity()
Set the transform to identity, the spacing to 1 and origin to 0.
void SetIndexToWorldTransform(mitk::AffineTransform3D *transform)
void SetIndexToWorldTransformByVtkMatrix(vtkMatrix4x4 *vtkmatrix)
Convenience method for setting the ITK transform (m_IndexToWorldTransform) via an vtkMatrix4x4....
void IndexToWorld(const itk::Index< VIndexDimension > &index, mitk::Point3D &pt_mm) const
Convert (discrete) index coordinates of a point to world coordinates (in mm) For further information ...
void WorldToIndex(const mitk::Vector3D &vec_mm, mitk::Vector3D &vec_units) const
Convert world coordinates (in mm) of a vector vec_mm to (continuous!) index coordinates....
itk::BoundingBox< unsigned long, 3, ScalarType > BoundingBoxType
BoundingBoxType::BoundsArrayType BoundsArrayType
void WorldToIndex(const mitk::Point3D &pt_mm, mitk::Point3D &pt_units) const
Convert world coordinates (in mm) of a point to (continuous!) index coordinates.
void SetSpacing(const mitk::Vector3D &aSpacing, bool enforceSetSpacing=false)
Set the spacing (m_Spacing).
const BoundsArrayType GetBounds() const
virtual void ChangeImageGeometryConsideringOriginOffset(const bool isAnImageGeometry)
When switching from an Image Geometry to a normal Geometry (and the other way around),...
void Compose(const vtkMatrix4x4 *vtkmatrix, bool pre=false)
Compose new IndexToWorldTransform with a given vtkMatrix4x4.
void SetIndexToWorldTransformWithoutChangingSpacing(mitk::AffineTransform3D *transform)
vtkLinearTransform * GetVtkTransform() const
Get the m_IndexToWorldTransform as a vtkLinearTransform.
void IndexToWorld(const mitk::Point3D &atPt3d_units, const mitk::Vector3D &vec_units, mitk::Vector3D &vec_mm) const
Convert (continuous or discrete) index coordinates of a vector vec_units to world coordinates (in mm)
double GetDiagonalLength2() const
Get the squared length of the diagonal of the bounding-box in mm.
void SetExtentInMM(int direction, ScalarType extentInMM)
Set the extent of the bounding-box in the specified direction in mm.
double GetDiagonalLength() const
Get the length of the diagonal of the bounding-box in mm.
void SetBounds(const BoundsArrayType &bounds)
Set the bounding box (in index/unit coordinates)
void SetIndexToWorldTransformByVtkMatrixWithoutChangingSpacing(vtkMatrix4x4 *vtkmatrix)
Convenience method for setting the ITK transform (m_IndexToWorldTransform) via an vtkMatrix4x4....
void WorldToIndex(const mitk::Point3D &atPt3d_mm, const mitk::Vector3D &vec_mm, mitk::Vector3D &vec_units) const
Convert world coordinates (in mm) of a vector vec_mm to (continuous!) index coordinates.
ScalarType GetExtentInMM(int direction) const
Get the extent of the bounding-box in the specified direction in mm.
mitk::AffineTransform3D * GetIndexToWorldTransform()
Get the transformation used to convert from index to world coordinates.
void WorldToItkPhysicalPoint(const mitk::Point3D &pt_mm, itk::Point< TCoordRep, 3 > &itkPhysicalPoint) const
Deprecated for use with ITK version 3.10 or newer. Convert world coordinates (in mm) of a point to IT...
Point3D GetCornerPoint(int id) const
Get the position of the corner number id (in world coordinates)
void Initialize()
Initialize the BaseGeometry.
Point3D ClampPoint(const Point3D &point) const
Clamps a point to lie within the geometry's bounds.
ScalarType GetExtent(unsigned int direction) const
Set the time bounds (in ms)
void SetFloatBounds(const float bounds[6])
Set the bounding box (in index/unit coordinates) via a float array.
const vtkMatrix4x4 * GetVtkMatrix() const
Point3D GetCenter() const
Get the center of the bounding-box in mm.
void SetOrigin(const Point3D &origin)
Set the origin, i.e. the upper-left corner of the plane.
virtual void CheckIndexToWorldTransform(mitk::AffineTransform3D *)
CheckIndexToWorldTransform.
GeometryTransformHolder::TransformType TransformType
Point3D GetCornerPoint(bool xFront=true, bool yFront=true, bool zFront=true) const
Get the position of a corner (in world coordinates)
void Modified() const override
Overload of function Modified() to prohibit several calls of Modified() using the ModifiedLock class.
void IndexToWorld(const mitk::Vector3D &vec_units, mitk::Vector3D &vec_mm) const
Convert (continuous or discrete) index coordinates of a vector vec_units to world coordinates (in mm)...
Vector3D GetAxisVector(unsigned int direction) const
Get vector along bounding-box in the specified direction in mm.
ModifiedLock manages the calls of Modified() functions.
abstract class, that can be used by Undo to undo an operation.
Base class of all Operation-classes.
Find image slices visible on a given plane.
itk::FixedArray< ScalarType, 3 > FixedArrayType
MITKCORE_EXPORT const ScalarType eps
itk::BoundingBox< unsigned long, 3, ScalarType > BoundingBox
Standard 3D-BoundingBox typedef.
MITKCORE_EXPORT bool IsSubGeometry(const mitk::BaseGeometry &testGeo, const mitk::BaseGeometry &referenceGeo, ScalarType coordinateEps, ScalarType directionEps, bool verbose=false)
A function checks if a test geometry is a sub geometry of a given reference geometry.
itk::ScalableAffineTransform< ScalarType, 3 > AffineTransform3D
itk::FixedArray< ScalarType, 2 > TimeBounds
Standard typedef for time-bounds.
vnl_vector< ScalarType > VnlVector
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
void vtk2itk(const Tin &in, Tout &out)