23 #include <vcl_iostream.h>
24 #include <vnl/algo/vnl_svd.h>
40 itkDebugMacro(<<
"GenerateOutputInformation()");
45 if (m_PointSet ==
nullptr)
51 if (output->GetGeometry() ==
nullptr || output->GetTimeGeometry() ==
nullptr)
53 if ((!update) && (output->GetTimeGeometry()->CountTimeSteps() != input->GetTimeGeometry()->CountTimeSteps()))
61 timeGeometry->Initialize(planeGeometry, m_PointSet->GetPointSetSeriesSize());
66 for (timeStep = 0; (timeStep < m_PointSet->GetPointSetSeriesSize()) && (timeStep < m_Planes.size()); ++timeStep)
68 timeGeometry->SetTimeStepGeometry(m_Planes[timeStep], timeStep);
71 output->SetTimeGeometry(m_TimeGeometry);
78 for (t = 0; t < m_PointSet->GetPointSetSeriesSize(); ++t)
81 if (m_PointSet->GetSize(t) >= 3)
83 this->CalculateCentroid(t);
85 this->ProcessPointSet(t);
87 this->InitializePlane(t);
95 this->ProcessObject::SetNthInput(0, const_cast<mitk::PointSet *>(pointSet));
97 m_PointSet = pointSet;
100 m_Planes.resize(pointSetSize);
101 m_Centroids.resize(pointSetSize);
102 m_PlaneVectors.resize(pointSetSize);
105 for (t = 0; t < pointSetSize; ++t)
113 if (this->GetNumberOfInputs() < 1)
118 return static_cast<const mitk::PointSet *
>(this->ProcessObject::GetInput(0));
123 if (m_PointSet ==
nullptr)
126 int ps_total = m_PointSet->GetSize(t);
128 m_Centroids[t][0] = m_Centroids[t][1] = m_Centroids[t][2] = 0.0;
130 for (
int i = 0; i < ps_total; i++)
133 m_Centroids[t][0] += p3d[0];
134 m_Centroids[t][1] += p3d[1];
135 m_Centroids[t][2] += p3d[2];
139 m_Centroids[t][0] /= ps_total;
140 m_Centroids[t][1] /= ps_total;
141 m_Centroids[t][2] /= ps_total;
146 if (m_PointSet ==
nullptr)
150 vnl_matrix<mitk::ScalarType> dataM(m_PointSet->GetSize(t), 3);
152 int ps_total = m_PointSet->GetSize(t);
153 for (
int i = 0; i < ps_total; i++)
156 dataM[i][0] = p3d[0] - m_Centroids[t][0];
157 dataM[i][1] = p3d[1] - m_Centroids[t][1];
158 dataM[i][2] = p3d[2] - m_Centroids[t][2];
162 vnl_svd<mitk::ScalarType> svd(dataM, 0.0);
165 vnl_vector<mitk::ScalarType> v = svd.nullvector();
174 m_PlaneVectors[t][0] = v[0];
175 m_PlaneVectors[t][1] = v[1];
176 m_PlaneVectors[t][2] = v[2];
186 return m_PlaneVectors[t];
191 return m_Centroids[t];
196 m_Planes[t]->InitializePlane(m_Centroids[t], m_PlaneVectors[t]);
virtual unsigned int GetPointSetSeriesSize() const
void CalculateCentroid(int t=0)
void InitializePlane(int t=0)
virtual void SetInput(const mitk::PointSet *ps)
virtual void GenerateOutputInformation() override
void ProcessPointSet(int t=0)
virtual void GenerateData() override
virtual const mitk::Point3D & GetCentroid(int t=0) const
Data structure which stores a set of points. Superclass of mitk::Mesh.
virtual const mitk::Vector3D & GetPlaneNormal(int t=0) const
std::vcl_size_t TimeStepType
virtual mitk::PlaneGeometry::Pointer GetPlaneGeometry(int t=0)
const mitk::PointSet * GetInput()