OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::GLCanvas3D::SequentialPrintClearance Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/GLCanvas3D.hpp>

Collaboration diagram for Slic3r::GUI::GLCanvas3D::SequentialPrintClearance:

Public Member Functions

void set_polygons (const Polygons &polygons, const std::vector< std::pair< Polygon, float > > &height_polygons)
void set_render_fill (bool render_fill)
void set_visible (bool visible)
void render ()

Private Attributes

GLModel m_height_limit
GLModel m_fill
GLModel m_perimeter
bool m_render_fill { true }
bool m_visible { false }
std::vector< Pointf3s > m_hull_2d_cache

Friends

class GLCanvas3D

Detailed Description

Member Function Documentation

◆ render()

void Slic3r::GUI::GLCanvas3D::SequentialPrintClearance::render ( )
1443{
1444 const ColorRGBA FILL_COLOR = { 0.7f, 0.7f, 1.0f, 0.5f };
1445 const ColorRGBA NO_FILL_COLOR = { 0.75f, 0.75f, 0.75f, 0.75f };
1446
1447 GLShaderProgram* shader = wxGetApp().get_shader("flat");
1448 if (shader == nullptr)
1449 return;
1450
1451 shader->start_using();
1452
1453 const Camera& camera = wxGetApp().plater()->get_camera();
1454 shader->set_uniform("view_model_matrix", camera.get_view_matrix());
1455 shader->set_uniform("projection_matrix", camera.get_projection_matrix());
1456
1461
1462 m_perimeter.set_color(m_render_fill ? FILL_COLOR : NO_FILL_COLOR);
1463 m_perimeter.render();
1464 m_fill.render();
1465 //BBS: add height limit
1466 m_height_limit.set_color(m_render_fill ? FILL_COLOR : NO_FILL_COLOR);
1467 m_height_limit.render();
1468
1472
1473 shader->stop_using();
1474}
#define glsafe(cmd)
Definition OpenGLUtils.hpp:25
GLModel m_height_limit
Definition GLCanvas3D.hpp:859
bool m_render_fill
Definition GLCanvas3D.hpp:862
GLModel m_fill
Definition GLCanvas3D.hpp:860
GLModel m_perimeter
Definition GLCanvas3D.hpp:861
Camera camera
Definition GLCanvas3D.hpp:794
#define glEnable
Definition gl.h:3667
#define GL_DEPTH_TEST
Definition gl.h:574
#define GL_SRC_ALPHA
Definition gl.h:1621
#define GL_CULL_FACE
Definition gl.h:500
#define GL_BLEND
Definition gl.h:275
#define GL_ONE_MINUS_SRC_ALPHA
Definition gl.h:1239
#define glDisable
Definition gl.h:3607
#define glBlendFunc
Definition gl.h:3325
@ Camera
Definition Shortcuts.hpp:72
const Transform3d & get_projection_matrix() const
Definition Camera.hpp:116
const Transform3d & get_view_matrix() const
Definition Camera.hpp:115

References Slic3r::GUI::GLCanvas3D::camera, GL_BLEND, GL_CULL_FACE, GL_DEPTH_TEST, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, glBlendFunc, glDisable, glEnable, glsafe, m_fill, m_height_limit, m_perimeter, m_render_fill, render(), Slic3r::GLShaderProgram::set_uniform(), Slic3r::GLShaderProgram::start_using(), and Slic3r::GLShaderProgram::stop_using().

Referenced by render().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_polygons()

