From 5f37d422f069edef5302dd1c241c8dd2e3158a0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Wed, 31 Jan 2024 17:40:09 +0100 Subject: [PATCH] Switch orientation of passed into Voronoi generator, because previously were opposite. So previously, SOURCE_CATEGORY_SEGMENT_START_POINT and SOURCE_CATEGORY_SEGMENT_END_POINT were swapped. --- .../Arachne/SkeletalTrapezoidation.cpp | 19 ------------------- .../Arachne/utils/PolygonsSegmentIndex.hpp | 19 +++++++++++++++++++ src/libslic3r/Arachne/utils/VoronoiUtils.cpp | 10 ++++------ 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/libslic3r/Arachne/SkeletalTrapezoidation.cpp b/src/libslic3r/Arachne/SkeletalTrapezoidation.cpp index 26d2dbeee3..2be3ef1949 100644 --- a/src/libslic3r/Arachne/SkeletalTrapezoidation.cpp +++ b/src/libslic3r/Arachne/SkeletalTrapezoidation.cpp @@ -21,25 +21,6 @@ #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). -namespace boost::polygon { - -template<> struct geometry_concept -{ - typedef segment_concept type; -}; - -template<> struct segment_traits -{ - typedef coord_t coordinate_type; - typedef Slic3r::Point point_type; - static inline point_type get(const Slic3r::Arachne::PolygonsSegmentIndex &CSegment, direction_1d dir) - { - return dir.to_int() ? CSegment.p() : CSegment.next().p(); - } -}; - -} // namespace boost::polygon - namespace Slic3r::Arachne { diff --git a/src/libslic3r/Arachne/utils/PolygonsSegmentIndex.hpp b/src/libslic3r/Arachne/utils/PolygonsSegmentIndex.hpp index 6eff3d62ee..3258b41c7d 100644 --- a/src/libslic3r/Arachne/utils/PolygonsSegmentIndex.hpp +++ b/src/libslic3r/Arachne/utils/PolygonsSegmentIndex.hpp @@ -27,5 +27,24 @@ public: } // namespace Slic3r::Arachne +namespace boost::polygon { + +template<> struct geometry_concept +{ + typedef segment_concept type; +}; + +template<> struct segment_traits +{ + typedef coord_t coordinate_type; + typedef Slic3r::Point point_type; + + static inline point_type get(const Slic3r::Arachne::PolygonsSegmentIndex &CSegment, direction_1d dir) + { + return dir.to_int() ? CSegment.to() : CSegment.from(); + } +}; + +} // namespace boost::polygon #endif//UTILS_POLYGONS_SEGMENT_INDEX_H diff --git a/src/libslic3r/Arachne/utils/VoronoiUtils.cpp b/src/libslic3r/Arachne/utils/VoronoiUtils.cpp index 675a0ebb42..033657e5a8 100644 --- a/src/libslic3r/Arachne/utils/VoronoiUtils.cpp +++ b/src/libslic3r/Arachne/utils/VoronoiUtils.cpp @@ -34,11 +34,11 @@ Point VoronoiUtils::getSourcePoint(const vd_t::cell_type& cell, const std::vecto break; case boost::polygon::SOURCE_CATEGORY_SEGMENT_START_POINT: assert(cell.source_index() < segments.size()); - return segments[cell.source_index()].to(); + return boost::polygon::segment_traits::get(segments[cell.source_index()], boost::polygon::LOW); break; case boost::polygon::SOURCE_CATEGORY_SEGMENT_END_POINT: assert(cell.source_index() < segments.size()); - return segments[cell.source_index()].from(); + return boost::polygon::segment_traits::get(segments[cell.source_index()], boost::polygon::HIGH); break; default: assert(false && "getSourcePoint should only be called on point cells!\n"); @@ -60,14 +60,12 @@ PolygonsPointIndex VoronoiUtils::getSourcePointIndex(const vd_t::cell_type& cell switch (cell.source_category()) { case boost::polygon::SOURCE_CATEGORY_SEGMENT_START_POINT: { assert(cell.source_index() < segments.size()); - PolygonsPointIndex ret = segments[cell.source_index()]; - ++ret; - return ret; + return segments[cell.source_index()]; break; } case boost::polygon::SOURCE_CATEGORY_SEGMENT_END_POINT: { assert(cell.source_index() < segments.size()); - return segments[cell.source_index()]; + return segments[cell.source_index()].next(); break; } default: