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

Method RequestData

Infovis/Core/vtkStringToCategory.cxx:40–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40int vtkStringToCategory::RequestData(
41 vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
42{
43 // Get the info objects
44 vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
45 vtkInformation* outInfo = outputVector->GetInformationObject(0);
46 vtkInformation* outKeyInfo = outputVector->GetInformationObject(1);
47
48 // Get the input and output objects
49 vtkDataObject* input = inInfo->Get(vtkDataObject::DATA_OBJECT());
50 vtkDataObject* output = outInfo->Get(vtkDataObject::DATA_OBJECT());
51 output->ShallowCopy(input);
52
53 // This second output stores a list of the unique strings, in the same order
54 // as used in the first output.
55 vtkTable* stringTable = vtkTable::SafeDownCast(outKeyInfo->Get(vtkDataObject::DATA_OBJECT()));
56 vtkStringArray* strings =
57 vtkArrayDownCast<vtkStringArray>(stringTable->GetColumnByName("Strings"));
58 if (strings)
59 {
60 strings->SetNumberOfTuples(0);
61 }
62 else
63 {
64 strings = vtkStringArray::New();
65 strings->SetName("Strings");
66 stringTable->AddColumn(strings);
67 strings->Delete();
68 }
69
70 vtkAbstractArray* arr = this->GetInputAbstractArrayToProcess(0, 0, inputVector);
71 vtkStringArray* stringArr = vtkArrayDownCast<vtkStringArray>(arr);
72 if (!stringArr)
73 {
74 vtkErrorMacro("String array input could not be found");
75 return 0;
76 }
77
78 vtkInformation* arrayInfo = this->GetInputArrayInformation(0);
79 // Find where the input array came from
80 vtkFieldData* fd =
81 output->GetAttributesAsFieldData(arrayInfo->Get(vtkDataObject::FIELD_ASSOCIATION()));
82 if (!fd)
83 {
84 vtkErrorMacro("Could not find where the input array came from");
85 return 0;
86 }
87
88 // Perform the conversion
89 vtkIdType numTuples = stringArr->GetNumberOfTuples();
90 int numComp = stringArr->GetNumberOfComponents();
91 vtkIntArray* catArr = vtkIntArray::New();
92 if (this->CategoryArrayName)
93 {
94 catArr->SetName(this->CategoryArrayName);
95 }
96 else
97 {

Callers

nothing calls this directly

Calls 15

GetInformationObjectMethod · 0.80
GetColumnByNameMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
GetMethod · 0.45
ShallowCopyMethod · 0.45
SetNumberOfTuplesMethod · 0.45
SetNameMethod · 0.45
AddColumnMethod · 0.45

Tested by

no test coverage detected