Go to the documentation of this file.
18 #ifndef viskores_worklet_KernelSplatter_h
19 #define viskores_worklet_KernelSplatter_h
36 #include <viskores/worklet/splatkernels/Gaussian.h>
37 #include <viskores/worklet/splatkernels/KernelBase.h>
38 #include <viskores/worklet/splatkernels/Spline3rdOrder.h>
45 #if defined(__VISKORES_GAUSSIAN_SPLATTER_BENCHMARK) && !defined(START_TIMER_BLOCK)
47 #define START_TIMER_BLOCK(name) \
48 viskores::cont::Timer timer_##name{ DeviceAdapter() }; \
52 #define END_TIMER_BLOCK(name) \
53 std::cout << #name " : elapsed : " << timer_##name.GetElapsedTime() << "\n";
55 #if !defined(START_TIMER_BLOCK)
56 #define START_TIMER_BLOCK(name)
57 #define END_TIMER_BLOCK(name)
72 template <
typename T,
typename S = VISKORES_DEFAULT_STORAGE_TAG>
76 using StorageType = viskores::cont::internal::Storage<T, S>;
77 using PortalConstType =
typename StorageType::PortalConstType;
78 PortalConstType readPortal = outputArray.
ReadPortal();
80 std::vector<ValueType> result(readPortal.GetNumberOfValues());
81 std::copy(iterators.GetBegin(), iterators.GetEnd(), result.begin());
83 std::copy(result.begin(), result.end(), std::ostream_iterator<ValueType>(std::cout,
" "));
84 std::cout << std::endl;
88 template <
typename T,
int S>
90 const std::string& name)
94 PortalConstType readPortal = outputArray.
ReadPortal();
100 std::cout << portal.Get(i);
102 std::cout << std::endl;
105 template <
typename I,
typename T,
int S>
109 const std::string& name)
111 using PortalConstType =
typename viskores::cont::
112 ArrayHandlePermutation<I, viskores::cont::ArrayHandle<viskores::Vec<T, S>>>::ReadPortalType;
113 PortalConstType readPortal = outputArray.
ReadPortal();
119 std::cout << outputPortal.Get(i);
121 std::cout << std::endl;
125 template <
typename T,
typename S>
131 template <
typename T,
int S>
138 template <
typename I,
typename T,
int S>
148 template <
typename Kernel,
typename DeviceAdapter>
179 template <
typename T>
182 T& voxel_value)
const
211 const Kernel& kernel)
219 template <
typename T,
typename T2>
232 double cutoff =
kernel_.maxDistance(h);
233 for (
int i = 0; i < 3; i++)
235 splat[i] = (sample[i] - this->origin_[i]) / this->spacing_[i];
236 min[i] =
static_cast<viskores::Id>(ceil(
static_cast<double>(splat[i]) - cutoff));
237 max[i] =
static_cast<viskores::Id>(floor(
static_cast<double>(splat[i]) + cutoff));
242 if (max[i] >= this->VolumeDimensions[i])
244 max[i] = this->VolumeDimensions[i] - 1;
246 size =
static_cast<viskores::Id>(size * (1 + max[i] - min[i]));
251 footprintSize = size;
269 template <
typename T>
275 localId = (index - offset) % modulus;
311 template <
typename T,
typename T2,
typename P>
331 (splatPoint[1] - voxel[1]) *
spacing_[0],
332 (splatPoint[2] - voxel[2]) *
spacing_[0]);
336 splatValue = scale *
kernel.w2(kernel_H, dist2);
340 if (neighborVoxelId < 0)
341 neighborVoxelId = -1;
360 template <
typename ExecArgPortalType>
363 ExecArgPortalType& execArg)
const
379 const Kernel& kernel)
401 template <
typename StorageT>
425 footprintDispatcher.SetDevice(DeviceAdapter());
428 footprintDispatcher.Invoke(
429 xValues, yValues, zValues, rValues, splatPoints, footprintMin, footprintMax, numNeighbors);
448 numNeighborsPrefixSum);
451 std::cout <<
"totalSplatSize " << totalSplatSize <<
"\n";
458 numNeighborsExclusiveSum);
472 numNeighborsPrefixSum, countingArray, neighbor2SplatId);
482 IdPermType modulii(neighbor2SplatId, numNeighbors);
485 IdPermType offsets(neighbor2SplatId, numNeighborsExclusiveSum);
489 idDispatcher.SetDevice(DeviceAdapter());
491 idDispatcher.Invoke(modulii, offsets, localNeighborIds);
504 VecPermType ptFootprintMins(neighbor2SplatId, footprintMin);
505 VecPermType ptFootprintMaxs(neighbor2SplatId, footprintMax);
523 splatterDispatcher_worklet);
524 splatterDispatcher.SetDevice(DeviceAdapter());
527 splatterDispatcher.Invoke(ptSplatPoints,
563 neighborVoxelIds, splatValues, uniqueVoxelIds, voxelSplatSums,
viskores::Add());
578 zeroDispatcher.SetDevice(DeviceAdapter());
579 zeroDispatcher.Invoke(indexArray, scalarSplatOutput);
588 scatterDispatcher.SetDevice(DeviceAdapter());
591 scatterDispatcher.Invoke(uniqueVoxelIds, voxelSplatSums, scalarSplatOutput);
603 #endif //viskores_worklet_KernelSplatter_h
static void UpperBounds(const viskores::cont::ArrayHandle< T, CIn > &input, const viskores::cont::ArrayHandle< T, CVal > &values, viskores::cont::ArrayHandle< viskores::Id, COut > &output)
Output is the last index in input for each item in values that wouldn't alter the ordering of input.
ReadPortalType ReadPortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:447
Contains and manages the geometric data structures that Viskores operates on.
Definition: DataSet.h:66
viskores::Vec< viskores::Float64, 3 > Vec3f_64
Vec3f_64 corresponds to a 3-dimensional vector of 64-bit floating point values.
Definition: Types.h:1076
A control signature tag for input fields.
Definition: WorkletMapField.h:68
#define viskoresNotUsed(parameter_name)
Simple macro to identify a parameter as unused.
Definition: ExportMacros.h:136
Manages an array-worth of data.
Definition: ArrayHandle.h:313
A control signature tag for output fields.
Definition: WorkletMapField.h:88
#define END_TIMER_BLOCK(name)
Definition: KernelSplatter.h:57
#define VISKORES_EXEC_CONT
Definition: ExportMacros.h:60
static T ScanExclusive(const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output)
Compute an exclusive prefix sum operation on the input ArrayHandle.
void OutputArrayDebug(const viskores::cont::ArrayHandle< T, S > &, const std::string &)
Definition: KernelSplatter.h:126
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
void ReleaseResources() const
Releases all resources in both the control and execution environments.
Definition: ArrayHandle.h:600
static void SortByKey(viskores::cont::ArrayHandle< T, StorageT > &keys, viskores::cont::ArrayHandle< U, StorageU > &values)
Unstable ascending sort of keys and values.
#define VISKORES_CONT
Definition: ExportMacros.h:65
Groups connected points that have the same field value.
Definition: Atomic.h:27
Dispatcher for worklets that inherit from WorkletMapField.
Definition: DispatcherMapField.h:33
#define START_TIMER_BLOCK(name)
Definition: KernelSplatter.h:56
float Float32
Base type to use for 32-bit floating-point numbers.
Definition: Types.h:165
static T ScanInclusive(const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output)
Compute an inclusive prefix sum operation on the input ArrayHandle.
viskores::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:482
ArrayHandleCounting is a specialization of ArrayHandle.
Definition: ArrayHandleCounting.h:140
Definition: ArrayPortalToIterators.h:35
constexpr viskores::Vec< T, viskores::IdComponent(sizeof...(Ts)+1)> make_Vec(T value0, Ts &&... args)
Initializes and returns a Vec containing all the arguments.
Definition: Types.h:1262
static void ReduceByKey(const viskores::cont::ArrayHandle< T, CKeyIn > &keys, const viskores::cont::ArrayHandle< U, CValIn > &values, viskores::cont::ArrayHandle< T, CKeyOut > &keys_output, viskores::cont::ArrayHandle< U, CValOut > &values_output, BinaryFunctor binary_functor)
Compute a accumulated sum operation on the input key value pairs.
viskores::Vec< viskores::Float32, 3 > Vec3f_32
Vec3f_32 corresponds to a 3-dimensional vector of 32-bit floating point values.
Definition: Types.h:1070
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:47
double Float64
Base type to use for 64-bit floating-point numbers.
Definition: Types.h:169
A short fixed-length array.
Definition: Types.h:365
Implicitly permutes the values in an array.
Definition: ArrayHandlePermutation.h:242
The ExecutionSignature tag to use to get the work index.
Definition: WorkIndex.h:47