Go to the documentation of this file.
10 #ifndef vtk_m_rendering_raytracing_Ray_Operations_h
11 #define vtk_m_rendering_raytracing_Ray_Operations_h
19 #include <vtkm/rendering/vtkm_rendering_export.h>
35 using ControlSignature = void(FieldIn, FieldInOut);
36 using ExecutionSignature = void(_1, _2);
63 : InverseProjView(inverseProjView)
73 using ControlSignature = void(FieldIn, FieldInOut, FieldIn, WholeArrayIn);
74 using ExecutionSignature = void(_1, _2, _3, _4);
76 template <
typename Precision,
typename DepthPortalType>
78 Precision& maxDistance,
79 const Vec<Precision, 3>& origin,
80 const DepthPortalType& depths)
const
85 position[2] =
static_cast<vtkm::Float32>(depths.Get(pixelId));
88 position[0] = position[0] * DoubleInvWidth - 1.f;
89 position[1] = position[1] * DoubleInvHeight - 1.f;
90 position[2] = 2.f * position[2] - 1.f;
92 position[2] -= 0.00001f;
95 p[0] = position[0] / position[3];
96 p[1] = position[1] / position[3];
97 p[2] = position[2] / position[3];
109 template <
typename T>
121 template <
typename Device,
typename T>
125 detail::RayStatusFilter{}) };
126 dispatcher.SetDevice(Device());
130 template <
typename T>
134 detail::RayStatusFilter{}) };
142 template <
typename T>
153 dispatcher.Invoke(rays.
Status, masks);
161 template <
typename T>
165 if (status < 0 || status > 255)
175 dispatcher.Invoke(rays.
Status, masks);
183 template <
typename T>
195 dispatcher.Invoke(rays.
Status, masks);
203 template <
typename T>
213 dispatcher.Invoke(rays.
Status, masks);
225 floatArrayPointers[0] = &rays.
OriginX;
226 floatArrayPointers[1] = &rays.
OriginY;
227 floatArrayPointers[2] = &rays.
OriginZ;
228 floatArrayPointers[3] = &rays.
DirX;
229 floatArrayPointers[4] = &rays.
DirY;
230 floatArrayPointers[5] = &rays.
DirZ;
231 floatArrayPointers[6] = &rays.
Distance;
235 floatArrayPointers[9] = &rays.
Scalar;
239 floatArrayPointers[13] = &rays.
U;
240 floatArrayPointers[14] = &rays.
V;
241 floatArrayPointers[15] = &rays.
NormalX;
242 floatArrayPointers[16] = &rays.
NormalY;
243 floatArrayPointers[17] = &rays.
NormalZ;
246 for (
int i = 0; i < numFloatArrays; ++i)
254 *floatArrayPointers[i] = compacted;
268 rays.
HitIdx = compactedHits;
276 rays.
Status = compactedStatus;
280 const size_t bufferCount =
static_cast<size_t>(rays.
Buffers.size());
281 for (
size_t i = 0; i < bufferCount; ++i)
288 template <
typename Device,
typename T>
302 rays.
U.PrepareForOutput(rays.
NumRays, Device(), token);
303 rays.
V.PrepareForOutput(rays.
NumRays, Device(), token);
315 rays.
DirX.PrepareForOutput(rays.
NumRays, Device(), token);
316 rays.
DirY.PrepareForOutput(rays.
NumRays, Device(), token);
317 rays.
DirZ.PrepareForOutput(rays.
NumRays, Device(), token);
326 const size_t bufferCount =
static_cast<size_t>(rays.
Buffers.size());
327 for (
size_t i = 0; i < bufferCount; ++i)
333 template <
typename T>
static void CopyDistancesToMin(Ray< T > rays, const T offset=0.f)
Definition: RayOperations.h:334
#define VTKM_EXEC
Definition: ExportMacros.h:51
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::cont::ArrayHandle< vtkm::UInt8 > Status
Definition: Ray.h:95
static void Resize(Ray< T > &rays, const vtkm::Int32 newSize, Device)
Definition: RayOperations.h:289
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
vtkm::cont::ArrayHandle< Precision > U
Definition: Ray.h:81
VTKM_EXEC_CONT detail::FloatingPointReturnType< T >::Type Magnitude(const T &x)
Returns the magnitude of a vector.
Definition: VectorAnalysis.h:100
static vtkm::cont::ArrayHandle< vtkm::UInt8 > CompactActiveRays(Ray< T > &rays)
Definition: RayOperations.h:204
vtkm::cont::ArrayHandle< Precision > NormalZ
Definition: Ray.h:85
vtkm::cont::ArrayHandle< Precision > Scalar
Definition: Ray.h:86
vtkm::cont::ArrayHandle< Precision > OriginZ
Definition: Ray.h:75
bool IntersectionDataEnabled
Definition: Ray.h:40
#define RAY_EXITED_DOMAIN
Definition: Ray.h:24
static VTKM_CONT bool Copy(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< U, COut > &output)
Definition: Algorithm.h:410
std::vector< ChannelBuffer< Precision > > Buffers
Definition: Ray.h:97
vtkm::cont::ArrayHandle< Precision > NormalY
Definition: Ray.h:84
vtkm::cont::ArrayHandle< Precision > IntersectionX
Definition: Ray.h:68
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::cont::ArrayHandle< Precision > V
Definition: Ray.h:82
static vtkm::Id RaysProcessed(Ray< T > &rays)
Definition: RayOperations.h:184
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::cont::ArrayHandle< Precision > MinDistance
Definition: Ray.h:93
VTKM_CONT ArrayHandleCompositeVector< ArrayTs... > make_ArrayHandleCompositeVector(const ArrayTs &... arrays)
Create a composite vector array from other arrays.
Definition: ArrayHandleCompositeVector.h:430
static void ResetStatus(Ray< T > &rays, vtkm::UInt8 status)
Definition: RayOperations.h:110
Dispatcher for worklets that inherit from WorkletMapField.
Definition: DispatcherMapField.h:25
VTKM_EXEC_CONT vtkm::Matrix< T, NumRow, NumCol > MatrixMultiply(const vtkm::Matrix< T, NumRow, NumInternal > &leftFactor, const vtkm::Matrix< T, NumInternal, NumCol > &rightFactor)
Standard matrix multiplication.
Definition: Matrix.h:156
static vtkm::Id RaysInMesh(Ray< T > &rays)
Definition: RayOperations.h:143
vtkm::cont::ArrayHandle< Precision > DirY
Definition: Ray.h:78
vtkm::cont::ArrayHandle< Precision > OriginX
Definition: Ray.h:73
vtkm::cont::ArrayHandle< vtkm::Id > PixelIdx
Definition: Ray.h:91
vtkm::cont::ArrayHandleCompositeVector< vtkm::cont::ArrayHandle< Precision >, vtkm::cont::ArrayHandle< Precision >, vtkm::cont::ArrayHandle< Precision > > Normal
Definition: Ray.h:54
static VTKM_CONT void CopyIf(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< U, CStencil > &stencil, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: Algorithm.h:435
Definition: RayOperations.h:106
static vtkm::Id GetStatusCount(Ray< T > &rays, vtkm::Id status)
Definition: RayOperations.h:162
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::cont::ArrayHandle< Precision > OriginY
Definition: Ray.h:74
vtkm::cont::ArrayHandle< vtkm::Id > HitIdx
Definition: Ray.h:90
vtkm::cont::ArrayHandle< Precision > IntersectionZ
Definition: Ray.h:70
An array handle with a constant value.
Definition: ArrayHandleConstant.h:63
uint8_t UInt8
Definition: Types.h:157
Definition: Worklets.h:60
#define RAY_ABANDONED
Definition: Ray.h:26
vtkm::cont::ArrayHandle< Precision > Distance
Definition: Ray.h:88
#define RAY_ACTIVE
Definition: Ray.h:20
vtkm::cont::ArrayHandleCompositeVector< vtkm::cont::ArrayHandle< Precision >, vtkm::cont::ArrayHandle< Precision >, vtkm::cont::ArrayHandle< Precision > > Dir
Definition: Ray.h:66
Definition: Worklets.h:110
static void Compact(ChannelBuffer< Precision > &buffer, vtkm::cont::ArrayHandle< UInt8 > &masks, const vtkm::Id &newSize)
Definition: ChannelBufferOperations.h:97
vtkm::cont::ArrayHandle< Precision > IntersectionY
Definition: Ray.h:69
vtkm::Id NumRays
Definition: Ray.h:100
#define RAY_EXITED_MESH
Definition: Ray.h:23
vtkm::Id Width
Definition: Wireframer.h:379
vtkm::cont::ArrayHandle< Precision > DirX
Definition: Ray.h:77
static void UpdateRayStatus(Ray< T > &rays, Device)
Definition: RayOperations.h:122
This class is thrown when a VTKm function or method encounters an invalid value that inhibits progres...
Definition: ErrorBadValue.h:25
Cast the values of an array to the specified type, on demand.
Definition: ArrayHandleCast.h:141
#define RAY_LOST
Definition: Ray.h:25
static void UpdateRayStatus(Ray< T > &rays)
Definition: RayOperations.h:131
static VTKM_CONT U Reduce(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue)
Definition: Algorithm.h:656
VTKM_CONT ReadPortalType ReadPortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:414
VTKM_CONT WritePortalType PrepareForOutput(vtkm::Id numberOfValues, vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Prepares (allocates) this array to be used as an output from an operation in the execution environmen...
Definition: ArrayHandle.h:613
#define RAY_TERMINATED
Definition: Ray.h:22
float Float32
Definition: Types.h:154
int32_t Int32
Definition: Types.h:160
vtkm::cont::ArrayHandle< Precision > DirZ
Definition: Ray.h:79
Definition: CanvasRayTracer.h:23
vtkm::cont::ArrayHandleCompositeVector< vtkm::cont::ArrayHandle< Precision >, vtkm::cont::ArrayHandle< Precision >, vtkm::cont::ArrayHandle< Precision > > Origin
Definition: Ray.h:60
Definition: Worklets.h:86
vtkm::cont::ArrayHandle< Precision > NormalX
Definition: Ray.h:83
vtkm::cont::ArrayHandle< Precision > MaxDistance
Definition: Ray.h:94
static VTKM_RENDERING_EXPORT void MapCanvasToRays(Ray< vtkm::Float32 > &rays, const vtkm::rendering::Camera &camera, const vtkm::rendering::CanvasRayTracer &canvas)
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38