void
   PlaneGeometry::SetSizeInUnits(mitk::ScalarType width, mitk::ScalarType height)
 {
   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);
 }
 void PlaneGeometry::PrintSelf( std::ostream& os, itk::Indent indent ) const
 {
   Superclass::PrintSelf(os,indent);
   os << indent << " ScaleFactorMMPerUnitX: "
     << GetExtentInMM(0) / GetExtent(0) << std::endl;
   os << indent << " ScaleFactorMMPerUnitY: "
     << GetExtentInMM(1) / GetExtent(1) << std::endl;
   os << indent << " Normal: " << GetNormal() << std::endl;
 }
Beispiel #3
0
void 
mitk::Geometry2D::SetExtentInMM(int direction, ScalarType extentInMM)
{
  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());
}
  bool PlaneGeometry::Map(const mitk::Point3D &pt3d_mm, mitk::Point2D &pt2d_mm) const
  {
    assert(this->IsBoundingBoxNull()==false);

    Point3D pt3d_units;
    Superclass::WorldToIndex(pt3d_mm, pt3d_units);
    pt2d_mm[0] = pt3d_units[0] * GetExtentInMM(0) / GetExtent(0);
    pt2d_mm[1] = pt3d_units[1] * GetExtentInMM(1) / GetExtent(1);
    pt3d_units[2]=0;
    return const_cast<BoundingBox*>(this->GetBoundingBox())->IsInside(pt3d_units);
  }
Beispiel #5
0
void 
mitk::Geometry2D::SetIndexToWorldTransform(
  mitk::AffineTransform3D* transform)
{
  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
   PlaneGeometry::Map(const mitk::Point2D &pt2d_mm, mitk::Point3D &pt3d_mm) const
 {
   //pt2d_mm is measured from the origin of the world geometry (at leats it called form BaseRendere::Mouse...Event)
   Point3D pt3d_units;
   pt3d_units[0] = pt2d_mm[0] / (GetExtentInMM(0) / GetExtent(0));
   pt3d_units[1] = pt2d_mm[1] / (GetExtentInMM(1) / GetExtent(1));
   pt3d_units[2]=0;
   //pt3d_units is a continuos index. We divided it with the Scale Factor (= spacing in x and y) to convert it from mm to index units.
   //
   pt3d_mm = GetIndexToWorldTransform()->TransformPoint(pt3d_units);
   //now we convert the 3d index to a 3D world point in mm. We could have used IndexToWorld as well as GetITW->Transform...
 }
Beispiel #7
0
unsigned int
PlaneGeometry::IntersectWithPlane2D(
  const PlaneGeometry* plane, Point2D& lineFrom, Point2D &lineTo ) const
{
  Line3D crossline;
  if ( this->IntersectionLine( plane, crossline ) == false )
    return 0;

  Point2D  point2;
  Vector2D direction2;

  this->Map( crossline.GetPoint(), point2 );
  this->Map( crossline.GetPoint(), crossline.GetDirection(), direction2 );

  return
    Line3D::RectangleLineIntersection(
    0, 0, GetExtentInMM(0), GetExtentInMM(1),
    point2, direction2, lineFrom, lineTo );
}
Beispiel #8
0
void mitk::BaseGeometry::SetExtentInMM(int direction, ScalarType extentInMM)
{
  mitk::ModifiedLock lock(this);

  ScalarType len = GetExtentInMM(direction);
  if (fabs(len - extentInMM) >= mitk::eps)
  {
    AffineTransform3D::MatrixType::InternalMatrixType vnlmatrix;
    vnlmatrix = m_GeometryTransform->GetVnlMatrix();
    if (len > extentInMM)
      vnlmatrix.set_column(direction, vnlmatrix.get_column(direction) / len * extentInMM);
    else
      vnlmatrix.set_column(direction, vnlmatrix.get_column(direction) * extentInMM / len);
    Matrix3D matrix;
    matrix = vnlmatrix;
    m_GeometryTransform->SetMatrix(matrix);

    Modified();
  }
}
 void PlaneGeometry::WorldToIndex( const Point2D &pt_mm, Point2D &pt_units ) const
 {
   pt_units[0] = pt_mm[0] * (1.0 / (GetExtentInMM(0) / GetExtent(0)));
   pt_units[1] = pt_mm[1] * (1.0 / (GetExtentInMM(1) / GetExtent(1)));
 }
 void
   PlaneGeometry::IndexToWorld( const Point2D &pt_units, Point2D &pt_mm ) const
 {
   pt_mm[0] = GetExtentInMM(0) / GetExtent(0)*pt_units[0];
   pt_mm[1] = GetExtentInMM(1) / GetExtent(1)*pt_units[1];
 }
 void
   PlaneGeometry::WorldToIndex( const Vector2D &vec_mm, Vector2D &vec_units) const
 {
   vec_units[0] = vec_mm[0] * (1.0 / (GetExtentInMM(0) / GetExtent(0)));
   vec_units[1] = vec_mm[1] * (1.0 / (GetExtentInMM(1) / GetExtent(1)));
 }
 void PlaneGeometry::IndexToWorld(const Vector2D &vec_units, Vector2D &vec_mm) const
 {
   vec_mm[0] = (GetExtentInMM(0) / GetExtent(0)) * vec_units[0];
   vec_mm[1] = (GetExtentInMM(1) / GetExtent(1)) * vec_units[1];
 }