Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

mitk::Geometry2D Class Reference
[Geometry Classes]

Describes the geometry of a two-dimensional object. More...

#include <mitkGeometry2D.h>

Inheritance diagram for mitk::Geometry2D:
Inheritance graph
[legend]
Collaboration diagram for mitk::Geometry2D:
Collaboration graph
[legend]

List of all members.

Public Types

typedef Geometry2D Self
typedef mitk::Geometry3D Superclass
typedef itk::SmartPointer< SelfPointer
typedef itk::SmartPointer
< const Self
ConstPointer

Public Member Functions

virtual const char * GetClassName () const
 Method for creation through the object factory.
virtual bool Map (const mitk::Point3D &pt3d_mm, mitk::Point2D &pt2d_mm) const
 Project a 3D point given in mm (pt3d_mm) onto the 2D geometry. The result is a 2D point in mm (pt2d_mm).
virtual void Map (const mitk::Point2D &pt2d_mm, mitk::Point3D &pt3d_mm) const
 Converts a 2D point given in mm (pt2d_mm) relative to the upper-left corner of the geometry into the corresponding world-coordinate (a 3D point in mm, pt3d_mm).
virtual void IndexToWorld (const mitk::Point2D &pt_units, mitk::Point2D &pt_mm) const
 Convert a 2D point given in units (e.g., pixels in case of an image) into a 2D point given in mm.
virtual void WorldToIndex (const mitk::Point2D &pt_mm, mitk::Point2D &pt_units) const
 Convert a 2D point given in mm into a 2D point given in mm (e.g., pixels in case of an image)
virtual void IndexToWorld (const mitk::Point2D &atPt2d_units, const mitk::Vector2D &vec_units, mitk::Vector2D &vec_mm) const
 Convert a 2D vector given in units (e.g., pixels in case of an image) into a 2D vector given in mm.
virtual void WorldToIndex (const mitk::Point2D &atPt2d_mm, const mitk::Vector2D &vec_mm, mitk::Vector2D &vec_units) const
 Convert a 2D vector given in mm into a 2D point vector in mm (e.g., pixels in case of an image)
virtual void SetSizeInUnits (mitk::ScalarType width, mitk::ScalarType height)
 Set the width and height of this 2D-geometry in units by calling SetBounds. This does not change the extent in mm!
virtual bool Project (const mitk::Point3D &pt3d_mm, mitk::Point3D &projectedPt3d_mm) const
 Project a 3D point given in mm (pt3d_mm) onto the 2D geometry. The result is a 3D point in mm (projectedPt3d_mm).
virtual bool Map (const mitk::Point3D &atPt3d_mm, const mitk::Vector3D &vec3d_mm, mitk::Vector2D &vec2d_mm) const
 Project a 3D vector given in mm (vec3d_mm) onto the 2D geometry. The result is a 2D vector in mm (vec2d_mm).
virtual void Map (const mitk::Point2D &atPt2d_mm, const mitk::Vector2D &vec2d_mm, mitk::Vector3D &vec3d_mm) const
 Converts a 2D vector given in mm (vec2d_mm) relative to the upper-left corner of the geometry into the corresponding world-coordinate (a 3D vector in mm, vec3d_mm).
virtual bool Project (const mitk::Point3D &atPt3d_mm, const mitk::Vector3D &vec3d_mm, mitk::Vector3D &projectedVec3d_mm) const
 Project a 3D vector given in mm (vec3d_mm) onto the 2D geometry. The result is a 3D vector in mm (projectedVec3d_mm).
ScalarType Distance (const Point3D &pt3d_mm) const
 Distance of the point from the geometry (bounding-box not considered)
virtual ScalarType SignedDistance (const Point3D &pt3d_mm) const
 Signed distance of the point from the geometry (bounding-box not considered)
virtual bool IsAbove (const Point3D &pt3d_mm) const
 Test if the point is above the geometry (bounding-box not considered)
virtual void SetIndexToWorldTransform (mitk::AffineTransform3D *transform)
virtual void SetExtentInMM (int direction, ScalarType extentInMM)
 Set the extent of the bounding-box in the specified direction in mm.
