VTK-m  2.0
DataSetBuilderUniform.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_cont_DataSetBuilderUniform_h
11 #define vtk_m_cont_DataSetBuilderUniform_h
12 
14 #include <vtkm/cont/DataSet.h>
15 
16 namespace vtkm
17 {
18 namespace cont
19 {
20 
21 class VTKM_CONT_EXPORT DataSetBuilderUniform
22 {
24 
25 public:
26  VTKM_CONT
28 
29  //1D uniform grid
30  template <typename T>
31  VTKM_CONT static vtkm::cont::DataSet Create(const vtkm::Id& dimension,
32  const T& origin,
33  const T& spacing,
34  const std::string& coordNm = "coords")
35  {
37  vtkm::Id3(dimension, 1, 1),
38  VecType(static_cast<vtkm::FloatDefault>(origin), 0, 0),
39  VecType(static_cast<vtkm::FloatDefault>(spacing), 1, 1),
40  coordNm);
41  }
42 
43  VTKM_CONT
44  static vtkm::cont::DataSet Create(const vtkm::Id& dimension,
45  const std::string& coordNm = "coords");
46 
47  //2D uniform grids.
48  template <typename T>
49  VTKM_CONT static vtkm::cont::DataSet Create(const vtkm::Id2& dimensions,
50  const vtkm::Vec<T, 2>& origin,
51  const vtkm::Vec<T, 2>& spacing,
52  const std::string& coordNm = "coords")
53  {
54  return DataSetBuilderUniform::CreateDataSet(vtkm::Id3(dimensions[0], dimensions[1], 1),
55  VecType(static_cast<vtkm::FloatDefault>(origin[0]),
56  static_cast<vtkm::FloatDefault>(origin[1]),
57  0),
58  VecType(static_cast<vtkm::FloatDefault>(spacing[0]),
59  static_cast<vtkm::FloatDefault>(spacing[1]),
60  1),
61  coordNm);
62  }
63 
64  VTKM_CONT
65  static vtkm::cont::DataSet Create(const vtkm::Id2& dimensions,
66  const std::string& coordNm = "coords");
67 
68  //3D uniform grids.
69  template <typename T>
70  VTKM_CONT static vtkm::cont::DataSet Create(const vtkm::Id3& dimensions,
71  const vtkm::Vec<T, 3>& origin,
72  const vtkm::Vec<T, 3>& spacing,
73  const std::string& coordNm = "coords")
74  {
76  vtkm::Id3(dimensions[0], dimensions[1], dimensions[2]),
77  VecType(static_cast<vtkm::FloatDefault>(origin[0]),
78  static_cast<vtkm::FloatDefault>(origin[1]),
79  static_cast<vtkm::FloatDefault>(origin[2])),
80  VecType(static_cast<vtkm::FloatDefault>(spacing[0]),
81  static_cast<vtkm::FloatDefault>(spacing[1]),
82  static_cast<vtkm::FloatDefault>(spacing[2])),
83  coordNm);
84  }
85 
86  VTKM_CONT
87  static vtkm::cont::DataSet Create(const vtkm::Id3& dimensions,
88  const std::string& coordNm = "coords");
89 
90 private:
91  VTKM_CONT
92  static vtkm::cont::DataSet CreateDataSet(const vtkm::Id3& dimensions,
93  const vtkm::Vec3f& origin,
94  const vtkm::Vec3f& spacing,
95  const std::string& coordNm);
96 };
97 
98 } // namespace cont
99 } // namespace vtkm
100 
101 #endif //vtk_m_cont_DataSetBuilderUniform_h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::cont::DataSetBuilderUniform::Create
static VTKM_CONT vtkm::cont::DataSet Create(const vtkm::Id &dimension, const T &origin, const T &spacing, const std::string &coordNm="coords")
Definition: DataSetBuilderUniform.h:31
vtkm::cont::DataSet
Definition: DataSet.h:34
vtkm::cont::DataSetBuilderUniform::CreateDataSet
static VTKM_CONT vtkm::cont::DataSet CreateDataSet(const vtkm::Id3 &dimensions, const vtkm::Vec3f &origin, const vtkm::Vec3f &spacing, const std::string &coordNm)
CoordinateSystem.h
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::cont::DataSetBuilderUniform
Definition: DataSetBuilderUniform.h:21
vtkm::cont::DataSetBuilderUniform::Create
static VTKM_CONT vtkm::cont::DataSet Create(const vtkm::Id2 &dimensions, const vtkm::Vec< T, 2 > &origin, const vtkm::Vec< T, 2 > &spacing, const std::string &coordNm="coords")
Definition: DataSetBuilderUniform.h:49
vtkm::Vec< T, 2 >
Definition: Types.h:859
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::Vec3f
vtkm::Vec< vtkm::FloatDefault, 3 > Vec3f
Vec3f corresponds to a 3-dimensional vector of floating point values.
Definition: Types.h:1014
vtkm::Vec< T, 3 >
Definition: Types.h:975
vtkm::Vec< vtkm::FloatDefault, 3 >
vtkm::FloatDefault
vtkm::Float32 FloatDefault
The floating point type to use when no other precision is specified.
Definition: Types.h:198
DataSet.h
vtkm::cont::DataSetBuilderUniform::Create
static VTKM_CONT vtkm::cont::DataSet Create(const vtkm::Id3 &dimensions, const vtkm::Vec< T, 3 > &origin, const vtkm::Vec< T, 3 > &spacing, const std::string &coordNm="coords")
Definition: DataSetBuilderUniform.h:70