43 vtkInformationVector** inputVector,
44 vtkInformationVector* outputVector)
48 ERR(
"VtkAppendArrayFilter::RequestData(): Selection array is empty.");
51 vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
52 vtkUnstructuredGrid* input = vtkUnstructuredGrid::SafeDownCast(
53 inInfo->Get(vtkDataObject::DATA_OBJECT()));
55 vtkSmartPointer<vtkDoubleArray> colors =
56 vtkSmartPointer<vtkDoubleArray>::New();
57 colors->SetNumberOfComponents(1);
58 std::size_t arrayLength = this->
_array.size();
59 colors->SetNumberOfValues(arrayLength);
60 colors->SetName(
"Selection");
62 std::size_t nCells = input->GetNumberOfCells();
63 if (nCells > arrayLength)
65 "VtkAppendArrayFilter::RequestData(): Number of cells exceeds "
66 "selection array length. Surplus cells won't be examined.");
68 for (std::size_t i = 0; i < arrayLength; i++)
70 colors->SetValue(i,
_array[i]);
73 vtkInformation* outInfo = outputVector->GetInformationObject(0);
74 vtkUnstructuredGrid* output = vtkUnstructuredGrid::SafeDownCast(
75 outInfo->Get(vtkDataObject::DATA_OBJECT()));
76 output->CopyStructure(input);
77 output->GetPointData()->PassData(input->GetPointData());
78 output->GetCellData()->PassData(input->GetCellData());
79 output->GetCellData()->AddArray(colors);
80 output->GetCellData()->SetActiveScalars(
_array_name.c_str());