VTK-m  2.2
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 
31 {
33 
34 public:
35  VTKM_CONT
37 
38  // It's OK for regular _point_ fields to become a CoordinateSystem object.
40 
41  VTKM_CONT CoordinateSystem(std::string name, const vtkm::cont::UnknownArrayHandle& data);
42 
43  template <typename T, typename Storage>
44  VTKM_CONT CoordinateSystem(std::string name, const ArrayHandle<T, Storage>& data)
45  : Superclass(name, Association::Points, data)
46  {
47  }
48 
51  VTKM_CONT
52  CoordinateSystem(std::string name,
53  vtkm::Id3 dimensions,
54  vtkm::Vec3f origin = vtkm::Vec3f(0.0f, 0.0f, 0.0f),
55  vtkm::Vec3f spacing = vtkm::Vec3f(1.0f, 1.0f, 1.0f));
56 
57  VTKM_CONT
58  vtkm::Id GetNumberOfPoints() const { return this->GetNumberOfValues(); }
59 
61  GetData() const;
62 
63 private:
64 #ifdef VTKM_USE_DOUBLE_PRECISION
65  using FloatNonDefault = vtkm::Float32;
66 #else
68 #endif
70 
72  {
73  template <typename S>
74  using IsInvalid = vtkm::cont::internal::IsInvalidArrayHandle<vtkm::Vec3f, S>;
75 
76  template <typename S>
78  };
79 
81  {
82  template <typename S>
83  using IsInvalid = vtkm::cont::internal::IsInvalidArrayHandle<Vec3f_nd, S>;
84 
85  template <typename S>
86  using Transform =
88  };
89 
96 
97 public:
98  using MultiplexerArrayType = //
101 
108  VTKM_CONT MultiplexerArrayType GetDataAsMultiplexer() const;
109 
110  VTKM_CONT
111  void GetRange(vtkm::Range* range) const { this->Superclass::GetRange(range); }
112 
113  VTKM_CONT
115  {
117  this->GetRange(&range[0]);
118  return range;
119  }
120 
121  VTKM_CONT
123  {
124  return this->Superclass::GetRange();
125  }
126 
127  VTKM_CONT
129  {
130  vtkm::Range ranges[3];
131  this->GetRange(ranges);
132  return vtkm::Bounds(ranges[0], ranges[1], ranges[2]);
133  }
134 
135  void PrintSummary(std::ostream& out, bool full = false) const override;
136 
138  {
139  this->Superclass::ReleaseResourcesExecution();
140  this->GetData().ReleaseResourcesExecution();
141  }
142 };
143 
144 template <typename Functor, typename... Args>
145 void CastAndCall(const vtkm::cont::CoordinateSystem& coords, Functor&& f, Args&&... args)
146 {
147  CastAndCall(coords.GetData(), std::forward<Functor>(f), std::forward<Args>(args)...);
148 }
149 
150 template <typename T>
152  const std::vector<T>& data,
154 {
156 }
157 
158 template <typename T>
160  const T* data,
161  vtkm::Id numberOfValues,
163 {
164  return vtkm::cont::CoordinateSystem(name,
165  vtkm::cont::make_ArrayHandle(data, numberOfValues, copy));
166 }
167 
168 namespace internal
169 {
170 
171 template <>
172 struct DynamicTransformTraits<vtkm::cont::CoordinateSystem>
173 {
174  using DynamicTag = vtkm::cont::internal::DynamicTransformTagCastAndCall;
175 };
176 
177 
178 } // namespace internal
179 } // namespace cont
180 } // namespace vtkm
181 
182 //=============================================================================
183 // Specializations of serialization related classes
185 namespace mangled_diy_namespace
186 {
187 
188 template <>
189 struct Serialization<vtkm::cont::CoordinateSystem> : Serialization<vtkm::cont::Field>
190 {
191 };
192 
193 } // diy
195 
196 #endif //vtk_m_cont_CoordinateSystem_h
vtkm::cont::CoordinateSystem::ReleaseResourcesExecution
void ReleaseResourcesExecution() override
Remove the data from the device memory (but preserve the data on the host).
Definition: CoordinateSystem.h:137
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:151
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:300
vtkm::cont::CoordinateSystem::GetRange
vtkm::Vec< vtkm::Range, 3 > GetRange() const
Definition: CoordinateSystem.h:114
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
ArrayHandleCast.h
vtkm::ListAppend
typename detail::ListAppendImpl< Lists... >::type ListAppend
Concatinates a set of lists into a single list.
Definition: List.h:281
vtkm::cont::Field::Association
Association
Identifies what elements of a data set a field is associated with.
Definition: Field.h:38
vtkm::cont::UnknownArrayHandle
An ArrayHandle of an unknown value type and storage.
Definition: UnknownArrayHandle.h:430
vtkm::cont::CoordinateSystem::GetNumberOfPoints
vtkm::Id GetNumberOfPoints() const
Definition: CoordinateSystem.h:58
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:680
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:351
vtkm::cont::CoordinateSystem::StorageToArrayNonDefault
Definition: CoordinateSystem.h:80
vtkm::cont::CoordinateSystem
Manages a coordinate system for a DataSet.
Definition: CoordinateSystem.h:30
vtkm::cont::CoordinateSystem::FloatNonDefault
vtkm::Float64 FloatNonDefault
Definition: CoordinateSystem.h:67
UncertainArrayHandle.h
vtkm::cont::CoordinateSystem::MultiplexerArrayType
vtkm::cont::ArrayHandleMultiplexerFromList< vtkm::ListAppend< ArraysFloatDefault, ArraysFloatNonDefault > > MultiplexerArrayType
Definition: CoordinateSystem.h:100
vtkm::cont::CoordinateSystem::StorageToArrayNonDefault::IsInvalid
vtkm::cont::internal::IsInvalidArrayHandle< Vec3f_nd, S > IsInvalid
Definition: CoordinateSystem.h:83
Bounds.h
vtkm::cont::CoordinateSystem::CoordinateSystem
CoordinateSystem(std::string name, const ArrayHandle< T, Storage > &data)
Definition: CoordinateSystem.h:44
vtkm::cont::CoordinateSystem::StorageToArrayDefault
Definition: CoordinateSystem.h:71
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:598
vtkm::cont::Field
A Field encapsulates an array on some piece of the mesh, such as the points, a cell set,...
Definition: Field.h:31
VTKM_CONT_EXPORT
#define VTKM_CONT_EXPORT
Definition: vtkm_cont_export.h:44
vtkm::cont::CoordinateSystem::GetRange
void GetRange(vtkm::Range *range) const
Definition: CoordinateSystem.h:111
vtkm::cont::CoordinateSystem::ArraysFloatNonDefault
vtkm::ListTransform< vtkm::ListRemoveIf< ::vtkm::cont::StorageListCommon, StorageToArrayNonDefault::IsInvalid >, StorageToArrayNonDefault::Transform > ArraysFloatNonDefault
Definition: CoordinateSystem.h:95
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
Field.h
vtkm::cont::ArrayHandleMultiplexerFromList
vtkm::ListApply< List, ArrayHandleMultiplexer > ArrayHandleMultiplexerFromList
Converts avtkm::List to an ArrayHandleMultiplexer
Definition: ArrayHandleMultiplexer.h:457
vtkm::Id
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
vtkm::Bounds
Represent an axis-aligned 3D bounds in space.
Definition: Bounds.h:29
vtkm::cont::CoordinateSystem::GetData
vtkm::cont::UncertainArrayHandle< vtkm::TypeListFieldVec3, ::vtkm::cont::StorageListCommon > GetData() const
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::ArrayHandleCast
Cast the values of an array to the specified type, on demand.
Definition: ArrayHandleCast.h:141
vtkm::cont::CoordinateSystem::GetRangeAsArrayHandle
vtkm::cont::ArrayHandle< vtkm::Range > GetRangeAsArrayHandle() const
Definition: CoordinateSystem.h:122
vtkm::Float32
float Float32
Base type to use for 32-bit floating-point numbers.
Definition: Types.h:157
vtkm::Float64
double Float64
Base type to use for 64-bit floating-point numbers.
Definition: Types.h:161
vtkm::CopyFlag
CopyFlag
Identifier used to specify whether a function should deep copy data.
Definition: Flags.h:17
vtkm::cont::CoordinateSystem::GetBounds
vtkm::Bounds GetBounds() const
Definition: CoordinateSystem.h:128
vtkm::cont::CoordinateSystem::ArraysFloatDefault
vtkm::ListTransform< vtkm::ListRemoveIf< ::vtkm::cont::StorageListCommon, StorageToArrayDefault::IsInvalid >, StorageToArrayDefault::Transform > ArraysFloatDefault
Definition: CoordinateSystem.h:92
vtkm::cont::make_ArrayHandle
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:270
vtkm::cont::CoordinateSystem::StorageToArrayDefault::IsInvalid
vtkm::cont::internal::IsInvalidArrayHandle< vtkm::Vec3f, S > IsInvalid
Definition: CoordinateSystem.h:74
vtkm::Range
Represent a continuous scalar range of values.
Definition: Range.h:31