MCPcopy Create free account
hub / github.com/Kitware/VTK / ComparePolyData

Function ComparePolyData

Filters/Geometry/Testing/Cxx/UnitTestProjectSphereFilter.cxx:108–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108int ComparePolyData(vtkPolyData* p1, vtkPolyData* p2)
109{
110 int status = 0;
111 if (p1->GetNumberOfCells() != p2->GetNumberOfCells())
112 {
113 std::cout << "ERROR: ComparePolyData - p1->GetNumberOfCells() " << p1->GetNumberOfCells()
114 << " != "
115 << "p2->GetNumberOfCells() " << p2->GetNumberOfCells() << std::endl;
116 status++;
117 }
118 vtkIdList* pointIdList1;
119 vtkIdType* ptIds1;
120 int numCellPts1;
121 vtkIdList* pointIdList2;
122 vtkIdType* ptIds2;
123 int numCellPts2;
124
125 vtkSmartPointer<vtkCellIterator> cellIter1 =
126 vtkSmartPointer<vtkCellIterator>::Take(p1->NewCellIterator());
127 vtkSmartPointer<vtkCellIterator> cellIter2 =
128 vtkSmartPointer<vtkCellIterator>::Take(p2->NewCellIterator());
129 for (cellIter1->InitTraversal(), cellIter2->InitTraversal(); cellIter1->IsDoneWithTraversal();
130 cellIter1->GoToNextCell(), cellIter2->GoToNextCell())
131 {
132 pointIdList1 = cellIter1->GetPointIds();
133 numCellPts1 = pointIdList1->GetNumberOfIds();
134 ptIds1 = pointIdList1->GetPointer(0);
135 pointIdList2 = cellIter2->GetPointIds();
136 numCellPts2 = pointIdList2->GetNumberOfIds();
137 ptIds2 = pointIdList2->GetPointer(0);
138
139 if (numCellPts1 != numCellPts2)
140 {
141 std::cout << "numCellPts1 != numCellPts2 " << numCellPts1 << " != " << numCellPts2
142 << std::endl;
143 return 1;
144 }
145 for (vtkIdType i = 0; i < numCellPts1; ++i)
146 {
147 if (ptIds1[i] != ptIds2[i])
148 {
149 std::cout << ptIds1[i] << " != " << ptIds2[i] << std::endl;
150 }
151 }
152 }
153 vtkPointData* pointData1;
154 pointData1 = p1->GetPointData();
155 vtkPointData* pointData2;
156 pointData2 = p2->GetPointData();
157
158 vtkSmartPointer<vtkFloatArray> normals1 = vtkFloatArray::SafeDownCast(pointData1->GetNormals());
159 vtkSmartPointer<vtkFloatArray> normals2 = vtkFloatArray::SafeDownCast(pointData2->GetNormals());
160
161 for (vtkIdType i = 0; i < normals1->GetNumberOfTuples(); ++i)
162 {
163 double normal1[3], normal2[3];
164 normals1->GetTuple(i, normal1);
165 normals2->GetTuple(i, normal2);

Callers 1

Calls 13

TakeFunction · 0.85
GoToNextCellMethod · 0.80
GetNumberOfCellsMethod · 0.45
NewCellIteratorMethod · 0.45
InitTraversalMethod · 0.45
IsDoneWithTraversalMethod · 0.45
GetPointIdsMethod · 0.45
GetNumberOfIdsMethod · 0.45
GetPointerMethod · 0.45
GetPointDataMethod · 0.45
GetNormalsMethod · 0.45
GetNumberOfTuplesMethod · 0.45

Tested by

no test coverage detected