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

mitk::PlaneFit Class Reference

#include <mitkPlaneFit.h>

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

List of all members.

Public Types

typedef PlaneFit Self
typedef GeometryDataSource Superclass
typedef itk::SmartPointer< SelfPointer
typedef itk::SmartPointer
< const Self
ConstPointer
typedef
mitk::PointSet::PointDataType 
PointDataType
typedef
mitk::PointSet::PointDataIterator 
PointDataIterator

Public Member Functions

virtual const char * GetClassName () const
virtual void GenerateOutputInformation ()
virtual void GenerateData ()
const mitk::PointSetGetInput ()
virtual void SetInput (const mitk::PointSet *ps)
virtual const mitk::Point3D & GetCentroid (int t=0) const
virtual
mitk::PlaneGeometry::Pointer 
GetPlaneGeometry (int t=0)
virtual const mitk::Vector3D & GetPlaneNormal (int t=0) const

Static Public Member Functions

static Pointer New ()

Protected Member Functions

 PlaneFit ()
virtual ~PlaneFit ()
void CalculateCentroid (int t=0)
void ProcessPointSet (int t=0)
void InitializePlane (int t=0)

Detailed Description

Definition at line 66 of file mitkPlaneFit.h.


Member Typedef Documentation

typedef itk::SmartPointer<const Self> mitk::PlaneFit::ConstPointer

Reimplemented from mitk::GeometryDataSource.

Definition at line 70 of file mitkPlaneFit.h.

Definition at line 74 of file mitkPlaneFit.h.

Definition at line 71 of file mitkPlaneFit.h.

typedef itk::SmartPointer<Self> mitk::PlaneFit::Pointer

Reimplemented from mitk::GeometryDataSource.

Definition at line 70 of file mitkPlaneFit.h.

Reimplemented from mitk::GeometryDataSource.

Definition at line 70 of file mitkPlaneFit.h.

Reimplemented from mitk::GeometryDataSource.

Definition at line 70 of file mitkPlaneFit.h.


Constructor & Destructor Documentation

mitk::PlaneFit::PlaneFit (  ) [protected]

Definition at line 27 of file mitkPlaneFit.cpp.

References New().

: m_PointSet( NULL )
{
  m_TimeSlicedGeometry = mitk::TimeSlicedGeometry::New();
}
mitk::PlaneFit::~PlaneFit (  ) [protected, virtual]

Definition at line 33 of file mitkPlaneFit.cpp.

{
}

Member Function Documentation

void mitk::PlaneFit::CalculateCentroid ( int  t = 0 ) [protected]

Calculates the centroid of the point set. the center of gravity is calculated through the mean value of the whole point set

Definition at line 125 of file mitkPlaneFit.cpp.

References QuadProgPP::t().

{  
  if ( m_PointSet == NULL ) return;

  int ps_total = m_PointSet->GetSize( t );
  
  m_Centroids[t][0] = m_Centroids[t][1] = m_Centroids[t][2] = 0.0;

  // sum of all points
  mitk::PointSet::PointsContainer::Iterator pit, end;
  pit = m_PointSet->GetPointSet( t )->GetPoints()->Begin();
  end = m_PointSet->GetPointSet( t )->GetPoints()->End();
  for ( ; pit!=end; ++pit )
  {
    mitk::Point3D p3d = pit.Value();
    m_Centroids[t][0] += p3d[0]; 
    m_Centroids[t][1] += p3d[1];
    m_Centroids[t][2] += p3d[2];
  }

  // calculation of centroid
  m_Centroids[t][0] /= ps_total;
  m_Centroids[t][1] /= ps_total;
  m_Centroids[t][2] /= ps_total;
}
void mitk::PlaneFit::GenerateData (  ) [virtual]

Definition at line 77 of file mitkPlaneFit.cpp.

References QuadProgPP::t().

{
  unsigned int t;
  for ( t = 0; t < m_PointSet->GetPointSetSeriesSize(); ++t )
  {
    // check number of data points - less then 3points isn't enough
    if ( m_PointSet->GetSize( t ) >= 3 )
    {
      this->CalculateCentroid( t );

      this->ProcessPointSet( t );

      this->InitializePlane( t );
    }
  }
}
void mitk::PlaneFit::GenerateOutputInformation ( void   ) [virtual]

Definition at line 38 of file mitkPlaneFit.cpp.

References mitk::PlaneGeometry::New(), and QuadProgPP::t().

{
  mitk::PointSet::ConstPointer input  = this->GetInput();
  mitk::GeometryData::Pointer output  = this->GetOutput();

  itkDebugMacro(<<"GenerateOutputInformation()");

  if (input.IsNull()) return;

  if ( m_PointSet == NULL )
  {
    return;
  }

  bool update = false;
  if ( output->GetGeometry() == NULL || output->GetTimeSlicedGeometry() == NULL )
    update = true;
  if ( ( ! update ) && ( output->GetTimeSlicedGeometry()->GetTimeSteps() != input->GetTimeSlicedGeometry()->GetTimeSteps() ) )
    update = true;
  if ( update )
  {
    mitk::PlaneGeometry::Pointer planeGeometry = mitk::PlaneGeometry::New();
  
    m_TimeSlicedGeometry->InitializeEvenlyTimed( 
      planeGeometry, m_PointSet->GetPointSetSeriesSize() );
  
    unsigned int t;
    for ( t = 0;
          (t < m_PointSet->GetPointSetSeriesSize())
          && (t < m_Planes.size());
          ++t )
    {
      m_TimeSlicedGeometry->SetGeometry3D( m_Planes[t], (int) t );
    }
  
    output->SetGeometry( m_TimeSlicedGeometry );
  }
}
const mitk::Point3D & mitk::PlaneFit::GetCentroid ( int  t = 0 ) const [virtual]

