Easy3D 2.6.1
Loading...
Searching...
No Matches
Renderer Class Reference

A Renderer manages the drawables (and thus the rendering) of a model. More...

#include <easy3d/renderer/renderer.h>

Public Member Functions

 Renderer (Model *model, bool create_drawables=true)
 Constructor.
 
Modelmodel ()
 The model to which this renderer is attached.
 
bool is_visible () const
 Returns whether the model is currently visible.
 
void set_visible (bool b)
 Shows/Hides the model.
 
bool is_selected () const
 Returns whether the model has been selected.
 
void set_selected (bool b)
 Select/Deselect the model. The state of all its drawables will change accordingly.
 
void update ()
 Invalidates the rendering buffers of the model and thus updates the rendering (delayed in rendering).
 
PointsDrawableget_points_drawable (const std::string &name, bool warning_not_found=true) const
 
LinesDrawableget_lines_drawable (const std::string &name, bool warning_not_found=true) const
 
TrianglesDrawableget_triangles_drawable (const std::string &name, bool warning_not_found=true) const
 
PointsDrawableadd_points_drawable (const std::string &name)
 
LinesDrawableadd_lines_drawable (const std::string &name)
 
TrianglesDrawableadd_triangles_drawable (const std::string &name)
 
const std::vector< std::shared_ptr< PointsDrawable > > & points_drawables () const
 
const std::vector< std::shared_ptr< LinesDrawable > > & lines_drawables () const
 
const std::vector< std::shared_ptr< TrianglesDrawable > > & triangles_drawables () const
 

Static Public Member Functions

template<typename FT>
static void color_from_segmentation (SurfaceMesh *mesh, SurfaceMesh::FaceProperty< FT > segments, SurfaceMesh::FaceProperty< vec3 > colors)
 Generates random colors for visualizing face-based segmentation of a SurfaceMesh.
 
template<typename FT>
static void color_from_segmentation (SurfaceMesh *mesh, SurfaceMesh::VertexProperty< FT > segments, SurfaceMesh::VertexProperty< vec3 > colors)
 Generates random colors for visualizing vertex-based segmentation of a SurfaceMesh.
 
template<typename FT>
static void color_from_segmentation (PointCloud *cloud, PointCloud::VertexProperty< FT > segments, PointCloud::VertexProperty< vec3 > colors)
 Generates random colors for visualizing the segmentation of a PointCloud.
 

Detailed Description

A Renderer manages the drawables (and thus the rendering) of a model.

Renderer also allow to create default drawables for most rendering purposes.

See also
Drawable, PointsDrawable, LinesDrawable, TrianglesDrawable

The following code shows how to use renderer:

// create a renderer and attach it to the model
model->set_renderer(std::make_shared<Renderer>(model.get(), create));
Model * model()
The model to which this renderer is attached.
Definition renderer.h:86

Constructor & Destructor Documentation

◆ Renderer()

Renderer ( Model * model,
bool create_drawables = true )
explicit

Constructor.

Parameters
modelThe model to which this renderer is attached.
create_drawablestrue to create default drawables for this model. Skip the creation if false. The supported default drawables are
  • PointCloud: "vertices".
  • SurfaceMesh: "faces", "vertices", "edges", and "borders".
  • Graph: "vertices", and "edges".
  • PolyMesh: "faces:border" and "faces:interior". After the model has been changed or modified (in geometry, texture, color, etc.), client code can call update() for the rendering buffers of its default drawable to be automatically updated during the rendering stage. In case the default drawables don't meet a particular visualization purpose, client code should skip the creation of the default drawables (by passing false to create_drawables). Instead, create a customized drawable and update the buffers accordingly. If the drawable changes or will be modified frequently and its visualization is expected to be automatically updated after each change, provide an update function.
See also
update(),

Member Function Documentation

◆ add_lines_drawable()

LinesDrawable * add_lines_drawable ( const std::string & name)

Create a new lines drawable and add it to this renderer.

Parameters
nameThe name of the lines drawable to be created.
Returns
The created lines drawable. If a lines drawable with 'name' already exists, the creation will be ignored and the existing drawable is returned.

◆ add_points_drawable()

PointsDrawable * add_points_drawable ( const std::string & name)

Create a new points drawable and add it to this renderer.

