EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
EBGeometry::Render::Renderer< T > Class Template Reference

Renders shapes into images. More...

#include <EBGeometry_Render.hpp>

Public Member Functions

 Renderer (const Settings< T > &a_settings=Settings< T >()) noexcept
 Renderer with given settings.
 
Settings< T > & settings () noexcept
 The settings.
 
const Settings< T > & settings () const noexcept
 The settings.
 
template<class S >
Stats render (const S &a_shape, const Camera< T > &a_camera, Image &a_image) const
 Render a shape on the host, on Settings::m_threads threads.
 
template<class S >
Stats render (const S &a_shape, const Camera< T > &a_camera, Image &a_image, const std::atomic< bool > &a_cancel, std::atomic< uint32_t > *a_rowsDone=nullptr) const
 Render a shape on the host, stopping early when asked to (for an interactive viewer).
 
template<class S >
Stats renderOnDevice (const S &a_deviceShape, const Camera< T > &a_camera, Image &a_image) const
 Render a shape through GPU::parallelFor(): in kernels in a CUDA or HIP build, in a host loop otherwise.
 
template<class S >
Stats renderOnDevice (const S &a_deviceShape, const Camera< T > &a_camera, Image &a_image, const std::atomic< bool > &a_cancel, std::atomic< uint32_t > *a_rowsDone=nullptr) const
 Render a shape through GPU::parallelFor(), stopping early when asked to.
 
template<class S >
HitT< T > pick (const S &a_shape, const Camera< T > &a_camera, T a_column, T a_row) const
 What the camera sees at a point of the image: the crossing of the ray through it with the shape, cut by the section plane as the render cuts it, so that it names what a render draws there.
 
template<class S >
std::vector< HitT< T > > pickAll (const S &a_shape, const Camera< T > &a_camera, T a_column, T a_row) const
 Every crossing of the shape under a point of the image, front to back, cut by the section plane as the render cuts it: what a viewer steps through to pick a surface behind others.
 

Static Public Attributes

static constexpr uint32_t MaxCrossings = 64
 The most crossings one ray follows: in pickAll(), and in the views that look past the first surface (ViewMode::XRay, see-through primitives, a filled part).
 

Detailed Description

template<class T>
class EBGeometry::Render::Renderer< T >

Renders shapes into images.

Holds the settings; the shape and camera are given to each render. Use render() for a shape the host can evaluate and renderOnDevice() for a device view of one (see Tape::rebasedView()).

Template Parameters
TFloating-point precision.

Constructor & Destructor Documentation

◆ Renderer()

template<class T >
EBGeometry::Render::Renderer< T >::Renderer ( const Settings< T > &  a_settings = Settings< T >())
explicitnoexcept

Renderer with given settings.

Parameters
[in]a_settingsSettings.

Member Function Documentation

◆ pick()

template<class T >
template<class S >
HitT< T > EBGeometry::Render::Renderer< T >::pick ( const S &  a_shape,
const Camera< T > &  a_camera,
T  a_column,
T  a_row 
) const
inline

What the camera sees at a point of the image: the crossing of the ray through it with the shape, cut by the section plane as the render cuts it, so that it names what a render draws there.

For picking in a viewer: HitT::m_primitive names the primitive (a tape's leaf, a mesh's face), and the point and normal where the ray meets it. The ray is the one through the point (a_column, a_row) of an image of the settings' size, with (0, 0) the top left corner of the top left pixel; a pixel's center is at half-integers. On the host.

Template Parameters
SShape type (see isShape).
Parameters
[in]a_shapeShape.
[in]a_cameraCamera.
[in]a_columnDistance from the image's left edge, in pixels.
[in]a_rowDistance from its top edge, in pixels.
Returns
The crossing, or a miss.

◆ pickAll()

template<class T >
template<class S >
std::vector< HitT< T > > EBGeometry::Render::Renderer< T >::pickAll ( const S &  a_shape,
const Camera< T > &  a_camera,
T  a_column,
T  a_row 
) const
inline

Every crossing of the shape under a point of the image, front to back, cut by the section plane as the render cuts it: what a viewer steps through to pick a surface behind others.