virtual
AffineGeometryFrame3D::Pointer 
Clone () const
 clones the geometry
void SetReferenceGeometry (mitk::Geometry3D *geometry)
 Set the geometrical frame of reference in which this Geometry2D is placed.
Geometry3DGetReferenceGeometry () const
 Get the geometrical frame of reference for this Geometry2D.
bool HasReferenceGeometry () const

Static Public Member Functions

static Pointer New ()

Protected Member Functions

 Geometry2D ()
virtual ~Geometry2D ()
virtual void InitializeGeometry (Self *newGeometry) const
virtual void PrintSelf (std::ostream &os, itk::Indent indent) const

Protected Attributes

mitk::ScalarType m_ScaleFactorMMPerUnitX
 factor to convert x-coordinates from mm to units and vice versa
mitk::ScalarType m_ScaleFactorMMPerUnitY
 factor to convert y-coordinates from mm to units and vice versa
mitk::Geometry3Dm_ReferenceGeometry

Detailed Description

Describes the geometry of a two-dimensional object.

Describes a two-dimensional manifold, i.e., to put it simply, an object that can be described using a 2D coordinate-system.

Geometry2D can map points between 3D world coordinates (in mm) and the described 2D coordinate-system (in mm) by first projecting the 3D point onto the 2D manifold and then calculating the 2D-coordinates (in mm). These 2D-mm-coordinates can be further converted into 2D-unit-coordinates (e.g., pixels), giving a parameter representation of the object with parameter values inside a rectangle (e.g., [0,0]..[width, height]), which is the bounding box (bounding range in z-direction always [0]..[1]).

A Geometry2D describes the 2D representation within a 3D object and is therefore itself a Geometry3D (derived from Geometry3D). For example, a single CT-image (slice) is 2D in the sense that you can access the pixels using 2D-coordinates, but is also 3D, as the pixels are really voxels, thus have an extension (thickness) in the 3rd dimension.

Most often, instances of Geometry2D will be used to descibe a plane, which is represented by the sub-class PlaneGeometry, but curved surfaces are also possible.

Optionally, a reference Geometry3D can be specified, which usually would be the geometry associated with the underlying dataset. This is currently used for calculating the intersection of inclined / rotated planes (represented as Geometry2D) with the bounding box of the associated Geometry3D.

Warning:
The Geometry2Ds are not necessarily up-to-date and not even initialized. As described in the previous paragraph, one of the Generate-/Copy-/UpdateOutputInformation methods have to initialize it. mitk::BaseData::GetGeometry2D() makes sure, that the Geometry2D is up-to-date before returning it (by setting the update extent appropriately and calling UpdateOutputInformation).

Rule: everything is in mm (or ms for temporal information) if not stated otherwise.

Definition at line 69 of file mitkGeometry2D.h.


Member Typedef Documentation

typedef itk::SmartPointer<const Self> mitk::Geometry2D::ConstPointer
typedef itk::SmartPointer<Self> mitk::Geometry2D::Pointer

Constructor & Destructor Documentation

mitk::Geometry2D::Geometry2D (  ) [protected]

Definition at line 23 of file mitkGeometry2D.cpp.

mitk::Geometry2D::~Geometry2D (  ) [protected, virtual]

Definition at line 31 of file mitkGeometry2D.cpp.

{
}

Member Function Documentation

mitk::AffineGeometryFrame3D::Pointer mitk::Geometry2D::Clone (  ) const [virtual]

clones the geometry

Overwrite in all sub-classes. Normally looks like:

  //##  Self::Pointer newGeometry = Self::New();
  //##  newGeometry->Initialize();
  //##  InitializeGeometry(newGeometry);
  //##  return newGeometry.GetPointer();
  //## 
See also:
InitializeGeometry

Reimplemented from mitk::Geometry3D.

Reimplemented in mitk::AbstractTransformGeometry, mitk::DisplayGeometry, mitk::PlaneGeometry, mitk::ThinPlateSplineCurvedGeometry, and mitk::ExternAbstractTransformGeometry.

