Viskores  1.0
CoordinateSystem.h
Go to the documentation of this file.
1 //============================================================================
2 // The contents of this file are covered by the Viskores license. See
3 // LICENSE.txt for details.
4 //
5 // By contributing to this file, all contributors agree to the Developer
6 // Certificate of Origin Version 1.1 (DCO 1.1) as stated in DCO.txt.
7 //============================================================================
8 
9 //============================================================================
10 // Copyright (c) Kitware, Inc.
11 // All rights reserved.
12 // See LICENSE.txt for details.
13 //
14 // This software is distributed WITHOUT ANY WARRANTY; without even
15 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 // PURPOSE. See the above copyright notice for more information.
17 //============================================================================
18 #ifndef viskores_cont_CoordinateSystem_h
19 #define viskores_cont_CoordinateSystem_h
20 
21 #include <viskores/Bounds.h>
22 
25 #include <viskores/cont/Field.h>
27 
28 namespace viskores
29 {
30 namespace cont
31 {
32 
38 class VISKORES_CONT_EXPORT CoordinateSystem : public viskores::cont::Field
39 {
41 
42 public:
45 
46  // It's OK for regular _point_ fields to become a CoordinateSystem object.
48 
50 
51  template <typename T, typename Storage>
53  : Superclass(name, Association::Points, data)
54  {
55  }
56 
60  CoordinateSystem(std::string name,
61  viskores::Id3 dimensions,
62  viskores::Vec3f origin = viskores::Vec3f(0.0f, 0.0f, 0.0f),
63  viskores::Vec3f spacing = viskores::Vec3f(1.0f, 1.0f, 1.0f));
64 
66  viskores::Id GetNumberOfPoints() const { return this->GetNumberOfValues(); }
67 
70  GetData() const;
71 
72 private:
73 #ifdef VISKORES_USE_DOUBLE_PRECISION
74  using FloatNonDefault = viskores::Float32;
75 #else
77 #endif
79 
81  {
82  template <typename S>
83  using IsInvalid = viskores::cont::internal::IsInvalidArrayHandle<viskores::Vec3f, S>;
84 
85  template <typename S>
87  };
88 
90  {
91  template <typename S>
92  using IsInvalid = viskores::cont::internal::IsInvalidArrayHandle<Vec3f_nd, S>;
93 
94  template <typename S>
95  using Transform =
97  };
98 
105 
106 public:
107  using MultiplexerArrayType = //
110 
117  VISKORES_CONT MultiplexerArrayType GetDataAsMultiplexer() const;
118 
120  void GetRange(viskores::Range* range) const { this->Superclass::GetRange(range); }
121 
124  {
126  this->GetRange(&range[0]);
127  return range;
128  }
129 
132  {
133  return this->Superclass::GetRange();
134  }
135 
138  {
139  viskores::Range ranges[3];
140  this->GetRange(ranges);
141  return viskores::Bounds(ranges[0], ranges[1], ranges[2]);
142  }
143 
144  void PrintSummary(std::ostream& out, bool full = false) const override;
145 
147  {
148  this->Superclass::ReleaseResourcesExecution();
149  this->GetData().ReleaseResourcesExecution();
150  }
151 };
152 
153 template <typename Functor, typename... Args>
154 void CastAndCall(const viskores::cont::CoordinateSystem& coords, Functor&& f, Args&&... args)
155 {
156  CastAndCall(coords.GetData(), std::forward<Functor>(f), std::forward<Args>(args)...);
157 }
158 
159 template <typename T>
161  std::string name,
162  const std::vector<T>& data,
164 {
166 }
167 
168 template <typename T>
170  std::string name,
171  const T* data,
172  viskores::Id numberOfValues,
174 {
176  name, viskores::cont::make_ArrayHandle(data, numberOfValues, copy));
177 }
178 
179 namespace internal
180 {
181 
182 template <>
183 struct DynamicTransformTraits<viskores::cont::CoordinateSystem>
184 {
185  using DynamicTag = viskores::cont::internal::DynamicTransformTagCastAndCall;
186 };
187 
188 
189 } // namespace internal
190 } // namespace cont
191 } // namespace viskores
192 
193 //=============================================================================
194 // Specializations of serialization related classes
196 namespace mangled_diy_namespace
197 {
198 
199 template <>
200 struct Serialization<viskores::cont::CoordinateSystem> : Serialization<viskores::cont::Field>
201 {
202 };
203 
204 } // diy
206 
207 #endif //viskores_cont_CoordinateSystem_h
viskores::CopyFlag::Off
@ Off
viskores::cont::UncertainArrayHandle
An ArrayHandle of an uncertain value type and storage.
Definition: UncertainArrayHandle.h:47
ArrayHandleCast.h
viskores::cont::Field::Association
Association
Identifies what elements of a data set a field is associated with.
Definition: Field.h:46
viskores::Bounds
Represent an axis-aligned 3D bounds in space.
Definition: Bounds.h:37
viskores::cont::CoordinateSystem::StorageToArrayNonDefault
Definition: CoordinateSystem.h:89
viskores::cont::CastAndCall
void CastAndCall(const DynamicObject &dynamicObject, Functor &&f, Args &&... args)
A Generic interface to CastAndCall.
Definition: CastAndCall.h:55
viskores::cont::CoordinateSystem::GetBounds
viskores::Bounds GetBounds() const
Definition: CoordinateSystem.h:137
viskores::cont::ArrayHandleCast
Cast the values of an array to the specified type, on demand.
Definition: ArrayHandleCast.h:151
viskores::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:313
viskores::cont::CoordinateSystem
Manages a coordinate system for a DataSet.
Definition: CoordinateSystem.h:38
viskores::cont::CoordinateSystem::FloatNonDefault
viskores::Float64 FloatNonDefault
Definition: CoordinateSystem.h:76
mangled_diy_namespace
Definition: Particle.h:373
viskores::cont::CoordinateSystem::StorageToArrayDefault::IsInvalid
viskores::cont::internal::IsInvalidArrayHandle< viskores::Vec3f, S > IsInvalid
Definition: CoordinateSystem.h:83
viskores::Id
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
UncertainArrayHandle.h
viskores::cont::CoordinateSystem::ArraysFloatDefault
viskores::ListTransform< viskores::ListRemoveIf< ::viskores::cont::StorageListCommon, StorageToArrayDefault::IsInvalid >, StorageToArrayDefault::Transform > ArraysFloatDefault
Definition: CoordinateSystem.h:101
VISKORES_CONT
#define VISKORES_CONT
Definition: ExportMacros.h:65
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
Bounds.h
CastAndCall.h
viskores::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:617
viskores::cont::CoordinateSystem::ArraysFloatNonDefault
viskores::ListTransform< viskores::ListRemoveIf< ::viskores::cont::StorageListCommon, StorageToArrayNonDefault::IsInvalid >, StorageToArrayNonDefault::Transform > ArraysFloatNonDefault
Definition: CoordinateSystem.h:104
viskores::Float32
float Float32
Base type to use for 32-bit floating-point numbers.
Definition: Types.h:165
viskores::cont::CoordinateSystem::CoordinateSystem
CoordinateSystem(std::string name, const ArrayHandle< T, Storage > &data)
Definition: CoordinateSystem.h:52
viskores::cont::CoordinateSystem::GetRangeAsArrayHandle
viskores::cont::ArrayHandle< viskores::Range > GetRangeAsArrayHandle() const
Definition: CoordinateSystem.h:131
viskores::cont::CoordinateSystem::GetData
viskores::cont::UncertainArrayHandle< viskores::TypeListFieldVec3, ::viskores::cont::StorageListCommon > GetData() const
Field.h
viskores::cont::CoordinateSystem::GetRange
void GetRange(viskores::Range *range) const
Definition: CoordinateSystem.h:120
viskores::cont::CoordinateSystem::MultiplexerArrayType
viskores::cont::ArrayHandleMultiplexerFromList< viskores::ListAppend< ArraysFloatDefault, ArraysFloatNonDefault > > MultiplexerArrayType
Definition: CoordinateSystem.h:109
viskores::cont::CoordinateSystem::StorageToArrayNonDefault::IsInvalid
viskores::cont::internal::IsInvalidArrayHandle< Vec3f_nd, S > IsInvalid
Definition: CoordinateSystem.h:92
viskores::Range
Represent a continuous scalar range of values.
Definition: Range.h:39
viskores::cont::CoordinateSystem::ReleaseResourcesExecution
void ReleaseResourcesExecution() override
Remove the data from the device memory (but preserve the data on the host).
Definition: CoordinateSystem.h:146
viskores::cont::ArrayHandleMultiplexerFromList
viskores::ListApply< List, ArrayHandleMultiplexer > ArrayHandleMultiplexerFromList
Converts aviskores::List to an ArrayHandleMultiplexer
Definition: ArrayHandleMultiplexer.h:472
viskores::cont::CoordinateSystem::GetNumberOfPoints
viskores::Id GetNumberOfPoints() const
Definition: CoordinateSystem.h:66
viskores::cont::CoordinateSystem::GetRange
viskores::Vec< viskores::Range, 3 > GetRange() const
Definition: CoordinateSystem.h:123
viskores::ListAppend
typename detail::ListAppendImpl< Lists... >::type ListAppend
Concatinates a set of lists into a single list.
Definition: List.h:289
viskores::cont::CoordinateSystem::StorageToArrayDefault
Definition: CoordinateSystem.h:80
viskores::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:700
viskores::cont::UnknownArrayHandle
An ArrayHandle of an unknown value type and storage.
Definition: UnknownArrayHandle.h:451
viskores::cont::make_CoordinateSystem
viskores::cont::CoordinateSystem make_CoordinateSystem(std::string name, const std::vector< T > &data, viskores::CopyFlag copy=viskores::CopyFlag::Off)
Definition: CoordinateSystem.h:160
viskores::CopyFlag
CopyFlag
Identifier used to specify whether a function should deep copy data.
Definition: Flags.h:25
viskores::Float64
double Float64
Base type to use for 64-bit floating-point numbers.
Definition: Types.h:169
viskores::cont::Field
A Field encapsulates an array on some piece of the mesh, such as the points, a cell set,...
Definition: Field.h:39
viskores::cont::make_ArrayHandle
viskores::cont::ArrayHandleBasic< T > make_ArrayHandle(const T *array, viskores::Id numberOfValues, viskores::CopyFlag copy)
A convenience function for creating an ArrayHandle from a standard C array.
Definition: ArrayHandleBasic.h:285
viskores::Vec< viskores::Id, 3 >