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;
42 typedef itk::BoundingBox<unsigned long, 3, ScalarType>
BoundingBox;
161 itkGetConstMacro(FrameOfReferenceID,
unsigned int);
166 itkSetMacro(FrameOfReferenceID,
unsigned int);
172 itkGetConstMacro(IndexToWorldTransformLastModified,
unsigned long);
328 void Compose(
const vtkMatrix4x4 *vtkmatrix,
bool pre =
false);
381 template <
unsigned int VIndexDimension>
384 typedef itk::Index<VIndexDimension> IndexType;
386 this->WorldToIndex(pt_mm, pt_units);
387 int i, dim = index.GetIndexDimension();
393 for (i = 0; i < dim; ++i)
395 index[i] = itk::Math::RoundHalfIntegerUp<typename IndexType::IndexValueType>(pt_units[i]);
422 template <
unsigned int VIndexDimension>
427 int i, dim = index.GetIndexDimension();
432 for (i = 0; i < dim; ++i)
434 pt_units[i] = index[i];
437 IndexToWorld(pt_units, pt_mm);
452 template <
class TCoordRep>
472 template <
class TCoordRep>
571 ScalarType GetExtent(
unsigned int direction)
const;
712 template <
unsigned int VIndexDimension>
715 int i, dim = index.GetIndexDimension();
718 for (i = 0; i < dim; ++i)
720 pt_index[i] = index[i];
722 return IsIndexInside(pt_index);
758 itkGetConstMacro(ImageGeometry,
bool)
771 itkSetMacro(ImageGeometry,
bool);
776 itkBooleanMacro(ImageGeometry);
797 void MapAxesToOrientations(
int axes[]) const;
805 void PrintSelf(std::ostream &os,
itk::Indent indent) const override;
807 static const std::
string GetTransformAsString(
TransformType *transformType);
809 itkGetConstMacro(NDimensions,
unsigned int);
811 bool IsBoundingBoxNull() const;
813 bool IsIndexToWorldTransformNull() const;
815 void SetVtkMatrixDeepCopy(vtkTransform *vtktransform);
817 void _SetSpacing(const
mitk::
Vector3D &aSpacing,
bool enforceSetSpacing = false);
848 void InitializeGeometryTransformHolder(
const BaseGeometry *otherGeometry);
853 BoundingBoxPointer m_BoundingBox;
855 unsigned int m_FrameOfReferenceID;
859 static const unsigned int m_NDimensions = 3;
861 mutable TransformType::Pointer m_InvertedTransform;
863 mutable unsigned long m_IndexToWorldTransformLastModified;
865 bool m_ImageGeometry;
872 bool m_ModifiedLockFlag;
879 mutable bool m_ModifiedCalledFlag;
909 bool verbose =
false);
928 bool verbose =
false);
993 bool verbose =
false);
1011 bool verbose =
false);
Abstract base class describing the geometry of a data object.
VnlVector GetMatrixColumn(unsigned int direction) const
Get a column of the IndexToWorldTransform matrix as a VnlVector.
mitk::BoundingBox::Pointer CalculateBoundingBoxRelativeToTransform(const mitk::AffineTransform3D *transform) const
Calculate a bounding box relative to a given transform.
void SetFloatBounds(const double bounds[6])
Set the bounding box via a double array.
bool IsIndexInside(const itk::Index< VIndexDimension > &index) const
Test whether a discrete ITK index lies inside the bounding box.
virtual bool IsValid() const
Check whether this geometry is in a valid state.
void IndexToWorld(const mitk::Point3D &pt_units, mitk::Point3D &pt_mm) const
Convert continuous or discrete index coordinates of a point to world coordinates (mm).
void Compose(const TransformType *other, bool pre=false)
Compose the IndexToWorldTransform with another transform.
mitk::Vector3D GetSpacing() const
Get the spacing (voxel size) in mm per unit for each axis.
vtkMatrix4x4 * GetVtkMatrix()
Get the IndexToWorldTransform as a 4x4 VTK matrix.
bool IsIndexInside(const mitk::Point3D &index) const
Test whether a point in continuous index coordinates lies inside the bounding box.
void ExecuteOperation(Operation *operation) override
Execute an affine operation (translate, rotate, scale) on this geometry.
void WorldToIndex(const mitk::Point3D &pt_mm, itk::Index< VIndexDimension > &index) const
Convert world coordinates (mm) of a point to discrete (integer) index coordinates.
const mitk::AffineTransform3D * GetIndexToWorldTransform() const
Get the affine transform that maps index coordinates to world coordinates (const).
bool IsInside(const mitk::Point3D &p) const
Test whether a point (world coordinates, mm) lies inside the bounding box.
VnlVector GetOriginVnl() const
Get the origin as a VNL vector.
void InitializeGeometry(Self *newGeometry) const
Copy the essential geometry properties into another instance.
BoundingBoxType::Pointer BoundingBoxPointer
Smart-pointer type for BoundingBoxType.
Point3D GetOrigin() const
Get the origin of the geometry in world coordinates (mm).
virtual void CheckBounds(const BoundsArrayType &)
CheckBounds.
void ItkPhysicalPointToWorld(const itk::Point< TCoordRep, 3 > &itkPhysicalPoint, mitk::Point3D &pt_mm) const
Convert an ITK physical point to MITK world coordinates.
void Translate(const Vector3D &vector)
Translate the origin by a given vector.
virtual bool Is2DConvertable()
Check if this geometry can be converted to 2D without information loss.
mitkClassMacroItkParent(BaseGeometry, itk::Object)
void SetIdentity()
Reset the geometry to identity.
void SetIndexToWorldTransform(mitk::AffineTransform3D *transform)
Set the affine transform for index-to-world coordinate mapping.
void SetIndexToWorldTransformByVtkMatrix(vtkMatrix4x4 *vtkmatrix)
Set the IndexToWorldTransform via a vtkMatrix4x4.
void IndexToWorld(const itk::Index< VIndexDimension > &index, mitk::Point3D &pt_mm) const
Convert discrete (itk::Index) index coordinates of a point to world coordinates (mm).
void WorldToIndex(const mitk::Vector3D &vec_mm, mitk::Vector3D &vec_units) const
Convert world coordinates (mm) of a vector to continuous index coordinates.
itk::BoundingBox< unsigned long, 3, ScalarType > BoundingBoxType
3D bounding box type parameterized with ScalarType.
BoundingBoxType::BoundsArrayType BoundsArrayType
Fixed-size array of six ScalarType values representing axis-aligned bounds [xmin,xmax,...
void WorldToIndex(const mitk::Point3D &pt_mm, mitk::Point3D &pt_units) const
Convert world coordinates (mm) of a point to continuous index coordinates.
void SetSpacing(const mitk::Vector3D &aSpacing, bool enforceSetSpacing=false)
Set the spacing (voxel size) for each axis.
const BoundsArrayType GetBounds() const
Get the bounding box bounds as a BoundsArrayType in index/unit coordinates.
virtual void ChangeImageGeometryConsideringOriginOffset(const bool isAnImageGeometry)
Switch between image geometry and normal geometry with origin correction.
void Compose(const vtkMatrix4x4 *vtkmatrix, bool pre=false)
Compose the IndexToWorldTransform with a vtkMatrix4x4.
void SetIndexToWorldTransformWithoutChangingSpacing(mitk::AffineTransform3D *transform)
Set the IndexToWorldTransform while preserving the current spacing.
vtkLinearTransform * GetVtkTransform() const
Get the IndexToWorldTransform as a vtkLinearTransform.
double GetDiagonalLength2() const
Get the squared length of the bounding-box diagonal in mm.
void SetExtentInMM(int direction, ScalarType extentInMM)
Set the extent of the bounding box in mm along the specified direction.
double GetDiagonalLength() const
Get the length of the bounding-box diagonal in mm.
void SetBounds(const BoundsArrayType &bounds)
Set the bounding box in index/unit coordinates.
void SetIndexToWorldTransformByVtkMatrixWithoutChangingSpacing(vtkMatrix4x4 *vtkmatrix)
Set the IndexToWorldTransform via a vtkMatrix4x4 while preserving spacing.
ScalarType GetExtentInMM(int direction) const
Get the extent of the bounding box in mm along the specified direction.
mitk::AffineTransform3D * GetIndexToWorldTransform()
Get the affine transform that maps index coordinates to world coordinates.
void WorldToItkPhysicalPoint(const mitk::Point3D &pt_mm, itk::Point< TCoordRep, 3 > &itkPhysicalPoint) const
Convert MITK world coordinates to ITK physical coordinates.
Point3D GetCornerPoint(int id) const
Get the position of corner number id in world coordinates.
void Initialize()
Initialize the geometry to default values.
Point3D ClampPoint(const Point3D &point) const
Clamp a point to lie within the geometry's world-coordinate bounds.
ScalarType GetExtent(unsigned int direction) const
Set the time bounds (in ms)
void SetFloatBounds(const float bounds[6])
Set the bounding box via a float array.
const vtkMatrix4x4 * GetVtkMatrix() const
Get the IndexToWorldTransform as a 4x4 VTK matrix (const).
Point3D GetCenter() const
Get the center of the bounding box in world coordinates (mm).
void SetOrigin(const Point3D &origin)
Set the origin of the geometry in world coordinates (mm).
virtual void CheckIndexToWorldTransform(mitk::AffineTransform3D *)
CheckIndexToWorldTransform.
GeometryTransformHolder::TransformType TransformType
Affine transform type used for index-to-world mapping.
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
Overloaded Modified() to support the ModifiedLock mechanism.
void IndexToWorld(const mitk::Vector3D &vec_units, mitk::Vector3D &vec_mm) const
Convert index coordinates of a vector to world coordinates (mm).
Vector3D GetAxisVector(unsigned int direction) const
Get a vector along the bounding box in the specified direction in mm.
RAII guard that defers BaseGeometry::Modified() calls until destruction.
abstract class, that can be used by Undo to undo an operation.
Base class for all operations in the undo/redo framework.
Convenience header that includes all MITK numeric types.
Find image slices visible on a given plane.
itk::FixedArray< ScalarType, 3 > FixedArrayType
Fixed-size array of three ScalarType values (e.g., for spacing or axis components).
MITKCORE_EXPORT const ScalarType eps
Epsilon value for floating point comparison (vnl_math::eps * 100).
void FillArray(itk::FixedArray< TCoordRep, NVectorDimension > &toArray, const ArrayType &array)
Methods to copy between itk::FixedArray types (like mitk::Vector and mitk::Point) and ArrayTypes.
itk::BoundingBox< unsigned long, 3, ScalarType > BoundingBox
Standard 3D bounding box type.
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
3D affine transform type used throughout MITK.
itk::FixedArray< ScalarType, 2 > TimeBounds
Fixed-size array holding a pair of time bound values [min, max] in milliseconds.
vnl_vector< ScalarType > VnlVector
double ScalarType
Scalar type used throughout MITK for geometric computations.
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.