mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Add vtkm::cont::Field,CoordinateSystem as Invokable parameters.
Originally, only array handles could be passed to the dispatcher. This update extends the list to Field and CoordinateSystem as dynamic objects.
This commit is contained in:
parent
2b011c621c
commit
927387b1a2
@ -83,6 +83,9 @@ class CoordinateSystem : public vtkm::cont::Field
|
||||
typedef vtkm::cont::Field Superclass;
|
||||
|
||||
public:
|
||||
VTKM_CONT_EXPORT
|
||||
CoordinateSystem() : Superclass() { }
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
CoordinateSystem(std::string name,
|
||||
const vtkm::cont::DynamicArrayHandle &data)
|
||||
@ -255,10 +258,28 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
|
||||
template<>
|
||||
struct DynamicTransformTraits<vtkm::cont::CoordinateSystem>
|
||||
{
|
||||
typedef vtkm::cont::internal::DynamicTransformTagCastAndCall DynamicTag;
|
||||
};
|
||||
|
||||
template<typename Functor>
|
||||
struct CastAndCall<vtkm::cont::CoordinateSystem, Functor>
|
||||
{
|
||||
VTKM_CONT_EXPORT
|
||||
void operator()(const vtkm::cont::CoordinateSystem &coordinateSystem,
|
||||
const Functor &func) const
|
||||
{
|
||||
coordinateSystem.GetData().CastAndCall(func);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace cont
|
||||
} // namespace vtkm
|
||||
|
||||
|
||||
#endif //vtk_m_cont_CoordinateSystem_h
|
||||
|
||||
|
||||
|
@ -518,7 +518,25 @@ private:
|
||||
mutable bool ModifiedFlag;
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
|
||||
template<>
|
||||
struct DynamicTransformTraits<vtkm::cont::Field>
|
||||
{
|
||||
typedef vtkm::cont::internal::DynamicTransformTagCastAndCall DynamicTag;
|
||||
};
|
||||
|
||||
template<typename Functor>
|
||||
struct CastAndCall<vtkm::cont::Field, Functor>
|
||||
{
|
||||
VTKM_CONT_EXPORT
|
||||
void operator()(const vtkm::cont::Field &field, const Functor &func) const
|
||||
{
|
||||
field.GetData().CastAndCall(func);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace cont
|
||||
} // namespace vtkm
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
|
||||
namespace internal {
|
||||
|
||||
/// Tag used to identify an object that is a dynamic object that contains a
|
||||
@ -56,6 +57,19 @@ struct DynamicTransformTraits {
|
||||
typedef vtkm::cont::internal::DynamicTransformTagStatic DynamicTag;
|
||||
};
|
||||
|
||||
/// A Generic interface to CastAndCall. The default implementation simply calls
|
||||
/// DynamicObject's CastAndCall, but specializations of this function exist for
|
||||
/// other classes (e.g. Field, CoordinateSystem).
|
||||
template<typename DynamicObject, typename Functor>
|
||||
struct CastAndCall
|
||||
{
|
||||
VTKM_CONT_EXPORT
|
||||
void operator()(const DynamicObject& dynamicObject, const Functor &f)
|
||||
{
|
||||
dynamicObject.CastAndCall(f);
|
||||
}
|
||||
};
|
||||
|
||||
/// This functor can be used as the transform in the \c DynamicTransformCont
|
||||
/// method of \c FunctionInterface. It will allow dynamic objects like
|
||||
/// \c DynamicArray to be cast to their concrete types for templated operation.
|
||||
@ -92,7 +106,8 @@ private:
|
||||
const ContinueFunctor &continueFunc,
|
||||
vtkm::cont::internal::DynamicTransformTagCastAndCall) const
|
||||
{
|
||||
dynamicInput.CastAndCall(continueFunc);
|
||||
CastAndCall<InputType, ContinueFunctor> castAndCall;
|
||||
castAndCall(dynamicInput, continueFunc);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -253,7 +253,7 @@ void TestMarchingCubesUniformGrid()
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsArray;
|
||||
isosurfaceFilter.Run(0.5f,
|
||||
cellSet,
|
||||
dataSet.GetCoordinateSystem().GetData(),
|
||||
dataSet.GetCoordinateSystem(),
|
||||
fieldArray,
|
||||
verticesArray,
|
||||
normalsArray,
|
||||
|
Loading…
Reference in New Issue
Block a user