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

Method PopulateDataColumn

Infovis/Core/vtkReduceTable.cxx:132–186  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

130
131//------------------------------------------------------------------------------
132void 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//------------------------------------------------------------------------------
189void vtkReduceTable::ReduceValuesToMean(

Callers 1

RequestDataMethod · 0.95

Calls 10

ReduceValuesToModeMethod · 0.95
ReduceValuesToMedianMethod · 0.95
ReduceValuesToMeanMethod · 0.95
IsNumericMethod · 0.45
GetValueMethod · 0.45
GetNumberOfRowsMethod · 0.45
sizeMethod · 0.45
SetValueMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected