From 7449c7419a2e945e8d149acdd19a937e60ae5ef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 9 Feb 2023 23:28:52 +0100 Subject: [PATCH] Do not needless lose precision in outer frame computations --- .../include/CGAL/create_offset_polygons_2.h | 13 ++++++------- .../include/CGAL/create_straight_skeleton_2.h | 13 ++++++------- .../CGAL/create_weighted_straight_skeleton_2.h | 13 +++++++------ 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h b/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h index 39ee6bec9cc..20c5c85ab42 100644 --- a/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h +++ b/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h @@ -166,16 +166,15 @@ create_partial_exterior_straight_skeleton_2 ( FT const& aMaxOffset if ( margin ) { - double lm = CGAL::to_double(*margin); - Bbox_2 bbox = bbox_2(aVerticesBegin, aVerticesEnd); + const IFT lm = *margin; + const Bbox_2 bbox = bbox_2(aVerticesBegin, aVerticesEnd); - FT fxmin = bbox.xmin() - lm ; - FT fxmax = bbox.xmax() + lm ; - FT fymin = bbox.ymin() - lm ; - FT fymax = bbox.ymax() + lm ; + const IFT fxmin = IFT(bbox.xmin()) - lm ; + const IFT fxmax = IFT(bbox.xmax()) + lm ; + const IFT fymin = IFT(bbox.ymin()) - lm ; + const IFT fymax = IFT(bbox.ymax()) + lm ; Point_2 frame[4] ; - frame[0] = Point_2(fxmin,fymin) ; frame[1] = Point_2(fxmax,fymin) ; frame[2] = Point_2(fxmax,fymax) ; diff --git a/Straight_skeleton_2/include/CGAL/create_straight_skeleton_2.h b/Straight_skeleton_2/include/CGAL/create_straight_skeleton_2.h index c61300b38dd..ab985800ffa 100644 --- a/Straight_skeleton_2/include/CGAL/create_straight_skeleton_2.h +++ b/Straight_skeleton_2/include/CGAL/create_straight_skeleton_2.h @@ -165,16 +165,15 @@ create_exterior_straight_skeleton_2 ( FT const& aMaxOffset if ( margin ) { - const double lm = CGAL::to_double(*margin); - Bbox_2 bbox = bbox_2(aVerticesBegin, aVerticesEnd); + const IFT lm = *margin; + const Bbox_2 bbox = bbox_2(aVerticesBegin, aVerticesEnd); - FT fxmin = bbox.xmin() - lm ; - FT fxmax = bbox.xmax() + lm ; - FT fymin = bbox.ymin() - lm ; - FT fymax = bbox.ymax() + lm ; + const IFT fxmin = IFT(bbox.xmin()) - lm ; + const IFT fxmax = IFT(bbox.xmax()) + lm ; + const IFT fymin = IFT(bbox.ymin()) - lm ; + const IFT fymax = IFT(bbox.ymax()) + lm ; Point_2 frame[4] ; - frame[0] = Point_2(fxmin,fymin) ; frame[1] = Point_2(fxmax,fymin) ; frame[2] = Point_2(fxmax,fymax) ; diff --git a/Straight_skeleton_2/include/CGAL/create_weighted_straight_skeleton_2.h b/Straight_skeleton_2/include/CGAL/create_weighted_straight_skeleton_2.h index 80f8d7777c2..cf0cff8129f 100644 --- a/Straight_skeleton_2/include/CGAL/create_weighted_straight_skeleton_2.h +++ b/Straight_skeleton_2/include/CGAL/create_weighted_straight_skeleton_2.h @@ -182,17 +182,18 @@ create_exterior_weighted_straight_skeleton_2(const FT& max_offset, // converter stuff that is done in `create_partial_exterior_straight_skeleton_2`?). boost::optional margin = compute_outer_frame_margin(vertices_begin, vertices_end, + weights[0], offset); if(margin) { - const double lm = CGAL::to_double(*margin); - Bbox_2 bbox = bbox_2(vertices_begin, vertices_end); + const IFT lm = *margin; + const Bbox_2 bbox = bbox_2(vertices_begin, vertices_end); - FT fxmin = bbox.xmin() - lm; - FT fxmax = bbox.xmax() + lm; - FT fymin = bbox.ymin() - lm; - FT fymax = bbox.ymax() + lm; + const IFT fxmin = IFT(bbox.xmin()) - lm; + const IFT fxmax = IFT(bbox.xmax()) + lm; + const IFT fymin = IFT(bbox.ymin()) - lm; + const IFT fymax = IFT(bbox.ymax()) + lm; Point_2 frame[4]; frame[0] = Point_2(fxmin,fymin);