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

Method RequestData

Filters/General/vtkExplodeDataSet.cxx:79–123  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

77
78//------------------------------------------------------------------------------
79int 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//------------------------------------------------------------------------------
126int vtkExplodeDataSet::FillInputPortInformation(int, vtkInformation* info)

Callers

nothing calls this directly

Calls 15

GetIdListsByValueMethod · 0.95
CreatePartitionMethod · 0.95
SetTuple1Method · 0.80
GetDataFunction · 0.50
to_stringFunction · 0.50
sizeMethod · 0.45
GetNameMethod · 0.45
SetPartitionMethod · 0.45
SetMethod · 0.45
GetMetaDataMethod · 0.45

Tested by

no test coverage detected