| 91 | } |
| 92 | |
| 93 | int vtkBoostSplitTableField::RequestData( |
| 94 | vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector* outputVector) |
| 95 | { |
| 96 | vtkTable* const input = vtkTable::GetData(inputVector[0]); |
| 97 | vtkTable* const output = vtkTable::GetData(outputVector); |
| 98 | |
| 99 | // If the number of fields and delimiters don't match, we're done ... |
| 100 | if (this->Fields->GetNumberOfValues() != this->Delimiters->GetNumberOfValues()) |
| 101 | { |
| 102 | vtkErrorMacro("The number of fields and the number of delimiters must match"); |
| 103 | return 0; |
| 104 | } |
| 105 | |
| 106 | // If no fields were specified, we don't do any splitting - just shallow copy ... |
| 107 | if (0 == this->Fields->GetNumberOfValues()) |
| 108 | { |
| 109 | output->ShallowCopy(input); |
| 110 | return 1; |
| 111 | } |
| 112 | |
| 113 | // Setup the columns for our output table ... |
| 114 | for (vtkIdType i = 0; i < input->GetNumberOfColumns(); ++i) |
| 115 | { |
| 116 | vtkAbstractArray* const column = input->GetColumn(i); |
| 117 | vtkAbstractArray* const new_column = vtkAbstractArray::CreateArray(column->GetDataType()); |
| 118 | new_column->SetName(column->GetName()); |
| 119 | new_column->SetNumberOfComponents(column->GetNumberOfComponents()); |
| 120 | output->AddColumn(new_column); |
| 121 | if (input->GetRowData()->GetPedigreeIds() == column) |
| 122 | { |
| 123 | output->GetRowData()->SetPedigreeIds(new_column); |
| 124 | } |
| 125 | new_column->Delete(); |
| 126 | } |
| 127 | |
| 128 | // Setup a tokenizer for each column that will be split ... |
| 129 | implementation::tokenizers_t tokenizers; |
| 130 | for (vtkIdType column = 0; column < input->GetNumberOfColumns(); ++column) |
| 131 | { |
| 132 | tokenizers.push_back(static_cast<implementation::tokenizer_t*>(nullptr)); |
| 133 | |
| 134 | for (vtkIdType field = 0; field < this->Fields->GetNumberOfValues(); ++field) |
| 135 | { |
| 136 | if (this->Fields->GetValue(field) == input->GetColumn(column)->GetName()) |
| 137 | { |
| 138 | tokenizers[column] = new implementation::tokenizer_t( |
| 139 | std::string(), implementation::delimiter_t(this->Delimiters->GetValue(field).c_str())); |
| 140 | break; |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | // Iterate over each row in the input table, generating one-to-many rows in the output table ... |
| 146 | vtkVariantArray* const output_row = vtkVariantArray::New(); |
| 147 | output_row->SetNumberOfValues(input->GetNumberOfColumns()); |
| 148 | |
| 149 | for (vtkIdType i = 0; i < input->GetNumberOfRows(); ++i) |
| 150 | { |
nothing calls this directly
no test coverage detected