diff options
author | Vojtech Bubnik <bubnikv@gmail.com> | 2021-01-29 18:46:26 +0300 |
---|---|---|
committer | Vojtech Bubnik <bubnikv@gmail.com> | 2021-01-29 18:46:26 +0300 |
commit | ed9fa26b367d1ea4cd988373d09aab3f34833d90 (patch) | |
tree | 4f98d58033de9847801c25fcf02b942da8150c10 | |
parent | 89c251a5df5efaadc0b36a7711c79e4181ef107d (diff) |
WIP Perimeter genrator using the Voronoi offsetter: Some morevb_voronoi_offset
experiments
-rw-r--r-- | src/libslic3r/PerimeterGenerator.cpp | 24 | ||||
-rw-r--r-- | src/libslic3r/PrintObject.cpp | 9 |
2 files changed, 32 insertions, 1 deletions
diff --git a/src/libslic3r/PerimeterGenerator.cpp b/src/libslic3r/PerimeterGenerator.cpp index 633603640..94e199a87 100644 --- a/src/libslic3r/PerimeterGenerator.cpp +++ b/src/libslic3r/PerimeterGenerator.cpp @@ -467,7 +467,7 @@ void PerimeterGenerator::process() Lines lines = to_lines(expoly); boost::polygon::construct_voronoi(lines.begin(), lines.end(), &vd); Voronoi::annotate_inside_outside(vd, lines); - std::vector<Vec2d> skeleton_edges = Voronoi::skeleton_edges_rough(vd, lines, M_PI / 12.); // 30 degrees + std::vector<Vec2d> skeleton_edges = Voronoi::skeleton_edges_rough(vd, lines, 55. * M_PI / 180.); bool has_invalid_cell = std::find_if(vd.cells().begin(), vd.cells().end(), [](auto &cell){ return cell.incident_edge() == nullptr; }) != vd.cells().end(); #ifdef VORONOI_DEBUG_OUT if (has_invalid_cell) @@ -497,6 +497,28 @@ void PerimeterGenerator::process() ilines.emplace_back(edge(ie.first)); ilines.emplace_back(edge(ie.second)); } +#if 1 + if (! has_self_intersections) { + for (const auto &edge : vd.edges()) + if (&edge < edge.twin() && edge.is_finite()) { + const Vec2d &skeleton_pt = skeleton_edges[&edge - &vd.edges().front()]; + const Vec2d &skeleton_pt2 = skeleton_edges[edge.twin() - &vd.edges().front()]; + bool has_skeleton_pt = ! std::isnan(skeleton_pt.x()); + bool has_skeleton_pt2 = ! std::isnan(skeleton_pt2.x()); + const Vec2d &vertex_pt = Voronoi::vertex_point(edge.vertex0()); + const Vec2d &vertex_pt2 = Voronoi::vertex_point(edge.vertex1()); + if (has_skeleton_pt && has_skeleton_pt2) { + // Complete edge is part of the skeleton. + ilines.emplace_back(Line(Point(vertex_pt.x(), vertex_pt.y()), Point(vertex_pt2.x(), vertex_pt2.y()))); + } else { + if (has_skeleton_pt) + ilines.emplace_back(Line(Point(vertex_pt2.x(), vertex_pt2.y()), Point(skeleton_pt.x(), skeleton_pt.y()))); + if (has_skeleton_pt2) + ilines.emplace_back(Line(Point(vertex_pt.x(), vertex_pt.y()), Point(skeleton_pt2.x(), skeleton_pt2.y()))); + } + } + } +#endif dump_voronoi_to_svg(debug_out_path(has_self_intersections ? "perimeter-voronoi-bad-%d.svg" : "perimeter-voronoi-ok-%d.svg", irun).c_str(), vd, Points(), lines, offsets, ilines); #endif diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 543a45846..a6f8f6abf 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -1699,6 +1699,15 @@ void PrintObject::_slice(const std::vector<coordf_t> &layer_height_profile) m_typed_slices = false; +<<<<<<< Updated upstream +======= +#if 1 // #ifdef SLIC3R_PROFILE + // Disable parallelization so the Shiny profiler works + static tbb::task_scheduler_init *tbb_init = nullptr; + tbb_init = new tbb::task_scheduler_init(1); +#endif + +>>>>>>> Stashed changes // 1) Initialize layers and their slice heights. std::vector<float> slice_zs; { |