------------------------------------------------------------------------------
| 804 | |
| 805 | //------------------------------------------------------------------------------ |
| 806 | void vtkSelectPolyData::SetClippedResultToOutput(vtkPointData* originalPointData, |
| 807 | vtkCellData* originalCellData, vtkPolyData* mesh, vtkIntArray* cellMarks, vtkPolyData* output) |
| 808 | { |
| 809 | vtkCellData* outCD = output->GetCellData(); |
| 810 | outCD->CopyAllOn(vtkDataSetAttributes::COPYTUPLE); |
| 811 | outCD->CopyAllocate(originalCellData); |
| 812 | |
| 813 | // spit out all the negative cells |
| 814 | vtkNew<vtkCellArray> newPolys; |
| 815 | vtkIdType numCells = mesh->GetNumberOfCells(); |
| 816 | newPolys->AllocateEstimate(numCells / 2, 3); |
| 817 | vtkIdType newID = 0; |
| 818 | for (vtkIdType i = 0; i < numCells; i++) |
| 819 | { |
| 820 | if (this->CheckAbort()) |
| 821 | { |
| 822 | break; |
| 823 | } |
| 824 | if ((cellMarks->GetValue(i) < 0) || (cellMarks->GetValue(i) > 0 && this->InsideOut)) |
| 825 | { |
| 826 | const vtkIdType* pts; |
| 827 | vtkIdType npts; |
| 828 | mesh->GetCellPoints(i, npts, pts); |
| 829 | newID = newPolys->InsertNextCell(npts, pts); |
| 830 | outCD->CopyData(originalCellData, i, newID); |
| 831 | } |
| 832 | } |
| 833 | vtkPoints* inPts = mesh->GetPoints(); |
| 834 | output->SetPoints(inPts); |
| 835 | output->SetPolys(newPolys); |
| 836 | vtkPointData* outPD = output->GetPointData(); |
| 837 | outPD->PassData(originalPointData); |
| 838 | |
| 839 | if (this->GenerateUnselectedOutput) |
| 840 | { |
| 841 | vtkCellData* unCD = this->GetUnselectedOutput()->GetCellData(); |
| 842 | unCD->CopyAllOn(vtkDataSetAttributes::COPYTUPLE); |
| 843 | unCD->CopyAllocate(originalCellData); |
| 844 | |
| 845 | vtkNew<vtkCellArray> unPolys; |
| 846 | unPolys->AllocateEstimate(numCells / 2, 3); |
| 847 | for (vtkIdType i = 0; i < numCells; i++) |
| 848 | { |
| 849 | if (this->CheckAbort()) |
| 850 | { |
| 851 | break; |
| 852 | } |
| 853 | if ((cellMarks->GetValue(i) >= 0) || this->InsideOut) |
| 854 | { |
| 855 | const vtkIdType* pts; |
| 856 | vtkIdType npts; |
| 857 | mesh->GetCellPoints(i, npts, pts); |
| 858 | newID = unPolys->InsertNextCell(npts, pts); |
| 859 | unCD->CopyData(originalCellData, i, newID); |
| 860 | } |
| 861 | } |
| 862 | this->GetUnselectedOutput()->SetPoints(inPts); |
| 863 | this->GetUnselectedOutput()->SetPolys(unPolys); |
no test coverage detected