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

Method RequestData

Filters/General/vtkSplitColumnComponents.cxx:39–175  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

37
38//------------------------------------------------------------------------------
39int vtkSplitColumnComponents::RequestData(
40 vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
41{
42 // Get input tables
43 vtkInformation* table1Info = inputVector[0]->GetInformationObject(0);
44 vtkTable* table = vtkTable::SafeDownCast(table1Info->Get(vtkDataObject::DATA_OBJECT()));
45
46 // Get output table
47 vtkInformation* outInfo = outputVector->GetInformationObject(0);
48 vtkTable* output = vtkTable::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
49
50 vtkDataSetAttributes* inputRD = table->GetRowData();
51 vtkDataSetAttributes* outputRD = output->GetRowData();
52
53 vtkDataArray* inputGlobalIds = inputRD->GetGlobalIds();
54
55 // Add columns from table, split multiple component columns as necessary
56 for (int i = 0; i < table->GetNumberOfColumns(); ++i)
57 {
58 if (this->CheckAbort())
59 {
60 break;
61 }
62 vtkAbstractArray* col = table->GetColumn(i);
63 if (col->GetName() == nullptr)
64 {
65 vtkWarningMacro("Skipping column with no name!");
66 continue;
67 }
68
69 int components = col->GetNumberOfComponents();
70 if (components == 1)
71 {
72 output->AddColumn(col);
73 vtkDataArray* newCol =
74 vtkArrayDownCast<vtkDataArray>(output->GetColumn(output->GetNumberOfColumns() - 1));
75
76 if (col == inputGlobalIds)
77 {
78 outputRD->SetGlobalIds(newCol);
79 }
80 }
81 else if (components > 1)
82 {
83 // Split the multicomponent column up into individual columns
84 int colSize = col->GetNumberOfTuples();
85 for (int j = 0; j < components; ++j)
86 {
87 const std::string component_label = this->GetComponentLabel(col, j);
88 vtkAbstractArray* newCol = vtkAbstractArray::CreateArray(col->GetDataType());
89 newCol->SetName(component_label.c_str());
90 newCol->SetNumberOfTuples(colSize);
91 // pass component name overrides, if provided.
92 if (col->HasAComponentName())
93 {
94 newCol->SetComponentName(0, col->GetComponentName(j));
95 }
96 // Now copy the components into their new columns

Callers

nothing calls this directly

Calls 15

GetComponentLabelMethod · 0.95
GetInformationObjectMethod · 0.80
GetRowDataMethod · 0.80
GetGlobalIdsMethod · 0.80
CheckAbortMethod · 0.80
SetGlobalIdsMethod · 0.80
HasAComponentNameMethod · 0.80
SetComponentNameMethod · 0.80
GetComponentNameMethod · 0.80
IsAMethod · 0.80
DeleteMethod · 0.65
CreateArrayFunction · 0.50

Tested by

no test coverage detected