---------------------------------------------------------------------------- * We're doing a homebrewed shallow copy because we do not want to share any pointer with the input, * which is the case for unstructured grid cell connectivity information. */
| 3808 | * which is the case for unstructured grid cell connectivity information. |
| 3809 | */ |
| 3810 | void CloneUnstructuredGrid( |
| 3811 | vtkUnstructuredGrid* ug, vtkUnstructuredGrid* clone, ::UnstructuredGridInformation& info) |
| 3812 | { |
| 3813 | ::CloneDataObject(ug, clone); |
| 3814 | ::ClonePointData(ug, clone, info); |
| 3815 | ::ClonePoints(ug, clone, info); |
| 3816 | ::CloneCellData(ug, clone, info); |
| 3817 | |
| 3818 | if (!ug->GetPolyhedronFaces() && clone->GetPolyhedronFaces() && |
| 3819 | clone->GetPolyhedronFaceLocations()) |
| 3820 | { |
| 3821 | // initialize empty polyhedron when none are present but they are required for output. |
| 3822 | |
| 3823 | // use generic cell array API since speed is not that important for this rare case. |
| 3824 | auto polyhedronFaceLocations = clone->GetPolyhedronFaceLocations(); |
| 3825 | for (vtkIdType pos = 0; pos < polyhedronFaceLocations->GetNumberOfCells() + 1; ++pos) |
| 3826 | { |
| 3827 | polyhedronFaceLocations->SetOffset(pos, 0); |
| 3828 | } |
| 3829 | // use generic cell array API since speed is not that important for this rare case. |
| 3830 | auto polyhedronFaces = clone->GetPolyhedronFaces(); |
| 3831 | for (vtkIdType pos = 0; pos < polyhedronFaces->GetNumberOfCells() + 1; ++pos) |
| 3832 | { |
| 3833 | polyhedronFaces->SetOffset(pos, 0); |
| 3834 | } |
| 3835 | } |
| 3836 | |
| 3837 | if (vtkIdList* redirectionMap = info.OutputToInputCellIdRedirectionMap) |
| 3838 | { |
| 3839 | ::DeepCopyCells( |
| 3840 | ug->GetCells(), clone->GetCells(), redirectionMap, info.InputToOutputPointIdRedirectionMap); |
| 3841 | ug->GetCellTypes()->GetTuples(redirectionMap, clone->GetCellTypes()); |
| 3842 | |
| 3843 | vtkCellArray* ugFaceLocations = ug->GetPolyhedronFaceLocations(); |
| 3844 | if (clone->GetPolyhedronFaceLocations() && ugFaceLocations && |
| 3845 | ugFaceLocations->GetNumberOfCells()) |
| 3846 | { |
| 3847 | ::DeepCopyPolyhedrons(ug, clone, info); |
| 3848 | } |
| 3849 | } |
| 3850 | else |
| 3851 | { |
| 3852 | vtkCellArray* ugCellArray = ug->GetCells(); |
| 3853 | vtkCellArray* cloneCellArray = clone->GetCells(); |
| 3854 | vtkDataArray* ugConnectivity = ugCellArray->GetConnectivityArray(); |
| 3855 | vtkDataArray* ugOffsets = ugCellArray->GetOffsetsArray(); |
| 3856 | |
| 3857 | ugConnectivity->GetTuples( |
| 3858 | 0, ugConnectivity->GetNumberOfTuples() - 1, cloneCellArray->GetConnectivityArray()); |
| 3859 | ugOffsets->GetTuples(0, ugOffsets->GetNumberOfTuples() - 1, cloneCellArray->GetOffsetsArray()); |
| 3860 | ug->GetCellTypes()->GetTuples(0, ug->GetNumberOfCells() - 1, clone->GetCellTypes()); |
| 3861 | |
| 3862 | vtkCellArray* ugFaces = ug->GetPolyhedronFaces(); |
| 3863 | |
| 3864 | if (clone->GetPolyhedronFaces() && ugFaces && ugFaces->GetNumberOfCells()) |
| 3865 | { |
| 3866 | vtkDataArray* ugFaceConnectivity = ug->GetPolyhedronFaces()->GetConnectivityArray(); |
| 3867 | vtkDataArray* ugFaceOffsets = ug->GetPolyhedronFaces()->GetOffsetsArray(); |
no test coverage detected