EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Public Member Functions | 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.
 

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.

◆ 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 row, and the render returns soon after it is set, with Stats::m_complete false and the rows 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 bands of rows, one launch each, 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&), with a_cancel checked between the bands: the render returns after the band under way when it is set, with Stats::m_complete false. a_rowsDone, if given, counts the finished rows.

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: