Salome HOME
ParaView-5.8.0 build options and patches
[tools/configuration.git] / config / patches / paraview.0002-vtkUnstructuredGridRelevantPointsFilter-fix-for-poly.patch
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
5  polyhedra
6
7 ---
8  .../vtkUnstructuredGridRelevantPointsFilter.C | 67 ++++++++-----------
9  1 file changed, 27 insertions(+), 40 deletions(-)
10
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(
16      {
17      pointMap[i] = -1;
18      }
19 -  vtkCellArray *cells = input->GetCells();
20 -  auto cellIter = vtk::TakeSmartPointer(cells->NewIterator());
21 +
22    int numOutPts = 0;
23 -  for (cellIter->GoToFirstCell();
24 -       !cellIter->IsDoneWithTraversal();
25 -       cellIter->GoToNextCell())
26 +  vtkIdList *list = vtkIdList::New();
27 +  for (i = 0; i < numCells; i++)
28      {
29 -    vtkIdList *cell = cellIter->GetCurrentCell();
30 -    int npts = static_cast<int>(cell->GetNumberOfIds());
31 -    for (j = 0 ; j < npts ; j++)
32 -      {
33 -      int oldPt = static_cast<int>(cell->GetId(j));
34 -      if (pointMap[oldPt] == -1)
35 -        pointMap[oldPt] = numOutPts++;
36 -      }
37 +    input->GetCellPoints(i, list);
38 +    for (j = 0; j < list->GetNumberOfIds(); j++) if (pointMap[list->GetId(j)] < 0) pointMap[list->GetId(j)] = numOutPts++;
39      }
40  
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);
46    
47 +  vtkPoints *newPts = vtkPoints::New(input->GetPoints()->GetDataType());
48 +  newPts->SetNumberOfPoints(numOutPts);
49    for (j = 0 ; j < numInPts ; j++)
50      {
51      if (pointMap[j] != -1)
52 @@ -149,43 +141,38 @@ vtkUnstructuredGridRelevantPointsFilter::RequestData(
53        outputPD->CopyData(inputPD, j, pointMap[j]);
54        }
55      }
56 +  output->SetPoints(newPts);
57  
58    vtkCellData  *inputCD = input->GetCellData();
59    vtkCellData  *outputCD = output->GetCellData();
60    outputCD->PassData(inputCD);
61 -  
62 -  vtkIdList *cellIds = vtkIdList::New();
63 -
64 -  output->SetPoints(newPts);
65 -
66 -  // now work through cells, changing associated point id to coincide
67 -  // with the new ones as specified in the pointmap;
68  
69 -  vtkIdList *oldIds = vtkIdList::New(); 
70 -  vtkIdList *newIds = vtkIdList::New();
71 -  int id, cellType;
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++)
78      {
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);
85 +      
86 +      for (j = 0; j < list->GetNumberOfIds(); j++) points.push_back(pointMap[list->GetId(j)]);
87  
88 -    newIds->SetNumberOfIds(npts);
89 -    for (j = 0; j < npts ; j++)
90 +      if (CellType == VTK_POLYHEDRON) //must deal with faces stream
91        {
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++)
97 +        {
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++;
101 +        }
102 +        output->InsertNextCell(CellType, points.size(), &points[0], nfaces, &faces[0]);
103        }
104 -      output->InsertNextCell(cellType, newIds);
105 +      else output->InsertNextCell(CellType, points.size(), &points[0]);      
106      }
107  
108    newPts->Delete();
109 -  oldIds->Delete();
110 -  newIds->Delete();
111 -  cellIds->Delete();
112 +  list->Delete();
113    delete [] pointMap;
114  
115    return 1;
116 -- 
117 2.17.0
118