27#ifndef EASY3D_RENDERER_RENDERER_H
28#define EASY3D_RENDERER_RENDERER_H
34#include <easy3d/core/types.h>
35#include <easy3d/core/point_cloud.h>
36#include <easy3d/core/surface_mesh.h>
159 const std::vector< std::shared_ptr<PointsDrawable> > &
points_drawables()
const {
return points_drawables_; }
164 const std::vector< std::shared_ptr<LinesDrawable> > &
lines_drawables()
const {
return lines_drawables_; }
169 const std::vector< std::shared_ptr<TrianglesDrawable> > &
triangles_drawables()
const {
return triangles_drawables_; }
181 template<
typename FT>
196 template<
typename FT>
211 template<
typename FT>
230 void create_default_drawables();
281 std::vector< std::shared_ptr<PointsDrawable> > points_drawables_;
282 std::vector< std::shared_ptr<LinesDrawable> > lines_drawables_;
283 std::vector< std::shared_ptr<TrianglesDrawable> > triangles_drawables_;
293#include <easy3d/core/random.h>
298 template<
typename FT>
inline
302 LOG(WARNING) <<
"model has no valid geometry";
307 LOG(WARNING) <<
"the surface mesh does not have face property \'" << segments.
name() <<
"\'";
311 LOG(WARNING) <<
"color property not allocated";
316 for (
auto f : mesh->faces())
317 max_index = std::max(max_index,
static_cast<int>(segments[f]));
320 std::vector<vec3> color_table(max_index + 1);
321 for (
auto &c : color_table)
324 for (
auto f : mesh->faces()) {
325 int idx =
static_cast<int>(segments[f]);
327 colors[f] =
vec3(0, 0, 0);
329 colors[f] = color_table[idx];
334 template<
typename FT>
inline
338 LOG(WARNING) <<
"model has no valid geometry";
343 LOG(WARNING) <<
"the surface mesh does not have vertex property \'" << segments.
name() <<
"\'";
347 LOG(WARNING) <<
"color property not allocated";
352 for (
auto v : mesh->vertices())
353 max_index = std::max(max_index,
static_cast<int>(segments[v]));
356 std::vector<vec3> color_table(max_index + 1);
357 for (
auto &c : color_table)
360 for (
auto v : mesh->vertices()) {
361 int idx =
static_cast<int>(segments[v]);
363 colors[v] =
vec3(0, 0, 0);
365 colors[v] = color_table[idx];
370 template<
typename FT>
inline
374 if (cloud->
empty()) {
375 LOG(WARNING) <<
"model has no valid geometry";
380 LOG(WARNING) <<
"the point cloud does not have vertex property \'" << segments.
name() <<
"\'";
384 LOG(WARNING) <<
"color property not allocated" <<
"\'";
390 max_index = std::max(max_index,
static_cast<int>(segments[v]));
393 std::vector<vec3> color_table(max_index + 1);
394 for (
auto &c : color_table)
398 int idx =
static_cast<int>(segments[v]);
400 colors[v] =
vec3(0, 0, 0);
402 colors[v] = color_table[idx];
A Graph data structure with easy property management.
Definition graph.h:50
The drawable for rendering a set of line segments, e.g., edges of a mesh, vector fields.
Definition drawable_lines.h:40
The base class of renderable 3D models.
Definition model.h:50
bool empty() const
Tests if the model is empty.
Definition model.h:84
Vertex property of type T.
Definition point_cloud.h:151
A data structure for point clouds.
Definition point_cloud.h:45
VertexContainer vertices() const
Returns vertex container for C++11 range-based for-loops.
Definition point_cloud.h:671
The drawable for rendering a set of points, e.g., point clouds, vertices of a mesh.
Definition drawable_points.h:42
const std::string & name() const
Returns the name of the property.
Definition property.h:436
const std::vector< std::shared_ptr< LinesDrawable > > & lines_drawables() const
Definition renderer.h:164
const std::vector< std::shared_ptr< TrianglesDrawable > > & triangles_drawables() const
Definition renderer.h:169
Model * model()
The model to which this renderer is attached.
Definition renderer.h:86
bool is_visible() const
Returns whether the model is currently visible.
Definition renderer.h:91
PointsDrawable * add_points_drawable(const std::string &name)
Definition renderer.cpp:362
LinesDrawable * add_lines_drawable(const std::string &name)
Definition renderer.cpp:376
TrianglesDrawable * add_triangles_drawable(const std::string &name)
Definition renderer.cpp:395
TrianglesDrawable * get_triangles_drawable(const std::string &name, bool warning_not_found=true) const
Definition renderer.cpp:352
LinesDrawable * get_lines_drawable(const std::string &name, bool warning_not_found=true) const
Definition renderer.cpp:342
Renderer(Model *model, bool create_drawables=true)
Constructor.
Definition renderer.cpp:41
void set_selected(bool b)
Select/Deselect the model. The state of all its drawables will change accordingly.
Definition renderer.cpp:311
PointsDrawable * get_points_drawable(const std::string &name, bool warning_not_found=true) const
Definition renderer.cpp:332
bool is_selected() const
Returns whether the model has been selected.
Definition renderer.h:97
void set_visible(bool b)
Shows/Hides the model.
Definition renderer.h:94
void update()
Invalidates the rendering buffers of the model and thus updates the rendering (delayed in rendering).
Definition renderer.cpp:322
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.
Definition renderer.h:299
const std::vector< std::shared_ptr< PointsDrawable > > & points_drawables() const
Definition renderer.h:159
Face property of type T.
Definition surface_mesh.h:363
Vertex property of type T.
Definition surface_mesh.h:255
A halfedge data structure for polygonal meshes of 2-manifold.
Definition surface_mesh.h:51
The drawable for rendering a set of triangles, e.g., the surface of a triangular mesh.
Definition drawable_triangles.h:46
Definition collider.cpp:182
Vec< 3, float > vec3
A 3D point/vector of float type.
Definition types.h:44
vec3 random_color(bool allow_dark=false)
Generates a random color. The parameter allow_dark controls if too dark colors are allowed.
Definition random.h:49