mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-17 02:22:17 +00:00
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:
@@ -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)
|
||||
|
||||
@@ -128,8 +128,10 @@ private:
|
||||
Transform3d m_grabber_trans_matrix;
|
||||
Slic3r::Geometry::Transformation position;
|
||||
std::vector<Vec3f> positions;
|
||||
ExPolygon m_print_polygon;
|
||||
PickingModel m_triangles;
|
||||
GLModel m_exclude_triangles;
|
||||
GLModel m_wrapping_detection_triangles;
|
||||
GLModel m_logo_triangles;
|
||||
GLModel m_gridlines;
|
||||
GLModel m_gridlines_bolder;
|
||||
@@ -172,6 +174,7 @@ private:
|
||||
void calc_bounding_boxes() const;
|
||||
void calc_triangles(const ExPolygon& poly);
|
||||
void calc_exclude_triangles(const ExPolygon& poly);
|
||||
void calc_triangles_from_polygon(const ExPolygon &poly, GLModel& render_model);
|
||||
void calc_gridlines(const ExPolygon& poly, const BoundingBox& pp_bbox);
|
||||
void calc_height_limit();
|
||||
void calc_vertex_for_number(int index, bool one_number, GLModel &buffer);
|
||||
@@ -184,6 +187,7 @@ private:
|
||||
void render_exclude_area(bool force_default_color);
|
||||
//void render_background_for_picking(const ColorRGBA render_color) const;
|
||||
void render_grid(bool bottom);
|
||||
void render_wrapping_detection_area(bool force_default_color);
|
||||
void render_height_limit(PartPlate::HeightLimitMode mode = HEIGHT_LIMIT_BOTH);
|
||||
// void render_label(GLCanvas3D& canvas) const;
|
||||
// void render_grabber(const ColorRGBA render_color, bool use_lighting) const;
|
||||
|
||||
@@ -4932,6 +4932,13 @@ std::map<std::string, std::string> Plater::get_bed_texture_maps()
|
||||
return {};
|
||||
}
|
||||
|
||||
bool Plater::get_enable_wrapping_detection()
|
||||
{
|
||||
const DynamicPrintConfig & printer_config = wxGetApp().preset_bundle->printers.get_edited_preset().config;
|
||||
const ConfigOptionBool * wrapping_detection = printer_config.option<ConfigOptionBool>("enable_wrapping_detection");
|
||||
return (wrapping_detection != nullptr) && wrapping_detection->value;
|
||||
}
|
||||
|
||||
wxColour Plater::get_next_color_for_filament()
|
||||
{
|
||||
static int curr_color_filamenet = 0;
|
||||
|
||||
@@ -357,6 +357,7 @@ public:
|
||||
|
||||
const VendorProfile::PrinterModel * get_curr_printer_model();
|
||||
std::map<std::string, std::string> get_bed_texture_maps();
|
||||
bool get_enable_wrapping_detection();
|
||||
|
||||
static wxColour get_next_color_for_filament();
|
||||
static wxString get_slice_warning_string(GCodeProcessorResult::SliceWarning& warning);
|
||||
|
||||
Reference in New Issue
Block a user