VTK  9.1.0
vtkStatisticsAlgorithmPrivate.h
Go to the documentation of this file.
1/*=========================================================================
2
3Program: Visualization Toolkit
4Module: vtkStatisticsAlgorithmPrivate.h
5
6Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7All rights reserved.
8See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10This software is distributed WITHOUT ANY WARRANTY; without even
11the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12PURPOSE. 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#ifndef __VTK_WRAP__
38
39#include "vtkStdString.h"
40
41#include <set> // used to iterate over internal organs
42
44{
45public:
46 // --------------------------------------------------------------------
50 void ResetRequests() { this->Requests.clear(); }
51 // --------------------------------------------------------------------
53
57 {
58 int rval = this->Buffer.empty() ? 0 : 1;
59 this->Buffer.clear();
60 return rval;
61 }
62 // --------------------------------------------------------------------
63 int SetBufferColumnStatus(const char* colName, int status)
64 {
65 if (status)
66 {
67 return this->Buffer.insert(colName).second ? 1 : 0;
68 }
69 else
70 {
71 return this->Buffer.erase(colName) ? 1 : 0;
72 }
73 }
74 // --------------------------------------------------------------------
76 {
77 bool result = false;
78 // Don't add empty selections to the list of requests.
79 if (!this->Buffer.empty())
80 {
81 result = this->Requests.insert(this->Buffer).second;
82 }
83 return result ? 1 : 0;
84 }
85 // --------------------------------------------------------------------
88
91 int AddColumnToRequests(const char* col)
92 {
93 if (col && strlen(col))
94 {
95 std::set<vtkStdString> tmp;
96 tmp.insert(col);
97 if (this->Requests.insert(tmp).second)
98 {
99 return 1;
100 }
101 }
102 return 0;
103 }
104 // --------------------------------------------------------------------
107
110 int AddColumnPairToRequests(const char* cola, const char* colb)
111 {
112 if (cola && colb && strlen(cola) && strlen(colb))
113 {
114 std::set<vtkStdString> tmp;
115 tmp.insert(cola);
116 tmp.insert(colb);
117 if (this->Requests.insert(tmp).second)
118 {
119 return 1;
120 }
121 }
122 return 0;
123 }
124 // --------------------------------------------------------------------
126
129 vtkIdType GetNumberOfRequests() { return static_cast<vtkIdType>(this->Requests.size()); }
130 // --------------------------------------------------------------------
132
136 {
137 if (r < 0 || r > static_cast<vtkIdType>(this->Requests.size()))
138 {
139 return 0;
140 }
141 std::set<std::set<vtkStdString>>::iterator it = this->Requests.begin();
142 for (vtkIdType i = 0; i < r; ++i)
143 {
144 ++it;
145 }
146 return static_cast<vtkIdType>(it->size());
147 }
148 // --------------------------------------------------------------------
151
156 {
157 if (r < 0 || r > static_cast<vtkIdType>(this->Requests.size()) || c < 0)
158 {
159 return false;
160 }
161 std::set<std::set<vtkStdString>>::const_iterator it = this->Requests.begin();
162 for (vtkIdType i = 0; i < r; ++i)
163 {
164 ++it;
165 }
166 if (c > static_cast<vtkIdType>(it->size()))
167 {
168 return false;
169 }
170 std::set<vtkStdString>::const_iterator cit = it->begin();
171 for (vtkIdType j = 0; j < c; ++j)
172 {
173 ++cit;
174 }
175 columnName = *cit;
176 return true;
177 }
179
180 std::set<std::set<vtkStdString>> Requests;
181 std::set<vtkStdString> Buffer;
182};
183
184#endif // __VTK_WRAP__
185
186#endif // vtkStatisticsAlgorithmPrivate_h
187
188// 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:105
int vtkIdType
Definition: vtkType.h:332