00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 00019 #if !defined(MITK_PLANEFIT_H__INCLUDED_) 00020 #define MITK_PLANEFIT_H__INCLUDED_ 00021 00022 #include "mitkPointSet.h" 00023 #include "MitkExtExports.h" 00024 #include "mitkTimeSlicedGeometry.h" 00025 #include "mitkPlaneGeometry.h" 00026 #include "mitkGeometryDataSource.h" 00027 00028 namespace mitk { 00029 00031 // kind regards to dr. math! 00032 // function [x0, a, d, normd] = lsplane(X) 00033 // --------------------------------------------------------------------- 00034 // LSPLANE.M Least-squares plane (orthogonal distance 00035 // regression). 00036 // 00037 // Version 1.0 00038 // Last amended I M Smith 27 May 2002. 00039 // Created I M Smith 08 Mar 2002 00040 // --------------------------------------------------------------------- 00041 // Input 00042 // X Array [x y z] where x = vector of x-coordinates, 00043 // y = vector of y-coordinates and z = vector of 00044 // z-coordinates. 00045 // Dimension: m x 3. 00046 // 00047 // Output 00048 // x0 Centroid of the data = point on the best-fit plane. 00049 // Dimension: 3 x 1. 00050 // 00051 // a Direction cosines of the normal to the best-fit 00052 // plane. 00053 // Dimension: 3 x 1. 00054 // 00055 // <Optional... 00056 // d Residuals. 00057 // Dimension: m x 1. 00058 // 00059 // normd Norm of residual errors. 00060 // Dimension: 1 x 1. 00061 // ...> 00062 // 00063 // [x0, a <, d, normd >] = lsplane(X) 00064 // --------------------------------------------------------------------- 00065 00066 class MitkExt_EXPORT PlaneFit : public GeometryDataSource 00067 { 00068 public: 00069 00070 mitkClassMacro( PlaneFit, GeometryDataSource); 00071 itkNewMacro(Self); 00072 00073 typedef mitk::PointSet::PointDataType PointDataType; 00074 typedef mitk::PointSet::PointDataIterator PointDataIterator; 00075 00076 virtual void GenerateOutputInformation(); 00077 00078 virtual void GenerateData(); 00079 00083 const mitk::PointSet *GetInput(); 00084 00088 virtual void SetInput( const mitk::PointSet *ps ); 00089 00093 virtual const mitk::Point3D &GetCentroid( int t = 0 ) const; 00094 00098 virtual mitk::PlaneGeometry::Pointer GetPlaneGeometry( int t = 0 ); 00099 00103 virtual const mitk::Vector3D &GetPlaneNormal( int t = 0 ) const; 00104 00105 protected: 00106 PlaneFit(); 00107 virtual ~PlaneFit(); 00108 00112 void CalculateCentroid( int t = 0 ); 00113 00121 void ProcessPointSet( int t = 0 ); 00122 00126 void InitializePlane( int t = 0 ); 00127 00128 00129 private: 00130 00132 const mitk::PointSet* m_PointSet; 00133 00134 /* output object - a time sliced geometry.*/ 00135 mitk::TimeSlicedGeometry::Pointer m_TimeSlicedGeometry; 00136 00137 std::vector< mitk::PlaneGeometry::Pointer > m_Planes; 00138 00140 std::vector< mitk::Point3D > m_Centroids; 00141 00142 /* the normal vector to descrie a plane gemoetry.*/ 00143 std::vector< mitk::Vector3D > m_PlaneVectors; 00144 }; 00145 }//namespace mitk 00146 #endif //MITK_PLANFIT_INCLUDE_ 00147 00148