VTK  9.4.20241217
vtkStatisticsAlgorithmPrivate.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-FileCopyrightText: Copyright 2011 Sandia Corporation
3// SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
18#ifndef vtkStatisticsAlgorithmPrivate_h
19#define vtkStatisticsAlgorithmPrivate_h
20
21#include "vtkStdString.h"
22
23#include <set> // used to iterate over internal organs
24
25VTK_ABI_NAMESPACE_BEGIN
27{
28public:
29 // --------------------------------------------------------------------
33 void ResetRequests() { this->Requests.clear(); }
34 // --------------------------------------------------------------------
36
40 {
41 int rval = this->Buffer.empty() ? 0 : 1;
42 this->Buffer.clear();
43 return rval;
44 }
45 // --------------------------------------------------------------------
46 int SetBufferColumnStatus(const char* colName, int status)
47 {
48 if (status)
49 {
50 return this->Buffer.insert(colName).second ? 1 : 0;
51 }
52 else
53 {
54 return this->Buffer.erase(colName) ? 1 : 0;
55 }
56 }
57 // --------------------------------------------------------------------
59 {
60 bool result = false;
61 // Don't add empty selections to the list of requests.
62 if (!this->Buffer.empty())
63 {
64 result = this->Requests.insert(this->Buffer).second;
65 }
66 return result ? 1 : 0;
67 }
68 // --------------------------------------------------------------------
71
74 int AddColumnToRequests(const char* col)
75 {
76 if (col && *col)
77 {
78 std::set<vtkStdString> tmp;
79 tmp.insert(col);
80 if (this->Requests.insert(tmp).second)
81 {
82 return 1;
83 }
84 }
85 return 0;
86 }
87 // --------------------------------------------------------------------
90
93 int AddColumnPairToRequests(const char* cola, const char* colb)
94 {
95 if (cola && colb && *cola && *colb)
96 {
97 std::set<vtkStdString> tmp;
98 tmp.insert(cola);
99 tmp.insert(colb);
100 if (this->Requests.insert(tmp).second)
101 {
102 return 1;
103 }
104 }
105 return 0;
106 }
107 // --------------------------------------------------------------------
109
112 vtkIdType GetNumberOfRequests() { return static_cast<vtkIdType>(this->Requests.size()); }
113 // --------------------------------------------------------------------
115
119 {
120 if (r < 0 || r > static_cast<vtkIdType>(this->Requests.size()))
121 {
122 return 0;
123 }
124 std::set<std::set<vtkStdString>>::iterator it = this->Requests.begin();
125 for (vtkIdType i = 0; i < r; ++i)
126 {
127 ++it;
128 }
129 return static_cast<vtkIdType>(it->size());
130 }
131 // --------------------------------------------------------------------
134
139 {
140 if (r < 0 || r > static_cast<vtkIdType>(this->Requests.size()) || c < 0)
141 {
142 return false;
143 }
144 std::set<std::set<vtkStdString>>::const_iterator it = this->Requests.begin();
145 for (vtkIdType i = 0; i < r; ++i)
146 {
147 ++it;
148 }
149 if (c > static_cast<vtkIdType>(it->size()))
150 {
151 return false;
152 }
153 std::set<vtkStdString>::const_iterator cit = it->begin();
154 for (vtkIdType j = 0; j < c; ++j)
155 {
156 ++cit;
157 }
158 columnName = *cit;
159 return true;
160 }
162
163 std::set<std::set<vtkStdString>> Requests;
164 std::set<vtkStdString> Buffer;
165};
166
167VTK_ABI_NAMESPACE_END
168#endif // vtkStatisticsAlgorithmPrivate_h
169
170// 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.
int vtkIdType
Definition vtkType.h:315