Definition at line 232 of file mitkGeometry2D.cpp.

Referenced by mitk::Image::Initialize().

{
  Self::Pointer newGeometry = Self::New();
  newGeometry->Initialize();
  InitializeGeometry(newGeometry);
  return newGeometry.GetPointer();
}
ScalarType mitk::Geometry2D::Distance ( const Point3D &  pt3d_mm ) const [inline]
virtual const char* mitk::Geometry2D::GetClassName (  ) const [virtual]
mitk::Geometry3D * mitk::Geometry2D::GetReferenceGeometry (  ) const
bool mitk::Geometry2D::HasReferenceGeometry (  ) const

Definition at line 272 of file mitkGeometry2D.cpp.

{
  return ( m_ReferenceGeometry != NULL );
}
void mitk::Geometry2D::IndexToWorld ( const mitk::Point2D &  pt_units,
mitk::Point2D &  pt_mm 
) const [virtual]

Convert a 2D point given in units (e.g., pixels in case of an image) into a 2D point given in mm.

Reimplemented in mitk::AbstractTransformGeometry.

Definition at line 90 of file mitkGeometry2D.cpp.

Referenced by mitk::ImageMapperGL2D::Paint().

{
  itkExceptionMacro(<< "No general transform possible (only affine) ==> no general" \
    " IndexToWorld(const mitk::Point2D &pt_mm, mitk::Point2D &pt_units)" \
    " possible. Has to be implemented in sub-class.");
}
void mitk::Geometry2D::IndexToWorld ( const mitk::Point2D &  atPt2d_units,
const mitk::Vector2D &  vec_units,
mitk::Vector2D &  vec_mm 
) const [virtual]

Convert a 2D vector given in units (e.g., pixels in case of an image) into a 2D vector given in mm.

Warning:
strange: in contrast to vtkTransform the class itk::Transform does not have the parameter, where the vector that is to be transformed is located. This method here should also need this information for general transforms.

Reimplemented in mitk::AbstractTransformGeometry.

Definition at line 110 of file mitkGeometry2D.cpp.

{
  itkExceptionMacro(<< "No general transform possible (only affine) ==> no general" \
    " IndexToWorld(const mitk::Vector2D &vec_mm, mitk::Vector2D &vec_units)" \
    " possible. Has to be implemented in sub-class.");
}
void mitk::Geometry2D::InitializeGeometry ( Self newGeometry ) const [protected, virtual]

Reimplemented in mitk::PlaneGeometry.

Definition at line 242 of file mitkGeometry2D.cpp.

References SetReferenceGeometry().

Referenced by mitk::PlaneGeometry::PrintSelf().

{
  Superclass::InitializeGeometry(newGeometry);

  newGeometry->SetReferenceGeometry( m_ReferenceGeometry );
}
virtual bool mitk::Geometry2D::IsAbove ( const Point3D &  pt3d_mm ) const [virtual]

Test if the point is above the geometry (bounding-box not considered)

Reimplemented in mitk::AbstractTransformGeometry, and mitk::PlaneGeometry.

void mitk::Geometry2D::Map ( const mitk::Point2D &  pt2d_mm,
mitk::Point3D &  pt3d_mm 
) const [virtual]

Converts a 2D point given in mm (pt2d_mm) relative to the upper-left corner of the geometry into the corresponding world-coordinate (a 3D point in mm, pt3d_mm).

To convert a 2D point given in units (e.g., pixels in case of an image) into a 2D point given in mm (as required by this method), use IndexToWorld.

Reimplemented in mitk::AbstractTransformGeometry.

Definition at line 79 of file mitkGeometry2D.cpp.

{
  Point3D pt3d_units;
  pt3d_units[0]=pt2d_mm[0]/m_ScaleFactorMMPerUnitX;
  pt3d_units[1]=pt2d_mm[1]/m_ScaleFactorMMPerUnitY;
  pt3d_units[2]=0;
  pt3d_mm = GetParametricTransform()->TransformPoint(pt3d_units);
}
bool mitk::Geometry2D::Map ( const mitk::Point3D &  atPt3d_mm,
const mitk::Vector3D &  vec3d_mm,
mitk::Vector2D &  vec2d_mm 
) const [virtual]

