------------------------------------------------------------------------------ Compare the cell type, point ids, and points in 'grid' with those returned in 'iter'.
| 22 | // Compare the cell type, point ids, and points in 'grid' with those returned |
| 23 | // in 'iter'. |
| 24 | bool testCellIterator(vtkCellIterator* iter, vtkUnstructuredGrid* grid) |
| 25 | { |
| 26 | vtkIdType cellId = 0; |
| 27 | vtkNew<vtkGenericCell> cell; |
| 28 | iter->InitTraversal(); |
| 29 | while (!iter->IsDoneWithTraversal()) |
| 30 | { |
| 31 | grid->GetCell(cellId, cell); |
| 32 | |
| 33 | if (iter->GetCellType() != cell->GetCellType()) |
| 34 | { |
| 35 | std::cerr << "Type mismatch for cell " << cellId << std::endl; |
| 36 | return false; |
| 37 | } |
| 38 | |
| 39 | vtkIdType numPoints = iter->GetNumberOfPoints(); |
| 40 | if (numPoints != cell->GetNumberOfPoints()) |
| 41 | { |
| 42 | std::cerr << "Number of points mismatch for cell " << cellId << std::endl; |
| 43 | return false; |
| 44 | } |
| 45 | |
| 46 | for (vtkIdType pointInd = 0; pointInd < numPoints; ++pointInd) |
| 47 | { |
| 48 | if (iter->GetPointIds()->GetId(pointInd) != cell->PointIds->GetId(pointInd)) |
| 49 | { |
| 50 | std::cerr << "Point id mismatch in cell " << cellId << std::endl; |
| 51 | return false; |
| 52 | } |
| 53 | |
| 54 | double iterPoint[3]; |
| 55 | double cellPoint[3]; |
| 56 | iter->GetPoints()->GetPoint(pointInd, iterPoint); |
| 57 | cell->Points->GetPoint(pointInd, cellPoint); |
| 58 | if (iterPoint[0] != cellPoint[0] || iterPoint[1] != cellPoint[1] || |
| 59 | iterPoint[2] != cellPoint[2]) |
| 60 | { |
| 61 | std::cerr << "Point mismatch in cell " << cellId << std::endl; |
| 62 | return false; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | iter->GoToNextCell(); |
| 67 | ++cellId; |
| 68 | } |
| 69 | |
| 70 | // ensure that we checked all of the cells |
| 71 | if (cellId != grid->GetNumberOfCells()) |
| 72 | { |
| 73 | std::cerr << "Iterator did not cover all cells in the dataset!" << std::endl; |
| 74 | return false; |
| 75 | } |
| 76 | |
| 77 | // std::cout << "Verified " << cellId << " cells with a " << iter->GetClassName() |
| 78 | // << "." << std::endl; |
| 79 | return true; |
| 80 | } |
| 81 |
nothing calls this directly
no test coverage detected