Go to the documentation of this file.
18 #ifndef viskores_cont_UnknownCellSet_h
19 #define viskores_cont_UnknownCellSet_h
35 template <
typename CellSetList>
36 class UncertainCellSet;
66 template <
typename CellSetType>
71 this->Container = std::shared_ptr<viskores::cont::CellSet>(
new CellSetType(cellSet));
77 template <
typename CellSetType>
80 this->InitializeKnownOrUnknownCellSet(
81 cellSet,
typename std::is_base_of<UnknownCellSet, CellSetType>::type{});
96 return this->Container.get();
116 template <
typename CellSetType>
119 return (
dynamic_cast<const CellSetType*
>(this->Container.get()) !=
nullptr);
124 return this->Container ? this->Container->GetNumberOfCells() : 0;
128 return this->Container ? this->Container->GetNumberOfFaces() : 0;
132 return this->Container ? this->Container->GetNumberOfEdges() : 0;
136 return this->Container ? this->Container->GetNumberOfPoints() : 0;
141 return this->GetCellSetBase()->GetCellShape(
id);
145 return this->GetCellSetBase()->GetNumberOfPointsInCell(
id);
149 return this->GetCellSetBase()->GetCellPointIds(
id, ptids);
160 this->Container->ReleaseResourcesExecution();
171 template <
typename CellSetType>
177 return this->IsType<CellSetType>();
188 template <
typename CellSetType>
192 CellSetType* cellSetPointer =
dynamic_cast<CellSetType*
>(this->Container.get());
193 if (cellSetPointer ==
nullptr)
199 cellSet = *cellSetPointer;
202 template <
typename CellSetType>
206 this->AsCellSet(cellSet);
219 template <
typename CellSetList>
221 template <
typename CellSetList>
233 template <
typename CellSetList,
typename Functor,
typename... Args>
234 VISKORES_CONT void CastAndCallForTypes(Functor&& functor, Args&&... args)
const;
243 template <
typename CellSetType>
246 return unknownCellSet.
IsType<CellSetType>();
253 template <
typename CellSetType>
256 return unknownCellSet.
AsCellSet<CellSetType>();
263 const std::type_info&);
268 using DynamicTag = viskores::cont::internal::DynamicTransformTagCastAndCall;
273 template <
typename CellSetList,
typename Functor,
typename... Args>
281 if (!called && this->
CanConvert<decltype(cellSet)>())
292 functor(cellSet, args...);
300 internal::ThrowCastAndCallException(*
this,
typeid(CellSetList));
306 template <
typename Functor,
typename... Args>
310 std::forward<Args>(args)...);
319 template <
typename T>
320 using UnknownCellSetCheck =
typename std::is_base_of<viskores::cont::UnknownCellSet, T>::type;
322 #define VISKORES_IS_UNKNOWN_CELL_SET(T) \
323 VISKORES_STATIC_ASSERT(::viskores::cont::internal::UnknownCellSetCheck<T>::value)
325 #define VISKORES_IS_KNOWN_OR_UNKNOWN_CELL_SET(T) \
326 VISKORES_STATIC_ASSERT(::viskores::cont::internal::CellSetCheck<T>::type::value || \
327 ::viskores::cont::internal::UnknownCellSetCheck<T>::value)
344 struct VISKORES_CONT_EXPORT SerializableTypeString<
viskores::cont::UnknownCellSet>
355 struct VISKORES_CONT_EXPORT Serialization<
viskores::cont::UnknownCellSet>
371 #endif //viskores_cont_UnknownCellSet_h
T load(const U &u, viskores::Id v)
Definition: FetchTagArrayDirectIn.h:44
void InitializeKnownOrUnknownCellSet(const CellSetType &cellSet, std::false_type)
Definition: UnknownCellSet.h:67
bool IsType() const
Returns true if this cell set matches the CellSetType template argument.
Definition: UnknownCellSet.h:117
viskores::Id GetNumberOfEdges() const
Definition: UnknownCellSet.h:130
void CastAndCall(const DynamicObject &dynamicObject, Functor &&f, Args &&... args)
A Generic interface to CastAndCall.
Definition: CastAndCall.h:55
#define VISKORES_LOG_CAST_FAIL(inObj, outType)
Convenience macro for logging a failed cast of dynamic object.
Definition: Logging.h:241
viskores::cont::CellSet * GetCellSetBase()
Returns a pointer to the CellSet base class.
Definition: UnknownCellSet.h:93
UnknownCellSet(const CellSetType &cellSet)
Definition: UnknownCellSet.h:78
#define viskoresNotUsed(parameter_name)
Simple macro to identify a parameter as unused.
Definition: ExportMacros.h:136
void CastAndCallForTypes(Functor &&functor, Args &&... args) const
Call a functor using the underlying cell set type.
Definition: UnknownCellSet.h:274
void DeepCopyFrom(const CellSet *src)
Definition: UnknownCellSet.h:152
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
Definition: Particle.h:373
viskores::UInt8 GetCellShape(viskores::Id id) const
Definition: UnknownCellSet.h:139
bool IsType(const viskores::cont::UnknownArrayHandle &array)
Returns true if variant matches the type of ArrayHandleType.
Definition: UnknownArrayHandle.h:1272
std::shared_ptr< viskores::cont::CellSet > Container
Definition: UnknownCellSet.h:58
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
#define VISKORES_CONT
Definition: ExportMacros.h:65
bool IsValid() const
Returns whether a cell set is stored in this UnknownCellSet.
Definition: UnknownCellSet.h:89
Groups connected points that have the same field value.
Definition: Atomic.h:27
#define VISKORES_DEFAULT_CELL_SET_LIST
Definition: DefaultTypes.h:85
viskores::IdComponent GetNumberOfPointsInCell(viskores::Id id) const
Definition: UnknownCellSet.h:143
void throwFailedDynamicCast(const std::string &baseType, const std::string &derivedType)
Throws an ErrorBadType exception with the following message: Cast failed: baseType --> derivedType".
CellSetType AsCellSet() const
Get the cell set as a known type.
Definition: UnknownCellSet.h:203
viskores::Id GetNumberOfCells() const
Definition: UnknownCellSet.h:122
viskores::Id GetNumberOfPoints() const
Definition: UnknownCellSet.h:134
void ReleaseResourcesExecution()
Definition: UnknownCellSet.h:156
uint8_t UInt8
Base type to use for 8-bit unsigned integer numbers.
Definition: Types.h:177
const viskores::cont::CellSet * GetCellSetBase() const
Definition: UnknownCellSet.h:94
bool CanConvert() const
Returns true if this cell set can be retrieved as the given type.
Definition: UnknownCellSet.h:172
ArrayHandleType Cast(const viskores::cont::UnknownArrayHandle &array)
Returns variant cast to the given ArrayHandle type.
Definition: UnknownArrayHandle.h:1282
A CellSet of an unknown type.
Definition: UnknownCellSet.h:56
void ListForEach(Functor &&f, viskores::List< Ts... >, Args &&... args)
For each typename represented by the list, call the functor with a default instance of that type.
Definition: List.h:745
A CellSet of an uncertain type.
Definition: UncertainCellSet.h:46
auto Get(const viskores::Tuple< Ts... > &tuple)
Retrieve the object from a viskores::Tuple at the given index.
Definition: Tuple.h:89
void GetCellPointIds(viskores::Id id, viskores::Id *ptids) const
Definition: UnknownCellSet.h:147
#define VISKORES_IS_CELL_SET(T)
Definition: CellSet.h:97
#define VISKORES_LOG_CAST_SUCC(inObj, outObj)
Convenience macro for logging the successful cast of dynamic object.
Definition: Logging.h:232
void AsCellSet(CellSetType &cellSet) const
Get the cell set as a known type.
Definition: UnknownCellSet.h:189
Defines the topological structure of the data in a DataSet.
Definition: CellSet.h:36
void InitializeKnownOrUnknownCellSet(const UnknownCellSet &cellSet, std::true_type)
Definition: UnknownCellSet.h:60
std::string TypeToString(const std::type_info &t)
Use RTTI information to retrieve the name of the type T.
viskores::Id GetNumberOfFaces() const
Definition: UnknownCellSet.h:126
#define VISKORES_IS_LIST(type)
Checks that the argument is a proper list.
Definition: List.h:77