4#include <vtkFieldData.h>
5#include <vtkIdTypeArray.h>
6#include <vtkInformation.h>
7#include <vtkPointData.h>
8#include <vtkStringArray.h>
20 this->SetNumberOfInputPorts(1);
21 this->SetNumberOfOutputPorts(1);
25 vtkInformation *info) {
27 info->Set(vtkDataObject::DATA_TYPE_NAME(),
"vtkDataSet");
34 vtkInformation *info) {
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)]);
#define ttkNotUsed(x)
Mark function/method parameters that are not used in the function body at all.
static vtkInformationIntegerKey * SAME_DATA_TYPE_AS_INPUT_PORT()
TTK VTK-filter that reads a Cinema Spec D Database.
ttkStringArrayConverter()
int FillOutputPortInformation(int port, vtkInformation *info) override
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
int FillInputPortInformation(int port, vtkInformation *info) override
void setDebugMsgPrefix(const std::string &prefix)
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
vtkStandardNewMacro(ttkStringArrayConverter)