VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkStatisticsAlgorithmPrivate.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 =========================================================================*/ 00015 /*------------------------------------------------------------------------- 00016 Copyright 2011 Sandia Corporation. 00017 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00018 the U.S. Government retains certain rights in this software. 00019 -------------------------------------------------------------------------*/ 00033 #ifndef __vtkStatisticsAlgorithmPrivate_h 00034 #define __vtkStatisticsAlgorithmPrivate_h 00035 00036 #include "vtkStdString.h" 00037 00038 #include <vtksys/stl/set> // used to iterate over internal organs 00039 00040 class vtkStatisticsAlgorithmPrivate 00041 { 00042 public: 00043 vtkStatisticsAlgorithmPrivate() 00044 { 00045 } 00046 ~vtkStatisticsAlgorithmPrivate() 00047 { 00048 } 00049 // -------------------------------------------------------------------- 00051 00052 void ResetRequests() 00053 { 00054 this->Requests.clear(); 00055 } 00056 // -------------------------------------------------------------------- 00058 00059 00060 int ResetBuffer() 00061 { 00062 int rval = this->Buffer.empty() ? 0 : 1; 00063 this->Buffer.clear(); 00064 return rval; 00065 } 00066 // -------------------------------------------------------------------- 00067 int SetBufferColumnStatus( const char* colName, int status ) 00068 { 00069 if ( status ) 00070 { 00071 return this->Buffer.insert( colName ).second ? 1 : 0; 00072 } 00073 else 00074 { 00075 return this->Buffer.erase( colName ) ? 1 : 0; 00076 } 00077 } 00078 // -------------------------------------------------------------------- 00079 int AddBufferToRequests() 00080 { 00081 bool result = false; 00082 // Don't add empty selections to the list of requests. 00083 if ( ! this->Buffer.empty() ) 00084 { 00085 result = this->Requests.insert( this->Buffer ).second; 00086 } 00087 return result ? 1 : 0; 00088 } 00089 // -------------------------------------------------------------------- 00091 00092 00094 int AddColumnToRequests( const char* col ) 00095 { 00096 if ( col && strlen( col ) ) 00097 { 00098 vtksys_stl::set<vtkStdString> tmp; 00099 tmp.insert( col ); 00100 if ( this->Requests.insert( tmp ).second ) 00101 { 00102 return 1; 00103 } 00104 } 00105 return 0; 00106 } 00107 // -------------------------------------------------------------------- 00109 00110 00112 int AddColumnPairToRequests( const char* cola, const char* colb ) 00113 { 00114 if ( cola && colb && strlen( cola ) && strlen( colb ) ) 00115 { 00116 vtksys_stl::set<vtkStdString> tmp; 00117 tmp.insert( cola ); 00118 tmp.insert( colb ); 00119 if ( this->Requests.insert( tmp ).second ) 00120 { 00121 return 1; 00122 } 00123 } 00124 return 0; 00125 } 00126 // -------------------------------------------------------------------- 00128 00129 00130 vtkIdType GetNumberOfRequests() 00131 { 00132 return static_cast<vtkIdType>( this->Requests.size() ); 00133 } 00134 // -------------------------------------------------------------------- 00136 00137 00138 vtkIdType GetNumberOfColumnsForRequest( vtkIdType r ) 00139 { 00140 if ( r < 0 || r > static_cast<vtkIdType>( this->Requests.size() ) ) 00141 { 00142 return 0; 00143 } 00144 vtksys_stl::set<vtksys_stl::set<vtkStdString> >::iterator it = this->Requests.begin(); 00145 for ( vtkIdType i = 0; i < r; ++ i ) 00146 { 00147 ++ it; 00148 } 00149 return it->size(); 00150 } 00151 // -------------------------------------------------------------------- 00153 00154 00157 bool GetColumnForRequest( vtkIdType r, vtkIdType c, vtkStdString& columnName ) 00158 { 00159 if ( r < 0 || r > static_cast<vtkIdType>( this->Requests.size() ) || c < 0 ) 00160 { 00161 return false; 00162 } 00163 vtksys_stl::set<vtksys_stl::set<vtkStdString> >::const_iterator it = this->Requests.begin(); 00164 for ( vtkIdType i = 0; i < r; ++ i ) 00165 { 00166 ++ it; 00167 } 00168 if ( c > static_cast<vtkIdType>( it->size() ) ) 00169 { 00170 return false; 00171 } 00172 vtksys_stl::set<vtkStdString>::const_iterator cit = it->begin(); 00173 for ( vtkIdType j = 0; j < c; ++ j ) 00174 { 00175 ++ cit; 00176 } 00177 columnName = *cit; 00178 return true; 00179 } 00181 00182 vtksys_stl::set<vtksys_stl::set<vtkStdString> > Requests; 00183 vtksys_stl::set<vtkStdString> Buffer; 00184 }; 00185 00186 #endif // __vtkStatisticsAlgorithmPrivate_h 00187 00188 // VTK-HeaderTest-Exclude: vtkStatisticsAlgorithmPrivate.h