VTK  9.2.20230328
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 
41 VTK_ABI_NAMESPACE_BEGIN
43 {
44 public:
45  // --------------------------------------------------------------------
49  void ResetRequests() { this->Requests.clear(); }
50  // --------------------------------------------------------------------
52 
56  {
57  int rval = this->Buffer.empty() ? 0 : 1;
58  this->Buffer.clear();
59  return rval;
60  }
61  // --------------------------------------------------------------------
62  int SetBufferColumnStatus(const char* colName, int status)
63  {
64  if (status)
65  {
66  return this->Buffer.insert(colName).second ? 1 : 0;
67  }
68  else
69  {
70  return this->Buffer.erase(colName) ? 1 : 0;
71  }
72  }
73  // --------------------------------------------------------------------
75  {
76  bool result = false;
77  // Don't add empty selections to the list of requests.
78  if (!this->Buffer.empty())
79  {
80  result = this->Requests.insert(this->Buffer).second;
81  }
82  return result ? 1 : 0;
83  }
84  // --------------------------------------------------------------------
87 
90  int AddColumnToRequests(const char* col)
91  {
92  if (col && *col)
93  {
94  std::set<vtkStdString> tmp;
95  tmp.insert(col);
96  if (this->Requests.insert(tmp).second)
97  {
98  return 1;
99  }
100  }
101  return 0;
102  }
103  // --------------------------------------------------------------------
106 
109  int AddColumnPairToRequests(const char* cola, const char* colb)
110  {
111  if (cola && colb && *cola && *colb)
112  {
113  std::set<vtkStdString> tmp;
114  tmp.insert(cola);
115  tmp.insert(colb);
116  if (this->Requests.insert(tmp).second)
117  {
118  return 1;
119  }
120  }
121  return 0;
122  }
123  // --------------------------------------------------------------------
125 
128  vtkIdType GetNumberOfRequests() { return static_cast<vtkIdType>(this->Requests.size()); }
129  // --------------------------------------------------------------------
131 
135  {
136  if (r < 0 || r > static_cast<vtkIdType>(this->Requests.size()))
137  {
138  return 0;
139  }
140  std::set<std::set<vtkStdString>>::iterator it = this->Requests.begin();
141  for (vtkIdType i = 0; i < r; ++i)
142  {
143  ++it;
144  }
145  return static_cast<vtkIdType>(it->size());
146  }
147  // --------------------------------------------------------------------
150 
155  {
156  if (r < 0 || r > static_cast<vtkIdType>(this->Requests.size()) || c < 0)
157  {
158  return false;
159  }
160  std::set<std::set<vtkStdString>>::const_iterator it = this->Requests.begin();
161  for (vtkIdType i = 0; i < r; ++i)
162  {
163  ++it;
164  }
165  if (c > static_cast<vtkIdType>(it->size()))
166  {
167  return false;
168  }
169  std::set<vtkStdString>::const_iterator cit = it->begin();
170  for (vtkIdType j = 0; j < c; ++j)
171  {
172  ++cit;
173  }
174  columnName = *cit;
175  return true;
176  }
178 
179  std::set<std::set<vtkStdString>> Requests;
180  std::set<vtkStdString> Buffer;
181 };
182 
183 VTK_ABI_NAMESPACE_END
184 #endif // vtkStatisticsAlgorithmPrivate_h
185 
186 // VTK-HeaderTest-Exclude: vtkStatisticsAlgorithmPrivate.h
int AddColumnToRequests(const char *col)
This function does not use the buffer like other column selection methods.
vtkIdType GetNumberOfRequests()
Return the number of currently-defined requests.
void ResetRequests()
Empty current set of requests.
int SetBufferColumnStatus(const char *colName, int status)
Empty current buffer.
int AddBufferToRequests()
Empty current buffer.
bool GetColumnForRequest(vtkIdType r, vtkIdType c, vtkStdString &columnName)
Provide the name of the c-th column of the r-th request in columnName.
int AddColumnPairToRequests(const char *cola, const char *colb)
This function does not use the buffer like other column selection methods.
std::set< std::set< vtkStdString > > Requests
vtkIdType GetNumberOfColumnsForRequest(vtkIdType r)
Return the number of columns associated with request r.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:110
int vtkIdType
Definition: vtkType.h:327