VTK  9.2.6
vtkSelection.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkSelection.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=========================================================================*/
55#ifndef vtkSelection_h
56#define vtkSelection_h
57
58#include "vtkCommonDataModelModule.h" // For export macro
59#include "vtkDataObject.h"
60#include "vtkSmartPointer.h" // for vtkSmartPointer.
61
62#include <memory> // for unique_ptr.
63#include <string> // for string.
64
67
68class VTKCOMMONDATAMODEL_EXPORT vtkSelection : public vtkDataObject
69{
70public:
72 void PrintSelf(ostream& os, vtkIndent indent) override;
73 static vtkSelection* New();
74
78 void Initialize() override;
79
83 int GetDataObjectType() override { return VTK_SELECTION; }
84
89 unsigned int GetNumberOfNodes() const;
90
95 virtual vtkSelectionNode* GetNode(unsigned int idx) const;
96
100 virtual vtkSelectionNode* GetNode(const std::string& name) const;
101
107 virtual std::string AddNode(vtkSelectionNode*);
108
114 virtual void SetNode(const std::string& name, vtkSelectionNode*);
115
119 virtual std::string GetNodeNameAtIndex(unsigned int idx) const;
120
122
125 virtual void RemoveNode(unsigned int idx);
126 virtual void RemoveNode(const std::string& name);
129
133 virtual void RemoveAllNodes();
134
136
147 vtkSetMacro(Expression, std::string);
148 vtkGetMacro(Expression, std::string);
150
154 void DeepCopy(vtkDataObject* src) override;
155
161 void ShallowCopy(vtkDataObject* src) override;
162
168 virtual void Union(vtkSelection* selection);
169
175 virtual void Union(vtkSelectionNode* node);
176
181 virtual void Subtract(vtkSelection* selection);
182
187 virtual void Subtract(vtkSelectionNode* node);
188
193
195
198 virtual void Dump();
199 virtual void Dump(ostream& os);
201
203
209
217 vtkSignedCharArray* const* values, unsigned int num_values) const;
218
223 template <typename MapType>
224 vtkSmartPointer<vtkSignedCharArray> Evaluate(const MapType& values_map) const;
225
226protected:
228 ~vtkSelection() override;
229
230 std::string Expression;
231
232private:
233 vtkSelection(const vtkSelection&) = delete;
234 void operator=(const vtkSelection&) = delete;
235
236 class vtkInternals;
237 vtkInternals* Internals;
238};
239
240//----------------------------------------------------------------------------
241template <typename MapType>
242inline vtkSmartPointer<vtkSignedCharArray> vtkSelection::Evaluate(const MapType& values_map) const
243{
244 const unsigned int num_nodes = this->GetNumberOfNodes();
245 std::unique_ptr<vtkSignedCharArray*[]> values(new vtkSignedCharArray*[num_nodes]);
246 for (unsigned int cc = 0; cc < num_nodes; ++cc)
247 {
248 auto iter = values_map.find(this->GetNodeNameAtIndex(cc));
249 values[cc] = iter != values_map.end() ? iter->second : nullptr;
250 }
251 return this->Evaluate(&values[0], num_nodes);
252}
253
254#endif
general representation of visualization data
a simple class to control print indentation
Definition vtkIndent.h:49
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
a node in a vtkSelection the defines the selection criteria.
data object that represents a "selection" in VTK.
virtual void RemoveNode(unsigned int idx)
Removes a selection node.
vtkMTimeType GetMTime() override
Return the MTime taking into account changes to the properties.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkSelection * GetData(vtkInformationVector *v, int i=0)
Retrieve a vtkSelection stored inside an invormation object.
virtual vtkSelectionNode * GetNode(unsigned int idx) const
Returns a node given it's index.
unsigned int GetNumberOfNodes() const
Returns the number of nodes in this selection.
virtual void SetNode(const std::string &name, vtkSelectionNode *)
Adds a vtkSelectionNode and assigns it the specified name.
virtual void Union(vtkSelection *selection)
Union this selection with the specified selection.
virtual void RemoveNode(const std::string &name)
Removes a selection node.
virtual vtkSelectionNode * GetNode(const std::string &name) const
Returns a node with the given name, if present, else nullptr is returned.
void DeepCopy(vtkDataObject *src) override
Copy selection nodes of the input.
virtual void Subtract(vtkSelection *selection)
Remove the nodes from the specified selection from this selection.
virtual void Union(vtkSelectionNode *node)
Union this selection with the specified selection node.
static vtkSelection * New()
void ShallowCopy(vtkDataObject *src) override
Copy selection nodes of the input.
~vtkSelection() override
virtual void Subtract(vtkSelectionNode *node)
Remove the nodes from the specified selection from this selection.
void Initialize() override
Restore data object to initial state,.
std::string Expression
virtual std::string GetNodeNameAtIndex(unsigned int idx) const
Returns the name for a node at the given index.
virtual void Dump()
Dumps the contents of the selection, giving basic information only.
int GetDataObjectType() override
Returns VTK_SELECTION enumeration value.
virtual void Dump(ostream &os)
Dumps the contents of the selection, giving basic information only.
virtual std::string AddNode(vtkSelectionNode *)
Adds a selection node.
vtkSmartPointer< vtkSignedCharArray > Evaluate(vtkSignedCharArray *const *values, unsigned int num_values) const
Evaluates the expression for each element in the values.
static vtkSelection * GetData(vtkInformation *info)
Retrieve a vtkSelection stored inside an invormation object.
virtual void RemoveAllNodes()
Removes all selection nodes.
virtual void RemoveNode(vtkSelectionNode *)
Removes a selection node.
dynamic, self-adjusting array of signed char
Hold a reference to a vtkObjectBase instance.
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:287
#define VTK_SELECTION
Definition vtkType.h:99