------------------------------------------------------------------------------
| 894 | |
| 895 | //------------------------------------------------------------------------------ |
| 896 | void vtkExtractSelection::ExtractSelectedCells( |
| 897 | vtkDataSet* input, vtkUnstructuredGrid* output, vtkSignedCharArray* cellInside, bool extractAll) |
| 898 | { |
| 899 | vtkLogScopeF(TRACE, "ExtractSelectedCells"); |
| 900 | const vtkIdType numPts = input->GetNumberOfPoints(); |
| 901 | const vtkIdType numCells = input->GetNumberOfCells(); |
| 902 | |
| 903 | // The "input" is a shallow copy of the input to this filter and hence we can |
| 904 | // modify it. We add original cell ids and point ids arrays. |
| 905 | vtkNew<vtkIdTypeArray> originalPointIds; |
| 906 | originalPointIds->SetNumberOfComponents(1); |
| 907 | originalPointIds->SetName("vtkOriginalPointIds"); |
| 908 | originalPointIds->SetNumberOfTuples(numPts); |
| 909 | vtkSMPTools::For(0, numPts, |
| 910 | [&](vtkIdType begin, vtkIdType end) |
| 911 | { |
| 912 | for (vtkIdType ptId = begin; ptId < end; ++ptId) |
| 913 | { |
| 914 | originalPointIds->SetValue(ptId, ptId); |
| 915 | } |
| 916 | }); |
| 917 | input->GetPointData()->AddArray(originalPointIds); |
| 918 | |
| 919 | vtkNew<vtkIdTypeArray> originalCellIds; |
| 920 | originalCellIds->SetNumberOfComponents(1); |
| 921 | originalCellIds->SetName("vtkOriginalCellIds"); |
| 922 | originalCellIds->SetNumberOfTuples(numCells); |
| 923 | vtkSMPTools::For(0, numCells, |
| 924 | [&](vtkIdType begin, vtkIdType end) |
| 925 | { |
| 926 | for (vtkIdType cellId = begin; cellId < end; ++cellId) |
| 927 | { |
| 928 | originalCellIds->SetValue(cellId, cellId); |
| 929 | } |
| 930 | }); |
| 931 | input->GetCellData()->AddArray(originalCellIds); |
| 932 | |
| 933 | vtkNew<vtkExtractCells> extractor; |
| 934 | extractor->SetContainerAlgorithm(this); |
| 935 | if (extractAll) |
| 936 | { |
| 937 | // all elements are selected, pass all data. |
| 938 | // we still use the extractor since it does the data conversion, if needed |
| 939 | extractor->SetExtractAllCells(true); |
| 940 | } |
| 941 | else |
| 942 | { |
| 943 | // convert insideness array to cell ids to extract. |
| 944 | vtkNew<vtkIdList> ids; |
| 945 | ids->Allocate(numCells); |
| 946 | vtkUnsignedCharArray* ghostArray = input->GetCellGhostArray(); |
| 947 | for (vtkIdType cc = 0; cc < numCells; ++cc) |
| 948 | { |
| 949 | if (ghostArray && ghostArray->GetValue(cc) == vtkDataSetAttributes::HIDDENCELL) |
| 950 | { |
| 951 | // skip this cell |
| 952 | continue; |
| 953 | } |
no test coverage detected