99 vtkPointSet *inputSurface = vtkPointSet::GetData(inputVector[0]);
102 printErr(
"Unable to load triangulation.");
108 vtkTable *distanceMatrixVTK = vtkTable::GetData(inputVector[1]);
109 std::vector<tableDataType *> distanceMatrix;
110 if(distanceMatrixVTK) {
111 auto noRows = distanceMatrixVTK->GetNumberOfRows();
112 distanceMatrix = std::vector<tableDataType *>(noRows);
113 for(
unsigned int i = 0; i < noRows; ++i) {
114 auto row = vtkDataArray::SafeDownCast(distanceMatrixVTK->GetColumn(i));
116 printErr(
"Unable to load column " + std::to_string(i)
117 +
" in the distance matrix.");
120 distanceMatrix[i] = ttkUtils::GetPointer<tableDataType>(row);
128 metricArea_, ratioArea_);
131 surfaceDistance_, metricDistance_, ratioDistance_,
132 surfacePointDistance_, metricPointDistance_,
133 ratioPointDistance_);
136 surfaceCurvature_, metricCurvature_, diffCurvature_);
142 vtkInformationVector **inputVector,
143 vtkInformationVector *outputVector) {
149 vtkPointSet *inputSurface = vtkPointSet::GetData(inputVector[0]);
151 printErr(
"Unable to load input surface.");
154 auto noPoints = inputSurface->GetNumberOfPoints();
156 printErr(
"Input surface should not have 0 points.");
159 auto noCells = inputSurface->GetNumberOfCells();
161 vtkTable *distanceMatrixVTK = vtkTable::GetData(inputVector[1]);
162 bool const validDistanceMatrix
164 and distanceMatrixVTK->GetNumberOfColumns() == noPoints);
165 if(distanceMatrixVTK and not validDistanceMatrix) {
166 printErr(
"Distance matrix should have the same number of rows/columns than "
167 "the surface's number of points.");
171 and distanceMatrixVTK->GetNumberOfColumns()
172 != distanceMatrixVTK->GetNumberOfRows()) {
173 printErr(
"Distance matrix should be square.");
176 int const tableDataType
177 = (validDistanceMatrix ? distanceMatrixVTK->GetColumn(0)->GetDataType()
180 surfaceArea_.clear();
183 surfaceDistance_.clear();
184 metricDistance_.clear();
185 ratioDistance_.clear();
186 surfacePointDistance_.clear();
187 metricPointDistance_.clear();
188 ratioPointDistance_.clear();
189 surfaceCurvature_.clear();
190 metricCurvature_.clear();
191 diffCurvature_.clear();
193 switch(tableDataType) {
194 vtkTemplateMacro(res = this->run<VTK_TT>(inputVector));
203 auto outputSurface = vtkPointSet::GetData(outputVector, 0);
204 outputSurface->DeepCopy(inputSurface);
206 vtkNew<vtkDoubleArray> surfaceCurvature_Array{};
207 surfaceCurvature_Array->SetName(
"SurfaceCurvature");
208 surfaceCurvature_Array->SetNumberOfTuples(noPoints);
209 vtkNew<vtkDoubleArray> metricCurvature_Array{};
210 metricCurvature_Array->SetName(
"MetricCurvature");
211 metricCurvature_Array->SetNumberOfTuples(noPoints);
212 vtkNew<vtkDoubleArray> ratioCurvatureArray{};
213 ratioCurvatureArray->SetName(
"CurvatureDiff");
214 ratioCurvatureArray->SetNumberOfTuples(noPoints);
216 for(
unsigned int i = 0; i < noPoints; ++i) {
217 surfaceCurvature_Array->SetTuple1(i, surfaceCurvature_[i]);
218 metricCurvature_Array->SetTuple1(i, metricCurvature_[i]);
219 ratioCurvatureArray->SetTuple1(i, diffCurvature_[i]);
222 outputSurface->GetPointData()->AddArray(surfaceCurvature_Array);
223 if(validDistanceMatrix) {
224 outputSurface->GetPointData()->AddArray(metricCurvature_Array);
225 outputSurface->GetPointData()->AddArray(ratioCurvatureArray);
228 for(
unsigned int i = 0; i < 3; ++i) {
229 std::string
const type{(i == 0 ?
"Min" : (i == 1) ?
"Max" :
"Avg")};
230 vtkNew<vtkDoubleArray> surfaceIDistanceArray{};
231 surfaceIDistanceArray->SetName((type +
"SurfaceEdgeLength").c_str());
232 surfaceIDistanceArray->SetNumberOfTuples(noPoints);
233 vtkNew<vtkDoubleArray> metricIDistanceArray{};
234 metricIDistanceArray->SetName((type +
"MetricEdgeLength").c_str());
235 metricIDistanceArray->SetNumberOfTuples(noPoints);
236 vtkNew<vtkDoubleArray> ratioIDistanceArray{};
237 ratioIDistanceArray->SetName((type +
"EdgeLengthRatio").c_str());
238 ratioIDistanceArray->SetNumberOfTuples(noPoints);
239 for(
unsigned int j = 0; j < noPoints; ++j) {
240 surfaceIDistanceArray->SetTuple1(j, surfacePointDistance_[j][i]);
241 metricIDistanceArray->SetTuple1(j, metricPointDistance_[j][i]);
242 ratioIDistanceArray->SetTuple1(j, ratioPointDistance_[j][i]);
244 outputSurface->GetPointData()->AddArray(surfaceIDistanceArray);
245 if(validDistanceMatrix) {
246 outputSurface->GetPointData()->AddArray(metricIDistanceArray);
247 outputSurface->GetPointData()->AddArray(ratioIDistanceArray);
252 vtkNew<vtkDoubleArray> surfaceArea_Array{};
253 surfaceArea_Array->SetName(
"SurfaceArea");
254 surfaceArea_Array->SetNumberOfTuples(noCells);
255 vtkNew<vtkDoubleArray> metricArea_Array{};
256 metricArea_Array->SetName(
"MetricArea");
257 metricArea_Array->SetNumberOfTuples(noCells);
258 vtkNew<vtkDoubleArray> ratioArea_Array{};
259 ratioArea_Array->SetName(
"AreaRatio");
260 ratioArea_Array->SetNumberOfTuples(noCells);
262 vtkNew<vtkDoubleArray> surfaceDistance_Array{};
263 surfaceDistance_Array->SetName(
"SurfaceEdgeLength");
264 surfaceDistance_Array->SetNumberOfTuples(noCells);
265 vtkNew<vtkDoubleArray> metricDistance_Array{};
266 metricDistance_Array->SetName(
"MetricEdgeLength");
267 metricDistance_Array->SetNumberOfTuples(noCells);
268 vtkNew<vtkDoubleArray> ratioDistance_Array{};
269 ratioDistance_Array->SetName(
"EdgeLengthRatio");
270 ratioDistance_Array->SetNumberOfTuples(noCells);
272 bool distanceAllNan =
true;
273 for(
unsigned int i = 0; i < noCells; ++i) {
274 surfaceArea_Array->SetTuple1(i, surfaceArea_[i]);
275 metricArea_Array->SetTuple1(i, metricArea_[i]);
276 ratioArea_Array->SetTuple1(i, ratioArea_[i]);
277 surfaceDistance_Array->SetTuple1(i, surfaceDistance_[i]);
278 metricDistance_Array->SetTuple1(i, metricDistance_[i]);
279 ratioDistance_Array->SetTuple1(i, ratioDistance_[i]);
280 if(surfaceDistance_[i] == surfaceDistance_[i])
281 distanceAllNan =
false;
284 outputSurface->GetCellData()->AddArray(surfaceArea_Array);
285 if(validDistanceMatrix) {
286 outputSurface->GetCellData()->AddArray(metricArea_Array);
287 outputSurface->GetCellData()->AddArray(ratioArea_Array);
289 if(not distanceAllNan) {
290 outputSurface->GetCellData()->AddArray(surfaceDistance_Array);
291 if(validDistanceMatrix) {
292 outputSurface->GetCellData()->AddArray(metricDistance_Array);
293 outputSurface->GetCellData()->AddArray(ratioDistance_Array);