Project a 3D vector given in mm (vec3d_mm) onto the 2D geometry. The result is a 2D vector in mm (vec2d_mm).

The result is a 2D vector in mm (vec2d_mm) relative to the upper-left corner of the geometry. To convert this point into units (e.g., pixels in case of an image), use WorldToIndex.

Returns:
true projection was possible
See also:
Project(const mitk::Vector3D &vec3d_mm, mitk::Vector3D &projectedVec3d_mm)

Reimplemented in mitk::AbstractTransformGeometry.

Definition at line 170 of file mitkGeometry2D.cpp.

{
  Point2D pt2d_mm_start, pt2d_mm_end;
  Point3D pt3d_mm_end;
  bool inside=Map(atPt3d_mm, pt2d_mm_start);
  pt3d_mm_end = atPt3d_mm+vec3d_mm;
  inside&=Map(pt3d_mm_end, pt2d_mm_end);
  vec2d_mm=pt2d_mm_end-pt2d_mm_start;
  return inside;
}
void mitk::Geometry2D::Map ( const mitk::Point2D &  atPt2d_mm,
const mitk::Vector2D &  vec2d_mm,
mitk::Vector3D &  vec3d_mm 
) const [virtual]

Converts a 2D vector given in mm (vec2d_mm) relative to the upper-left corner of the geometry into the corresponding world-coordinate (a 3D vector in mm, vec3d_mm).

To convert a 2D vector given in units (e.g., pixels in case of an image) into a 2D vector given in mm (as required by this method), use IndexToWorld.

Reimplemented in mitk::AbstractTransformGeometry.

Definition at line 184 of file mitkGeometry2D.cpp.

{
  //@todo implement parallel to the other Map method!
  assert(false);
}
bool mitk::Geometry2D::Map ( const mitk::Point3D &  pt3d_mm,
mitk::Point2D &  pt2d_mm 
) const [virtual]

Project a 3D point given in mm (pt3d_mm) onto the 2D geometry. The result is a 2D point in mm (pt2d_mm).

The result is a 2D point in mm (pt2d_mm) relative to the upper-left corner of the geometry. To convert this point into units (e.g., pixels in case of an image), use WorldToIndex.

Returns:
true projection was possible
See also:
Project(const mitk::Point3D &pt3d_mm, mitk::Point3D &projectedPt3d_mm)

Reimplemented in mitk::AbstractTransformGeometry.

Definition at line 64 of file mitkGeometry2D.cpp.

Referenced by QmitkVtkLineProfileWidget::CreatePathFromPlanarFigure(), mitk::PlanarFigureInteractor::ExecuteAction(), mappingTests2D(), mitk::Geometry2DDataMapper2D::Paint(), mitk::VectorImageMapper2D::PaintCells(), mitk::SurfaceGLMapper2D::PaintCells(), mitk::PlanarFigureMapper2D::TransformObjectToDisplay(), mitk::PlanarFigureInteractor::TransformObjectToDisplay(), and mitk::PlanarFigureInteractor::TransformPositionEventToPoint2D().

{
  assert(m_BoundingBox.IsNotNull());

  Point3D pt3d_units;
  BackTransform(pt3d_mm, pt3d_units);
  pt2d_mm[0]=pt3d_units[0]*m_ScaleFactorMMPerUnitX;
  pt2d_mm[1]=pt3d_units[1]*m_ScaleFactorMMPerUnitY;
  pt3d_units[2]=0;
  return const_cast<BoundingBox*>(m_BoundingBox.GetPointer())->IsInside(pt3d_units);
}
static Pointer mitk::Geometry2D::New (  ) [static]
void mitk::Geometry2D::PrintSelf ( std::ostream &  os,
itk::Indent  indent 
) const [protected, virtual]

Reimplemented from mitk::Geometry3D.

Reimplemented in mitk::DisplayGeometry, and mitk::PlaneGeometry.

Definition at line 250 of file mitkGeometry2D.cpp.

