MCPcopy Create free account
hub / github.com/Kitware/VTK / ExtractSelectedCells

Method ExtractSelectedCells

Filters/Extraction/vtkExtractSelection.cxx:896–966  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

894
895//------------------------------------------------------------------------------
896void 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 }

Callers 1

ExtractElementsMethod · 0.95

Calls 15

GetCellGhostArrayMethod · 0.80
InsertNextIdMethod · 0.80
SetCellListMethod · 0.80
ForFunction · 0.50
GetNumberOfPointsMethod · 0.45
GetNumberOfCellsMethod · 0.45
SetNumberOfComponentsMethod · 0.45
SetNameMethod · 0.45
SetNumberOfTuplesMethod · 0.45
SetValueMethod · 0.45
AddArrayMethod · 0.45
GetPointDataMethod · 0.45

Tested by

no test coverage detected