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 2010 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  -------------------------------------------------------------------------*/
33 #ifndef __vtkStatisticsAlgorithmPrivate_h
34 #define __vtkStatisticsAlgorithmPrivate_h
35 
36 #include "vtkStdString.h"
37 
38 #include <vtksys/stl/set> // used to iterate over internal organs
39 
41 {
42 public:
44  {
45  }
47  {
48  }
49  int SetBufferColumnStatus( const char* colName, int status )
50  {
51  if ( status )
52  {
53  return this->Buffer.insert( colName ).second ? 1 : 0;
54  }
55  else
56  {
57  return this->Buffer.erase( colName ) ? 1 : 0;
58  }
59  }
61  {
62  bool result = false;
63  // Don't add empty selections to the list of requests.
64  if ( ! this->Buffer.empty() )
65  {
66  result = this->Requests.insert( this->Buffer ).second;
67  }
68  return result ? 1 : 0;
69  }
71  {
72  int count = 0;
73  vtksys_stl::set<vtkStdString>::iterator it;
74  for ( it = this->Buffer.begin(); it != this->Buffer.end(); ++ it )
75  {
76  vtksys_stl::set<vtkStdString> tmp;
77  tmp.insert( *it );
78  if ( this->Requests.insert( tmp ).second )
79  {
80  ++ count;
81  }
82  }
83  return count;
84  }
86  {
87  int count = 0;
88  vtksys_stl::pair<vtksys_stl::set<vtksys_stl::set<vtkStdString> >::iterator,bool> result;
89  vtksys_stl::set<vtkStdString>::iterator it;
90  for ( it = this->Buffer.begin(); it != this->Buffer.end(); ++ it )
91  {
92  vtksys_stl::set<vtkStdString>::iterator it2 = it;
93  for ( ++ it2; it2 != this->Buffer.end(); ++ it2 )
94  {
95  vtksys_stl::set<vtkStdString> tmp;
96  tmp.insert( *it );
97  tmp.insert( *it2 );
98  if ( this->Requests.insert( tmp ).second )
99  {
100  ++ count;
101  }
102  }
103  }
104  return count;
105  }
107  int AddColumnPairToRequests( const char* cola, const char* colb )
108  {
109  if ( cola && colb && strlen( cola ) && strlen( colb ) )
110  {
111  vtksys_stl::set<vtkStdString> tmp;
112  tmp.insert( cola );
113  tmp.insert( colb );
114  if ( this->Requests.insert( tmp ).second )
115  {
116  return 1;
117  }
118  }
119  return 0;
120  }
122  {
123  this->Requests.clear();
124  }
126  {
127  int rval = this->Buffer.empty() ? 0 : 1;
128  this->Buffer.clear();
129  return rval;
130  }
133  {
134  return static_cast<vtkIdType>( this->Requests.size() );
135  }
138  {
139  if ( r < 0 || r > static_cast<vtkIdType>( this->Requests.size() ) )
140  {
141  return 0;
142  }
143  vtksys_stl::set<vtksys_stl::set<vtkStdString> >::iterator it = this->Requests.begin();
144  for ( vtkIdType i = 0; i < r; ++ i )
145  {
146  ++ it;
147  }
148  return it->size();
149  }
154  {
155  if ( r < 0 || r > static_cast<vtkIdType>( this->Requests.size() ) || c < 0 )
156  {
157  return false;
158  }
159  vtksys_stl::set<vtksys_stl::set<vtkStdString> >::const_iterator it = this->Requests.begin();
160  for ( vtkIdType i = 0; i < r; ++ i )
161  {
162  ++ it;
163  }
164  if ( c > static_cast<vtkIdType>( it->size() ) )
165  {
166  return false;
167  }
168  vtksys_stl::set<vtkStdString>::const_iterator cit = it->begin();
169  for ( vtkIdType j = 0; j < c; ++ j )
170  {
171  ++ cit;
172  }
173  columnName = *cit;
174  return true;
175  }
176 
177  vtksys_stl::set<vtksys_stl::set<vtkStdString> > Requests;
178  vtksys_stl::set<vtkStdString> Buffer;
179 };
180 
181 #endif // __vtkStatisticsAlgorithmPrivate_h
182 
int SetBufferColumnStatus(const char *colName, int status)
Wrapper around vtkstd::string to keep symbols short.
Definition: vtkStdString.h:45
vtksys_stl::set< vtkStdString > Buffer
int vtkIdType
Definition: vtkType.h:255
vtksys_stl::set< vtksys_stl::set< vtkStdString > > Requests
vtkIdType GetNumberOfColumnsForRequest(vtkIdType r)
Return the number of columns associated with request r.
int AddColumnPairToRequests(const char *cola, const char *colb)
This function doesn't use the buffer like other column selection methods.
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.