March along connected lines to the end---------------------------------- pts[0] is assumed to be the starting point and already inserted.
| 71 | // March along connected lines to the end---------------------------------- |
| 72 | // pts[0] is assumed to be the starting point and already inserted. |
| 73 | vtkIdType TraverseLoop(double dir, vtkPolyData* polyData, vtkIdType lineId, vtkIdType start, |
| 74 | LoopPointType& sortedPoints, std::vector<signed char>& visited, vtkDataArray* scalars, |
| 75 | double range[2]) |
| 76 | { |
| 77 | vtkIdType last = start, numInserted = 0; |
| 78 | double t = 0.0; |
| 79 | bool terminated = false; |
| 80 | vtkIdType ncells; |
| 81 | vtkIdType npts; |
| 82 | const vtkIdType* pts; |
| 83 | vtkIdType* cells; |
| 84 | vtkIdType nei; |
| 85 | vtkIdType lastCell = lineId; |
| 86 | polyData->GetCellPoints(lineId, npts, pts); |
| 87 | |
| 88 | // Recall that we are working with 2-pt lines |
| 89 | while (!terminated) |
| 90 | { |
| 91 | last = (pts[0] != last ? pts[0] : pts[1]); |
| 92 | numInserted++; |
| 93 | t = dir * static_cast<double>(numInserted); |
| 94 | sortedPoints.emplace_back(t, last); |
| 95 | UpdateRange(scalars, last, range); |
| 96 | |
| 97 | polyData->GetPointCells(last, ncells, cells); |
| 98 | if (ncells == 1 || last == start) // this is the last point |
| 99 | { |
| 100 | return last; |
| 101 | } |
| 102 | else if (ncells == 2) // continue along loop |
| 103 | { |
| 104 | nei = (cells[0] != lastCell ? cells[0] : cells[1]); |
| 105 | polyData->GetCellPoints(nei, npts, pts); |
| 106 | visited[nei] = 1; |
| 107 | lastCell = nei; |
| 108 | } |
| 109 | else // non-manifold, for now just quit (TODO: break apart loops) |
| 110 | { |
| 111 | terminated = true; |
| 112 | break; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | return last; |
| 117 | } |
| 118 | |
| 119 | // March along connected lines to the end---------------------------------- |
| 120 | void OutputPolygon(LoopPointType& sortedPoints, vtkPoints* inPts, vtkCellArray* outLines, |
no test coverage detected