32 vtkInformationVector** inputVector,
33 vtkInformationVector* outputVector)
37 ERR(
"VtkAppendArrayFilter::RequestData(): Selection array is empty.");
40 vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
41 vtkUnstructuredGrid* input = vtkUnstructuredGrid::SafeDownCast(
42 inInfo->Get(vtkDataObject::DATA_OBJECT()));
44 vtkSmartPointer<vtkDoubleArray> colors =
45 vtkSmartPointer<vtkDoubleArray>::New();
46 colors->SetNumberOfComponents(1);
47 std::size_t arrayLength = this->
_array.size();
48 colors->SetNumberOfValues(arrayLength);
49 colors->SetName(
"Selection");
51 std::size_t nCells = input->GetNumberOfCells();
52 if (nCells > arrayLength)
54 "VtkAppendArrayFilter::RequestData(): Number of cells exceeds "
55 "selection array length. Surplus cells won't be examined.");
57 for (std::size_t i = 0; i < arrayLength; i++)
59 colors->SetValue(i,
_array[i]);
62 vtkInformation* outInfo = outputVector->GetInformationObject(0);
63 vtkUnstructuredGrid* output = vtkUnstructuredGrid::SafeDownCast(
64 outInfo->Get(vtkDataObject::DATA_OBJECT()));
65 output->CopyStructure(input);
66 output->GetPointData()->PassData(input->GetPointData());
67 output->GetCellData()->PassData(input->GetCellData());
68 output->GetCellData()->AddArray(colors);
69 output->GetCellData()->SetActiveScalars(
_array_name.c_str());