{
  Superclass::PrintSelf(os,indent);
  os << indent << " ScaleFactorMMPerUnitX: "
     << m_ScaleFactorMMPerUnitX << std::endl;
  os << indent << " ScaleFactorMMPerUnitY: "
     << m_ScaleFactorMMPerUnitY << std::endl;
}
bool mitk::Geometry2D::Project ( const mitk::Point3D &  pt3d_mm,
mitk::Point3D &  projectedPt3d_mm 
) const [virtual]

Project a 3D point given in mm (pt3d_mm) onto the 2D geometry. The result is a 3D point in mm (projectedPt3d_mm).

Returns:
true projection was possible

Reimplemented in mitk::AbstractTransformGeometry.

Definition at line 156 of file mitkGeometry2D.cpp.

Referenced by mitk::SegTool2D::DetermineAffectedImageSlice(), and mitk::SlicesRotator::RotateToPoint().

{
  assert(m_BoundingBox.IsNotNull());

  Point3D pt3d_units;
  BackTransform(pt3d_mm, pt3d_units);
  pt3d_units[2] = 0;
  projectedPt3d_mm = GetParametricTransform()->TransformPoint(pt3d_units);
  return const_cast<BoundingBox*>(m_BoundingBox.GetPointer())->IsInside(pt3d_units);
}
bool mitk::Geometry2D::Project ( const mitk::Point3D &  atPt3d_mm,
const mitk::Vector3D &  vec3d_mm,
mitk::Vector3D &  projectedVec3d_mm 
) const [virtual]

Project a 3D vector given in mm (vec3d_mm) onto the 2D geometry. The result is a 3D vector in mm (projectedVec3d_mm).

Returns:
true projection was possible

Reimplemented in mitk::AbstractTransformGeometry.

Definition at line 193 of file mitkGeometry2D.cpp.

{
  assert(m_BoundingBox.IsNotNull());

  Vector3D vec3d_units;
  BackTransform(atPt3d_mm, vec3d_mm, vec3d_units);
  vec3d_units[2] = 0;
  projectedVec3d_mm = GetParametricTransform()->TransformVector(vec3d_units);

  Point3D pt3d_units;
  BackTransform(atPt3d_mm, pt3d_units);
  return const_cast<BoundingBox*>(m_BoundingBox.GetPointer())->IsInside(pt3d_units);
}
void mitk::Geometry2D::SetExtentInMM ( int  direction,
ScalarType  extentInMM 
) [virtual]

Set the extent of the bounding-box in the specified direction in mm.

Note:
This changes the matrix in the transform, not the bounds, which are given in units!

Reimplemented from mitk::Geometry3D.

Definition at line 51 of file mitkGeometry2D.cpp.

{
  Superclass::SetExtentInMM(direction, extentInMM);

  m_ScaleFactorMMPerUnitX=GetExtentInMM(0)/GetExtent(0);
  m_ScaleFactorMMPerUnitY=GetExtentInMM(1)/GetExtent(1);  

  assert(m_ScaleFactorMMPerUnitX<ScalarTypeNumericTraits::infinity());
  assert(m_ScaleFactorMMPerUnitY<ScalarTypeNumericTraits::infinity());
}
void mitk::Geometry2D::SetIndexToWorldTransform ( mitk::AffineTransform3D transform ) [virtual]

Reimplemented from mitk::Geometry3D.

Reimplemented in mitk::PlaneGeometry.

Definition at line 37 of file mitkGeometry2D.cpp.

{
  Superclass::SetIndexToWorldTransform(transform);
  
  m_ScaleFactorMMPerUnitX=GetExtentInMM(0)/GetExtent(0);
  m_ScaleFactorMMPerUnitY=GetExtentInMM(1)/GetExtent(1);  

  assert(m_ScaleFactorMMPerUnitX<ScalarTypeNumericTraits::infinity());
  assert(m_ScaleFactorMMPerUnitY<ScalarTypeNumericTraits::infinity());
}
void mitk::Geometry2D::SetReferenceGeometry ( mitk::Geometry3D geometry )

