Go to the documentation of this file.
19 #ifndef viskores_rendering_Wireframer_h
20 #define viskores_rendering_Wireframer_h
65 return 1.0f - FractionalPart(x);
84 return PackColor(color[0], color[1], color[2], color[3]);
94 packed |= (ScaleColorComponent(g) << 16);
95 packed |= (ScaleColorComponent(b) << 8);
96 packed |= ScaleColorComponent(a);
110 UnpackColor(packedColor, color[0], color[1], color[2], color[3]);
143 using ControlSignature = void(FieldIn, FieldIn, FieldOut);
144 using ExecutionSignature = void(_1, _2, _3);
147 CopyIntoFrameBuffer() {}
155 packed.Ints.Color = PackColor(color);
156 packed.Floats.Depth = depth;
157 outValue = packed.Raw;
161 template <
typename DeviceTag>
168 using ControlSignature = void(FieldIn, WholeArrayIn, WholeArrayIn);
169 using ExecutionSignature = void(_1, _2, _3);
170 using InputDomain = _1;
182 const ColorMapHandle& colorMap,
183 const AtomicPackedFrameBuffer& frameBuffer,
194 ,
ColorMap(colorMap.PrepareForInput(DeviceTag(), token))
196 ,
FrameBuffer(frameBuffer.PrepareForExecution(DeviceTag(), token))
200 if (fieldLength == 0.f)
212 template <
typename CoordinatesPortalType,
typename ScalarFieldPortalType>
214 const CoordinatesPortalType& coordsPortal,
215 const ScalarFieldPortalType& fieldPortal)
const
223 TransformWorldToViewport(point1);
224 TransformWorldToViewport(point2);
235 bool transposed = viskores::Abs(y2 - y1) > viskores::Abs(x2 - x1);
253 dx = viskores::Epsilon32();
264 point2Field = fieldPortal.Get(point2Idx);
269 point2Field = point1Field;
276 Plot(yPxl1, xPxl1, zPxl1, color, 1.0f);
280 Plot(xPxl1, yPxl1, zPxl1, color, 1.0f);
285 yEnd = y2 + gradient * (xEnd - x2);
290 color = GetColor(point2Field);
293 Plot(yPxl2, xPxl2, zPxl2, color, 1.0f);
297 Plot(xPxl2, yPxl2, zPxl2, color, 1.0f);
309 color = GetColor(fieldValue);
310 Plot(t, x, depth, color, ReverseFractionalPart(interY));
311 Plot(t + 1, x, depth, color, FractionalPart(interY));
323 color = GetColor(fieldValue);
324 Plot(x, t, depth, color, ReverseFractionalPart(interY));
325 Plot(x, t + 1, depth, color, FractionalPart(interY));
332 using ColorMapPortalConst =
typename ColorMapHandle::ReadPortalType;
341 point[i] = temp[i] / temp[3];
349 point[2] = point[2] * 0.5f + 0.5f;
361 viskores::Max(0, colorIdx));
362 return this->
ColorMap.Get(colorIdx);
373 if (xi < 0 || xi >=
Width || yi < 0 || yi >=
Height)
378 PackedValue current, next;
379 current.Raw = ClearValue;
380 next.Floats.Depth = depth;
385 UnpackColor(current.Ints.Color, srcColor);
388 blendedColor[0] = color[0] * intensity + srcColor[0] * alpha;
389 blendedColor[1] = color[1] * intensity + srcColor[1] * alpha;
390 blendedColor[2] = color[2] * intensity + srcColor[2] * alpha;
391 blendedColor[3] = alpha + intensity;
392 next.Ints.Color = PackColor(blendedColor);
394 }
while (current.Floats.Depth > next.Floats.Depth);
419 using ControlSignature = void(FieldIn, WholeArrayOut, WholeArrayOut);
420 using ExecutionSignature = void(_1, _2, _3, WorkIndex);
422 template <
typename DepthBufferPortalType,
typename ColorBufferPortalType>
424 DepthBufferPortalType& depthBuffer,
425 ColorBufferPortalType& colorBuffer,
429 packed.Raw = packedValue;
430 float depth = packed.Floats.Depth;
431 if (depth <= depthBuffer.Get(index))
434 UnpackColor(packed.Ints.Color, color);
435 colorBuffer.Set(index, color);
436 depthBuffer.Set(index, depth);
468 const IndicesHandle& endPointIndices,
487 template <
typename DeviceTag>
502 modelMatrix[2][3] = offset;
520 CopyIntoFrameBuffer bufferCopy;
552 if (!isSupportedField)
574 plotterDispatcher.SetDevice(DeviceTag());
577 viskores::rendering::raytracing::GetScalarFieldArray(
ScalarField));
580 BufferConverter converter;
582 converterDispatcher.SetDevice(DeviceTag());
596 template <
typename DeviceTag>
621 #endif //viskores_rendering_Wireframer_h
bool CompareExchange(viskores::Id index, ValueType *oldValue, const ValueType &newValue, viskores::MemoryOrder order=viskores::MemoryOrder::SequentiallyConsistent) const
Perform an atomic compare and exchange operation with sequentially consistent memory ordering.
Definition: AtomicArrayExecutionObject.h:250
viskores::Range ScalarFieldRange
Definition: Wireframer.h:614
viskores::rendering::Camera::Mode GetMode() const
The mode of the camera (2D or 3D).
Definition: Camera.h:151
viskores::rendering::Camera Camera
Definition: Wireframer.h:606
const ColorBufferType & GetColorBuffer() const
Get the color channels of the image.
bool ShowInternalZones
Definition: Wireframer.h:608
Wireframer * Renderer
Definition: Wireframer.h:589
AtomicPackedFrameBufferHandle FrameBuffer
Definition: Wireframer.h:407
viskores::Float32 Offset
Definition: Wireframer.h:410
void RenderWithDevice(DeviceTag)
Definition: Wireframer.h:488
viskores::Float64 Length() const
Returns the length of the range.
Definition: Range.h:99
Represent an axis-aligned 3D bounds in space.
Definition: Bounds.h:37
const DepthBufferType & GetDepthBuffer() const
Get the depth channel of the image.
Definition: Wireframer.h:443
viskores::Id GetHeight() const
The height of the image.
viskores::Bounds GetBounds() const
Definition: CoordinateSystem.h:137
viskores::Float64 Min
The minumum value of the range (inclusive).
Definition: Range.h:42
bool operator()(DeviceTag)
Definition: Wireframer.h:597
viskores::rendering::Canvas * Canvas
Definition: Wireframer.h:607
viskores::Float32 Color
Definition: Wireframer.h:130
viskores::Bounds Bounds
Definition: Wireframer.h:605
viskores::Id SubsetHeight
Definition: Wireframer.h:401
viskores::Id XOffset
Definition: Wireframer.h:402
viskores::Float32 Depth
Definition: Wireframer.h:131
viskores::cont::ArrayHandle< viskores::Float32 > SolidDepthBuffer
Definition: Wireframer.h:615
viskores::Id SubsetWidth
Definition: Wireframer.h:400
Manages an array-worth of data.
Definition: ArrayHandle.h:313
Manages a coordinate system for a DataSet.
Definition: CoordinateSystem.h:38
ColorMapHandle ColorMap
Definition: Wireframer.h:610
void SetData(const viskores::cont::CoordinateSystem &coords, const IndicesHandle &endPointIndices, const viskores::cont::Field &field, const viskores::Range &fieldRange)
Definition: Wireframer.h:467
void SetSolidDepthBuffer(const viskores::cont::ArrayHandle< viskores::Float32 > depthBuffer)
Definition: Wireframer.h:461
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
A type list containing types that can be used with an AtomicArray.
Definition: AtomicArray.h:61
#define VISKORES_EXEC_CONT
Definition: ExportMacros.h:60
void GetRealViewport(viskores::Id screenWidth, viskores::Id screenHeight, viskores::Float32 &left, viskores::Float32 &right, viskores::Float32 &bottom, viskores::Float32 &top) const
viskores::Float32 Round(viskores::Float32 x)
Definition: Math.h:2299
bool IsPointField() const
Return true if this field is associated with points.
Definition: Field.h:127
viskores::Float64 Max
Tha maximum value of the range (inclusive).
Definition: Range.h:44
viskores::Id GetWidth() const
The width of the image.
signed long long Int64
Base type to use for 64-bit signed integer numbers.
Definition: Types.h:212
static bool Copy(viskores::cont::DeviceAdapterId devId, const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< U, COut > &output)
Definition: Algorithm.h:422
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
bool AssocPoints
Definition: Wireframer.h:404
#define VISKORES_CONT
Definition: ExportMacros.h:65
Groups connected points that have the same field value.
Definition: Atomic.h:27
bool TryExecute(Functor &&functor, Args &&... args)
Try to execute a functor on a set of devices until one succeeds.
Definition: TryExecute.h:252
Dispatcher for worklets that inherit from WorkletMapField.
Definition: DispatcherMapField.h:33
float Float32
Base type to use for 32-bit floating-point numbers.
Definition: Types.h:165
viskores::Id Width
Definition: Wireframer.h:398
bool IsOverlay
Definition: Wireframer.h:609
An array handle with a constant value.
Definition: ArrayHandleConstant.h:78
viskores::cont::CoordinateSystem Coordinates
Definition: Wireframer.h:611
viskores::Id Height
Definition: Wireframer.h:399
viskores::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:482
viskores::Float32 InverseFieldDelta
Definition: Wireframer.h:409
#define VISKORES_ASSERT(condition)
Definition: Assert.h:51
PackedFrameBufferHandle FrameBuffer
Definition: Wireframer.h:616
viskores::Id YOffset
Definition: Wireframer.h:403
viskores::Matrix< T, Size, Size > MatrixIdentity()
Returns the identity matrix.
Definition: Matrix.h:221
struct viskores::rendering::@572::PackedValue::PackedInts Ints
void Swap(T &a, T &b)
Performs a swap operation. Safe to call from cuda code.
Definition: Swap.h:71
RenderWithDeviceFunctor(Wireframer *renderer)
Definition: Wireframer.h:591
viskores::Int64 Raw
Definition: Wireframer.h:138
IndicesHandle PointIndices
Definition: Wireframer.h:612
Represent a continuous scalar range of values.
Definition: Range.h:39
int32_t Int32
Base type to use for 32-bit signed integer numbers.
Definition: Types.h:189
viskores::Float32 FieldMin
Definition: Wireframer.h:408
viskores::cont::Field ScalarField
Definition: Wireframer.h:613
Specifies the viewport for a rendering.
Definition: Camera.h:45
struct viskores::rendering::@572::PackedValue::PackedFloats Floats
Definition: Wireframer.h:587
ValueType Lerp(const ValueType &value0, const ValueType &value1, const WeightType &weight)
Returns the linear interpolation of two values based on weight.
Definition: VectorAnalysis.h:40
This class is thrown when a Viskores function or method encounters an invalid value that inhibits pro...
Definition: ErrorBadValue.h:33
void Render()
Definition: Wireframer.h:480
viskores::Matrix< viskores::Float32, 4, 4 > WorldToProjection
Definition: Wireframer.h:397
viskores::Float32 ColorMapSize
Definition: Wireframer.h:406
Wireframer(viskores::rendering::Canvas *canvas, bool showInternalZones, bool isOverlay)
Definition: Wireframer.h:447
An object passed to a worklet when accessing an atomic array.
Definition: AtomicArrayExecutionObject.h:96
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:47
viskores::Float32 Floor(viskores::Float32 x)
Definition: Math.h:2238
viskores::Matrix< viskores::Float32, 4, 4 > CreateViewMatrix() const
#define VISKORES_IS_DEVICE_ADAPTER_TAG(tag)
Checks that the argument is a proper device adapter tag.
Definition: DeviceAdapterTag.h:208
viskores::Matrix< T, NumRow, NumCol > MatrixMultiply(const viskores::Matrix< T, NumRow, NumInternal > &leftFactor, const viskores::Matrix< T, NumInternal, NumCol > &rightFactor)
Standard matrix multiplication.
Definition: Matrix.h:168
viskores::Matrix< viskores::Float32, 4, 4 > CreateProjectionMatrix(viskores::Id screenWidth, viskores::Id screenHeight) const
double Float64
Base type to use for 64-bit floating-point numbers.
Definition: Types.h:169
viskores::Range GetClippingRange() const
The clipping range of the camera.
Definition: Camera.h:176
bool IsCellField() const
Return true if this field is associated with cells.
Definition: Field.h:125
A Field encapsulates an array on some piece of the mesh, such as the points, a cell set,...
Definition: Field.h:39
void SetColorMap(const ColorMapHandle &colorMap)
Definition: Wireframer.h:458
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:43
uint32_t UInt32
Base type to use for 32-bit unsigned integer numbers.
Definition: Types.h:193
#define VISKORES_EXEC
Definition: ExportMacros.h:59
ColorMapPortalConst ColorMap
Definition: Wireframer.h:405
Represents the image space that is the target of rendering.
Definition: Canvas.h:43
void SetCamera(const viskores::rendering::Camera &camera)
Definition: Wireframer.h:455