VTK-m  2.0
CoordinateSystem.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_CoordinateSystem_h
11 #define vtk_m_cont_CoordinateSystem_h
12 
13 #include <vtkm/Bounds.h>
14 
16 #include <vtkm/cont/CastAndCall.h>
17 #include <vtkm/cont/Field.h>
19 
20 namespace vtkm
21 {
22 namespace cont
23 {
24 
25 class VTKM_CONT_EXPORT CoordinateSystem : public vtkm::cont::Field
26 {
28 
29 public:
30  VTKM_CONT
32 
33  // It's OK for regular _point_ fields to become a CoordinateSystem object.
35 
36  VTKM_CONT CoordinateSystem(std::string name, const vtkm::cont::UnknownArrayHandle& data);
37 
38  template <typename T, typename Storage>
39  VTKM_CONT CoordinateSystem(std::string name, const ArrayHandle<T, Storage>& data)
40  : Superclass(name, Association::Points, data)
41  {
42  }
43 
46  VTKM_CONT
47  CoordinateSystem(std::string name,
48  vtkm::Id3 dimensions,
49  vtkm::Vec3f origin = vtkm::Vec3f(0.0f, 0.0f, 0.0f),
50  vtkm::Vec3f spacing = vtkm::Vec3f(1.0f, 1.0f, 1.0f));
51 
52  VTKM_CONT
53  vtkm::Id GetNumberOfPoints() const { return this->GetNumberOfValues(); }
54 
56  GetData() const;
57 
58 private:
59 #ifdef VTKM_USE_DOUBLE_PRECISION
60  using FloatNonDefault = vtkm::Float32;
61 #else
63 #endif
65 
67  {
68  template <typename S>
69  using IsInvalid = vtkm::cont::internal::IsInvalidArrayHandle<vtkm::Vec3f, S>;
70 
71  template <typename S>
73  };
74 
76  {
77  template <typename S>
78  using IsInvalid = vtkm::cont::internal::IsInvalidArrayHandle<Vec3f_nd, S>;
79 
80  template <typename S>
81  using Transform =
83  };
84 
91 
92 public:
93  using MultiplexerArrayType = //
96 
103  VTKM_CONT MultiplexerArrayType GetDataAsMultiplexer() const;
104 
105  VTKM_CONT
106  void GetRange(vtkm::Range* range) const { this->Superclass::GetRange(range); }
107 
108  VTKM_CONT
110  {
112  this->GetRange(&range[0]);
113  return range;
114  }
115 
116  VTKM_CONT
118  {
119  return this->Superclass::GetRange();
120  }
121 
122  VTKM_CONT
124  {
125  vtkm::Range ranges[3];
126  this->GetRange(ranges);
127  return vtkm::Bounds(ranges[0], ranges[1], ranges[2]);
128  }
129 
130  virtual void PrintSummary(std::ostream& out) const override;
131 
135  {
136  this->Superclass::ReleaseResourcesExecution();
137  this->GetData().ReleaseResourcesExecution();
138  }
139 };
140 
141 template <typename Functor, typename... Args>
142 void CastAndCall(const vtkm::cont::CoordinateSystem& coords, Functor&& f, Args&&... args)
143 {
144  CastAndCall(coords.GetData(), std::forward<Functor>(f), std::forward<Args>(args)...);
145 }
146 
147 template <typename T>
149  const std::vector<T>& data,
151 {
153 }
154 
155 template <typename T>
157  const T* data,
158  vtkm::Id numberOfValues,
160 {
161  return vtkm::cont::CoordinateSystem(name,
162  vtkm::cont::make_ArrayHandle(data, numberOfValues, copy));
163 }
164 
165 namespace internal
166 {
167 
168 template <>
169 struct DynamicTransformTraits<vtkm::cont::CoordinateSystem>
170 {
171  using DynamicTag = vtkm::cont::internal::DynamicTransformTagCastAndCall;
172 };
173 
174 
175 } // namespace internal
176 } // namespace cont
177 } // namespace vtkm
178 
179 //=============================================================================
180 // Specializations of serialization related classes
182 namespace mangled_diy_namespace
183 {
184 
185 template <>
186 struct Serialization<vtkm::cont::CoordinateSystem> : Serialization<vtkm::cont::Field>
187 {
188 };
189 
190 } // diy
192 
193 #endif //vtk_m_cont_CoordinateSystem_h
vtkm::cont::make_CoordinateSystem
vtkm::cont::CoordinateSystem make_CoordinateSystem(std::string name, const std::vector< T > &data, vtkm::CopyFlag copy=vtkm::CopyFlag::Off)
Definition: CoordinateSystem.h:148
vtkm::cont::CoordinateSystem::ArraysFloatNonDefault
vtkm::ListTransform< vtkm::ListRemoveIf< VTKM_DEFAULT_STORAGE_LIST, StorageToArrayNonDefault::IsInvalid >, StorageToArrayNonDefault::Transform > ArraysFloatNonDefault
Definition: CoordinateSystem.h:90
vtkm::cont::make_ArrayHandle
VTKM_CONT vtkm::cont::ArrayHandleBasic< T > make_ArrayHandle(const T *array, vtkm::Id numberOfValues, vtkm::CopyFlag copy)
A convenience function for creating an ArrayHandle from a standard C array.
Definition: ArrayHandleBasic.h:217
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:283
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::cont::CoordinateSystem::GetRangeAsArrayHandle
VTKM_CONT vtkm::cont::ArrayHandle< vtkm::Range > GetRangeAsArrayHandle() const
Definition: CoordinateSystem.h:117
ArrayHandleCast.h
vtkm::cont::CoordinateSystem::ArraysFloatDefault
vtkm::ListTransform< vtkm::ListRemoveIf< VTKM_DEFAULT_STORAGE_LIST, StorageToArrayDefault::IsInvalid >, StorageToArrayDefault::Transform > ArraysFloatDefault
Definition: CoordinateSystem.h:87
vtkm::cont::CoordinateSystem::GetRange
VTKM_CONT vtkm::Vec< vtkm::Range, 3 > GetRange() const
Definition: CoordinateSystem.h:109
vtkm::ListAppend
typename detail::ListAppendImpl< Lists... >::type ListAppend
Concatinates a set of lists into a single list.
Definition: List.h:275
vtkm::cont::Field::Association
Association
Definition: cont/Field.h:34
vtkm::cont::UnknownArrayHandle
An ArrayHandle of an unknown value type and storage.
Definition: UnknownArrayHandle.h:406
vtkm::ListRemoveIf
typename detail::ListRemoveIfImpl< List, Predicate >::type ListRemoveIf
Takes an existing List and a predicate template that is applied to each type in the List.
Definition: List.h:674
vtkm::cont::CastAndCall
void CastAndCall(const DynamicObject &dynamicObject, Functor &&f, Args &&... args)
A Generic interface to CastAndCall.
Definition: CastAndCall.h:47
mangled_diy_namespace
Definition: Particle.h:331
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::cont::CoordinateSystem::ReleaseResourcesExecution
VTKM_CONT void ReleaseResourcesExecution() override
Releases any resources being used in the execution environment (that are not being shared by the cont...
Definition: CoordinateSystem.h:134
vtkm::cont::CoordinateSystem::StorageToArrayNonDefault
Definition: CoordinateSystem.h:75
vtkm::cont::CoordinateSystem
Definition: CoordinateSystem.h:25
vtkm::cont::CoordinateSystem::FloatNonDefault
vtkm::Float64 FloatNonDefault
Definition: CoordinateSystem.h:62
vtkm::cont::CoordinateSystem::GetNumberOfPoints
VTKM_CONT vtkm::Id GetNumberOfPoints() const
Definition: CoordinateSystem.h:53
UncertainArrayHandle.h
vtkm::cont::CoordinateSystem::MultiplexerArrayType
vtkm::cont::ArrayHandleMultiplexerFromList< vtkm::ListAppend< ArraysFloatDefault, ArraysFloatNonDefault > > MultiplexerArrayType
Definition: CoordinateSystem.h:95
vtkm::cont::CoordinateSystem::StorageToArrayNonDefault::IsInvalid
vtkm::cont::internal::IsInvalidArrayHandle< Vec3f_nd, S > IsInvalid
Definition: CoordinateSystem.h:78
Bounds.h
vtkm::cont::CoordinateSystem::StorageToArrayDefault
Definition: CoordinateSystem.h:66
CastAndCall.h
vtkm::ListTransform
typename detail::ListTransformImpl< List, Transform >::type ListTransform
Constructs a list containing all types in a source list applied to a transform template.
Definition: List.h:592
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::CoordinateSystem::GetBounds
VTKM_CONT vtkm::Bounds GetBounds() const
Definition: CoordinateSystem.h:123
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::cont::ArrayHandleMultiplexerFromList
vtkm::ListApply< List, ArrayHandleMultiplexer > ArrayHandleMultiplexerFromList
Converts avtkm::List to an ArrayHandleMultiplexer
Definition: ArrayHandleMultiplexer.h:443
vtkm::Bounds
Represent an axis-aligned 3D bounds in space.
Definition: Bounds.h:29
vtkm::Vec< vtkm::Id, 3 >
vtkm::CopyFlag::Off
@ Off
vtkm::cont::UncertainArrayHandle
An ArrayHandle of an uncertain value type and storage.
Definition: UncertainArrayHandle.h:39
vtkm::cont::CoordinateSystem::CoordinateSystem
VTKM_CONT CoordinateSystem(std::string name, const ArrayHandle< T, Storage > &data)
Definition: CoordinateSystem.h:39
vtkm::cont::ArrayHandleCast
Cast the values of an array to the specified type, on demand.
Definition: ArrayHandleCast.h:141
vtkm::Float32
float Float32
Definition: Types.h:154
Field.h
vtkm::Float64
double Float64
Definition: Types.h:155
vtkm::CopyFlag
CopyFlag
Definition: Flags.h:16
vtkm::cont::CoordinateSystem::GetRange
VTKM_CONT void GetRange(vtkm::Range *range) const
Definition: CoordinateSystem.h:106
vtkm::cont::CoordinateSystem::GetData
VTKM_CONT vtkm::cont::UncertainArrayHandle< vtkm::TypeListFieldVec3, VTKM_DEFAULT_STORAGE_LIST > GetData() const
vtkm::cont::CoordinateSystem::StorageToArrayDefault::IsInvalid
vtkm::cont::internal::IsInvalidArrayHandle< vtkm::Vec3f, S > IsInvalid
Definition: CoordinateSystem.h:69
vtkm::Range
Represent a continuous scalar range of values.
Definition: Range.h:31