NEW:render wrapping_detection_triangles

jira: none
Change-Id: Ifdbd1ae8c3906abd235177f68fe0444bbcecb8ba
(cherry picked from commit d7df1b8a9c172731cdfb42371153f8781c268aad)
(cherry picked from commit 1277955c5f8e81f01c07408debc1338acac667cb)
(cherry picked from commit c09de4cff5dcae942e91feae3fafb097e33563b7)
This commit is contained in:
zhou.xu
2025-07-24 10:00:02 +08:00
committed by Noisyfox
parent 30bce5df45
commit 637a86b738
4 changed files with 50 additions and 1 deletions

View File

@@ -451,6 +451,17 @@ void PartPlate::calc_exclude_triangles(const ExPolygon &poly)
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ":Unable to create exclude triangles\n";
}
void PartPlate::calc_triangles_from_polygon(const ExPolygon &poly, GLModel &render_model){
if (poly.empty()) {
render_model.reset();
return;
}
render_model.reset();
if (!init_model_from_poly(render_model, poly, GROUND_Z)) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "calc_triangles_from_polygon fail";
}
}
static bool init_model_from_lines(GLModel &model, const Lines &lines, float z)
{
@@ -901,6 +912,15 @@ void PartPlate::render_logo(bool bottom, bool render_cali)
}
}
void PartPlate::render_wrapping_detection_area(bool force_default_color)
{
if (force_default_color || !m_wrapping_detection_triangles.is_initialized())
return;
ColorRGBA select_color{0.765f, 0.7686f, 0.7686f, 1.0f};
m_wrapping_detection_triangles.set_color(select_color);
m_wrapping_detection_triangles.render();
}
void PartPlate::render_exclude_area(bool force_default_color) {
if (force_default_color) //for thumbnail case
return;
@@ -924,7 +944,6 @@ void PartPlate::render_exclude_area(bool force_default_color) {
glsafe(::glDepthMask(GL_TRUE));
}
/*void PartPlate::render_background_for_picking(const ColorRGBA render_color) const
{
unsigned int triangles_vcount = m_triangles.get_vertices_count();
@@ -2955,6 +2974,7 @@ bool PartPlate::set_shape(const Pointfs& shape, const Pointfs& exclude_areas, co
poly.contour.append({ scale_(p(0)), scale_(p(1)) });
}*/
generate_print_polygon(poly);
m_print_polygon = poly;
calc_triangles(poly);
init_raycaster_from_model(m_triangles);
@@ -3072,6 +3092,23 @@ void PartPlate::render(const Transform3d& view_matrix, const Transform3d& projec
render_background(force_background_color);
render_exclude_area(force_background_color);
if(wxGetApp().plater()->get_enable_wrapping_detection()){
if(!m_wrapping_detection_triangles.is_initialized()){
auto points = get_plate_wrapping_detection_area();
if (points.size() > 0) {//wrapping_detection_area
ExPolygon temp_poly;
for (const Vec2d &p : points) {
temp_poly.contour.append({scale_(p(0)), scale_(p(1))});
}
auto result = intersection(m_print_polygon, temp_poly);
if (result.size() > 0) {
ExPolygon wrapp_poly(result[0]);
calc_triangles_from_polygon(wrapp_poly, m_wrapping_detection_triangles);
}
}
}
render_wrapping_detection_area(force_background_color);
}
}
if (show_grid)