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  -------------------------------------------------------------------------*/
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  // --------------------------------------------------------------------
51 
53  {
54  this->Requests.clear();
55  }
56  // --------------------------------------------------------------------
58 
59 
61  {
62  int rval = this->Buffer.empty() ? 0 : 1;
63  this->Buffer.clear();
64  return rval;
65  }
66  // --------------------------------------------------------------------
67  int SetBufferColumnStatus( const char* colName, int status )
68  {
69  if ( status )
70  {
71  return this->Buffer.insert( colName ).second ? 1 : 0;
72  }
73  else
74  {
75  return this->Buffer.erase( colName ) ? 1 : 0;
76  }
77  }
78  // --------------------------------------------------------------------
80  {
81  bool result = false;
82  // Don't add empty selections to the list of requests.
83  if ( ! this->Buffer.empty() )
84  {
85  result = this->Requests.insert( this->Buffer ).second;
86  }
87  return result ? 1 : 0;
88  }
89  // --------------------------------------------------------------------
91 
92 
94  int AddColumnToRequests( const char* col )
95  {
96  if ( col && strlen( col ) )
97  {
98  vtksys_stl::set<vtkStdString> tmp;
99  tmp.insert( col );
100  if ( this->Requests.insert( tmp ).second )
101  {
102  return 1;
103  }
104  }
105  return 0;
106  }
107  // --------------------------------------------------------------------
109 
110 
112  int AddColumnPairToRequests( const char* cola, const char* colb )
113  {
114  if ( cola && colb && strlen( cola ) && strlen( colb ) )
115  {
116  vtksys_stl::set<vtkStdString> tmp;
117  tmp.insert( cola );
118  tmp.insert( colb );
119  if ( this->Requests.insert( tmp ).second )
120  {
121  return 1;
122  }
123  }
124  return 0;
125  }
126  // --------------------------------------------------------------------
128 
129 
131  {
132  return static_cast<vtkIdType>( this->Requests.size() );
133  }
134  // --------------------------------------------------------------------
136 
137 
139  {
140  if ( r < 0 || r > static_cast<vtkIdType>( this->Requests.size() ) )
141  {
142  return 0;
143  }
144  vtksys_stl::set<vtksys_stl::set<vtkStdString> >::iterator it = this->Requests.begin();
145  for ( vtkIdType i = 0; i < r; ++ i )
146  {
147  ++ it;
148  }
149  return it->size();
150  }
151  // --------------------------------------------------------------------
153 
154 
158  {
159  if ( r < 0 || r > static_cast<vtkIdType>( this->Requests.size() ) || c < 0 )
160  {
161  return false;
162  }
163  vtksys_stl::set<vtksys_stl::set<vtkStdString> >::const_iterator it = this->Requests.begin();
164  for ( vtkIdType i = 0; i < r; ++ i )
165  {
166  ++ it;
167  }
168  if ( c > static_cast<vtkIdType>( it->size() ) )
169  {
170  return false;
171  }
172  vtksys_stl::set<vtkStdString>::const_iterator cit = it->begin();
173  for ( vtkIdType j = 0; j < c; ++ j )
174  {
175  ++ cit;
176  }
177  columnName = *cit;
178  return true;
179  }
181 
182  vtksys_stl::set<vtksys_stl::set<vtkStdString> > Requests;
183  vtksys_stl::set<vtkStdString> Buffer;
184 };
185 
186 #endif // vtkStatisticsAlgorithmPrivate_h
187 
188 // VTK-HeaderTest-Exclude: vtkStatisticsAlgorithmPrivate.h
int SetBufferColumnStatus(const char *colName, int status)
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
vtksys_stl::set< vtkStdString > Buffer
int vtkIdType
Definition: vtkType.h:275
vtksys_stl::set< vtksys_stl::set< vtkStdString > > Requests
vtkIdType GetNumberOfColumnsForRequest(vtkIdType r)
int AddColumnPairToRequests(const char *cola, const char *colb)
bool GetColumnForRequest(vtkIdType r, vtkIdType c, vtkStdString &columnName)