Set the geometrical frame of reference in which this Geometry2D is placed.

This would usually be the Geometry3D of the underlying dataset, but setting it is optional.

Definition at line 260 of file mitkGeometry2D.cpp.

Referenced by InitializeGeometry(), and mitk::SlicedGeometry3D::SetGeometry2D().

{
  m_ReferenceGeometry = geometry;
}
void mitk::Geometry2D::SetSizeInUnits ( mitk::ScalarType  width,
mitk::ScalarType  height 
) [virtual]

Set the width and height of this 2D-geometry in units by calling SetBounds. This does not change the extent in mm!

For an image, this is the number of pixels in x-/y-direction.

Note:
In contrast to calling SetBounds directly, this does not change the extent in mm!

Definition at line 129 of file mitkGeometry2D.cpp.

{
  ScalarType bounds[6]={0, width, 0, height, 0, 1};
  ScalarType extent, newextentInMM;
  if(GetExtent(0)>0)
  {
    extent = GetExtent(0);
    if(width>extent)
      newextentInMM = GetExtentInMM(0)/width*extent;
    else
      newextentInMM = GetExtentInMM(0)*extent/width;
    SetExtentInMM(0, newextentInMM);
  }
  if(GetExtent(1)>0)
  {
    extent = GetExtent(1);
    if(width>extent)
      newextentInMM = GetExtentInMM(1)/height*extent;
    else
      newextentInMM = GetExtentInMM(1)*extent/height;
    SetExtentInMM(1, newextentInMM);
  }
  SetBounds(bounds);
}
virtual ScalarType mitk::Geometry2D::SignedDistance ( const Point3D &  pt3d_mm ) const [virtual]

Signed distance of the point from the geometry (bounding-box not considered)

Reimplemented in mitk::PlaneGeometry.

void mitk::Geometry2D::WorldToIndex ( const mitk::Point2D &  pt_mm,
mitk::Point2D &  pt_units 
) const [virtual]

Convert a 2D point given in mm into a 2D point given in mm (e.g., pixels in case of an image)

Reimplemented in mitk::AbstractTransformGeometry.

Definition at line 100 of file mitkGeometry2D.cpp.

{
  itkExceptionMacro(<< "No general back transform possible (only affine) ==> no general" \
    " WorldToIndex(const mitk::Point2D &pt_mm, mitk::Point2D &pt_units)" \
    " possible. Has to be implemented in sub-class.");
}
void mitk::Geometry2D::WorldToIndex ( const mitk::Point2D &  atPt2d_mm,
const mitk::Vector2D &  vec_mm,
mitk::Vector2D &  vec_units 
) const [virtual]

Convert a 2D vector given in mm into a 2D point vector in mm (e.g., pixels in case of an image)

Warning:
strange: in contrast to vtkTransform the class itk::Transform does not have the parameter, where the vector that is to be transformed is located. This method here should also need this information for general transforms.

Reimplemented in mitk::AbstractTransformGeometry.

Definition at line 120 of file mitkGeometry2D.cpp.

{
  itkExceptionMacro(<< "No general back transform possible (only affine) ==> no general" \
    " WorldToIndex(const mitk::Vector2D &vec_mm, mitk::Vector2D &vec_units)" \
    " possible. Has to be implemented in sub-class.");
}

Member Data Documentation

Definition at line 259 of file mitkGeometry2D.h.

mitk::ScalarType mitk::Geometry2D::m_ScaleFactorMMPerUnitX [mutable, protected]

factor to convert x-coordinates from mm to units and vice versa

Definition at line 251 of file mitkGeometry2D.h.

Referenced by mitk::PlaneGeometry::IndexToWorld(), and mitk::PlaneGeometry::WorldToIndex().

mitk::ScalarType mitk::Geometry2D::m_ScaleFactorMMPerUnitY [mutable, protected]

factor to convert y-coordinates from mm to units and vice versa

Definition at line 257 of file mitkGeometry2D.h.

Referenced by mitk::PlaneGeometry::IndexToWorld(), and mitk::PlaneGeometry::WorldToIndex().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines