VTK
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 =========================================================================*/
50 #ifndef vtkSelection_h
51 #define vtkSelection_h
52 
53 #include "vtkCommonDataModelModule.h" // For export macro
54 #include "vtkDataObject.h"
55 #include "vtkSmartPointer.h" // for vtkSmartPointer.
56 
57 #include <string> // for string.
58 #include <memory> // for unique_ptr.
59 
60 class vtkSelectionNode;
61 class vtkSignedCharArray;
62 
63 class VTKCOMMONDATAMODEL_EXPORT vtkSelection : public vtkDataObject
64 {
65 public:
66  vtkTypeMacro(vtkSelection,vtkDataObject);
67  void PrintSelf(ostream& os, vtkIndent indent) override;
68  static vtkSelection* New();
69 
73  void Initialize() override;
74 
78  int GetDataObjectType() override {return VTK_SELECTION;}
79 
84  unsigned int GetNumberOfNodes() const;
85 
90  virtual vtkSelectionNode* GetNode(unsigned int idx) const;
91 
95  virtual vtkSelectionNode* GetNode(const std::string& name) const;
96 
102  virtual std::string AddNode(vtkSelectionNode*);
103 
109  virtual void SetNode(const std::string& name, vtkSelectionNode*);
110 
114  virtual std::string GetNodeNameAtIndex(unsigned int idx) const;
115 
117 
120  virtual void RemoveNode(unsigned int idx);
121  virtual void RemoveNode(const std::string& name);
122  virtual void RemoveNode(vtkSelectionNode*);
124 
128  virtual void RemoveAllNodes();
129 
131 
142  vtkSetMacro(Expression, std::string);
143  vtkGetMacro(Expression, std::string);
145 
149  void DeepCopy(vtkDataObject* src) override;
150 
156  void ShallowCopy(vtkDataObject* src) override;
157 
163  virtual void Union(vtkSelection* selection);
164 
170  virtual void Union(vtkSelectionNode* node);
171 
176  virtual void Subtract(vtkSelection* selection);
177 
182  virtual void Subtract(vtkSelectionNode* node);
183 
187  vtkMTimeType GetMTime() override;
188 
190 
193  virtual void Dump();
194  virtual void Dump(ostream& os);
196 
198 
202  static vtkSelection* GetData(vtkInformationVector* v, int i=0);
204 
212  vtkSignedCharArray* const* values, unsigned int num_values) const;
213 
218  template <typename MapType>
219  vtkSmartPointer<vtkSignedCharArray> Evaluate(const MapType& values_map) const;
220 
221 protected:
222  vtkSelection();
223  ~vtkSelection() override;
224 
226 
227 private:
228  vtkSelection(const vtkSelection&) = delete;
229  void operator=(const vtkSelection&) = delete;
230 
231  class vtkInternals;
232  vtkInternals* Internals;
233 };
234 
235 //----------------------------------------------------------------------------
236 template <typename MapType>
237 inline vtkSmartPointer<vtkSignedCharArray> vtkSelection::Evaluate(const MapType& values_map) const
238 {
239  const unsigned int num_nodes = this->GetNumberOfNodes();
240  std::unique_ptr<vtkSignedCharArray* []> values(new vtkSignedCharArray*[num_nodes]);
241  for (unsigned int cc = 0; cc < num_nodes; ++cc)
242  {
243  auto iter = values_map.find(this->GetNodeNameAtIndex(cc));
244  values[cc] = iter != values_map.end() ? iter->second : nullptr;
245  }
246  return this->Evaluate(&values[0], num_nodes);
247 }
248 
249 #endif
A node in a selection tree.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkDataObject * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
static vtkDataObject * New()
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:63
std::string Expression
Definition: vtkSelection.h:225
virtual void Initialize()
Restore data object to initial state,.
Hold a reference to a vtkObjectBase instance.
vtkSmartPointer< vtkSignedCharArray > Evaluate(vtkSignedCharArray *const *values, unsigned int num_values) const
Evaluates the expression for each element in the values.
int GetDataObjectType() override
Returns VTK_SELECTION enumeration value.
Definition: vtkSelection.h:78
#define VTK_SELECTION
Definition: vtkType.h:113
a simple class to control print indentation
Definition: vtkIndent.h:39
dynamic, self-adjusting array of signed char
Store zero or more vtkInformation instances.
vtkMTimeType GetMTime() override
Data objects are composite objects and need to check each part for MTime.
general representation of visualization data
Definition: vtkDataObject.h:64
virtual void DeepCopy(vtkDataObject *src)
Shallow and Deep copy.
virtual void ShallowCopy(vtkDataObject *src)
Shallow and Deep copy.