21 const std::vector<std::vector<double>> &embedding,
23 const std::vector<int> &removed,
24 vtkUnstructuredGrid *
const vtkOutputNode1,
25 vtkUnstructuredGrid *
const vtkOutputArc1,
26 const bool displayRemoved =
false) {
28 auto fullSize = intermediateMTrees.size() + removed.size();
29 std::vector<ttk::SimplexId> nodeSimplexId(fullSize);
30 vtkNew<vtkIntArray> treeId{};
31 treeId->SetName(
"TreeId");
32 vtkNew<vtkIntArray> nodePathId{};
33 nodePathId->SetName(
"NodePathId");
34 vtkNew<vtkIntArray> pathId{};
35 pathId->SetName(
"PathId");
36 vtkNew<vtkIntArray> nodeRemoved{};
37 nodeRemoved->SetName(
"isNodeRemoved");
38 vtkNew<vtkIntArray> nodeId{};
39 nodeId->SetName(
"NodeId");
40 vtkNew<vtkIntArray> arcId{};
41 arcId->SetName(
"ArcId");
43 vtkNew<vtkUnstructuredGrid> vtkArcs{};
44 vtkNew<vtkPoints> points{};
45 for(
unsigned int i = 0; i < embedding[0].size(); ++i) {
46 if(not displayRemoved and i >= intermediateMTrees.size())
50 double point[3] = {embedding[0][i], embedding[1][i], 0};
51 nodeSimplexId[i] = points->InsertNextPoint(point);
55 if(i >= intermediateMTrees.size())
56 index = removed[i - intermediateMTrees.size()];
57 treeId->InsertNextTuple1(index);
60 int thisPathId = (i < intermediateMTrees.size() ? 0 : 1);
61 nodePathId->InsertNextTuple1(thisPathId);
64 nodeId->InsertNextTuple1(i);
67 if(i > 0 and i < intermediateMTrees.size()) {
68 vtkIdType pointIds[2];
69 pointIds[0] = nodeSimplexId[i - 1];
70 pointIds[1] = nodeSimplexId[i];
71 vtkArcs->InsertNextCell(VTK_LINE, 2, pointIds);
74 pathId->InsertNextTuple1(0);
77 arcId->InsertNextTuple1(i);
82 for(
unsigned int i = 0; i < removed.size(); ++i) {
83 int const index = removed[i];
86 vtkIdType pointIds[2];
87 pointIds[0] = nodeSimplexId[index - 1];
88 pointIds[1] = nodeSimplexId[intermediateMTrees.size() + i];
89 vtkArcs->InsertNextCell(VTK_LINE, 2, pointIds);
90 pathId->InsertNextTuple1(1);
92 if(removed[i + 1] != index + 1) {
93 vtkIdType pointIds2[2];
94 pointIds2[0] = nodeSimplexId[intermediateMTrees.size() + i];
95 pointIds2[1] = nodeSimplexId[index + 1];
96 vtkArcs->InsertNextCell(VTK_LINE, 2, pointIds2);
97 pathId->InsertNextTuple1(1);
101 if(i > 0 and i < removed.size() - 1) {
102 vtkIdType pointIds[2];
104 = (removed[i - 1] == index - 1 ? intermediateMTrees.size() + i - 1
106 pointIds[0] = nodeSimplexId[prevIndex];
107 pointIds[1] = nodeSimplexId[intermediateMTrees.size() + i];
108 vtkArcs->InsertNextCell(VTK_LINE, 2, pointIds);
109 pathId->InsertNextTuple1(1);
111 vtkIdType pointIds2[2];
113 = (removed[i + 1] == index + 1 ? intermediateMTrees.size() + i + 1
115 pointIds2[0] = nodeSimplexId[intermediateMTrees.size() + i];
116 pointIds2[1] = nodeSimplexId[nextvIndex];
117 vtkArcs->InsertNextCell(VTK_LINE, 2, pointIds2);
118 pathId->InsertNextTuple1(1);
121 if(i == removed.size() - 1) {
122 vtkIdType pointIds[2];
123 pointIds[0] = nodeSimplexId[intermediateMTrees.size() + i];
124 pointIds[1] = nodeSimplexId[index + 1];
125 vtkArcs->InsertNextCell(VTK_LINE, 2, pointIds);
126 pathId->InsertNextTuple1(1);
128 if(removed[i - 1] != index - 1) {
129 vtkIdType pointIds2[2];
130 pointIds2[0] = nodeSimplexId[index - 1];
131 pointIds2[1] = nodeSimplexId[intermediateMTrees.size() + i];
132 vtkArcs->InsertNextCell(VTK_LINE, 2, pointIds2);
133 pathId->InsertNextTuple1(1);
138 for(
unsigned int i = 0; i < removed.size(); ++i) {
139 int before = removed[i] - 1;
142 while(before == removed[index]) {
143 before = removed[index] - 1;
147 int after = removed[i] + 1;
149 if(i < removed.size() - 1)
150 while(after == removed[index]) {
151 after = removed[index] + 1;
155 vtkIdType pointIds[2];
156 pointIds[0] = nodeSimplexId[before];
157 pointIds[1] = nodeSimplexId[after];
158 vtkArcs->InsertNextCell(VTK_LINE, 2, pointIds);
159 pathId->InsertNextTuple1(1);
160 arcId->InsertNextTuple1(intermediateMTrees.size() + i);
164 for(
unsigned int i = 0; i < fullSize; ++i)
165 nodeRemoved->InsertNextTuple1(0);
166 for(
unsigned int i = 0; i < removed.size(); ++i) {
167 nodeRemoved->SetTuple1(removed[i], 1);
168 nodeRemoved->SetTuple1(intermediateMTrees.size() + i, 1);
171 vtkOutputNode1->SetPoints(points);
172 vtkOutputNode1->GetPointData()->AddArray(treeId);
173 vtkOutputNode1->GetPointData()->AddArray(nodePathId);
174 vtkOutputNode1->GetPointData()->AddArray(nodeRemoved);
175 vtkOutputNode1->GetPointData()->AddArray(nodeId);
176 vtkArcs->SetPoints(points);
177 vtkArcs->GetCellData()->AddArray(pathId);
178 vtkArcs->GetCellData()->AddArray(arcId);
179 vtkOutputArc1->ShallowCopy(vtkArcs);