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 2008 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 int SetBufferColumnStatus( const char* colName, int status ) 00050 { 00051 if ( status ) 00052 { 00053 return this->Buffer.insert( colName ).second ? 1 : 0; 00054 } 00055 else 00056 { 00057 return this->Buffer.erase( colName ) ? 1 : 0; 00058 } 00059 } 00060 int AddBufferToRequests() 00061 { 00062 bool result = false; 00063 // Don't add empty selections to the list of requests. 00064 if ( ! this->Buffer.empty() ) 00065 { 00066 result = this->Requests.insert( this->Buffer ).second; 00067 } 00068 return result ? 1 : 0; 00069 } 00070 int AddBufferEntriesToRequests() 00071 { 00072 int count = 0; 00073 vtksys_stl::set<vtkStdString>::iterator it; 00074 for ( it = this->Buffer.begin(); it != this->Buffer.end(); ++ it ) 00075 { 00076 vtksys_stl::set<vtkStdString> tmp; 00077 tmp.insert( *it ); 00078 if ( this->Requests.insert( tmp ).second ) 00079 { 00080 ++ count; 00081 } 00082 } 00083 return count; 00084 } 00085 int AddBufferEntryPairsToRequests() 00086 { 00087 int count = 0; 00088 vtksys_stl::pair<vtksys_stl::set<vtksys_stl::set<vtkStdString> >::iterator,bool> result; 00089 vtksys_stl::set<vtkStdString>::iterator it; 00090 for ( it = this->Buffer.begin(); it != this->Buffer.end(); ++ it ) 00091 { 00092 vtksys_stl::set<vtkStdString>::iterator it2 = it; 00093 for ( ++ it2; it2 != this->Buffer.end(); ++ it2 ) 00094 { 00095 vtksys_stl::set<vtkStdString> tmp; 00096 tmp.insert( *it ); 00097 tmp.insert( *it2 ); 00098 if ( this->Requests.insert( tmp ).second ) 00099 { 00100 ++ count; 00101 } 00102 } 00103 } 00104 return count; 00105 } 00107 int AddColumnPairToRequests( const char* cola, const char* colb ) 00108 { 00109 if ( cola && colb && strlen( cola ) && strlen( colb ) ) 00110 { 00111 vtksys_stl::set<vtkStdString> tmp; 00112 tmp.insert( cola ); 00113 tmp.insert( colb ); 00114 if ( this->Requests.insert( tmp ).second ) 00115 { 00116 return 1; 00117 } 00118 } 00119 return 0; 00120 } 00121 void ResetRequests() 00122 { 00123 this->Requests.clear(); 00124 } 00125 int ResetBuffer() 00126 { 00127 int rval = this->Buffer.empty() ? 0 : 1; 00128 this->Buffer.clear(); 00129 return rval; 00130 } 00132 vtkIdType GetNumberOfRequests() 00133 { 00134 return static_cast<vtkIdType>( this->Requests.size() ); 00135 } 00137 vtkIdType GetNumberOfColumnsForRequest( vtkIdType r ) 00138 { 00139 if ( r < 0 || r > static_cast<vtkIdType>( this->Requests.size() ) ) 00140 { 00141 return 0; 00142 } 00143 vtksys_stl::set<vtksys_stl::set<vtkStdString> >::iterator it = this->Requests.begin(); 00144 for ( vtkIdType i = 0; i < r; ++ i ) 00145 { 00146 ++ it; 00147 } 00148 return it->size(); 00149 } 00153 bool GetColumnForRequest( vtkIdType r, vtkIdType c, vtkStdString& columnName ) 00154 { 00155 if ( r < 0 || r > static_cast<vtkIdType>( this->Requests.size() ) || c < 0 ) 00156 { 00157 return false; 00158 } 00159 vtksys_stl::set<vtksys_stl::set<vtkStdString> >::const_iterator it = this->Requests.begin(); 00160 for ( vtkIdType i = 0; i < r; ++ i ) 00161 { 00162 ++ it; 00163 } 00164 if ( c > static_cast<vtkIdType>( it->size() ) ) 00165 { 00166 return false; 00167 } 00168 vtksys_stl::set<vtkStdString>::const_iterator cit = it->begin(); 00169 for ( vtkIdType j = 0; j < c; ++ j ) 00170 { 00171 ++ cit; 00172 } 00173 columnName = *cit; 00174 return true; 00175 } 00176 00177 vtksys_stl::set<vtksys_stl::set<vtkStdString> > Requests; 00178 vtksys_stl::set<vtkStdString> Buffer; 00179 }; 00180 00181 #endif // __vtkStatisticsAlgorithmPrivate_h 00182