From 5503da721243483815caf0b0152a4708418d510e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Tue, 23 Jul 2024 07:51:24 +0200 Subject: [PATCH 1/2] Prepare v1.5.2 --- CMakeLists.txt | 2 +- NEWS | 7 ++++++- sonar-project.properties | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d9affa4..765d0ea3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,7 +50,7 @@ set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules;${CMAKE_MODULE_PATH}" set( SFCGAL_VERSION_MAJOR 1 ) set( SFCGAL_VERSION_MINOR 5 ) -set( SFCGAL_VERSION_PATCH 1 ) +set( SFCGAL_VERSION_PATCH 2 ) set( SFCGAL_VERSION "${SFCGAL_VERSION_MAJOR}.${SFCGAL_VERSION_MINOR}.${SFCGAL_VERSION_PATCH}" ) diff --git a/NEWS b/NEWS index aa1aadc4..551bf744 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,10 @@ -1.5.2 (2024-03-XX): +1.5.2 (2024-07-25): + * Force LHR / RHR: Fix invalid interior ring orientation and allow operation on 3D geometries too (Loïc Bartoletti, Fixes #268) + * Added community-oriented files: Code of Conduct, Contributing guidelines, Sponsors information, and Project Steering Committee (PSC) documentation (Raphaël Delhome, Loïc Bartoletti) + * WKB: add binary version of wkb for WkbReader and WkbWriter (Benoit De Mezzo) * Expose as_vtk to C Api (Loïc Bartoletti) + * Fix include. Use " instead of <> (Loïc Bartoletti) + * [CI] Fix MSYS test (Loïc Bartoletti) * Fix build with boost 1.85 (Dirk Stöcker, Fixes #266) * Add a CI job to build a windows docker image (Jean Felder) 1.5.1 (2023-12-21): diff --git a/sonar-project.properties b/sonar-project.properties index 932e8926..099bb1ff 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -3,7 +3,7 @@ sonar.organization=oslandia # This is the name and version displayed in the SonarCloud UI. sonar.projectName=SFCGAL -sonar.projectVersion=1.5.1 +sonar.projectVersion=1.5.2 # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. sonar.sources=src From 08a8704446109b49b4a56c48b4458f49fd1bd9d3 Mon Sep 17 00:00:00 2001 From: Sebastien Loriot Date: Fri, 26 Jul 2024 06:51:31 +0000 Subject: [PATCH 2/2] Compatibility with 6.0 and 5.6 --- CMakeLists.txt | 4 ---- src/algorithm/offset.cpp | 8 ++++++++ src/algorithm/straightSkeleton.cpp | 31 +++++++++++++++++------------ src/algorithm/visibility.cpp | 32 +++++++++++++++++++++++------- src/config.h.cmake | 10 ++++++---- src/detail/generator/building.cpp | 5 ++++- 6 files changed, 61 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d9affa4..d2c9241b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,10 +78,6 @@ message( STATUS "CGAL ${CGAL_VERSION} found" ) include_directories( ${CMAKE_BINARY_DIR}/include ) #-- BOOST -------------------------------------------------- -if( NOT CGAL_USE_GMPXX ) - add_definitions( "-DCGAL_DO_NOT_USE_BOOST_MP" ) -endif() - option( Boost_USE_AUTO_LINK "boost use autolink" OFF ) if( NOT ${Boost_USE_AUTO_LINK} ) add_definitions( "-DBOOST_ALL_NO_LIB" ) diff --git a/src/algorithm/offset.cpp b/src/algorithm/offset.cpp index 113d6fc1..20403abe 100644 --- a/src/algorithm/offset.cpp +++ b/src/algorithm/offset.cpp @@ -169,6 +169,7 @@ circleToPolygon(const Kernel::Circle_2 &circle) -> Offset_polygon_2 Gps_traits_2 const traits; Offset_curve_2 const curve(circle); +#if CGAL_VERSION_MAJOR < 6 std::list parts; traits.make_x_monotone_2_object()(curve, std::back_inserter(parts)); BOOST_ASSERT(parts.size() == 2U); @@ -181,6 +182,13 @@ circleToPolygon(const Kernel::Circle_2 &circle) -> Offset_polygon_2 CGAL::assign(arc, part); result.push_back(arc); } +#else + Offset_polygon_2 result; + + traits.make_x_monotone_2_object()( + curve, CGAL::dispatch_or_drop_output( + std::back_inserter(result))); +#endif return result; } diff --git a/src/algorithm/straightSkeleton.cpp b/src/algorithm/straightSkeleton.cpp index 13eb4270..42095f0f 100644 --- a/src/algorithm/straightSkeleton.cpp +++ b/src/algorithm/straightSkeleton.cpp @@ -38,6 +38,14 @@ using Polygon_with_holes_2 = CGAL::Polygon_with_holes_2; using Straight_skeleton_2 = CGAL::Straight_skeleton_2; using Mesh = CGAL::Surface_mesh; +#if CGAL_VERSION_MAJOR < 6 +template +using SHARED_PTR = boost::shared_ptr; +#else +template +using SHARED_PTR = std::shared_ptr; +#endif + namespace { // anonymous template @@ -181,14 +189,14 @@ straightSkeletonToMedialAxis(const CGAL::Straight_skeleton_2 &ss, auto straightSkeleton(const Polygon_with_holes_2 &poly) - -> boost::shared_ptr + -> SHARED_PTR { - boost::shared_ptr> const sk = + SHARED_PTR> const sk = CGAL::create_interior_straight_skeleton_2( poly.outer_boundary().vertices_begin(), poly.outer_boundary().vertices_end(), poly.holes_begin(), poly.holes_end(), CGAL::Epick()); - boost::shared_ptr ret; + SHARED_PTR ret; if (sk) { ret = CGAL::convert_straight_skeleton_2(*sk); } @@ -316,10 +324,9 @@ straightSkeleton(const Polygon &g, bool /*autoOrientation*/, bool innerOnly, return result; } - Kernel::Vector_2 trans; - Polygon_with_holes_2 const polygon = preparePolygon(g, trans); - boost::shared_ptr const skeleton = - straightSkeleton(polygon); + Kernel::Vector_2 trans; + Polygon_with_holes_2 const polygon = preparePolygon(g, trans); + SHARED_PTR const skeleton = straightSkeleton(polygon); if (skeleton == nullptr) { BOOST_THROW_EXCEPTION(Exception("CGAL failed to create straightSkeleton")); @@ -348,8 +355,7 @@ straightSkeleton(const MultiPolygon &g, bool /*autoOrientation*/, for (size_t i = 0; i < g.numGeometries(); i++) { Kernel::Vector_2 trans; Polygon_with_holes_2 const polygon = preparePolygon(g.polygonN(i), trans); - boost::shared_ptr const skeleton = - straightSkeleton(polygon); + SHARED_PTR const skeleton = straightSkeleton(polygon); if (skeleton == nullptr) { BOOST_THROW_EXCEPTION( @@ -379,10 +385,9 @@ approximateMedialAxis(const Geometry &g) -> std::unique_ptr extractPolygons(g, polys); for (auto &poly : polys) { - Kernel::Vector_2 trans; - Polygon_with_holes_2 const polygon = preparePolygon(poly, trans); - boost::shared_ptr const skeleton = - straightSkeleton(polygon); + Kernel::Vector_2 trans; + Polygon_with_holes_2 const polygon = preparePolygon(poly, trans); + SHARED_PTR const skeleton = straightSkeleton(polygon); if (skeleton == nullptr) { BOOST_THROW_EXCEPTION( diff --git a/src/algorithm/visibility.cpp b/src/algorithm/visibility.cpp index a99eaf19..9da4f09f 100644 --- a/src/algorithm/visibility.cpp +++ b/src/algorithm/visibility.cpp @@ -98,7 +98,6 @@ visibility(const Geometry &polygon, const Geometry &point, } // Find the face - Arrangement_2::Face_const_handle *face; CGAL::Arr_naive_point_location const pl(arr); CGAL::Arr_point_location_result::Type obj = pl.locate(queryPoint); @@ -108,9 +107,13 @@ visibility(const Geometry &polygon, const Geometry &point, // Create Triangular Expansion Visibility object. TEV const tev(arr); - - if (obj.which() == 0) { - +#if CGAL_VERSION_MAJOR < 6 + switch (obj.which()) +#else + switch (obj.index()) +#endif + { + case 0: { Halfedge_const_handle he = Halfedge_const_handle(); // If the point is in a boundary segment, find the corresponding half edge @@ -135,23 +138,38 @@ visibility(const Geometry &polygon, const Geometry &point, // Use the half edge to compute the visibility fh = tev.compute_visibility(queryPoint, he, output_arr); - - } else if (obj.which() == 1) { + break; + } + case 1: { Halfedge_const_handle *he = +#if CGAL_VERSION_MAJOR < 6 boost::get(&obj); +#else + std::get_if(&obj); +#endif if (he != nullptr) { fh = tev.compute_visibility(queryPoint, *he, output_arr); } else { BOOST_THROW_EXCEPTION(Exception("Can not find corresponding hedge.")); } - } else if (obj.which() == 2) { + break; + } + case 2: { Face_const_handle *face = +#if CGAL_VERSION_MAJOR < 6 boost::get(&obj); +#else + std::get_if(&obj); +#endif if ((face != nullptr) && !((*face)->is_unbounded())) { fh = tev.compute_visibility(queryPoint, *face, output_arr); } else { BOOST_THROW_EXCEPTION(Exception("Can not find corresponding face.")); } + break; + } + default: + break; } return query_visibility(fh, fh->outer_ccb()); diff --git a/src/config.h.cmake b/src/config.h.cmake index 5c4555dc..abb2eab5 100644 --- a/src/config.h.cmake +++ b/src/config.h.cmake @@ -8,19 +8,22 @@ * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * You should have received a copy of the GNU Library General Public - * License along with this library; if not, see . + * License along with this library; if not, see + . */ #ifndef _SFCGAL_CONFIG_H_ #define _SFCGAL_CONFIG_H_ -#define CGAL_DO_NOT_USE_BOOST_MP 1 +#ifndef CGAL_USE_GMPXX +#define CMAKE_OVERRIDDEN_DEFAULT_ENT_BACKEND 0 // GMP +#endif #include "SFCGAL/export.h" @@ -30,4 +33,3 @@ #cmakedefine SFCGAL_WITH_OSG #endif - diff --git a/src/detail/generator/building.cpp b/src/detail/generator/building.cpp index 93a3efde..0fb26515 100644 --- a/src/detail/generator/building.cpp +++ b/src/detail/generator/building.cpp @@ -75,8 +75,11 @@ building(const Polygon &g, const Kernel::FT &wallHeight, // fix orientation algorithm::makeValidOrientation(polygon); - +#if CGAL_VERSION_MAJOR < 6 boost::shared_ptr const skeleton = +#else + std::shared_ptr const skeleton = +#endif create_interior_straight_skeleton_2( polygon.outer_boundary().vertices_begin(), polygon.outer_boundary().vertices_end(), polygon.holes_begin(),