132 std::vector<ttk::ExTreeM::Branch> &mergeTree,
133 vtkDataArray *inputScalars,
134 const triangulationType *triangulation) {
135 vtkNew<vtkUnstructuredGrid> skeletonArcs{};
138 vtkNew<vtkPoints> points{};
139 vtkNew<vtkLongLongArray> data{};
140 data->SetNumberOfComponents(1);
141 data->SetName(
"Order");
142 vtkNew<vtkIdTypeArray> gIdArray{};
143 gIdArray->SetNumberOfComponents(1);
144 gIdArray->SetName(
"GlobalPointIds");
145 vtkNew<vtkIdTypeArray> downId{};
146 downId->SetNumberOfComponents(1);
147 downId->SetName(
"downNodeId");
148 vtkNew<vtkIdTypeArray> upId{};
149 upId->SetNumberOfComponents(1);
150 upId->SetName(
"upNodeId");
154 scalarArray->SetNumberOfComponents(1);
155 scalarArray->SetName(
"Scalar");
156 std::map<ttk::SimplexId, ttk::SimplexId> addedPoints;
158 for(
auto const &b : mergeTree) {
159 auto &vertices = b.vertices;
160 for(
size_t p = 0; p < vertices.size() - 1; p++) {
161 pointIds[0] = vertices[p].second;
162 pointIds[1] = vertices[p + 1].second;
163 pointOrders[0] = vertices[p].first;
164 pointOrders[1] = vertices[p + 1].first;
168 if(addedPoints.insert({pointIds[0], currentId}).second) {
169 triangulation->getVertexPoint(
170 pointIds[0], point[0], point[1], point[2]);
171 points->InsertNextPoint(point);
172 data->InsertNextTuple1(pointOrders[0]);
173 gIdArray->InsertNextTuple1(pointIds[0]);
174 scalarArray->InsertNextTuple1(inputScalars->GetTuple1(pointIds[0]));
177 if(addedPoints.insert({pointIds[1], currentId}).second) {
178 triangulation->getVertexPoint(
179 pointIds[1], point[0], point[1], point[2]);
180 points->InsertNextPoint(point);
181 data->InsertNextTuple1(pointOrders[1]);
182 gIdArray->InsertNextTuple1(pointIds[1]);
183 scalarArray->InsertNextTuple1(inputScalars->GetTuple1(pointIds[1]));
186 downId->InsertNextTuple1(pointIds[0]);
187 upId->InsertNextTuple1(pointIds[1]);
188 vtkIdType pointIdsASVTKIDTYPE[2];
189 pointIdsASVTKIDTYPE[0] = addedPoints.at(pointIds[0]);
190 pointIdsASVTKIDTYPE[1] = addedPoints.at(pointIds[1]);
191 skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIdsASVTKIDTYPE);
194 skeletonArcs->SetPoints(points);
195 outputSkeletonArcs->ShallowCopy(skeletonArcs);
196 outputSkeletonArcs->GetPointData()->AddArray(data);
197 outputSkeletonArcs->GetPointData()->AddArray(gIdArray);
198 outputSkeletonArcs->GetPointData()->AddArray(scalarArray);
199 outputSkeletonArcs->GetCellData()->AddArray(upId);
200 outputSkeletonArcs->GetCellData()->AddArray(downId);
207 vtkUnstructuredGrid *outputSkeletonNodes,
208 std::map<ttk::SimplexId, int> cpMap,
209 std::vector<std::pair<ttk::SimplexId, ttk::SimplexId>> &persistencePairs,
210 vtkDataArray *inputScalars,
211 const triangulationType *triangulation) {
212 vtkNew<vtkUnstructuredGrid> skeletonNodes{};
213 vtkNew<vtkPoints> points{};
214 vtkNew<vtkCellArray> cells{};
215 vtkNew<vtkLongLongArray> gIdArray{};
216 gIdArray->SetNumberOfComponents(1);
217 gIdArray->SetName(
"VertexId");
220 scalarArray->SetNumberOfComponents(1);
221 scalarArray->SetName(
"Scalar");
222 vtkNew<vtkIntArray> cpArray{};
223 cpArray->SetNumberOfComponents(1);
224 cpArray->SetName(
"CriticalType");
227 long long pointId = 0;
229 for(
auto const &pair : persistencePairs) {
230 triangulation->getVertexPoint(pair.first, point[0], point[1], point[2]);
231 points->InsertNextPoint(point);
232 gIdArray->InsertNextTuple1(pair.first);
233 scalarArray->InsertNextTuple1(inputScalars->GetTuple1(pair.first));
234 cpArray->InsertNextTuple1(cpMap[pair.first]);
235 triangulation->getVertexPoint(pair.second, point[0], point[1], point[2]);
236 points->InsertNextPoint(point);
237 gIdArray->InsertNextTuple1(pair.second);
238 scalarArray->InsertNextTuple1(inputScalars->GetTuple1(pair.second));
239 cpArray->InsertNextTuple1(cpMap[pair.second]);
240 skeletonNodes->InsertNextCell(VTK_VERTEX, 1, &pointId);
242 skeletonNodes->InsertNextCell(VTK_VERTEX, 1, &pointId);
245 skeletonNodes->SetPoints(points);
246 outputSkeletonNodes->ShallowCopy(skeletonNodes);
247 outputSkeletonNodes->GetPointData()->AddArray(gIdArray);
248 outputSkeletonNodes->GetPointData()->AddArray(scalarArray);
249 outputSkeletonNodes->GetPointData()->AddArray(cpArray);