VTK-m  2.0
Contour.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 
11 #ifndef vtk_m_filter_contour_Contour_h
12 #define vtk_m_filter_contour_Contour_h
13 
15 #include <vtkm/filter/contour/vtkm_filter_contour_export.h>
16 
17 namespace vtkm
18 {
19 namespace filter
20 {
21 namespace contour
22 {
24 
30 class VTKM_FILTER_CONTOUR_EXPORT Contour : public vtkm::filter::FilterField
31 {
32 public:
34  {
35  if (num >= 0)
36  {
37  this->IsoValues.resize(static_cast<std::size_t>(num));
38  }
39  }
40 
41  vtkm::Id GetNumberOfIsoValues() const { return static_cast<vtkm::Id>(this->IsoValues.size()); }
42 
43  void SetIsoValue(vtkm::Float64 v) { this->SetIsoValue(0, v); }
44 
46  {
47  std::size_t i = static_cast<std::size_t>(index);
48  if (i >= this->IsoValues.size())
49  {
50  this->IsoValues.resize(i + 1);
51  }
52  this->IsoValues[i] = v;
53  }
54 
55  void SetIsoValues(const std::vector<vtkm::Float64>& values) { this->IsoValues = values; }
56 
58  {
59  return this->IsoValues[static_cast<std::size_t>(index)];
60  }
61 
66  VTKM_CONT
67  void SetMergeDuplicatePoints(bool on);
68 
69  VTKM_CONT
70  bool GetMergeDuplicatePoints() const;
71 
77  VTKM_CONT
78  void SetGenerateNormals(bool on) { this->GenerateNormals = on; }
79  VTKM_CONT
80  bool GetGenerateNormals() const { return this->GenerateNormals; }
81 
83  VTKM_CONT
84  void SetAddInterpolationEdgeIds(bool on) { this->AddInterpolationEdgeIds = on; }
85  VTKM_CONT
86  bool GetAddInterpolationEdgeIds() const { return this->AddInterpolationEdgeIds; }
87 
90  VTKM_CONT
91  void SetComputeFastNormalsForStructured(bool on) { this->ComputeFastNormalsForStructured = on; }
92  VTKM_CONT
93  bool GetComputeFastNormalsForStructured() const { return this->ComputeFastNormalsForStructured; }
94 
97  VTKM_CONT
99  {
100  this->ComputeFastNormalsForUnstructured = on;
101  }
102  VTKM_CONT
104  {
105  return this->ComputeFastNormalsForUnstructured;
106  }
107 
108  VTKM_CONT
109  void SetNormalArrayName(const std::string& name) { this->NormalArrayName = name; }
110 
111  VTKM_CONT
112  const std::string& GetNormalArrayName() const { return this->NormalArrayName; }
113 
114 private:
115  VTKM_CONT
116 
117  std::vector<vtkm::Float64> IsoValues;
118  bool GenerateNormals = false;
119  bool AddInterpolationEdgeIds = false;
120  bool ComputeFastNormalsForStructured = false;
121  bool ComputeFastNormalsForUnstructured = true;
122  bool MergeDuplicatedPoints = true;
123  std::string NormalArrayName = "normals";
124  std::string InterpolationEdgeIdsArrayName = "edgeIds";
125 
126 protected:
127  // Needed by the subclass Slice
128  vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& result) override;
129 };
130 } // namespace contour
131 } // namespace filter
132 } // namespace vtkm
133 
134 #endif // vtk_m_filter_contour_Contour_h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::filter::contour::Contour::GetIsoValue
vtkm::Float64 GetIsoValue(vtkm::Id index) const
Definition: Contour.h:57
vtkm::filter::contour::Contour::SetComputeFastNormalsForUnstructured
VTKM_CONT void SetComputeFastNormalsForUnstructured(bool on)
Set/Get whether the fast path should be used for normals computation for unstructured datasets.
Definition: Contour.h:98
vtkm::filter::contour::Contour::SetIsoValue
void SetIsoValue(vtkm::Float64 v)
Definition: Contour.h:43
vtkm::cont::DataSet
Definition: DataSet.h:34
vtkm::filter::contour::Contour::GetNumberOfIsoValues
vtkm::Id GetNumberOfIsoValues() const
Definition: Contour.h:41
vtkm::filter::contour::Contour::GetComputeFastNormalsForUnstructured
VTKM_CONT bool GetComputeFastNormalsForUnstructured() const
Definition: Contour.h:103
vtkm::filter::contour::Contour::SetIsoValues
void SetIsoValues(const std::vector< vtkm::Float64 > &values)
Definition: Contour.h:55
vtkm::filter::contour::Contour::SetComputeFastNormalsForStructured
VTKM_CONT void SetComputeFastNormalsForStructured(bool on)
Set/Get whether the fast path should be used for normals computation for structured datasets.
Definition: Contour.h:91
vtkm::filter::contour::Contour::GetNormalArrayName
const VTKM_CONT std::string & GetNormalArrayName() const
Definition: Contour.h:112
vtkm::filter::contour::Contour::SetAddInterpolationEdgeIds
VTKM_CONT void SetAddInterpolationEdgeIds(bool on)
Set/Get whether to append the ids of the intersected edges to the vertices of the isosurface triangle...
Definition: Contour.h:84
vtkm::filter::contour::Contour::SetIsoValue
void SetIsoValue(vtkm::Id index, vtkm::Float64 v)
Definition: Contour.h:45
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::filter::contour::Contour::IsoValues
VTKM_CONT std::vector< vtkm::Float64 > IsoValues
Definition: Contour.h:117
FilterField.h
vtkm::filter::FilterField
Definition: FilterField.h:21
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::filter::contour::Contour::SetGenerateNormals
VTKM_CONT void SetGenerateNormals(bool on)
Set/Get whether normals should be generated.
Definition: Contour.h:78
vtkm::filter::contour::Contour::GetGenerateNormals
VTKM_CONT bool GetGenerateNormals() const
Definition: Contour.h:80
vtkm::filter::contour::Contour
generate isosurface(s) from a Volume
Definition: Contour.h:30
vtkm::filter::contour::Contour::GetComputeFastNormalsForStructured
VTKM_CONT bool GetComputeFastNormalsForStructured() const
Definition: Contour.h:93
vtkm::Float64
double Float64
Definition: Types.h:155
vtkm::filter::contour::Contour::GetAddInterpolationEdgeIds
VTKM_CONT bool GetAddInterpolationEdgeIds() const
Definition: Contour.h:86
vtkm::filter::contour::Contour::SetNumberOfIsoValues
void SetNumberOfIsoValues(vtkm::Id num)
Definition: Contour.h:33
vtkm::filter::contour::Contour::SetNormalArrayName
VTKM_CONT void SetNormalArrayName(const std::string &name)
Definition: Contour.h:109