VTK  9.2.6
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:
44  // --------------------------------------------------------------------
48  void ResetRequests() { this->Requests.clear(); }
49  // --------------------------------------------------------------------
51 
55  {
56  int rval = this->Buffer.empty() ? 0 : 1;
57  this->Buffer.clear();
58  return rval;
59  }
60  // --------------------------------------------------------------------
61  int SetBufferColumnStatus(const char* colName, int status)
62  {
63  if (status)
64  {
65  return this->Buffer.insert(colName).second ? 1 : 0;
66  }
67  else
68  {
69  return this->Buffer.erase(colName) ? 1 : 0;
70  }
71  }
72  // --------------------------------------------------------------------
74  {
75  bool result = false;
76  // Don't add empty selections to the list of requests.
77  if (!this->Buffer.empty())
78  {
79  result = this->Requests.insert(this->Buffer).second;
80  }
81  return result ? 1 : 0;
82  }
83  // --------------------------------------------------------------------
86 
89  int AddColumnToRequests(const char* col)
90  {
91  if (col && strlen(col))
92  {
93  std::set<vtkStdString> tmp;
94  tmp.insert(col);
95  if (this->Requests.insert(tmp).second)
96  {
97  return 1;
98  }
99  }
100  return 0;
101  }
102  // --------------------------------------------------------------------
105 
108  int AddColumnPairToRequests(const char* cola, const char* colb)
109  {
110  if (cola && colb && strlen(cola) && strlen(colb))
111  {
112  std::set<vtkStdString> tmp;
113  tmp.insert(cola);
114  tmp.insert(colb);
115  if (this->Requests.insert(tmp).second)
116  {
117  return 1;
118  }
119  }
120  return 0;
121  }
122  // --------------------------------------------------------------------
124 
127  vtkIdType GetNumberOfRequests() { return static_cast<vtkIdType>(this->Requests.size()); }
128  // --------------------------------------------------------------------
130 
134  {
135  if (r < 0 || r > static_cast<vtkIdType>(this->Requests.size()))
136  {
137  return 0;
138  }
139  std::set<std::set<vtkStdString>>::iterator it = this->Requests.begin();
140  for (vtkIdType i = 0; i < r; ++i)
141  {
142  ++it;
143  }
144  return static_cast<vtkIdType>(it->size());
145  }
146  // --------------------------------------------------------------------
149 
154  {
155  if (r < 0 || r > static_cast<vtkIdType>(this->Requests.size()) || c < 0)
156  {
157  return false;
158  }
159  std::set<std::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  std::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  }
177 
178  std::set<std::set<vtkStdString>> Requests;
179  std::set<vtkStdString> Buffer;
180 };
181 
182 #endif // vtkStatisticsAlgorithmPrivate_h
183 
184 // 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:38
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:332
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.