returns the center of gravity of the point set.

Definition at line 203 of file mitkPlaneFit.cpp.

References QuadProgPP::t().

{
  return m_Centroids[t];
}
virtual const char* mitk::PlaneFit::GetClassName (  ) const [virtual]

Reimplemented from mitk::GeometryDataSource.

const mitk::PointSet * mitk::PlaneFit::GetInput ( void   )

Getter for point set.

Definition at line 114 of file mitkPlaneFit.cpp.

{
  if (this->GetNumberOfInputs() < 1)
  {
    return 0;
  }

  return static_cast<const mitk::PointSet * > (this->ProcessObject::GetInput(0) );
}
mitk::PlaneGeometry::Pointer mitk::PlaneFit::GetPlaneGeometry ( int  t = 0 ) [virtual]

returns the plane geometry which represents the point set.

Definition at line 193 of file mitkPlaneFit.cpp.

References QuadProgPP::t().

{
  return m_Planes[t];
}
const mitk::Vector3D & mitk::PlaneFit::GetPlaneNormal ( int  t = 0 ) const [virtual]

returns the normal of the plane which represents the point set.

Definition at line 198 of file mitkPlaneFit.cpp.

References QuadProgPP::t().

{
  return m_PlaneVectors[t];
}
void mitk::PlaneFit::InitializePlane ( int  t = 0 ) [protected]

Initialize Plane and configuration.

Definition at line 208 of file mitkPlaneFit.cpp.

References QuadProgPP::t().

{
  m_Planes[t]->InitializePlane( m_Centroids[t], m_PlaneVectors[t] );
}
static Pointer mitk::PlaneFit::New (  ) [static]

Reimplemented from mitk::GeometryDataSource.

Referenced by mitkPlaneFitTest(), and PlaneFit().

void mitk::PlaneFit::ProcessPointSet ( int  t = 0 ) [protected]

working with an SVD algorithm form matrix dataM. ITK suplies the vnl_svd to solve an plan fit eigentvector problem points are processed in the SVD matrix. The normal vector is the singular vector of dataM corresponding to its smalest singular value. The mehtod uses VNL library from ITK and at least the mehtod nullvector() to extract the normalvector.

Definition at line 152 of file mitkPlaneFit.cpp.

References QuadProgPP::svd(), and QuadProgPP::t().

{
  if (m_PointSet == NULL ) return;

  // int matrix with POINTS x (X,Y,Z)
  vnl_matrix<mitk::ScalarType> dataM( m_PointSet->GetSize( t ), 3);

  // calculate point distance to centroid and inserting it in the matrix
  mitk::PointSet::PointsContainer::Iterator pit, end;
  pit = m_PointSet->GetPointSet( t )->GetPoints()->Begin();
  end = m_PointSet->GetPointSet( t )->GetPoints()->End();
  
  for (int p=0; pit!=end; pit++, p++)
  {
    mitk::Point3D p3d = pit.Value();
    dataM[p][0] = p3d[0] - m_Centroids[t][0];
    dataM[p][1] = p3d[1] - m_Centroids[t][1];
    dataM[p][2] = p3d[2] - m_Centroids[t][2];
  }

  // process the SVD (singular value decomposition) from ITK
  // the vector will be orderd   descending 
  vnl_svd<mitk::ScalarType> svd(dataM, 0.0);

  // calculate the SVD of A
  vnl_vector<mitk::ScalarType> v = svd.nullvector();


  // Avoid erratic normal sign switching when the plane changes minimally
  // by negating the vector for negative x values.
  if ( v[0] < 0 )
  {
    v = -v;
  }

  m_PlaneVectors[t][0] = v[0];
  m_PlaneVectors[t][1] = v[1];
  m_PlaneVectors[t][2] = v[2];

}
void mitk::PlaneFit::SetInput ( const mitk::PointSet ps ) [virtual]

filter initialisation.

Definition at line 94 of file mitkPlaneFit.cpp.

References mitk::PointSet::GetPointSetSeriesSize(), mitk::PlaneGeometry::New(), and QuadProgPP::t().

{
  // Process object is not const-correct so the const_cast is required here
  this->ProcessObject::SetNthInput(0, 
    const_cast< mitk::PointSet * >( pointSet ) );

  m_PointSet = pointSet;
  unsigned int pointSetSize = pointSet->GetPointSetSeriesSize();

  m_Planes.resize( pointSetSize );
  m_Centroids.resize( pointSetSize );
  m_PlaneVectors.resize( pointSetSize );

  unsigned int t;
  for ( t = 0; t < pointSetSize; ++t )
  {
    m_Planes[t] = mitk::PlaneGeometry::New();
  }
}

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