The ray is pick()'s; hidden primitives (Settings::m_hidden) are listed too. At most MaxCrossings crossings are listed. On the host.

Template Parameters
SShape type (see isShape).
Parameters
[in]a_shapeShape.
[in]a_cameraCamera.
[in]a_columnDistance from the image's left edge, in pixels.
[in]a_rowDistance from its top edge, in pixels.
Returns
The crossings, nearest first; empty where the ray meets nothing.

◆ render() [1/2]

template<class T >
template<class S >
Stats EBGeometry::Render::Renderer< T >::render ( const S &  a_shape,
const Camera< T > &  a_camera,
Image &  a_image 
) const
inline

Render a shape on the host, on Settings::m_threads threads.

Template Parameters
SShape type (see isShape).
Parameters
[in]a_shapeShape.
[in]a_cameraCamera.
[out]a_imageThe image, resized to the settings' size.
Returns
What the render saw.

◆ render() [2/2]

template<class T >
template<class S >
Stats EBGeometry::Render::Renderer< T >::render ( const S &  a_shape,
const Camera< T > &  a_camera,
Image &  a_image,
const std::atomic< bool > &  a_cancel,
std::atomic< uint32_t > *  a_rowsDone = nullptr 
) const
inline

Render a shape on the host, stopping early when asked to (for an interactive viewer).

As render(const S&, const Camera<T>&, Image&), but every thread checks a_cancel before each pixel, and the render returns as soon as the pixels being traced are done, with Stats::m_complete false and the pixels not reached left black. a_rowsDone, if given, counts the finished rows as they finish, so another thread can show the progress.

Template Parameters
SShape type (see isShape).
Parameters
[in]a_shapeShape.
[in]a_cameraCamera.
[out]a_imageThe image, resized to the settings' size.
[in]a_cancelSet (from another thread) to stop the render.
[out]a_rowsDoneFinished rows, or null.
Returns
What the render saw.

◆ renderOnDevice() [1/2]

template<class T >
template<class S >
Stats EBGeometry::Render::Renderer< T >::renderOnDevice ( const S &  a_deviceShape,
const Camera< T > &  a_camera,
Image &  a_image 
) const
inline

Render a shape through GPU::parallelFor(): in kernels in a CUDA or HIP build, in a host loop otherwise.

The image is rendered in one launch, into one buffer in device memory, which is copied back once at the end.

Template Parameters
SShape type (see isShape).
Parameters
[in]a_deviceShapeThe shape, as a view valid on the device.
[in]a_cameraCamera.
[out]a_imageThe image, resized to the settings' size.
Returns
What the render saw.

◆ renderOnDevice() [2/2]

template<class T >
template<class S >
Stats EBGeometry::Render::Renderer< T >::renderOnDevice ( const S &  a_deviceShape,
const Camera< T > &  a_camera,
Image &  a_image,
const std::atomic< bool > &  a_cancel,
std::atomic< uint32_t > *  a_rowsDone = nullptr 
) const
inline

Render a shape through GPU::parallelFor(), stopping early when asked to.

As renderOnDevice(const S&, const Camera<T>&, Image&), but the device's threads check a_cancel before each pixel, and the render returns soon after it is set, with Stats::m_complete false and the pixels not reached left black. a_rowsDone, if given, counts the rows as they finish, so another thread can show the progress (a row counts once its last pixel is done, possibly before some of its others). The flag reaches the device, and the count the host, through a thread the render starts, while the kernel runs.

Template Parameters
SShape type (see isShape).
Parameters
[in]a_deviceShapeThe shape, as a view valid on the device.
[in]a_cameraCamera.
[out]a_imageThe image, resized to the settings' size.
[in]a_cancelSet (from another thread) to stop the render.
[out]a_rowsDoneFinished rows, or null.
Returns
What the render saw.

◆ settings() [1/2]

template<class T >
const Settings< T > & EBGeometry::Render::Renderer< T >::settings ( ) const
inlinenoexcept

The settings.

Returns
The settings.

◆ settings() [2/2]

template<class T >
Settings< T > & EBGeometry::Render::Renderer< T >::settings ( )
inlinenoexcept

The settings.

Returns
The settings, to change.

The documentation for this class was generated from the following file: