diff --git a/src/libslic3r/Arachne/SkeletalTrapezoidation.cpp b/src/libslic3r/Arachne/SkeletalTrapezoidation.cpp index 04dede5469..b7e0ea61e9 100644 --- a/src/libslic3r/Arachne/SkeletalTrapezoidation.cpp +++ b/src/libslic3r/Arachne/SkeletalTrapezoidation.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include #include @@ -19,6 +18,7 @@ #include "Geometry/VoronoiVisualUtils.hpp" #include "Geometry/VoronoiUtilsCgal.hpp" #include "../EdgeGrid.hpp" +#include "ankerl/unordered_dense.h" #define SKELETAL_TRAPEZOIDATION_BEAD_SEARCH_MAX 1000 //A limit to how long it'll keep searching for adjacent beads. Increasing will re-use beadings more often (saving performance), but search longer for beading (costing performance). @@ -522,14 +522,14 @@ static bool has_missing_twin_edge(const SkeletalTrapezoidationGraph &graph) return false; } -inline static std::unordered_map try_to_fix_degenerated_voronoi_diagram_by_rotation( +inline static ankerl::unordered_dense::map try_to_fix_degenerated_voronoi_diagram_by_rotation( Geometry::VoronoiDiagram &voronoi_diagram, const Polygons &polys, Polygons &polys_rotated, std::vector &segments, const double fix_angle) { - std::unordered_map vertex_mapping; + ankerl::unordered_dense::map vertex_mapping; for (Polygon &poly : polys_rotated) poly.rotate(fix_angle); @@ -562,7 +562,7 @@ inline static std::unordered_map try_to_fix_degenerated inline static void rotate_back_skeletal_trapezoidation_graph_after_fix(SkeletalTrapezoidationGraph &graph, const double fix_angle, - const std::unordered_map &vertex_mapping) + const ankerl::unordered_dense::map &vertex_mapping) { for (STHalfEdgeNode &node : graph.nodes) { // If a mapping exists between a rotated point and an original point, use this mapping. Otherwise, rotate a point in the opposite direction. @@ -623,7 +623,7 @@ void SkeletalTrapezoidation::constructFromPolygons(const Polygons& polys) const bool is_voronoi_diagram_planar = Geometry::VoronoiUtilsCgal::is_voronoi_diagram_planar_angle(voronoi_diagram); const double fix_angle = PI / 6; - std::unordered_map vertex_mapping; + ankerl::unordered_dense::map vertex_mapping; // polys_copy is referenced through items stored in the std::vector segments. Polygons polys_copy = polys; if (has_missing_voronoi_vertex || !is_voronoi_diagram_planar) { @@ -751,7 +751,7 @@ process_voronoi_diagram: void SkeletalTrapezoidation::separatePointyQuadEndNodes() { - std::unordered_set visited_nodes; + ankerl::unordered_dense::set visited_nodes; for (edge_t& edge : graph.edges) { if (edge.prev) @@ -2221,7 +2221,7 @@ void SkeletalTrapezoidation::addToolpathSegment(const ExtrusionJunction& from, c void SkeletalTrapezoidation::connectJunctions(ptr_vector_t& edge_junctions) { - std::unordered_set unprocessed_quad_starts(graph.edges.size() * 5 / 2); + ankerl::unordered_dense::set unprocessed_quad_starts(graph.edges.size() * 5 / 2); for (edge_t& edge : graph.edges) { if (!edge.prev) @@ -2230,7 +2230,7 @@ void SkeletalTrapezoidation::connectJunctions(ptr_vector_t& edge_ } } - std::unordered_set passed_odd_edges; + ankerl::unordered_dense::set passed_odd_edges; while (!unprocessed_quad_starts.empty()) { diff --git a/src/libslic3r/Arachne/SkeletalTrapezoidation.hpp b/src/libslic3r/Arachne/SkeletalTrapezoidation.hpp index 819b71367b..225bf53861 100644 --- a/src/libslic3r/Arachne/SkeletalTrapezoidation.hpp +++ b/src/libslic3r/Arachne/SkeletalTrapezoidation.hpp @@ -7,7 +7,7 @@ #include #include // smart pointers -#include +#include #include // pair #include "utils/HalfEdgeGraph.hpp" @@ -163,8 +163,8 @@ protected: * mapping each voronoi VD edge to the corresponding halfedge HE edge * In case the result segment is discretized, we map the VD edge to the *last* HE edge */ - std::unordered_map vd_edge_to_he_edge; - std::unordered_map vd_node_to_he_node; + ankerl::unordered_dense::map vd_edge_to_he_edge; + ankerl::unordered_dense::map vd_node_to_he_node; node_t& makeNode(vd_t::vertex_type& vd_node, Point p); //!< Get the node which the VD node maps to, or create a new mapping if there wasn't any yet. /*! diff --git a/src/libslic3r/Arachne/SkeletalTrapezoidationGraph.cpp b/src/libslic3r/Arachne/SkeletalTrapezoidationGraph.cpp index 4ef96eda1a..e87bc4db7c 100644 --- a/src/libslic3r/Arachne/SkeletalTrapezoidationGraph.cpp +++ b/src/libslic3r/Arachne/SkeletalTrapezoidationGraph.cpp @@ -2,7 +2,8 @@ //CuraEngine is released under the terms of the AGPLv3 or higher. #include "SkeletalTrapezoidationGraph.hpp" -#include +#include + #include @@ -180,8 +181,8 @@ bool STHalfEdgeNode::isLocalMaximum(bool strict) const void SkeletalTrapezoidationGraph::collapseSmallEdges(coord_t snap_dist) { - std::unordered_map::iterator> edge_locator; - std::unordered_map::iterator> node_locator; + ankerl::unordered_dense::map::iterator> edge_locator; + ankerl::unordered_dense::map::iterator> node_locator; for (auto edge_it = edges.begin(); edge_it != edges.end(); ++edge_it) { diff --git a/src/libslic3r/Arachne/WallToolPaths.cpp b/src/libslic3r/Arachne/WallToolPaths.cpp index e46e64edca..a147e3f36d 100644 --- a/src/libslic3r/Arachne/WallToolPaths.cpp +++ b/src/libslic3r/Arachne/WallToolPaths.cpp @@ -782,10 +782,9 @@ bool WallToolPaths::removeEmptyToolPaths(std::vector &toolpa * * \param outer_to_inner Whether the wall polygons with a lower inset_idx should go before those with a higher one. */ -std::unordered_set, boost::hash>> WallToolPaths::getRegionOrder(const std::vector &input, const bool outer_to_inner) +WallToolPaths::ExtrusionLineSet WallToolPaths::getRegionOrder(const std::vector &input, const bool outer_to_inner) { - std::unordered_set, boost::hash>> order_requirements; - + ExtrusionLineSet order_requirements; // We build a grid where we map toolpath vertex locations to toolpaths, // so that we can easily find which two toolpaths are next to each other, // which is the requirement for there to be an order constraint. diff --git a/src/libslic3r/Arachne/WallToolPaths.hpp b/src/libslic3r/Arachne/WallToolPaths.hpp index 65a2271a34..02e780ff35 100644 --- a/src/libslic3r/Arachne/WallToolPaths.hpp +++ b/src/libslic3r/Arachne/WallToolPaths.hpp @@ -5,7 +5,7 @@ #define CURAENGINE_WALLTOOLPATHS_H #include -#include +#include #include "BeadingStrategy/BeadingStrategyFactory.hpp" #include "utils/ExtrusionLine.hpp" @@ -86,6 +86,8 @@ public: */ static bool removeEmptyToolPaths(std::vector &toolpaths); + using ExtrusionLineSet = ankerl::unordered_dense::set, boost::hash>>; + /*! * Get the order constraints of the insets when printing walls per region / hole. * Each returned pair consists of adjacent wall lines where the left has an inset_idx one lower than the right. @@ -94,7 +96,7 @@ public: * * \param outer_to_inner Whether the wall polygons with a lower inset_idx should go before those with a higher one. */ - static std::unordered_set, boost::hash>> getRegionOrder(const std::vector &input, bool outer_to_inner); + static ExtrusionLineSet getRegionOrder(const std::vector &input, bool outer_to_inner); protected: /*!