VTK  9.1.0
vtkSelection.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ParaView
4 Module: vtkSelection.h
5
6 Copyright (c) Kitware, Inc.
7 All rights reserved.
8 See Copyright.txt or http://www.paraview.org/HTML/Copyright.html 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=========================================================================*/
49#ifndef vtkSelection_h
50#define vtkSelection_h
51
52#include "vtkCommonDataModelModule.h" // For export macro
53#include "vtkDataObject.h"
54#include "vtkSmartPointer.h" // for vtkSmartPointer.
55
56#include <memory> // for unique_ptr.
57#include <string> // for string.
58
61
62class VTKCOMMONDATAMODEL_EXPORT vtkSelection : public vtkDataObject
63{
64public:
66 void PrintSelf(ostream& os, vtkIndent indent) override;
67 static vtkSelection* New();
68
72 void Initialize() override;
73
77 int GetDataObjectType() override { return VTK_SELECTION; }
78
83 unsigned int GetNumberOfNodes() const;
84
89 virtual vtkSelectionNode* GetNode(unsigned int idx) const;
90
94 virtual vtkSelectionNode* GetNode(const std::string& name) const;
95
102
108 virtual void SetNode(const std::string& name, vtkSelectionNode*);
109
113 virtual std::string GetNodeNameAtIndex(unsigned int idx) const;
114
116
119 virtual void RemoveNode(unsigned int idx);
120 virtual void RemoveNode(const std::string& name);
123
127 virtual void RemoveAllNodes();
128
130
141 vtkSetMacro(Expression, std::string);
142 vtkGetMacro(Expression, std::string);
144
148 void DeepCopy(vtkDataObject* src) override;
149
155 void ShallowCopy(vtkDataObject* src) override;
156
162 virtual void Union(vtkSelection* selection);
163
169 virtual void Union(vtkSelectionNode* node);
170
175 virtual void Subtract(vtkSelection* selection);
176
181 virtual void Subtract(vtkSelectionNode* node);
182
187
189
192 virtual void Dump();
193 virtual void Dump(ostream& os);
195
197
203
211 vtkSignedCharArray* const* values, unsigned int num_values) const;
212
217 template <typename MapType>
218 vtkSmartPointer<vtkSignedCharArray> Evaluate(const MapType& values_map) const;
219
220protected:
222 ~vtkSelection() override;
223
225
226private:
227 vtkSelection(const vtkSelection&) = delete;
228 void operator=(const vtkSelection&) = delete;
229
230 class vtkInternals;
231 vtkInternals* Internals;
232};
233
234//----------------------------------------------------------------------------
235template <typename MapType>
236inline vtkSmartPointer<vtkSignedCharArray> vtkSelection::Evaluate(const MapType& values_map) const
237{
238 const unsigned int num_nodes = this->GetNumberOfNodes();
239 std::unique_ptr<vtkSignedCharArray*[]> values(new vtkSignedCharArray*[num_nodes]);
240 for (unsigned int cc = 0; cc < num_nodes; ++cc)
241 {
242 auto iter = values_map.find(this->GetNodeNameAtIndex(cc));
243 values[cc] = iter != values_map.end() ? iter->second : nullptr;
244 }
245 return this->Evaluate(&values[0], num_nodes);
246}
247
248#endif
general representation of visualization data
Definition: vtkDataObject.h:69
a simple class to control print indentation
Definition: vtkIndent.h:43
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.
Definition: vtkSelection.h:63
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
Definition: vtkSelection.h:224
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.
Definition: vtkSelection.h:77
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
@ info
Definition: vtkX3D.h:382
@ name
Definition: vtkX3D.h:225
@ string
Definition: vtkX3D.h:496
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
#define VTK_SELECTION
Definition: vtkType.h:99