43 vtkInformationVector **inputVector,
44 vtkInformationVector *outputVector) {
45 const auto input = vtkDataSet::GetData(inputVector[0]);
46 auto output = vtkDataSet::GetData(outputVector);
48 if(input ==
nullptr || output ==
nullptr) {
49 this->
printErr(
"Null input data, aborting");
54 const auto sa = vtkStringArray::SafeDownCast(
55 this->GetInputAbstractArrayToProcess(0, inputVector));
58 this->
printErr(
"Cannot find the required string array");
62 const auto nvalues = sa->GetNumberOfTuples();
64 std::set<std::string> values{};
66 for(vtkIdType i = 0; i < nvalues; ++i) {
67 values.emplace(sa->GetValue(i));
70 std::map<std::string, size_t> valInd{};
74 for(
const auto &el : values) {
81 output->ShallowCopy(input);
83 const auto pdo = output->GetPointData();
86 vtkNew<vtkIdTypeArray> ia{};
88 std::string colname{sa->GetName()};
90 ia->SetName(colname.data());
91 ia->SetNumberOfTuples(nvalues);
93 for(vtkIdType i = 0; i < nvalues; ++i) {
94 ia->SetValue(i, valInd[sa->GetValue(i)]);