19 #include <vcl_iostream.h> 20 #include <vnl/algo/vnl_svd.h> 36 itkDebugMacro(<<
"GenerateOutputInformation()");
41 if (m_PointSet ==
nullptr)
47 if (output->GetGeometry() ==
nullptr || output->GetTimeGeometry() ==
nullptr)
49 if ((!update) && (output->GetTimeGeometry()->CountTimeSteps() != input->GetTimeGeometry()->CountTimeSteps()))
62 for (timeStep = 0; (timeStep < m_PointSet->
GetPointSetSeriesSize()) && (timeStep < m_Planes.size()); ++timeStep)
64 timeGeometry->SetTimeStepGeometry(m_Planes[timeStep], timeStep);
67 output->SetTimeGeometry(m_TimeGeometry);
77 if (m_PointSet->
GetSize(t) >= 3)
91 this->ProcessObject::SetNthInput(0, const_cast<mitk::PointSet *>(pointSet));
93 m_PointSet = pointSet;
96 m_Planes.resize(pointSetSize);
97 m_Centroids.resize(pointSetSize);
98 m_PlaneVectors.resize(pointSetSize);
101 for (t = 0; t < pointSetSize; ++t)
109 if (this->GetNumberOfInputs() < 1)
114 return static_cast<const mitk::PointSet *
>(this->ProcessObject::GetInput(0));
119 if (m_PointSet ==
nullptr)
122 int ps_total = m_PointSet->
GetSize(t);
124 m_Centroids[t][0] = m_Centroids[t][1] = m_Centroids[t][2] = 0.0;
126 for (
int i = 0; i < ps_total; i++)
129 m_Centroids[t][0] += p3d[0];
130 m_Centroids[t][1] += p3d[1];
131 m_Centroids[t][2] += p3d[2];
135 m_Centroids[t][0] /= ps_total;
136 m_Centroids[t][1] /= ps_total;
137 m_Centroids[t][2] /= ps_total;
142 if (m_PointSet ==
nullptr)
146 vnl_matrix<mitk::ScalarType> dataM(m_PointSet->
GetSize(t), 3);
148 int ps_total = m_PointSet->
GetSize(t);
149 for (
int i = 0; i < ps_total; i++)
152 dataM[i][0] = p3d[0] - m_Centroids[t][0];
153 dataM[i][1] = p3d[1] - m_Centroids[t][1];
154 dataM[i][2] = p3d[2] - m_Centroids[t][2];
158 vnl_svd<mitk::ScalarType> svd(dataM, 0.0);
161 vnl_vector<mitk::ScalarType> v = svd.nullvector();
170 m_PlaneVectors[t][0] = v[0];
171 m_PlaneVectors[t][1] = v[1];
172 m_PlaneVectors[t][2] = v[2];
182 return m_PlaneVectors[t];
187 return m_Centroids[t];
192 m_Planes[t]->InitializePlane(m_Centroids[t], m_PlaneVectors[t]);
void CalculateCentroid(int t=0)
void InitializePlane(int t=0)
virtual unsigned int GetPointSetSeriesSize() const
virtual void SetInput(const mitk::PointSet *ps)
void GenerateOutputInformation() override
void ProcessPointSet(int t=0)
void GenerateData() override
virtual int GetSize(unsigned int t=0) const
returns the current size of the point-list
Data structure which stores a set of points. Superclass of mitk::Mesh.
std::vcl_size_t TimeStepType
virtual mitk::PlaneGeometry::Pointer GetPlaneGeometry(int t=0)
virtual const mitk::Vector3D & GetPlaneNormal(int t=0) const
virtual const mitk::Point3D & GetCentroid(int t=0) const
PointType GetPoint(PointIdentifier id, int t=0) const
Get the point with ID id in world coordinates.
const mitk::PointSet * GetInput()