------------------------------------------------------------------------------
| 130 | |
| 131 | //------------------------------------------------------------------------------ |
| 132 | void vtkReduceTable::PopulateDataColumn(vtkTable* input, vtkTable* output, vtkIdType col) |
| 133 | { |
| 134 | int reductionMethod = 0; |
| 135 | |
| 136 | // check if this column has a reduction method |
| 137 | int columnSpecificMethod = this->GetReductionMethodForColumn(col); |
| 138 | if (columnSpecificMethod != -1) |
| 139 | { |
| 140 | reductionMethod = columnSpecificMethod; |
| 141 | } |
| 142 | else |
| 143 | { |
| 144 | // determine whether this column contains numerical or not. |
| 145 | if (input->GetValue(0, col).IsNumeric()) |
| 146 | { |
| 147 | reductionMethod = this->NumericalReductionMethod; |
| 148 | } |
| 149 | else |
| 150 | { |
| 151 | reductionMethod = this->NonNumericalReductionMethod; |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | for (vtkIdType row = 0; row < output->GetNumberOfRows(); ++row) |
| 156 | { |
| 157 | // look up the cells in the input table that should be represented by |
| 158 | // this cell in the output table |
| 159 | vtkVariant indexValue = output->GetValue(row, this->IndexColumn); |
| 160 | std::vector<vtkIdType> oldRows = this->NewRowToOldRowsMap[indexValue]; |
| 161 | |
| 162 | // special case: one-to-one mapping between input table and output table |
| 163 | // (no collapse necessary) |
| 164 | if (oldRows.size() == 1) |
| 165 | { |
| 166 | output->SetValue(row, col, input->GetValue(this->NewRowToOldRowsMap[indexValue].at(0), col)); |
| 167 | continue; |
| 168 | } |
| 169 | |
| 170 | // otherwise, combine them appropriately & store the value in the |
| 171 | // output table |
| 172 | switch (reductionMethod) |
| 173 | { |
| 174 | case vtkReduceTable::MODE: |
| 175 | this->ReduceValuesToMode(input, output, row, col, oldRows); |
| 176 | break; |
| 177 | case vtkReduceTable::MEDIAN: |
| 178 | this->ReduceValuesToMedian(input, output, row, col, oldRows); |
| 179 | break; |
| 180 | case vtkReduceTable::MEAN: |
| 181 | default: |
| 182 | this->ReduceValuesToMean(input, output, row, col, oldRows); |
| 183 | break; |
| 184 | } |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | //------------------------------------------------------------------------------ |
| 189 | void vtkReduceTable::ReduceValuesToMean( |
no test coverage detected