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 =========================================================================*/
40 #ifndef vtkSelection_h
41 #define vtkSelection_h
42 
43 #include "vtkCommonDataModelModule.h" // For export macro
44 #include "vtkDataObject.h"
45 #include "vtkSmartPointer.h" // for vtkSmartPointer.
46 
47 #include <memory> // for unique_ptr.
48 #include <string> // for string.
49 
50 class vtkSelectionNode;
51 class vtkSignedCharArray;
52 
53 class VTKCOMMONDATAMODEL_EXPORT vtkSelection : public vtkDataObject
54 {
55 public:
56  vtkTypeMacro(vtkSelection, vtkDataObject);
57  void PrintSelf(ostream& os, vtkIndent indent) override;
58  static vtkSelection* New();
59 
63  void Initialize() override;
64 
68  int GetDataObjectType() override { return VTK_SELECTION; }
69 
74  unsigned int GetNumberOfNodes() const;
75 
80  virtual vtkSelectionNode* GetNode(unsigned int idx) const;
81 
85  virtual vtkSelectionNode* GetNode(const std::string& name) const;
86 
93 
99  virtual void SetNode(const std::string& name, vtkSelectionNode*);
100 
104  virtual std::string GetNodeNameAtIndex(unsigned int idx) const;
105 
107 
110  virtual void RemoveNode(unsigned int idx);
111  virtual void RemoveNode(const std::string& name);
112  virtual void RemoveNode(vtkSelectionNode*);
114 
118  virtual void RemoveAllNodes();
119 
121 
132  vtkSetMacro(Expression, std::string);
133  vtkGetMacro(Expression, std::string);
135 
139  void DeepCopy(vtkDataObject* src) override;
140 
146  void ShallowCopy(vtkDataObject* src) override;
147 
153  virtual void Union(vtkSelection* selection);
154 
160  virtual void Union(vtkSelectionNode* node);
161 
166  virtual void Subtract(vtkSelection* selection);
167 
172  virtual void Subtract(vtkSelectionNode* node);
173 
177  vtkMTimeType GetMTime() override;
178 
180 
183  virtual void Dump();
184  virtual void Dump(ostream& os);
186 
188 
192  static vtkSelection* GetData(vtkInformationVector* v, int i = 0);
194 
202  vtkSignedCharArray* const* values, unsigned int num_values) const;
203 
208  template <typename MapType>
209  vtkSmartPointer<vtkSignedCharArray> Evaluate(const MapType& values_map) const;
210 
211 protected:
213  ~vtkSelection() override;
214 
216 
217 private:
218  vtkSelection(const vtkSelection&) = delete;
219  void operator=(const vtkSelection&) = delete;
220 
221  class vtkInternals;
222  vtkInternals* Internals;
223 };
224 
225 //----------------------------------------------------------------------------
226 template <typename MapType>
227 inline vtkSmartPointer<vtkSignedCharArray> vtkSelection::Evaluate(const MapType& values_map) const
228 {
229  const unsigned int num_nodes = this->GetNumberOfNodes();
230  std::unique_ptr<vtkSignedCharArray*[]> values(new vtkSignedCharArray*[num_nodes]);
231  for (unsigned int cc = 0; cc < num_nodes; ++cc)
232  {
233  auto iter = values_map.find(this->GetNodeNameAtIndex(cc));
234  values[cc] = iter != values_map.end() ? iter->second : nullptr;
235  }
236  return this->Evaluate(&values[0], num_nodes);
237 }
238 
239 #endif
general representation of visualization data
Definition: vtkDataObject.h:60
a simple class to control print indentation
Definition: vtkIndent.h:34
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:54
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.
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.
vtkSmartPointer< vtkSignedCharArray > Evaluate(vtkSignedCharArray *const *values, unsigned int num_values) const
Evaluates the expression for each element in the values.
virtual void Union(vtkSelection *selection)
Union this selection with the specified selection.
virtual void RemoveNode(const std::string &name)
Removes a selection node.
static vtkSelection * GetData(vtkInformation *info)
Retrieve a vtkSelection stored inside an invormation object.
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.
void ShallowCopy(vtkDataObject *src) override
Copy selection nodes of the input.
virtual vtkSelectionNode * GetNode(unsigned int idx) const
Returns a node given it's index.
~vtkSelection() override
virtual void Subtract(vtkSelectionNode *node)
Remove the nodes from the specified selection from this selection.
virtual vtkSelectionNode * GetNode(const std::string &name) const
Returns a node with the given name, if present, else nullptr is returned.
void Initialize() override
Restore data object to initial state,.
std::string Expression
Definition: vtkSelection.h:215
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:68
virtual void Dump(ostream &os)
Dumps the contents of the selection, giving basic information only.
virtual std::string AddNode(vtkSelectionNode *)
Adds a selection node.
static vtkSelection * New()
static vtkSelection * GetData(vtkInformationVector *v, int i=0)
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