From 2b771418e61a1ead835bc30e7a2e6a2d8854a36d Mon Sep 17 00:00:00 2001 From: Sujin Philip Date: Tue, 10 Nov 2015 12:24:45 -0500 Subject: [PATCH] Update Clip worklets to work with more types --- vtkm/worklet/Clip.h | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/vtkm/worklet/Clip.h b/vtkm/worklet/Clip.h index abbdb922f..2851faf1c 100644 --- a/vtkm/worklet/Clip.h +++ b/vtkm/worklet/Clip.h @@ -103,6 +103,20 @@ void swap(T &v1, T &v2) v2 = temp; } +template +VTKM_EXEC_CONT_EXPORT +T Scale(const T &val, vtkm::Float64 scale) +{ + return static_cast(scale * static_cast(val)); +} + +template +VTKM_EXEC_CONT_EXPORT +vtkm::Vec Scale(const vtkm::Vec &val, + vtkm::Float64 scale) +{ + return val * scale; +} template class ExecutionConnectivityExplicit : vtkm::exec::ExecutionObjectBase @@ -261,7 +275,7 @@ public: { public: typedef void ControlSignature(TopologyIn topology, - FieldInPoint scalars, + FieldInPoint scalars, FieldOutCell clipTableIdxs, FieldOutCell stats); typedef void ExecutionSignature(_2, CellShape, FromCount, _3, _4); @@ -322,7 +336,7 @@ public: { public: typedef void ControlSignature(TopologyIn topology, - FieldInPoint scalars, + FieldInPoint scalars, FieldInCell clipTableIdxs, FieldInCell cellSetIdxs, ExecObject connectivityExplicit, @@ -623,9 +637,8 @@ public: EdgeInterpolation ei = this->Interpolation.Get(idx); T v1 = Field.Get(ei.Vertex1); T v2 = Field.Get(ei.Vertex2); - typename VecTraits::ComponentType w = - static_cast::ComponentType>(ei.Weight); - Field.Set(this->NewPointsOffset + idx, (w * (v2 - v1)) + v1); + Field.Set(this->NewPointsOffset + idx, + internal::Scale(T(v2 - v1), ei.Weight) + v1); } private: