------------------------------------------------------------------------------
| 77 | |
| 78 | //------------------------------------------------------------------------------ |
| 79 | int vtkExplodeDataSet::RequestData(vtkInformation* vtkNotUsed(request), |
| 80 | vtkInformationVector** inputVector, vtkInformationVector* outputVector) |
| 81 | { |
| 82 | vtkDataSet* input = vtkDataSet::GetData(inputVector[0], 0); |
| 83 | vtkPartitionedDataSetCollection* output = |
| 84 | vtkPartitionedDataSetCollection::GetData(outputVector, 0); |
| 85 | |
| 86 | if (!input) |
| 87 | { |
| 88 | vtkErrorMacro(<< "Input is not a vtkDataSet. Aborting."); |
| 89 | } |
| 90 | |
| 91 | vtkDataArray* inScalars = this->GetInputArrayToProcess(0, inputVector); |
| 92 | if (!inScalars) |
| 93 | { |
| 94 | vtkErrorMacro(<< "No scalar data to process."); |
| 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | std::map<double, vtkSmartPointer<vtkIdList>> cellsPerValue = this->GetIdListsByValue(inScalars); |
| 99 | output->SetNumberOfPartitionedDataSets(static_cast<unsigned int>(cellsPerValue.size())); |
| 100 | |
| 101 | vtkIdType partId = 0; |
| 102 | std::string arrayName = inScalars->GetName(); |
| 103 | for (const std::pair<const double, vtkSmartPointer<vtkIdList>>& valueIter : cellsPerValue) |
| 104 | { |
| 105 | const double partValue = valueIter.first; |
| 106 | vtkIdList* partCellIds = valueIter.second; |
| 107 | |
| 108 | vtkSmartPointer<vtkPointSet> part = |
| 109 | vtk::TakeSmartPointer(this->CreatePartition(input, partCellIds)); |
| 110 | output->SetPartition(partId, 0, part); |
| 111 | std::string partName = arrayName + "_" + vtk::to_string(partId); |
| 112 | output->GetMetaData(partId)->Set(vtkCompositeDataSet::NAME(), partName.c_str()); |
| 113 | partId++; |
| 114 | |
| 115 | vtkSmartPointer<vtkDataArray> fieldScalar = vtk::TakeSmartPointer(inScalars->NewInstance()); |
| 116 | fieldScalar->SetName(arrayName.c_str()); |
| 117 | fieldScalar->SetNumberOfTuples(1); |
| 118 | fieldScalar->SetTuple1(0, partValue); |
| 119 | part->GetFieldData()->AddArray(fieldScalar); |
| 120 | } |
| 121 | |
| 122 | return 1; |
| 123 | } |
| 124 | |
| 125 | //------------------------------------------------------------------------------ |
| 126 | int vtkExplodeDataSet::FillInputPortInformation(int, vtkInformation* info) |
nothing calls this directly
no test coverage detected