TTK
Loading...
Searching...
No Matches
ttkReebSpace.cpp
Go to the documentation of this file.
1#include <vtkCellArray.h>
2#include <vtkCellData.h>
3#include <vtkDataArray.h>
4#include <vtkDoubleArray.h>
5#include <vtkInformation.h>
6#include <vtkNew.h>
7#include <vtkObjectFactory.h>
8#include <vtkPointData.h>
9#include <vtkSignedCharArray.h>
10#include <vtkUnstructuredGrid.h>
11
12#include <ttkMacros.h>
13#include <ttkReebSpace.h>
14#include <ttkUtils.h>
15
17
19 this->SetNumberOfInputPorts(1);
20 this->SetNumberOfOutputPorts(4);
21}
22
23int ttkReebSpace::FillInputPortInformation(int port, vtkInformation *info) {
24 if(port == 0) {
25 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet");
26 return 1;
27 }
28 return 0;
29}
30
31int ttkReebSpace::FillOutputPortInformation(int port, vtkInformation *info) {
32 if(port == 0 || port == 1 || port == 2) {
33 // 0-sheets, corners of jacobi set segments
34 // 1-sheets, jacobi sets
35 // 2-sheets, fiber surfaces of jacobi sets
36 info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkUnstructuredGrid");
37 return 1;
38 } else if(port == 3) {
40 return 1;
41 }
42 return 0;
43}
44
45template <class dataTypeU, class dataTypeV>
46int ttkReebSpace::dispatch(const dataTypeU *const uField,
47 const dataTypeV *const vField,
48 ttk::Triangulation *const triangulation) {
49
50 bool VaryingValues = this->setRangeDrivenOctree(UseOctreeAcceleration);
51
52 bool VaryingTriangulation = false;
53 if(triangulation->isEmpty())
54 VaryingTriangulation = true;
55
56 // go!
57 if(this->empty() || VaryingValues || VaryingTriangulation) {
58 this->printMsg("Starting computation");
60 triangulation->getType(),
61 this->execute(
62 uField, vField, *static_cast<TTK_TT *>(triangulation->getData())));
63 }
64
65 if(SimplificationThreshold > 0) {
67 triangulation->getType(),
68 this->simplify(uField, vField,
69 *static_cast<TTK_TT *>(triangulation->getData()),
70 SimplificationThreshold,
71 static_cast<ReebSpace::SimplificationCriterion>(
73 }
74
75 Modified();
76
77 return 0;
78}
79int ttkReebSpace::RequestData(vtkInformation *ttkNotUsed(request),
80 vtkInformationVector **inputVector,
81 vtkInformationVector *outputVector) {
82
83 const auto input = vtkDataSet::GetData(inputVector[0]);
84 auto sheet0 = vtkUnstructuredGrid::GetData(outputVector, 0);
85 auto sheet1 = vtkUnstructuredGrid::GetData(outputVector, 1);
86 auto sheet2 = vtkUnstructuredGrid::GetData(outputVector, 2);
87 auto sheet3 = vtkDataSet::GetData(outputVector, 3);
88
89 const auto uComponent = this->GetInputArrayToProcess(0, inputVector);
90 const auto vComponent = this->GetInputArrayToProcess(1, inputVector);
91 const auto offsetFieldU
92 = this->GetOrderArray(input, 0, 2, ForceInputOffsetScalarField);
93 const auto offsetFieldV
94 = this->GetOrderArray(input, 1, 3, ForceInputOffsetScalarField);
95
96 // check data components
97
98 if(uComponent == nullptr || vComponent == nullptr) {
99 return -1;
100 }
101
102 this->printMsg("U-component: `" + std::string{uComponent->GetName()} + "'");
103 this->printMsg("V-component: `" + std::string{vComponent->GetName()} + "'");
104
105 auto triangulation = ttkAlgorithm::GetTriangulation(input);
106 if(triangulation == nullptr) {
107 return -3;
108 }
109 this->preconditionTriangulation(triangulation);
110
111 this->setSosOffsetsU(
112 static_cast<ttk::SimplexId *>(ttkUtils::GetVoidPointer(offsetFieldU)));
113 this->setSosOffsetsV(
114 static_cast<ttk::SimplexId *>(ttkUtils::GetVoidPointer(offsetFieldV)));
115
116#ifndef TTK_ENABLE_DOUBLE_TEMPLATING
117 if(uComponent->GetDataType() != vComponent->GetDataType()) {
118 this->printErr(
119 "Scalar fields should have same input type. Use TTKPointDataConverter or "
120 "TTKArrayEditor to convert array types.");
121 return 0;
122 }
123 switch(uComponent->GetDataType()) {
124 vtkTemplateMacro(
125 dispatch(static_cast<VTK_TT *>(ttkUtils::GetVoidPointer(uComponent)),
126 static_cast<VTK_TT *>(ttkUtils::GetVoidPointer(vComponent)),
127 triangulation));
128 }
129#else
130 switch(vtkTemplate2PackMacro(
131 uComponent->GetDataType(), vComponent->GetDataType())) {
132 vtkTemplate2Macro(
133 dispatch(static_cast<VTK_T1 *>(ttkUtils::GetVoidPointer(uComponent)),
134 static_cast<VTK_T2 *>(ttkUtils::GetVoidPointer(vComponent)),
135 triangulation));
136 }
137#endif // TTK_ENABLE_DOUBLE_TEMPLATING
138
139 // prepare the output
140 this->printMsg("Preparing the VTK output...");
141
142 // 0-sheets -
143 // Optional additional fields:
144 // PointData; u, v, vertexId, type, sheetId
145 const auto sheet0segmentation = this->get0sheetSegmentation();
146 int vertexNumber = 0;
147 for(size_t i = 0; i < sheet0segmentation->size(); i++) {
148 int sheet0Id = (*sheet0segmentation)[i];
149 if(sheet0Id != -1) {
150 const ReebSpace::Sheet0 *sheet = this->get0sheet(sheet0Id);
151 if(sheet != nullptr && !sheet->pruned_) {
152 vertexNumber++;
153 }
154 }
155 }
156 vtkNew<vtkPoints> sheet0Points{};
157 if(!sheet0->GetPoints())
158 sheet0->SetPoints(sheet0Points);
159
160 sheet0->GetPoints()->SetNumberOfPoints(vertexNumber);
161
162 vtkNew<vtkDoubleArray> vertexScalarsU{};
163 vtkNew<vtkDoubleArray> vertexScalarsV{};
164 if(ZeroSheetValue) {
165 vertexScalarsU->SetNumberOfTuples(vertexNumber);
166 vertexScalarsU->SetName(uComponent->GetName());
167 vertexScalarsV->SetNumberOfTuples(vertexNumber);
168 vertexScalarsV->SetName(vComponent->GetName());
169 } else {
170 sheet0->GetPointData()->RemoveArray(uComponent->GetName());
171 sheet0->GetPointData()->RemoveArray(vComponent->GetName());
172 }
173
174 vtkNew<ttkSimplexIdTypeArray> vertexIds{};
175 if(ZeroSheetVertexId) {
176 vertexIds->SetNumberOfTuples(vertexNumber);
177 vertexIds->SetName(ttk::VertexScalarFieldName);
178 } else {
179 sheet0->GetPointData()->RemoveArray(ttk::VertexScalarFieldName);
180 }
181
182 vtkNew<vtkSignedCharArray> vertexTypes{};
183 if(ZeroSheetType) {
184 vertexTypes->SetNumberOfTuples(vertexNumber);
185 vertexTypes->SetName("SheetType");
186 } else {
187 sheet0->GetPointData()->RemoveArray("SheetType");
188 }
189
190 vtkNew<ttkSimplexIdTypeArray> vertexSheetId{};
191 if(ZeroSheetId) {
192 vertexSheetId->SetNumberOfTuples(vertexNumber);
193 vertexSheetId->SetName("0-SheetId");
194 } else {
195 sheet0->GetPointData()->RemoveArray("0-SheetId");
196 }
197
198 vertexNumber = 0;
199 double *p = nullptr;
200 for(size_t i = 0; i < sheet0segmentation->size(); i++) {
201 int sheet0Id = (*sheet0segmentation)[i];
202 if(sheet0Id != -1) {
203
204 const ReebSpace::Sheet0 *sheet = this->get0sheet(sheet0Id);
205
206 if(sheet != nullptr && !sheet->pruned_) {
207 p = input->GetPoint(i);
208
209 sheet0->GetPoints()->SetPoint(vertexNumber, p);
210
211 if(ZeroSheetId) {
212 vertexSheetId->SetTuple1(vertexNumber, (*sheet0segmentation)[i]);
213 }
214 if(ZeroSheetVertexId) {
215 vertexIds->SetTuple1(vertexNumber, i);
216 }
217 if(ZeroSheetValue) {
218 double u, v;
219
220 uComponent->GetTuple(i, &u);
221 vComponent->GetTuple(i, &v);
222
223 vertexScalarsU->SetTuple1(vertexNumber, u);
224 vertexScalarsV->SetTuple1(vertexNumber, v);
225 }
226 if(ZeroSheetType) {
227 const ReebSpace::Sheet0 *sht0
228 = this->get0sheet((*sheet0segmentation)[i]);
229 vertexTypes->SetTuple1(vertexNumber, sht0->type_);
230 }
231
232 vertexNumber++;
233 }
234 }
235 }
236 if(ZeroSheetId)
237 sheet0->GetPointData()->AddArray(vertexSheetId);
238 if(ZeroSheetVertexId)
239 sheet0->GetPointData()->AddArray(vertexIds);
240 if(ZeroSheetValue) {
241 sheet0->GetPointData()->AddArray(vertexScalarsU);
242 sheet0->GetPointData()->AddArray(vertexScalarsV);
243 }
244 if(ZeroSheetType)
245 sheet0->GetPointData()->AddArray(vertexTypes);
246
247 // 1-sheets
248 // Optional additional fields:
249 // PointData: u, v, vertexId,
250 // CellData: edgeId, type, sheetId
251 const auto sheet1segmentation = this->get1sheetSegmentation();
252
253 vtkNew<vtkPoints> sheet1Points{};
254 sheet1->SetPoints(sheet1Points);
255
256 vtkNew<vtkCellArray> sheet1Edges{};
257 vtkNew<vtkDoubleArray> edgeScalarsU{};
258 vtkNew<vtkDoubleArray> edgeScalarsV{};
259
260 if(OneSheetValue) {
261 edgeScalarsU->SetName(uComponent->GetName());
262 edgeScalarsV->SetName(vComponent->GetName());
263 } else {
264 sheet1->GetPointData()->RemoveArray(uComponent->GetName());
265 sheet1->GetPointData()->RemoveArray(vComponent->GetName());
266 }
267
268 vtkNew<ttkSimplexIdTypeArray> edgeVertexIds{};
269 if(OneSheetVertexId) {
270 edgeVertexIds->SetName(ttk::VertexScalarFieldName);
271 } else {
272 sheet1->GetPointData()->RemoveArray(ttk::VertexScalarFieldName);
273 }
274
275 vtkNew<vtkIntArray> edgeType{};
276 if(OneSheetType) {
277 edgeType->SetName("EdgeType");
278 } else {
279 sheet1->GetCellData()->RemoveArray("EdgeType");
280 }
281
282 vtkNew<ttkSimplexIdTypeArray> edgeIds{};
283 if(OneSheetEdgeId) {
284 edgeIds->SetName("EdgeIds");
285 } else {
286 sheet1->GetCellData()->RemoveArray("EdgeIds");
287 }
288
289 vtkNew<ttkSimplexIdTypeArray> edgeSheetIds{};
290 if(OneSheetId) {
291 edgeSheetIds->SetName("1-SheetId");
292 } else {
293 sheet1->GetCellData()->RemoveArray("1-SheetId");
294 }
295
296 vertexNumber = 0;
297 double p0[3], p1[3];
298 vtkNew<vtkIdList> idList{};
299 idList->SetNumberOfIds(2);
300 const auto edgeTypes = this->getEdgeTypes();
301
302 for(size_t i = 0; i < sheet1segmentation->size(); i++) {
303
304 int sheet1Id = (*sheet1segmentation)[i];
305
306 if(sheet1Id != -1) {
307
308 const ReebSpace::Sheet1 *sheet = this->get1sheet(sheet1Id);
309
310 if((sheet) && (!sheet->pruned_)) {
311
312 ttk::SimplexId vertexId0 = -1, vertexId1 = -1;
313 triangulation->getEdgeVertex(i, 0, vertexId0);
314 triangulation->getEdgeVertex(i, 1, vertexId1);
315
316 input->GetPoint(vertexId0, p0);
317 input->GetPoint(vertexId1, p1);
318
319 sheet1->GetPoints()->InsertNextPoint(p0);
320 sheet1->GetPoints()->InsertNextPoint(p1);
321
322 if(OneSheetValue) {
323 double u, v;
324 uComponent->GetTuple(vertexId0, &u);
325 vComponent->GetTuple(vertexId0, &v);
326
327 edgeScalarsU->InsertNextTuple1(u);
328 edgeScalarsV->InsertNextTuple1(v);
329
330 uComponent->GetTuple(vertexId1, &u);
331 vComponent->GetTuple(vertexId1, &v);
332
333 edgeScalarsU->InsertNextTuple1(u);
334 edgeScalarsV->InsertNextTuple1(v);
335 }
336
337 if(OneSheetVertexId) {
338 edgeVertexIds->InsertNextTuple1(vertexId0);
339 edgeVertexIds->InsertNextTuple1(vertexId1);
340 }
341
342 idList->SetId(0, vertexNumber);
343 idList->SetId(1, vertexNumber + 1);
344 sheet1Edges->InsertNextCell(idList);
345 vertexNumber += 2;
346
347 if(OneSheetEdgeId) {
348 edgeIds->InsertNextTuple1(i);
349 }
350 if(OneSheetType) {
351 edgeType->InsertNextTuple1((*edgeTypes)[i]);
352 }
353 if(OneSheetId) {
354 edgeSheetIds->InsertNextTuple1((*sheet1segmentation)[i]);
355 }
356 }
357 }
358 }
359
360 sheet1->SetCells(VTK_LINE, sheet1Edges);
361
362 if(OneSheetValue) {
363 sheet1->GetPointData()->AddArray(edgeScalarsU);
364 sheet1->GetPointData()->AddArray(edgeScalarsV);
365 }
366 if(OneSheetVertexId) {
367 sheet1->GetPointData()->AddArray(edgeVertexIds);
368 }
369 if(OneSheetId) {
370 sheet1->GetCellData()->AddArray(edgeSheetIds);
371 }
372 if(OneSheetEdgeId) {
373 sheet1->GetCellData()->AddArray(edgeIds);
374 }
375 if(OneSheetType) {
376 sheet1->GetCellData()->AddArray(edgeType);
377 }
378
379 // 2-sheets
380 // optional fields:
381 // pointdata: twoSheetValues, twoSheetParameterization
382 if(TwoSheets) {
383 const std::vector<ttk::FiberSurface::Vertex> *vertexList
384 = this->getFiberSurfaceVertices();
385
386 vtkNew<vtkPoints> sheet2Points{};
387 sheet2Points->SetNumberOfPoints(vertexList->size());
388 sheet2->SetPoints(sheet2Points);
389
390 vtkNew<vtkDoubleArray> triangleScalarsU{};
391 vtkNew<vtkDoubleArray> triangleScalarsV{};
392
393 if(TwoSheetValue) {
394 triangleScalarsU->SetName(uComponent->GetName());
395 triangleScalarsU->SetNumberOfTuples(vertexList->size());
396 triangleScalarsV->SetName(vComponent->GetName());
397 triangleScalarsV->SetNumberOfTuples(vertexList->size());
398 } else {
399 sheet2->GetPointData()->RemoveArray(uComponent->GetName());
400 sheet2->GetPointData()->RemoveArray(vComponent->GetName());
401 }
402
403 vtkNew<vtkDoubleArray> triangleParameterization{};
404 if(TwoSheetParameterization) {
405 triangleParameterization->SetName("EdgeParameterization");
406 triangleParameterization->SetNumberOfTuples(vertexList->size());
407 } else {
408 sheet2->GetPointData()->RemoveArray("EdgeParameterization");
409 }
410
411 int sheet2TriangleNumber = 0;
412 for(int i = 0; i < this->getNumberOf2sheets(); i++) {
413 const ReebSpace::Sheet2 *sheet = this->get2sheet(i);
414
415 if(sheet != nullptr && !sheet->pruned_) {
416 for(size_t j = 0; j < sheet->triangleList_.size(); j++) {
417 sheet2TriangleNumber += sheet->triangleList_[j].size();
418 }
419 }
420 }
421
422 vtkNew<vtkCellArray> sheet2Triangles{};
423
424 // celldata: twoSheetId, twoSheetEdgeId, twoSheetTetId
425 vtkNew<ttkSimplexIdTypeArray> triangleSheetIds{};
426 if(TwoSheetId) {
427 triangleSheetIds->SetName("2-SheetId");
428 triangleSheetIds->SetNumberOfTuples(sheet2TriangleNumber);
429 } else {
430 sheet2->GetCellData()->RemoveArray("2-SheetId");
431 }
432
433 vtkNew<ttkSimplexIdTypeArray> triangleEdgeIds{};
434 if(TwoSheetEdgeId) {
435 triangleEdgeIds->SetName("EdgeIds");
436 triangleEdgeIds->SetNumberOfTuples(sheet2TriangleNumber);
437 } else {
438 sheet2->GetCellData()->RemoveArray("EdgeIds");
439 }
440
441 vtkNew<vtkIntArray> triangleEdgeType{};
442 if(TwoSheetEdgeType) {
443 triangleEdgeType->SetName("EdgeType");
444 triangleEdgeType->SetNumberOfTuples(sheet2TriangleNumber);
445 } else {
446 sheet2->GetCellData()->RemoveArray("EdgeType");
447 }
448
449 vtkNew<ttkSimplexIdTypeArray> triangleTetIds{};
450 if(TwoSheetTetId) {
451 triangleTetIds->SetName("TetIds");
452 triangleTetIds->SetNumberOfTuples(sheet2TriangleNumber);
453 } else {
454 sheet2->GetCellData()->RemoveArray("TetIds");
455 }
456
457 vtkNew<ttkSimplexIdTypeArray> triangleCaseIds{};
458 if(TwoSheetCaseId) {
459 triangleCaseIds->SetName("CaseIds");
460 triangleCaseIds->SetNumberOfTuples(sheet2TriangleNumber);
461 } else {
462 sheet2->GetCellData()->RemoveArray("CaseIds");
463 }
464
465 for(size_t i = 0; i < vertexList->size(); i++) {
466 sheet2->GetPoints()->SetPoint(i, (*vertexList)[i].p_[0],
467 (*vertexList)[i].p_[1],
468 (*vertexList)[i].p_[2]);
469
470 if(TwoSheetValue) {
471 triangleScalarsU->SetTuple1(i, (*vertexList)[i].uv_.first);
472 triangleScalarsV->SetTuple1(i, (*vertexList)[i].uv_.second);
473 }
474 if(TwoSheetParameterization) {
475 triangleParameterization->SetTuple1(i, (*vertexList)[i].t_);
476 }
477 }
478 if(TwoSheetValue) {
479 sheet2->GetPointData()->AddArray(triangleScalarsU);
480 sheet2->GetPointData()->AddArray(triangleScalarsV);
481 }
482 if(TwoSheetParameterization) {
483 sheet2->GetPointData()->AddArray(triangleParameterization);
484 }
485
486 int triangleNumber = 0;
487 idList->SetNumberOfIds(3);
488 for(int i = 0; i < this->getNumberOf2sheets(); i++) {
489 const ReebSpace::Sheet2 *sht2 = this->get2sheet(i);
490
491 if(sht2 != nullptr && !sht2->pruned_) {
492 for(size_t j = 0; j < sht2->triangleList_.size(); j++) {
493
494 for(size_t k = 0; k < sht2->triangleList_[j].size(); k++) {
495
496 for(int l = 0; l < 3; l++) {
497 idList->SetId(l, sht2->triangleList_[j][k].vertexIds_[l]);
498 }
499
500 sheet2Triangles->InsertNextCell(idList);
501
502 if(TwoSheetId) {
503 triangleSheetIds->SetTuple1(triangleNumber, i);
504 }
505
506 if(TwoSheetEdgeId) {
507 const ReebSpace::Sheet1 *sht1 = this->get1sheet(sht2->sheet1Id_);
508 triangleEdgeIds->SetTuple1(triangleNumber, sht1->edgeList_[j]);
509 }
510
511 if(TwoSheetEdgeType) {
512 auto polygonEdgeId = sht2->triangleList_[j][k].polygonEdgeId_;
513 auto edgeId = this->getJacobi2Edge(polygonEdgeId);
514 triangleEdgeType->SetTuple1(triangleNumber, (*edgeTypes)[edgeId]);
515 }
516
517 if(TwoSheetTetId) {
518 triangleTetIds->SetTuple1(
519 triangleNumber, sht2->triangleList_[j][k].tetId_);
520 }
521 if(TwoSheetCaseId) {
522 triangleCaseIds->SetTuple1(
523 triangleNumber, sht2->triangleList_[j][k].caseId_);
524 }
525
526 triangleNumber++;
527 }
528 }
529 }
530 }
531 sheet2->SetCells(VTK_TRIANGLE, sheet2Triangles);
532
533 if(TwoSheetId) {
534 sheet2->GetCellData()->AddArray(triangleSheetIds);
535 }
536 if(TwoSheetEdgeId) {
537 sheet2->GetCellData()->AddArray(triangleEdgeIds);
538 }
539 if(TwoSheetEdgeType) {
540 sheet2->GetCellData()->AddArray(triangleEdgeType);
541 }
542 if(TwoSheetTetId) {
543 sheet2->GetCellData()->AddArray(triangleTetIds);
544 }
545 if(TwoSheetCaseId) {
546 sheet2->GetCellData()->AddArray(triangleCaseIds);
547 }
548 }
549
550 // now take care of the 3 sheets
551 // vector<float> *triangulationPoints
552 // = reebSpace_.getSheetTriangulationPoints();
553 // vector<long long int> *triangulationCells
554 // = reebSpace_.getSheetTriangulationCells();
555 //
556 // vtkSmartPointer<vtkPoints> sheet3Points =
557 // vtkSmartPointer<vtkPoints>::New(); vtkSmartPointer<vtkFloatArray>
558 // pointData =
559 // vtkSmartPointer<vtkFloatArray>::New();
560 // pointData->SetNumberOfComponents(3);
561 // ttkUtils::SetVoidArray(
562 // pointData, triangulationPoints->data(), triangulationPoints->size(),
563 // 1);
564 // sheet3Points->SetData(pointData);
565 // sheet3->SetPoints(sheet3Points);
566 //
567 // vtkSmartPointer<vtkCellArray> sheet3Cells
568 // = vtkSmartPointer<vtkCellArray>::New();
569 // vtkSmartPointer<ttkSimplexIdTypeArray> idArray
570 // = vtkSmartPointer<ttkSimplexIdTypeArray>::New();
571 // ttkUtils::SetVoidArray(
572 // idArray, triangulationCells->data(), triangulationCells->size(), 1);
573 // sheet3Cells->SetCells(triangulationCells->size()/5, idArray);
574 // sheet3->SetCells(VTK_TETRA, sheet3Cells);
575
576 // now take care of the 3 sheets
577 sheet3->ShallowCopy(input);
578 const auto vertex3sheets = this->get3sheetVertexSegmentation();
579
580 vtkNew<ttkSimplexIdTypeArray> vertexNumberField{};
581 vtkNew<ttkSimplexIdTypeArray> tetNumberField{};
582
583 if(ThreeSheetTetNumber) {
584 tetNumberField->SetNumberOfTuples(input->GetNumberOfPoints());
585 tetNumberField->SetName("3-SheetTetNumber");
586 for(int i = 0; i < input->GetNumberOfPoints(); i++) {
587 const ReebSpace::Sheet3 *sht3 = this->get3sheet((*vertex3sheets)[i]);
588 if((sht3) && (!sht3->pruned_))
589 tetNumberField->SetTuple1(i, sht3->tetList_.size());
590 else
591 tetNumberField->SetTuple1(i, 0);
592 }
593 sheet3->GetPointData()->AddArray(tetNumberField);
594 } else {
595 sheet3->GetPointData()->RemoveArray("3-SheetTetNumber");
596 }
597
598 if(ThreeSheetVertexNumber) {
599 vertexNumberField->SetNumberOfTuples(input->GetNumberOfPoints());
600 vertexNumberField->SetName("3-SheetVertexNumber");
601 for(int i = 0; i < input->GetNumberOfPoints(); i++) {
602 const ReebSpace::Sheet3 *sht3 = this->get3sheet((*vertex3sheets)[i]);
603 if((sht3) && (!sht3->pruned_))
604 vertexNumberField->SetTuple1(i, sht3->vertexList_.size());
605 else
606 vertexNumberField->SetTuple1(i, 0);
607 }
608 sheet3->GetPointData()->AddArray(vertexNumberField);
609 } else {
610 sheet3->GetPointData()->RemoveArray("3-SheetTetNumber");
611 }
612
613 vtkNew<vtkDoubleArray> domainVolume{};
614 if(ThreeSheetDomainVolume) {
615 domainVolume->SetNumberOfTuples(input->GetNumberOfPoints());
616 domainVolume->SetName("3-SheetDomainVolume");
617
618 for(int i = 0; i < input->GetNumberOfPoints(); i++) {
619 const ReebSpace::Sheet3 *sht3 = this->get3sheet((*vertex3sheets)[i]);
620 if((sht3) && (!sht3->pruned_)) {
621 domainVolume->SetTuple1(i, sht3->domainVolume_);
622 } else {
623 domainVolume->SetTuple1(i, 0);
624 }
625 }
626
627 sheet3->GetPointData()->AddArray(domainVolume);
628 } else {
629 sheet3->GetPointData()->RemoveArray("3-SheetDomainVolume");
630 }
631
632 vtkNew<vtkDoubleArray> rangeArea{};
633 if(ThreeSheetDomainVolume) {
634 rangeArea->SetNumberOfTuples(input->GetNumberOfPoints());
635 rangeArea->SetName("3-SheetRangeArea");
636
637 for(int i = 0; i < input->GetNumberOfPoints(); i++) {
638 const ReebSpace::Sheet3 *sht3 = this->get3sheet((*vertex3sheets)[i]);
639 if((sht3) && (!sht3->pruned_)) {
640 rangeArea->SetTuple1(i, sht3->rangeArea_);
641 } else {
642 rangeArea->SetTuple1(i, 0);
643 }
644 }
645
646 sheet3->GetPointData()->AddArray(rangeArea);
647 } else {
648 sheet3->GetPointData()->RemoveArray("3-SheetRangeArea");
649 }
650
651 vtkNew<vtkDoubleArray> hyperVolume{};
652 if(ThreeSheetDomainVolume) {
653 hyperVolume->SetNumberOfTuples(input->GetNumberOfPoints());
654 hyperVolume->SetName("3-SheetHyperVolume");
655
656 for(int i = 0; i < input->GetNumberOfPoints(); i++) {
657 const ReebSpace::Sheet3 *sht3 = this->get3sheet((*vertex3sheets)[i]);
658 if((sht3) && (!sht3->pruned_)) {
659 hyperVolume->SetTuple1(i, sht3->hyperVolume_);
660 } else {
661 hyperVolume->SetTuple1(i, 0);
662 }
663 }
664
665 sheet3->GetPointData()->AddArray(hyperVolume);
666 } else {
667 sheet3->GetPointData()->RemoveArray("3-SheetHyperVolume");
668 }
669
670 vtkNew<ttkSimplexIdTypeArray> vertexSegmentation{};
671 vertexSegmentation->SetName("3-SheetId");
672 vertexSegmentation->SetNumberOfTuples(input->GetNumberOfPoints());
673 for(int i = 0; i < input->GetNumberOfPoints(); i++) {
674 const ReebSpace::Sheet3 *sheet = this->get3sheet((*vertex3sheets)[i]);
675 if(sheet) {
676 vertexSegmentation->SetTuple1(i, sheet->simplificationId_);
677 } else {
678 vertexSegmentation->SetTuple1(i, (*vertex3sheets)[i]);
679 }
680 }
681 sheet3->GetPointData()->AddArray(vertexSegmentation);
682
683 const auto tet3sheets = this->get3sheetTetSegmentation();
684 vtkNew<ttkSimplexIdTypeArray> tetSegmentation{};
685 tetSegmentation->SetName("3-SheetId");
686 tetSegmentation->SetNumberOfTuples(input->GetNumberOfCells());
687 for(int i = 0; i < input->GetNumberOfCells(); i++) {
688 const ReebSpace::Sheet3 *sht3 = this->get3sheet((*tet3sheets)[i]);
689 if(sht3) {
690 tetSegmentation->SetTuple1(i, sht3->simplificationId_);
691 } else {
692 tetSegmentation->SetTuple1(i, (*tet3sheets)[i]);
693 }
694 }
695 sheet3->GetCellData()->AddArray(tetSegmentation);
696
697 return 1;
698}
#define ttkTemplateMacro(triangulationType, call)
#define ttkNotUsed(x)
Mark function/method parameters that are not used in the function body at all.
Definition: BaseClass.h:47
std::array< SimplexId, 2 > edgeType
static vtkInformationIntegerKey * SAME_DATA_TYPE_AS_INPUT_PORT()
vtkDataArray * GetOrderArray(vtkDataSet *const inputData, const int scalarArrayIdx, const int orderArrayIdx=0, const bool enforceOrderArrayIdx=false)
ttk::Triangulation * GetTriangulation(vtkDataSet *dataSet)
TTK VTK-filter that efficiently computes the Reeb space of bivariate volumetric data.
Definition: ttkReebSpace.h:77
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
int dispatch(const dataTypeU *const uField, const dataTypeV *const vField, ttk::Triangulation *const triangulation)
int FillInputPortInformation(int port, vtkInformation *info) override
int FillOutputPortInformation(int port, vtkInformation *info) override
static void * GetVoidPointer(vtkDataArray *array, vtkIdType start=0)
Definition: ttkUtils.cpp:225
int printMsg(const std::string &msg, const debug::Priority &priority=debug::Priority::INFO, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cout) const
Definition: Debug.h:118
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
Definition: Debug.h:149
void setSosOffsetsV(const SimplexId *const sosOffsetsV)
Definition: ReebSpace.h:232
const std::vector< SimplexId > * get0sheetSegmentation() const
Definition: ReebSpace.h:147
bool setRangeDrivenOctree(const bool &onOff)
Definition: ReebSpace.h:202
const std::vector< char > * getEdgeTypes() const
Definition: ReebSpace.h:163
int getJacobi2Edge(const SimplexId &jacobiEdgeId) const
Definition: ReebSpace.h:172
int preconditionTriangulation(AbstractTriangulation *const triangulation)
Definition: ReebSpace.h:250
bool empty() const
Definition: ReebSpace.h:96
const Sheet3 * get3sheet(const SimplexId &sheetId) const
Definition: ReebSpace.h:137
const std::vector< SimplexId > * get3sheetTetSegmentation() const
Definition: ReebSpace.h:159
const std::vector< SimplexId > * get3sheetVertexSegmentation() const
Definition: ReebSpace.h:155
const std::vector< SimplexId > * get1sheetSegmentation() const
Definition: ReebSpace.h:151
const Sheet0 * get0sheet(const SimplexId &sheetId) const
Definition: ReebSpace.h:105
const Sheet2 * get2sheet(const SimplexId &sheetId) const
Definition: ReebSpace.h:127
void setSosOffsetsU(const SimplexId *const sosOffsetsU)
Definition: ReebSpace.h:220
const Sheet1 * get1sheet(const SimplexId &sheetId) const
Definition: ReebSpace.h:116
const std::vector< FiberSurface::Vertex > * getFiberSurfaceVertices() const
Definition: ReebSpace.h:168
SimplexId getNumberOf2sheets() const
Definition: ReebSpace.h:179
Triangulation is a class that provides time and memory efficient traversal methods on triangulations ...
Definition: Triangulation.h:48
AbstractTriangulation * getData()
Triangulation::Type getType() const
bool isEmpty() const override
const char VertexScalarFieldName[]
default name for vertex scalar field
Definition: DataTypes.h:35
int SimplexId
Identifier type for simplices of any dimension.
Definition: DataTypes.h:22
vtkStandardNewMacro(ttkReebSpace)