void Slic3r::GUI::GLCanvas3D::SequentialPrintClearance::set_polygons ( const Polygons & polygons,
const std::vector< std::pair< Polygon, float > > & height_polygons )
1386{
1387 //BBS: add height limit logic
1388 m_height_limit.reset();
1389 m_perimeter.reset();
1390 m_fill.reset();
1391 if (!polygons.empty()) {
1392 if (m_render_fill) {
1393 GLModel::Geometry fill_data;
1395 fill_data.color = { 0.8f, 0.8f, 1.0f, 0.5f };
1396
1397 // vertices + indices
1398 const ExPolygons polygons_union = union_ex(polygons);
1399 unsigned int vertices_counter = 0;
1400 for (const ExPolygon& poly : polygons_union) {
1401 const std::vector<Vec3d> triangulation = triangulate_expolygon_3d(poly);
1402 fill_data.reserve_vertices(fill_data.vertices_count() + triangulation.size());
1403 fill_data.reserve_indices(fill_data.indices_count() + triangulation.size());
1404 for (const Vec3d& v : triangulation) {
1405 fill_data.add_vertex((Vec3f)(v.cast<float>() + 0.0125f * Vec3f::UnitZ())); // add a small positive z to avoid z-fighting
1406 ++vertices_counter;
1407 if (vertices_counter % 3 == 0)
1408 fill_data.add_triangle(vertices_counter - 3, vertices_counter - 2, vertices_counter - 1);
1409 }
1410 }
1411
1412 m_fill.init_from(std::move(fill_data));
1413 }
1414
1415 m_perimeter.init_from(polygons, 0.025f); // add a small positive z to avoid z-fighting
1416 }
1417
1418 //BBS: add the height limit compute logic
1419 if (!height_polygons.empty()) {
1420 GLModel::Geometry height_fill_data;
1422 height_fill_data.color = {0.8f, 0.8f, 1.0f, 0.5f};
1423
1424 // vertices + indices
1425 unsigned int vertices_counter = 0;
1426 for (const auto &poly : height_polygons) {
1427 ExPolygon ex_poly(poly.first);
1428 const std::vector<Vec3d> height_triangulation = triangulate_expolygon_3d(ex_poly);
1429 for (const Vec3d &v : height_triangulation) {
1430 Vec3f point{(float) v.x(), (float) v.y(), poly.second};
1431 height_fill_data.add_vertex(point);
1432 ++vertices_counter;
1433 if (vertices_counter % 3 == 0)
1434 height_fill_data.add_triangle(vertices_counter - 3, vertices_counter - 2, vertices_counter - 1);
1435 }
1436 }
1437
1438 m_height_limit.init_from(std::move(height_fill_data));
1439 }
1440}
void poly(std::vector< std::pair< Vec2d, Vec2d > > &out, std::initializer_list< Vec2d > p)
Definition DesignSketchTool.cpp:7751
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vec3d
Definition Point.hpp:68
std::vector< ExPolygon > ExPolygons
Definition ExPolygon.hpp:20
Eigen::Matrix< float, 3, 1, Eigen::DontAlign > Vec3f
Definition Point.hpp:65
std::vector< Vec3d > triangulate_expolygon_3d(const ExPolygon &poly, coordf_t z, bool flip)
Definition Tesselate.cpp:204
Slic3r::ExPolygons union_ex(const Slic3r::Polygons &subject, PolyFillType fill_type)
Definition ClipperUtils.cpp:1011

References Slic3r::GUI::GLModel::Geometry::add_triangle(), Slic3r::GUI::GLModel::Geometry::add_vertex(), Slic3r::GUI::GLModel::Geometry::color, Slic3r::GUI::GLModel::Geometry::format, Slic3r::GUI::GLModel::Geometry::indices_count(), m_fill, m_height_limit, m_perimeter, m_render_fill, Slic3r::GUI::GLModel::Geometry::P3, Slic3r::GUI::GLModel::Geometry::reserve_indices(), Slic3r::GUI::GLModel::Geometry::reserve_vertices(), set_polygons(), Slic3r::GUI::GLModel::Geometry::Triangles, Slic3r::triangulate_expolygon_3d(), Slic3r::union_ex(), and Slic3r::GUI::GLModel::Geometry::vertices_count().

Referenced by set_polygons().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_render_fill()

void Slic3r::GUI::GLCanvas3D::SequentialPrintClearance::set_render_fill ( bool render_fill)
inline
870{ m_render_fill = render_fill; }

References m_render_fill.

◆ set_visible()

void Slic3r::GUI::GLCanvas3D::SequentialPrintClearance::set_visible ( bool visible)
inline
871{ m_visible = visible; }
bool m_visible
Definition GLCanvas3D.hpp:863

References m_visible.

◆ GLCanvas3D

friend class GLCanvas3D
friend

References GLCanvas3D.

Referenced by GLCanvas3D.

Member Data Documentation

◆ m_fill

GLModel Slic3r::GUI::GLCanvas3D::SequentialPrintClearance::m_fill
private

Referenced by render(), and set_polygons().

◆ m_height_limit

GLModel Slic3r::GUI::GLCanvas3D::SequentialPrintClearance::m_height_limit
private

Referenced by render(), and set_polygons().

◆ m_hull_2d_cache

std::vector<Pointf3s> Slic3r::GUI::GLCanvas3D::SequentialPrintClearance::m_hull_2d_cache
private

◆ m_perimeter

GLModel Slic3r::GUI::GLCanvas3D::SequentialPrintClearance::m_perimeter
private

Referenced by render(), and set_polygons().

◆ m_render_fill

bool Slic3r::GUI::GLCanvas3D::SequentialPrintClearance::m_render_fill { true }
private
862{ true };

Referenced by render(), set_polygons(), and set_render_fill().

◆ m_visible

bool Slic3r::GUI::GLCanvas3D::SequentialPrintClearance::m_visible { false }
private
863{ false };

Referenced by set_visible().


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/GLCanvas3D.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/GLCanvas3D.cpp