------------------------------------------------------------------------------
| 1836 | |
| 1837 | //------------------------------------------------------------------------------ |
| 1838 | void vtkPStreamTracer::Prepend(vtkPolyData* pathPoly, vtkPolyData* headPoly) |
| 1839 | { |
| 1840 | vtkCellArray* pathCells = pathPoly->GetLines(); |
| 1841 | AssertEq(pathCells->GetNumberOfCells(), 1); |
| 1842 | AssertEq(headPoly->GetNumberOfPoints(), 1); |
| 1843 | |
| 1844 | double* newPoint = headPoly->GetPoint(0); |
| 1845 | AssertEq( |
| 1846 | headPoly->GetPointData()->GetNumberOfArrays(), pathPoly->GetPointData()->GetNumberOfArrays()); |
| 1847 | |
| 1848 | const vtkIdType* path(nullptr); |
| 1849 | vtkIdType nPoints(0); |
| 1850 | pathCells->InitTraversal(); |
| 1851 | pathCells->GetNextCell(nPoints, path); |
| 1852 | AssertNe(path, nullptr); |
| 1853 | AssertEq(nPoints, pathPoly->GetNumberOfPoints()); |
| 1854 | |
| 1855 | vtkIdType newPointId = pathPoly->GetPoints()->InsertNextPoint(newPoint); |
| 1856 | |
| 1857 | vtkPointData* headData = headPoly->GetPointData(); |
| 1858 | vtkPointData* pathData = pathPoly->GetPointData(); |
| 1859 | Assert(SameShape(headData, pathData), "Prepend failure"); |
| 1860 | |
| 1861 | int numArrays(headData->GetNumberOfArrays()); |
| 1862 | for (int i = 0; i < numArrays; i++) |
| 1863 | { |
| 1864 | pathData->CopyTuple( |
| 1865 | headData->GetAbstractArray(i), pathData->GetAbstractArray(i), 0, newPointId); |
| 1866 | } |
| 1867 | |
| 1868 | PRINT("Prepend Point " << newPointId << " " << newPoint[0] << " " << newPoint[1] << " " |
| 1869 | << newPoint[2]); |
| 1870 | vtkNew<vtkIdList> newPath; |
| 1871 | newPath->InsertNextId(newPointId); |
| 1872 | for (int i = 0; i < nPoints; i++) |
| 1873 | { |
| 1874 | newPath->InsertNextId(path[i]); |
| 1875 | } |
| 1876 | |
| 1877 | pathCells->Reset(); |
| 1878 | if (newPath->GetNumberOfIds() > 1) |
| 1879 | { |
| 1880 | pathCells->InsertNextCell(newPath); |
| 1881 | } |
| 1882 | AssertEq(pathCells->GetNumberOfCells(), 1); |
| 1883 | vtkIdType newNumPoints(0); |
| 1884 | pathCells->GetNextCell(newNumPoints, path); |
| 1885 | AssertEq(newNumPoints, nPoints + 1); |
| 1886 | AssertEq(newNumPoints, pathPoly->GetNumberOfPoints()); |
| 1887 | } |
| 1888 | VTK_ABI_NAMESPACE_END |
no test coverage detected