VTK
dox/Infovis/Core/vtkReduceTable.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkReduceTable.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00038 #ifndef __vtkReduceTable_h
00039 #define __vtkReduceTable_h
00040 
00041 #include "vtkInfovisCoreModule.h" // For export macro
00042 #include "vtkTableAlgorithm.h"
00043 
00044 #include <map>                   // For ivar
00045 #include <set>                   // For ivar
00046 #include <vector>                // For ivar
00047 
00048 class vtkVariant;
00049 
00050 class VTKINFOVISCORE_EXPORT vtkReduceTable : public vtkTableAlgorithm
00051 {
00052 public:
00053   static vtkReduceTable* New();
00054   vtkTypeMacro(vtkReduceTable,vtkTableAlgorithm);
00055   void PrintSelf(ostream& os, vtkIndent indent);
00056 
00058 
00061   vtkGetMacro(IndexColumn, vtkIdType);
00062   vtkSetMacro(IndexColumn, vtkIdType);
00064 
00066 
00067   vtkGetMacro(NumericalReductionMethod, int);
00068   vtkSetMacro(NumericalReductionMethod, int);
00070 
00072 
00074   vtkGetMacro(NonNumericalReductionMethod, int);
00075   vtkSetMacro(NonNumericalReductionMethod, int);
00077 
00081   int GetReductionMethodForColumn(vtkIdType col);
00082 
00085   void SetReductionMethodForColumn(vtkIdType col, int method);
00086 
00087   //BTX
00089 
00090   enum
00091     {
00092     MEAN,
00093     MEDIAN,
00094     MODE
00095     };
00096   //ETX
00098 
00099 protected:
00100   vtkReduceTable();
00101   ~vtkReduceTable();
00102 
00103   int RequestData(
00104     vtkInformation*,
00105     vtkInformationVector**,
00106     vtkInformationVector*);
00107 
00110   void InitializeOutputTable(vtkTable *input, vtkTable *output);
00111 
00114   void AccumulateIndexValues(vtkTable *input);
00115 
00117   void PopulateIndexColumn(vtkTable *output);
00118 
00122   void PopulateDataColumn(vtkTable *input, vtkTable *output, vtkIdType col);
00123 
00125 
00127   void ReduceValuesToMean(vtkTable *input, vtkTable *output,
00128                           vtkIdType row, vtkIdType col,
00129                           std::vector<vtkIdType> oldRows);
00131 
00133 
00135   void ReduceValuesToMedian(vtkTable *input, vtkTable *output,
00136                             vtkIdType row, vtkIdType col,
00137                             std::vector<vtkIdType> oldRows);
00139 
00141 
00143   void ReduceValuesToMode(vtkTable *input, vtkTable *output,
00144                           vtkIdType row, vtkIdType col,
00145                           std::vector<vtkIdType> oldRows);
00147 
00148   vtkIdType IndexColumn;
00149   std::set<vtkVariant> IndexValues;
00150   std::map<vtkVariant, std::vector<vtkIdType> > NewRowToOldRowsMap;
00151   std::map<vtkIdType, int> ColumnReductionMethods;
00152 
00153   int NumericalReductionMethod;
00154   int NonNumericalReductionMethod;
00155 
00156 private:
00157   vtkReduceTable(const vtkReduceTable&); // Not implemented
00158   void operator=(const vtkReduceTable&);   // Not implemented
00159 };
00160 
00161 #endif