| 137 | } |
| 138 | |
| 139 | void mitk::PlaneFit::ProcessPointSet(int t) |
| 140 | { |
| 141 | if (m_PointSet == nullptr) |
| 142 | return; |
| 143 | |
| 144 | // int matrix with POINTS x (X,Y,Z) |
| 145 | vnl_matrix<mitk::ScalarType> dataM(m_PointSet->GetSize(t), 3); |
| 146 | |
| 147 | int ps_total = m_PointSet->GetSize(t); |
| 148 | for (int i = 0; i < ps_total; i++) |
| 149 | { |
| 150 | mitk::Point3D p3d = m_PointSet->GetPoint(i, t); |
| 151 | dataM[i][0] = p3d[0] - m_Centroids[t][0]; |
| 152 | dataM[i][1] = p3d[1] - m_Centroids[t][1]; |
| 153 | dataM[i][2] = p3d[2] - m_Centroids[t][2]; |
| 154 | } |
| 155 | // process the SVD (singular value decomposition) from ITK |
| 156 | // the vector will be ordered descending |
| 157 | vnl_svd<mitk::ScalarType> svd(dataM, 0.0); |
| 158 | |
| 159 | // calculate the SVD of A |
| 160 | vnl_vector<mitk::ScalarType> v = svd.nullvector(); |
| 161 | |
| 162 | // Avoid erratic normal sign switching when the plane changes minimally |
| 163 | // by negating the vector for negative x values. |
| 164 | if (v[0] < 0) |
| 165 | { |
| 166 | v = -v; |
| 167 | } |
| 168 | |
| 169 | m_PlaneVectors[t][0] = v[0]; |
| 170 | m_PlaneVectors[t][1] = v[1]; |
| 171 | m_PlaneVectors[t][2] = v[2]; |
| 172 | } |
| 173 | |
| 174 | mitk::PlaneGeometry::Pointer mitk::PlaneFit::GetPlaneGeometry(int t) |
| 175 | { |
no test coverage detected