1 From 84627355e5b1d42754c655fdc5958695db11a25d Mon Sep 17 00:00:00 2001
2 From: Antoine Gerschenfeld <antoine.gerschenfeld@cea.fr>
3 Date: Fri, 13 Mar 2020 10:48:30 +0100
4 Subject: [PATCH 2/3] vtkUnstructuredGridRelevantPointsFilter: fix for
8 .../vtkUnstructuredGridRelevantPointsFilter.C | 67 ++++++++-----------
9 1 file changed, 27 insertions(+), 40 deletions(-)
11 diff --git a/Library/VisItLib/visit_vtk/full/vtkUnstructuredGridRelevantPointsFilter.C b/Library/VisItLib/visit_vtk/full/vtkUnstructuredGridRelevantPointsFilter.C
12 index 5c73502..c4e772c 100644
13 --- a/Library/VisItLib/visit_vtk/full/vtkUnstructuredGridRelevantPointsFilter.C
14 +++ b/Library/VisItLib/visit_vtk/full/vtkUnstructuredGridRelevantPointsFilter.C
15 @@ -116,29 +116,21 @@ vtkUnstructuredGridRelevantPointsFilter::RequestData(
19 - vtkCellArray *cells = input->GetCells();
20 - auto cellIter = vtk::TakeSmartPointer(cells->NewIterator());
23 - for (cellIter->GoToFirstCell();
24 - !cellIter->IsDoneWithTraversal();
25 - cellIter->GoToNextCell())
26 + vtkIdList *list = vtkIdList::New();
27 + for (i = 0; i < numCells; i++)
29 - vtkIdList *cell = cellIter->GetCurrentCell();
30 - int npts = static_cast<int>(cell->GetNumberOfIds());
31 - for (j = 0 ; j < npts ; j++)
33 - int oldPt = static_cast<int>(cell->GetId(j));
34 - if (pointMap[oldPt] == -1)
35 - pointMap[oldPt] = numOutPts++;
37 + input->GetCellPoints(i, list);
38 + for (j = 0; j < list->GetNumberOfIds(); j++) if (pointMap[list->GetId(j)] < 0) pointMap[list->GetId(j)] = numOutPts++;
41 - vtkPoints *newPts = vtkPoints::New(input->GetPoints()->GetDataType());
42 - newPts->SetNumberOfPoints(numOutPts);
43 vtkPointData *inputPD = input->GetPointData();
44 vtkPointData *outputPD = output->GetPointData();
45 outputPD->CopyAllocate(inputPD, numOutPts);
47 + vtkPoints *newPts = vtkPoints::New(input->GetPoints()->GetDataType());
48 + newPts->SetNumberOfPoints(numOutPts);
49 for (j = 0 ; j < numInPts ; j++)
51 if (pointMap[j] != -1)
52 @@ -149,43 +141,38 @@ vtkUnstructuredGridRelevantPointsFilter::RequestData(
53 outputPD->CopyData(inputPD, j, pointMap[j]);
56 + output->SetPoints(newPts);
58 vtkCellData *inputCD = input->GetCellData();
59 vtkCellData *outputCD = output->GetCellData();
60 outputCD->PassData(inputCD);
62 - vtkIdList *cellIds = vtkIdList::New();
64 - output->SetPoints(newPts);
66 - // now work through cells, changing associated point id to coincide
67 - // with the new ones as specified in the pointmap;
69 - vtkIdList *oldIds = vtkIdList::New();
70 - vtkIdList *newIds = vtkIdList::New();
72 - cellIter = vtk::TakeSmartPointer(cells->NewIterator());
73 - for (cellIter->GoToFirstCell();
74 - !cellIter->IsDoneWithTraversal();
75 - cellIter->GoToNextCell())
76 + std::vector<vtkIdType> points, faces;
77 + for (i = 0; i < numCells; i++)
79 - vtkIdList *cell = cellIter->GetCurrentCell();
80 - cellType = input->GetCellType(cellIter->GetCurrentCellId());
81 - int npts = static_cast<int>(cell->GetNumberOfIds());
82 + int CellType = input->GetCellType(i);
83 + points.resize(0), faces.resize(0);
84 + input->GetCellPoints(i, list);
86 + for (j = 0; j < list->GetNumberOfIds(); j++) points.push_back(pointMap[list->GetId(j)]);
88 - newIds->SetNumberOfIds(npts);
89 - for (j = 0; j < npts ; j++)
90 + if (CellType == VTK_POLYHEDRON) //must deal with faces stream
92 - id = cell->GetId(j);
93 - newIds->SetId(j, pointMap[id]);
94 + input->GetFaceStream(i, list);
95 + int nfaces = list->GetId(0), idx = 1;
96 + for (j = 0; j < nfaces; j++)
98 + int npts = list->GetId(idx);
99 + faces.push_back(npts), idx++;
100 + for (int k = 0; k < npts; k++) faces.push_back(pointMap[list->GetId(idx)]), idx++;
102 + output->InsertNextCell(CellType, points.size(), &points[0], nfaces, &faces[0]);
104 - output->InsertNextCell(cellType, newIds);
105 + else output->InsertNextCell(CellType, points.size(), &points[0]);