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 =========================================================================*/
149 #ifndef vtkSelection_h
150 #define vtkSelection_h
151 
152 #include "vtkCommonDataModelModule.h" // For export macro
153 #include "vtkDataObject.h"
154 #include "vtkSmartPointer.h" // for vtkSmartPointer.
155 
156 #include <memory> // for unique_ptr.
157 #include <string> // for string.
158 
159 class vtkSelectionNode;
160 class vtkSignedCharArray;
161 
162 class VTKCOMMONDATAMODEL_EXPORT vtkSelection : public vtkDataObject
163 {
164 public:
165  vtkTypeMacro(vtkSelection, vtkDataObject);
166  void PrintSelf(ostream& os, vtkIndent indent) override;
167  static vtkSelection* New();
168 
172  void Initialize() override;
173 
177  int GetDataObjectType() override { return VTK_SELECTION; }
178 
183  unsigned int GetNumberOfNodes() const;
184 
189  virtual vtkSelectionNode* GetNode(unsigned int idx) const;
190 
194  virtual vtkSelectionNode* GetNode(const std::string& name) const;
195 
202 
208  virtual void SetNode(const std::string& name, vtkSelectionNode*);
209 
213  virtual std::string GetNodeNameAtIndex(unsigned int idx) const;
214 
216 
219  virtual void RemoveNode(unsigned int idx);
220  virtual void RemoveNode(const std::string& name);
221  virtual void RemoveNode(vtkSelectionNode*);
223 
227  virtual void RemoveAllNodes();
228 
230 
241  vtkSetMacro(Expression, std::string);
242  vtkGetMacro(Expression, std::string);
244 
248  void DeepCopy(vtkDataObject* src) override;
249 
255  void ShallowCopy(vtkDataObject* src) override;
256 
262  virtual void Union(vtkSelection* selection);
263 
269  virtual void Union(vtkSelectionNode* node);
270 
275  virtual void Subtract(vtkSelection* selection);
276 
281  virtual void Subtract(vtkSelectionNode* node);
282 
286  vtkMTimeType GetMTime() override;
287 
289 
292  virtual void Dump();
293  virtual void Dump(ostream& os);
295 
297 
301  static vtkSelection* GetData(vtkInformationVector* v, int i = 0);
303 
311  vtkSignedCharArray* const* values, unsigned int num_values) const;
312 
317  template <typename MapType>
318  vtkSmartPointer<vtkSignedCharArray> Evaluate(const MapType& values_map) const;
319 
320 protected:
322  ~vtkSelection() override;
323 
325 
326 private:
327  vtkSelection(const vtkSelection&) = delete;
328  void operator=(const vtkSelection&) = delete;
329 
330  class vtkInternals;
331  vtkInternals* Internals;
332 };
333 
334 //----------------------------------------------------------------------------
335 template <typename MapType>
336 inline vtkSmartPointer<vtkSignedCharArray> vtkSelection::Evaluate(const MapType& values_map) const
337 {
338  const unsigned int num_nodes = this->GetNumberOfNodes();
339  std::unique_ptr<vtkSignedCharArray*[]> values(new vtkSignedCharArray*[num_nodes]);
340  for (unsigned int cc = 0; cc < num_nodes; ++cc)
341  {
342  auto iter = values_map.find(this->GetNodeNameAtIndex(cc));
343  values[cc] = iter != values_map.end() ? iter->second : nullptr;
344  }
345  return this->Evaluate(&values[0], num_nodes);
346 }
347 
348 #endif
vtkSelection::DeepCopy
void DeepCopy(vtkDataObject *src) override
Copy selection nodes of the input.
vtkSelection::SetNode
virtual void SetNode(const std::string &name, vtkSelectionNode *)
Adds a vtkSelectionNode and assigns it the specified name.
vtkSelection::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkSelectionNode
a node in a vtkSelection the defines the selection criteria.
Definition: vtkSelectionNode.h:341
vtkSelection::New
static vtkSelection * New()
vtkSelection::Expression
std::string Expression
Definition: vtkSelection.h:324
vtkSelection::AddNode
virtual std::string AddNode(vtkSelectionNode *)
Adds a selection node.
vtkSelection::RemoveNode
virtual void RemoveNode(const std::string &name)
Removes a selection node.
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:145
vtkSelection::RemoveNode
virtual void RemoveNode(vtkSelectionNode *)
Removes a selection node.
vtkSelection::GetDataObjectType
int GetDataObjectType() override
Returns VTK_SELECTION enumeration value.
Definition: vtkSelection.h:177
vtkSmartPointer< vtkSignedCharArray >
vtkSelection::GetData
static vtkSelection * GetData(vtkInformationVector *v, int i=0)
Retrieve a vtkSelection stored inside an invormation object.
vtkSignedCharArray
dynamic, self-adjusting array of signed char
Definition: vtkSignedCharArray.h:36
vtkSelection::GetNode
virtual vtkSelectionNode * GetNode(const std::string &name) const
Returns a node with the given name, if present, else nullptr is returned.
vtkSelection
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:163
vtkSelection::GetMTime
vtkMTimeType GetMTime() override
Return the MTime taking into account changes to the properties.
vtkSelection::GetNumberOfNodes
unsigned int GetNumberOfNodes() const
Returns the number of nodes in this selection.
vtkSelection::ShallowCopy
void ShallowCopy(vtkDataObject *src) override
Copy selection nodes of the input.
vtkSelection::RemoveAllNodes
virtual void RemoveAllNodes()
Removes all selection nodes.
vtkSelection::Dump
virtual void Dump(ostream &os)
Dumps the contents of the selection, giving basic information only.
vtkSelection::Union
virtual void Union(vtkSelectionNode *node)
Union this selection with the specified selection node.
vtkSelection::~vtkSelection
~vtkSelection() override
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkSelection::Evaluate
vtkSmartPointer< vtkSignedCharArray > Evaluate(vtkSignedCharArray *const *values, unsigned int num_values) const
Evaluates the expression for each element in the values.
VTK_SELECTION
#define VTK_SELECTION
Definition: vtkType.h:99
vtkSmartPointer.h
vtkSelection::Union
virtual void Union(vtkSelection *selection)
Union this selection with the specified selection.
vtkSelection::Subtract
virtual void Subtract(vtkSelection *selection)
Remove the nodes from the specified selection from this selection.
vtkX3D::name
@ name
Definition: vtkX3D.h:225
vtkSelection::GetNode
virtual vtkSelectionNode * GetNode(unsigned int idx) const
Returns a node given it's index.
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:183
vtkX3D::info
@ info
Definition: vtkX3D.h:382
vtkX3D::string
@ string
Definition: vtkX3D.h:496
vtkSelection::Dump
virtual void Dump()
Dumps the contents of the selection, giving basic information only.
vtkDataObject.h
vtkSelection::vtkSelection
vtkSelection()
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:169
vtkSelection::GetData
static vtkSelection * GetData(vtkInformation *info)
Retrieve a vtkSelection stored inside an invormation object.
vtkSelection::RemoveNode
virtual void RemoveNode(unsigned int idx)
Removes a selection node.
vtkSelection::Initialize
void Initialize() override
Restore data object to initial state,.
vtkSelection::Subtract
virtual void Subtract(vtkSelectionNode *node)
Remove the nodes from the specified selection from this selection.
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
vtkSelection::GetNodeNameAtIndex
virtual std::string GetNodeNameAtIndex(unsigned int idx) const
Returns the name for a node at the given index.