VTK
vtkStatisticsAlgorithmPrivate.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Program: Visualization Toolkit
4 Module: vtkStatisticsAlgorithmPrivate.h
5 
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16  Copyright 2011 Sandia Corporation.
17  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18  the U.S. Government retains certain rights in this software.
19  -------------------------------------------------------------------------*/
34 #ifndef vtkStatisticsAlgorithmPrivate_h
35 #define vtkStatisticsAlgorithmPrivate_h
36 
37 #include "vtkStdString.h"
38 
39 #include <set> // used to iterate over internal organs
40 
42 {
43 public:
45  {
46  }
48  {
49  }
50  // --------------------------------------------------------------------
55  {
56  this->Requests.clear();
57  }
58  // --------------------------------------------------------------------
60 
64  {
65  int rval = this->Buffer.empty() ? 0 : 1;
66  this->Buffer.clear();
67  return rval;
68  }
69  // --------------------------------------------------------------------
70  int SetBufferColumnStatus( const char* colName, int status )
71  {
72  if ( status )
73  {
74  return this->Buffer.insert( colName ).second ? 1 : 0;
75  }
76  else
77  {
78  return this->Buffer.erase( colName ) ? 1 : 0;
79  }
80  }
81  // --------------------------------------------------------------------
83  {
84  bool result = false;
85  // Don't add empty selections to the list of requests.
86  if ( ! this->Buffer.empty() )
87  {
88  result = this->Requests.insert( this->Buffer ).second;
89  }
90  return result ? 1 : 0;
91  }
92  // --------------------------------------------------------------------
94 
95 
98  int AddColumnToRequests( const char* col )
99  {
100  if ( col && strlen( col ) )
101  {
102  std::set<vtkStdString> tmp;
103  tmp.insert( col );
104  if ( this->Requests.insert( tmp ).second )
105  {
106  return 1;
107  }
108  }
109  return 0;
110  }
111  // --------------------------------------------------------------------
113 
114 
117  int AddColumnPairToRequests( const char* cola, const char* colb )
118  {
119  if ( cola && colb && strlen( cola ) && strlen( colb ) )
120  {
121  std::set<vtkStdString> tmp;
122  tmp.insert( cola );
123  tmp.insert( colb );
124  if ( this->Requests.insert( tmp ).second )
125  {
126  return 1;
127  }
128  }
129  return 0;
130  }
131  // --------------------------------------------------------------------
133 
137  {
138  return static_cast<vtkIdType>( this->Requests.size() );
139  }
140  // --------------------------------------------------------------------
142 
146  {
147  if ( r < 0 || r > static_cast<vtkIdType>( this->Requests.size() ) )
148  {
149  return 0;
150  }
151  std::set<std::set<vtkStdString> >::iterator it = this->Requests.begin();
152  for ( vtkIdType i = 0; i < r; ++ i )
153  {
154  ++ it;
155  }
156  return static_cast<vtkIdType>(it->size());
157  }
158  // --------------------------------------------------------------------
160 
161 
166  {
167  if ( r < 0 || r > static_cast<vtkIdType>( this->Requests.size() ) || c < 0 )
168  {
169  return false;
170  }
171  std::set<std::set<vtkStdString> >::const_iterator it = this->Requests.begin();
172  for ( vtkIdType i = 0; i < r; ++ i )
173  {
174  ++ it;
175  }
176  if ( c > static_cast<vtkIdType>( it->size() ) )
177  {
178  return false;
179  }
180  std::set<vtkStdString>::const_iterator cit = it->begin();
181  for ( vtkIdType j = 0; j < c; ++ j )
182  {
183  ++ cit;
184  }
185  columnName = *cit;
186  return true;
187  }
189 
190  std::set<std::set<vtkStdString> > Requests;
191  std::set<vtkStdString> Buffer;
192 };
193 
194 #endif // vtkStatisticsAlgorithmPrivate_h
195 
196 // VTK-HeaderTest-Exclude: vtkStatisticsAlgorithmPrivate.h
int SetBufferColumnStatus(const char *colName, int status)
Empty current buffer.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:40
int AddColumnToRequests(const char *col)
This function does not use the buffer like other column selection methods.
int ResetBuffer()
Empty current buffer.
int vtkIdType
Definition: vtkType.h:347
vtkIdType GetNumberOfColumnsForRequest(vtkIdType r)
Return the number of columns associated with request r.
int AddColumnPairToRequests(const char *cola, const char *colb)
This function does not use the buffer like other column selection methods.
int AddBufferToRequests()
Empty current buffer.
vtkIdType GetNumberOfRequests()
Return the number of currently-defined requests.
bool GetColumnForRequest(vtkIdType r, vtkIdType c, vtkStdString &columnName)
Provide the name of the c-th column of the r-th request in columnName.
std::set< std::set< vtkStdString > > Requests
void ResetRequests()
Empty current set of requests.