| 2909 | //---------------------------------------------------------------------------- |
| 2910 | template <typename TInputIdType, typename TFaceIdType> |
| 2911 | int ExecuteUnstructuredGrid(vtkGeometryFilter* self, vtkDataSet* dataSetInput, vtkPolyData* output, |
| 2912 | vtkGeometryFilterHelper* info, vtkExcludedFaces<TInputIdType>* exc) |
| 2913 | { |
| 2914 | vtkUnstructuredGridBase* uGridBase = vtkUnstructuredGridBase::SafeDownCast(dataSetInput); |
| 2915 | if (uGridBase->GetNumberOfCells() == 0) |
| 2916 | { |
| 2917 | vtkDebugWithObjectMacro(self, << "Nothing to extract"); |
| 2918 | return 0; |
| 2919 | } |
| 2920 | vtkUnstructuredGrid* uGrid = vtkUnstructuredGrid::SafeDownCast(uGridBase); |
| 2921 | |
| 2922 | // If no info, then compute information about the unstructured grid. |
| 2923 | // Depending on the outcome, we may process the data ourselves, or send over |
| 2924 | // to the faster vtkGeometryFilter. |
| 2925 | bool mayDelegate = (info == nullptr && self->GetDelegation()); |
| 2926 | bool info_owned = false; |
| 2927 | if (info == nullptr) |
| 2928 | { |
| 2929 | info = vtkGeometryFilterHelper::CharacterizeUnstructuredGrid(uGridBase); |
| 2930 | info_owned = true; |
| 2931 | } |
| 2932 | |
| 2933 | // Nonlinear cells are handled by vtkDataSetSurfaceFilter |
| 2934 | // non-linear cells using sub-division. |
| 2935 | if (!info->IsLinear && mayDelegate) |
| 2936 | { |
| 2937 | vtkNew<vtkDataSetSurfaceFilter> dssf; |
| 2938 | vtkGeometryFilterHelper::CopyFilterParams(self, dssf.Get()); |
| 2939 | dssf->UnstructuredGridExecute(dataSetInput, output, info); |
| 2940 | delete info; |
| 2941 | return 1; |
| 2942 | } |
| 2943 | // if it's an unstructured grid base and not an unstructured grid |
| 2944 | if (!uGrid && uGridBase) |
| 2945 | { |
| 2946 | if (info_owned) |
| 2947 | { |
| 2948 | delete info; |
| 2949 | } |
| 2950 | return self->DataSetExecute(uGridBase, output, exc->ExcludedFaces); |
| 2951 | } |
| 2952 | // fast conversion when input is actually polydata with one cell array |
| 2953 | if (uGrid && |
| 2954 | (info->HasOnlyVerts() || info->HasOnlyLines() || info->HasOnlyPolys() || info->HasOnlyStrips())) |
| 2955 | { |
| 2956 | vtkNew<vtkPolyData> polyDataInput; |
| 2957 | polyDataInput->SetPoints(uGrid->GetPoints()); |
| 2958 | polyDataInput->GetPointData()->ShallowCopy(uGrid->GetPointData()); |
| 2959 | if (self->GetPassThroughPointIds() && |
| 2960 | polyDataInput->GetPointData()->HasArray(self->GetOriginalPointIdsName())) |
| 2961 | { |
| 2962 | polyDataInput->GetPointData()->RemoveArray(self->GetOriginalPointIdsName()); |
| 2963 | } |
| 2964 | if (info->HasOnlyVerts()) |
| 2965 | { |
| 2966 | polyDataInput->SetVerts(uGrid->GetCells()); |
| 2967 | } |
| 2968 | else if (info->HasOnlyLines()) |
nothing calls this directly
no test coverage detected