Parameters
nameThe name of the points drawable to be created.
Returns
The created points drawable. If a points drawable with 'name' already exists, the creation will be ignored and the existing drawable is returned.

◆ add_triangles_drawable()

TrianglesDrawable * add_triangles_drawable ( const std::string & name)

Create a new triangles drawable and add it to this renderer.

Parameters
nameThe name of the triangles drawable to be created.
Returns
The created triangles drawable. If a triangles drawable with 'name' already exists, the creation will be ignored and the existing drawable is returned.

◆ color_from_segmentation() [1/3]

template<typename FT>
void color_from_segmentation ( PointCloud * cloud,
PointCloud::VertexProperty< FT > segments,
PointCloud::VertexProperty< vec3 > colors )
inlinestatic

Generates random colors for visualizing the segmentation of a PointCloud.

Parameters
cloudThe point cloud.
segmentsThe vertex property storing the segmentation of the point cloud.
Attention
The face property segments must have a type of int, {unsigned int}, std::size_t, bool, or {unsigned char}. Besides, any negative values are treated as out of range.
Parameters
colorsThe vertex property to store the colors. Must be allocated before hand.

◆ color_from_segmentation() [2/3]

template<typename FT>
void color_from_segmentation ( SurfaceMesh * mesh,
SurfaceMesh::FaceProperty< FT > segments,
SurfaceMesh::FaceProperty< vec3 > colors )
inlinestatic

Generates random colors for visualizing face-based segmentation of a SurfaceMesh.

Parameters
meshThe surface mesh.
segmentsThe face property storing the segmentation of the surface mesh.
colorsThe face property to store the colors. Must be allocated before hand.
Attention
The face property segments must have a type of int, {unsigned int}, std::size_t, bool, or {unsigned char}. Besides, any negative values are treated as out of range.

◆ color_from_segmentation() [3/3]

template<typename FT>
void color_from_segmentation ( SurfaceMesh * mesh,
SurfaceMesh::VertexProperty< FT > segments,
SurfaceMesh::VertexProperty< vec3 > colors )
inlinestatic

Generates random colors for visualizing vertex-based segmentation of a SurfaceMesh.

Parameters
meshThe surface mesh.
segmentsThe vertex property storing the segmentation of the surface mesh.
colorsThe vertex property to store the colors. Must be allocated before hand.
Attention
The face property segments must have a type of int, {unsigned int}, std::size_t, bool, or {unsigned char}. Besides, any negative values are treated as out of range.

◆ get_lines_drawable()

LinesDrawable * get_lines_drawable ( const std::string & name,
bool warning_not_found = true ) const

Get the lines drawable with a given name. Return nullptr if the drawable does not exist.

Examples
Tutorial_203_Viewer_wxWidgets/main.cpp.

◆ get_points_drawable()

PointsDrawable * get_points_drawable ( const std::string & name,
bool warning_not_found = true ) const

Get the points drawable with a given name. Return nullptr if the drawable does not exist.

Examples
Tutorial_203_Viewer_wxWidgets/main.cpp, and Tutorial_403_PointSelection/main.cpp.

◆ get_triangles_drawable()

TrianglesDrawable * get_triangles_drawable ( const std::string & name,
bool warning_not_found = true ) const

Get the triangles drawable with a given name. Return nullptr if the drawable does not exist.

◆ lines_drawables()

const std::vector< std::shared_ptr< LinesDrawable > > & lines_drawables ( ) const
inline

All available lines drawables managed by this renderer.

◆ points_drawables()

const std::vector< std::shared_ptr< PointsDrawable > > & points_drawables ( ) const
inline

All available points drawables managed by this renderer.

◆ triangles_drawables()

const std::vector< std::shared_ptr< TrianglesDrawable > > & triangles_drawables ( ) const
inline

All available triangles drawables managed by this renderer.

Examples
Tutorial_203_Viewer_wxWidgets/main.cpp.

◆ update()

void update ( )

Invalidates the rendering buffers of the model and thus updates the rendering (delayed in rendering).

This method triggers an update of the rendering buffers of all the drawables of the model to which this renderer is attached. The effect is equivalent to calling Drawable::update() functions for all the drawables of this model. todo: for better performance, it is wise to update only the affected drawables and buffers.

See also
Drawable::update()
Examples
Tutorial_312_MultiThread/main.cpp.

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