Go to the documentation of this file.
11 #ifndef vtk_m_rendering_Wireframer_h
12 #define vtk_m_rendering_Wireframer_h
57 return 1.0f - FractionalPart(x);
73 return PackColor(color[0], color[1], color[2], color[3]);
80 packed |= (ScaleColorComponent(g) << 16);
81 packed |= (ScaleColorComponent(b) << 8);
82 packed |= ScaleColorComponent(a);
96 UnpackColor(packedColor, color[0], color[1], color[2], color[3]);
128 using ControlSignature = void(FieldIn, FieldIn, FieldOut);
129 using ExecutionSignature = void(_1, _2, _3);
132 CopyIntoFrameBuffer() {}
140 packed.Ints.Color = PackColor(color);
141 packed.Floats.Depth = depth;
142 outValue = packed.Raw;
146 template <
typename DeviceTag>
153 using ControlSignature = void(FieldIn, WholeArrayIn, WholeArrayIn);
154 using ExecutionSignature = void(_1, _2, _3);
155 using InputDomain = _1;
167 const ColorMapHandle& colorMap,
168 const AtomicPackedFrameBuffer& frameBuffer,
179 ,
ColorMap(colorMap.PrepareForInput(DeviceTag(), token))
181 ,
FrameBuffer(frameBuffer.PrepareForExecution(DeviceTag(), token))
185 if (fieldLength == 0.f)
197 template <
typename CoordinatesPortalType,
typename ScalarFieldPortalType>
199 const CoordinatesPortalType& coordsPortal,
200 const ScalarFieldPortalType& fieldPortal)
const
202 vtkm::Id point1Idx = edgeIndices[0];
203 vtkm::Id point2Idx = edgeIndices[1];
208 TransformWorldToViewport(point1);
209 TransformWorldToViewport(point2);
220 bool transposed = vtkm::Abs(y2 - y1) > vtkm::Abs(x2 - x1);
238 dx = vtkm::Epsilon32();
249 point2Field = fieldPortal.Get(point2Idx);
254 point2Field = point1Field;
261 Plot(yPxl1, xPxl1, zPxl1, color, 1.0f);
265 Plot(xPxl1, yPxl1, zPxl1, color, 1.0f);
270 yEnd = y2 + gradient * (xEnd - x2);
275 color = GetColor(point2Field);
278 Plot(yPxl2, xPxl2, zPxl2, color, 1.0f);
282 Plot(xPxl2, yPxl2, zPxl2, color, 1.0f);
294 color = GetColor(fieldValue);
295 Plot(t, x, depth, color, ReverseFractionalPart(interY));
296 Plot(t + 1, x, depth, color, FractionalPart(interY));
308 color = GetColor(fieldValue);
309 Plot(x, t, depth, color, ReverseFractionalPart(interY));
310 Plot(x, t + 1, depth, color, FractionalPart(interY));
317 using ColorMapPortalConst =
typename ColorMapHandle::ReadPortalType;
326 point[i] = temp[i] / temp[3];
332 point[2] = point[2] * 0.5f + 0.5f;
345 return this->
ColorMap.Get(colorIdx);
356 if (xi < 0 || xi >=
Width || yi < 0 || yi >=
Height)
361 PackedValue current, next;
362 current.Raw = ClearValue;
363 next.Floats.Depth = depth;
368 UnpackColor(current.Ints.Color, srcColor);
371 blendedColor[0] = color[0] * intensity + srcColor[0] * alpha;
372 blendedColor[1] = color[1] * intensity + srcColor[1] * alpha;
373 blendedColor[2] = color[2] * intensity + srcColor[2] * alpha;
374 blendedColor[3] = alpha + intensity;
375 next.Ints.Color = PackColor(blendedColor);
377 }
while (current.Floats.Depth > next.Floats.Depth);
402 using ControlSignature = void(FieldIn, WholeArrayOut, WholeArrayOut);
403 using ExecutionSignature = void(_1, _2, _3, WorkIndex);
405 template <
typename DepthBufferPortalType,
typename ColorBufferPortalType>
407 DepthBufferPortalType& depthBuffer,
408 ColorBufferPortalType& colorBuffer,
412 packed.Raw = packedValue;
413 float depth = packed.Floats.Depth;
414 if (depth <= depthBuffer.Get(index))
417 UnpackColor(packed.Ints.Color, color);
418 colorBuffer.Set(index, color);
419 depthBuffer.Set(index, depth);
451 const IndicesHandle& endPointIndices,
470 template <
typename DeviceTag>
485 modelMatrix[2][3] = offset;
493 vtkm::Id pixelCount = width * height;
503 CopyIntoFrameBuffer bufferCopy;
528 subsetWidth =
static_cast<vtkm::Id>(_w);
529 subsetHeight =
static_cast<vtkm::Id>(_h);
530 yOffset =
static_cast<vtkm::Id>(_y);
531 xOffset =
static_cast<vtkm::Id>(_x);
535 if (!isSupportedField)
557 plotterDispatcher.SetDevice(DeviceTag());
558 plotterDispatcher.Invoke(
562 BufferConverter converter;
564 converterDispatcher.SetDevice(DeviceTag());
578 template <
typename DeviceTag>
603 #endif //vtk_m_rendering_Wireframer_h
vtkm::cont::CoordinateSystem Coordinates
Definition: Wireframer.h:593
ColorMapHandle ColorMap
Definition: Wireframer.h:592
Manages an array-worth of data.
Definition: ArrayHandle.h:300
vtkm::rendering::Camera Camera
Definition: Wireframer.h:588
vtkm::Matrix< vtkm::Float32, 4, 4 > CreateViewMatrix() const
AtomicPackedFrameBufferHandle FrameBuffer
Definition: Wireframer.h:390
vtkm::Id XOffset
Definition: Wireframer.h:385
const DepthBufferType & GetDepthBuffer() const
Get the depth channel of the image.
void Render()
Definition: Wireframer.h:463
vtkm::Float32 Floor(vtkm::Float32 x)
Definition: Math.h:2230
#define VTKM_EXEC
Definition: ExportMacros.h:51
PackedFrameBufferHandle FrameBuffer
Definition: Wireframer.h:598
Groups connected points that have the same field value.
Definition: Atomic.h:19
void SetSolidDepthBuffer(const vtkm::cont::ArrayHandle< vtkm::Float32 > depthBuffer)
Definition: Wireframer.h:444
bool IsCellField() const
Return true if this field is associated with cells.
Definition: Field.h:117
vtkm::Id Height
Definition: Wireframer.h:382
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::Float32 ColorMapSize
Definition: Wireframer.h:389
vtkm::Range GetClippingRange() const
The clipping range of the camera.
Definition: Camera.h:166
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
vtkm::Matrix< vtkm::Float32, 4, 4 > CreateProjectionMatrix(vtkm::Id screenWidth, vtkm::Id screenHeight) const
vtkm::Float64 Length() const
Returns the length of the range.
Definition: Range.h:91
struct vtkm::rendering::@567::PackedValue::PackedInts Ints
void SetData(const vtkm::cont::CoordinateSystem &coords, const IndicesHandle &endPointIndices, const vtkm::cont::Field &field, const vtkm::Range &fieldRange)
Definition: Wireframer.h:450
bool operator()(DeviceTag)
Definition: Wireframer.h:579
vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:468
ValueType Lerp(const ValueType &value0, const ValueType &value1, const WeightType &weight)
Returns the linear interpolation of two values based on weight.
Definition: VectorAnalysis.h:32
vtkm::Range ScalarFieldRange
Definition: Wireframer.h:596
void RenderWithDevice(DeviceTag)
Definition: Wireframer.h:471
vtkm::cont::ArrayHandle< vtkm::Float32 > SolidDepthBuffer
Definition: Wireframer.h:597
vtkm::cont::Field ScalarField
Definition: Wireframer.h:595
vtkm::Id YOffset
Definition: Wireframer.h:386
vtkm::Float32 FieldMin
Definition: Wireframer.h:391
Manages a coordinate system for a DataSet.
Definition: CoordinateSystem.h:30
vtkm::Matrix< T, Size, Size > MatrixIdentity()
Returns the identity matrix.
Definition: Matrix.h:211
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
bool ShowInternalZones
Definition: Wireframer.h:590
vtkm::Matrix< vtkm::Float32, 4, 4 > WorldToProjection
Definition: Wireframer.h:380
Represents the image space that is the target of rendering.
Definition: Canvas.h:35
bool AssocPoints
Definition: Wireframer.h:387
Dispatcher for worklets that inherit from WorkletMapField.
Definition: DispatcherMapField.h:25
bool IsOverlay
Definition: Wireframer.h:591
vtkm::Float32 Color
Definition: Wireframer.h:115
RenderWithDeviceFunctor(Wireframer *renderer)
Definition: Wireframer.h:573
vtkm::Float32 InverseFieldDelta
Definition: Wireframer.h:392
A Field encapsulates an array on some piece of the mesh, such as the points, a cell set,...
Definition: Field.h:31
Wireframer(vtkm::rendering::Canvas *canvas, bool showInternalZones, bool isOverlay)
Definition: Wireframer.h:430
IndicesHandle PointIndices
Definition: Wireframer.h:594
vtkm::Float32 Round(vtkm::Float32 x)
Definition: Math.h:2291
struct vtkm::rendering::@567::PackedValue::PackedFloats Floats
vtkm::Id GetWidth() const
The width of the image.
vtkm::Id SubsetHeight
Definition: Wireframer.h:384
void SetColorMap(const ColorMapHandle &colorMap)
Definition: Wireframer.h:441
bool TryExecute(Functor &&functor, Args &&... args)
Try to execute a functor on a set of devices until one succeeds.
Definition: TryExecute.h:244
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::Id SubsetWidth
Definition: Wireframer.h:383
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:158
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
signed long long Int64
Base type to use for 64-bit signed integer numbers.
Definition: Types.h:204
An array handle with a constant value.
Definition: ArrayHandleConstant.h:70
Definition: Wireframer.h:426
Represent an axis-aligned 3D bounds in space.
Definition: Bounds.h:29
static bool Copy(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< U, COut > &output)
Definition: Algorithm.h:411
vtkm::rendering::Camera::Mode GetMode() const
The mode of the camera (2D or 3D).
Definition: Camera.h:141
Definition: Wireframer.h:569
bool IsPointField() const
Return true if this field is associated with points.
Definition: Field.h:119
bool CompareExchange(vtkm::Id index, ValueType *oldValue, const ValueType &newValue, vtkm::MemoryOrder order=vtkm::MemoryOrder::SequentiallyConsistent) const
Perform an atomic compare and exchange operation with sequentially consistent memory ordering.
Definition: AtomicArrayExecutionObject.h:240
vtkm::Float32 Depth
Definition: Wireframer.h:116
vtkm::Id Width
Definition: Wireframer.h:381
uint32_t UInt32
Base type to use for 32-bit unsigned integer numbers.
Definition: Types.h:185
This class is thrown when a VTKm function or method encounters an invalid value that inhibits progres...
Definition: ErrorBadValue.h:25
vtkm::Float64 Min
The minumum value of the range (inclusive).
Definition: Range.h:34
vtkm::Int64 Raw
Definition: Wireframer.h:123
vtkm::rendering::Canvas * Canvas
Definition: Wireframer.h:589
float Float32
Base type to use for 32-bit floating-point numbers.
Definition: Types.h:157
int32_t Int32
Base type to use for 32-bit signed integer numbers.
Definition: Types.h:181
double Float64
Base type to use for 64-bit floating-point numbers.
Definition: Types.h:161
vtkm::Bounds GetBounds() const
Definition: CoordinateSystem.h:128
Specifies the viewport for a rendering.
Definition: Camera.h:37
vtkm::Float32 Offset
Definition: Wireframer.h:393
vtkm::Float64 Max
Tha maximum value of the range (inclusive).
Definition: Range.h:36
const ColorBufferType & GetColorBuffer() const
Get the color channels of the image.
An object passed to a worklet when accessing an atomic array.
Definition: AtomicArrayExecutionObject.h:88
A type list containing types that can be used with an AtomicArray.
Definition: AtomicArray.h:49
void SetCamera(const vtkm::rendering::Camera &camera)
Definition: Wireframer.h:438
void GetRealViewport(vtkm::Id screenWidth, vtkm::Id screenHeight, vtkm::Float32 &left, vtkm::Float32 &right, vtkm::Float32 &bottom, vtkm::Float32 &top) const
ColorMapPortalConst ColorMap
Definition: Wireframer.h:388
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:39
vtkm::Bounds Bounds
Definition: Wireframer.h:587
Wireframer * Renderer
Definition: Wireframer.h:571
void Swap(T &a, T &b)
Performs a swap operation. Safe to call from cuda code.
Definition: Swap.h:59
#define VTKM_IS_DEVICE_ADAPTER_TAG(tag)
Checks that the argument is a proper device adapter tag.
Definition: DeviceAdapterTag.h:194
vtkm::Id GetHeight() const
The height of the image.
Represent a continuous scalar range of values.
Definition: Range.h:31