VTK-m  2.0
FieldSelection.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_filter_FieldSelection_h
11 #define vtk_m_filter_FieldSelection_h
12 
13 #include <vtkm/Pair.h>
14 #include <vtkm/cont/Field.h>
15 
16 #include <vtkm/filter/vtkm_filter_core_export.h>
17 
18 #include <initializer_list>
19 #include <memory>
20 
21 namespace vtkm
22 {
23 namespace filter
24 {
25 
31 class VTKM_FILTER_CORE_EXPORT FieldSelection
32 {
33 public:
34  enum struct Mode
35  {
36  None,
37  All,
38  Select,
39  Exclude
40  };
41 
42  VTKM_CONT FieldSelection(Mode mode = Mode::Select);
43 
48  VTKM_CONT FieldSelection(const std::string& field, Mode mode = Mode::Select);
49 
54  VTKM_CONT FieldSelection(const char* field, Mode mode = Mode::Select);
55 
60  VTKM_CONT FieldSelection(const std::string& field,
62  Mode mode = Mode::Select);
63 
68  VTKM_CONT FieldSelection(std::initializer_list<std::string> fields, Mode mode = Mode::Select);
69 
79  std::initializer_list<std::pair<std::string, vtkm::cont::Field::Association>> fields,
80  Mode mode = Mode::Select);
81 
91  std::initializer_list<vtkm::Pair<std::string, vtkm::cont::Field::Association>> fields,
92  Mode mode = Mode::Select);
93 
96  VTKM_CONT FieldSelection& operator=(const FieldSelection& src);
97  VTKM_CONT FieldSelection& operator=(FieldSelection&& rhs);
98 
100 
103  VTKM_CONT
104  bool IsFieldSelected(const vtkm::cont::Field& inputField) const
105  {
106  return this->IsFieldSelected(inputField.GetName(), inputField.GetAssociation());
107  }
108 
109  VTKM_CONT bool IsFieldSelected(
110  const std::string& name,
112 
116  VTKM_CONT void AddField(const vtkm::cont::Field& inputField)
117  {
118  this->AddField(inputField.GetName(), inputField.GetAssociation(), this->GetMode());
119  }
120 
121  VTKM_CONT void AddField(const vtkm::cont::Field& inputField, Mode mode)
122  {
123  this->AddField(inputField.GetName(), inputField.GetAssociation(), mode);
124  }
125 
126  VTKM_CONT
127  void AddField(const std::string& fieldName,
129  {
130  this->AddField(fieldName, association, this->GetMode());
131  }
132 
133  VTKM_CONT void AddField(const std::string& fieldName, Mode mode)
134  {
135  this->AddField(fieldName, vtkm::cont::Field::Association::Any, mode);
136  }
137 
138  VTKM_CONT void AddField(const std::string& fieldName,
139  vtkm::cont::Field::Association association,
140  Mode mode);
142 
147  VTKM_CONT Mode GetFieldMode(const vtkm::cont::Field& inputField) const
148  {
149  return this->GetFieldMode(inputField.GetName(), inputField.GetAssociation());
150  }
151 
152  VTKM_CONT Mode GetFieldMode(
153  const std::string& fieldName,
156 
161  VTKM_CONT bool HasField(const vtkm::cont::Field& inputField) const
162  {
163  return this->HasField(inputField.GetName(), inputField.GetAssociation());
164  }
165 
167  const std::string& name,
169  {
170  return (this->GetFieldMode(name, association) != Mode::None);
171  }
172 
174  VTKM_CONT void ClearFields();
175 
181  VTKM_CONT Mode GetMode() const;
182 
193  VTKM_CONT void SetMode(Mode val);
194 
195 private:
196  struct InternalStruct;
197  std::unique_ptr<InternalStruct> Internals;
198 };
199 
200 }
201 } // namespace vtkm::filter
202 
203 #endif // vtk_m_filter_FieldSelection_h
vtkm::filter::FieldSelection::AddField
VTKM_CONT void AddField(const std::string &fieldName, Mode mode)
Definition: FieldSelection.h:133
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::filter::FieldSelection::AddField
VTKM_CONT void AddField(const vtkm::cont::Field &inputField, Mode mode)
Definition: FieldSelection.h:121
vtkm::filter::FieldSelection::AddField
VTKM_CONT void AddField(const vtkm::cont::Field &inputField)
Definition: FieldSelection.h:116
vtkm::filter::FieldSelection
A FieldSelection stores information about fields to map for input dataset to output when a filter is ...
Definition: FieldSelection.h:31
Pair.h
vtkm::cont::Field::Association
Association
Definition: cont/Field.h:34
vtkm::cont::Field::GetAssociation
VTKM_CONT Association GetAssociation() const
Definition: cont/Field.h:85
vtkm::filter::FieldSelection::HasField
VTKM_CONT bool HasField(const vtkm::cont::Field &inputField) const
Returns true if the input field has been added to this selection.
Definition: FieldSelection.h:161
vtkm::filter::FieldSelection::GetFieldMode
VTKM_CONT Mode GetFieldMode(const vtkm::cont::Field &inputField) const
Definition: FieldSelection.h:147
vtkm::cont::Field
A Field encapsulates an array on some piece of the mesh, such as the points, a cell set,...
Definition: cont/Field.h:31
vtkm::cont::Field::Association::Any
@ Any
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::filter::FieldSelection::Internals
std::unique_ptr< InternalStruct > Internals
Definition: FieldSelection.h:196
vtkm::filter::FieldSelection::AddField
VTKM_CONT void AddField(const std::string &fieldName, vtkm::cont::Field::Association association=vtkm::cont::Field::Association::Any)
Definition: FieldSelection.h:127
vtkm::cont::Field::GetName
const VTKM_CONT std::string & GetName() const
Definition: cont/Field.h:84
Field.h
vtkm::filter::FieldSelection::IsFieldSelected
VTKM_CONT bool IsFieldSelected(const vtkm::cont::Field &inputField) const
Returns true if the input field should be mapped to the output dataset.
Definition: FieldSelection.h:104
vtkm::filter::FieldSelection::HasField
VTKM_CONT bool HasField(const std::string &name, vtkm::cont::Field::Association association=vtkm::cont::Field::Association::Any) const
Definition: FieldSelection.h:166
vtkm::Pair
A vtkm::Pair is essentially the same as an STL pair object except that the methods (constructors and ...
Definition: Pair.h:29
vtkm::filter::FieldSelection::Mode
Mode
Definition: FieldSelection.h:34