From df1225ce9507b5e1042bd704af6f5e0ea9036ba2 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sun, 4 Oct 2020 10:42:05 +0200 Subject: [PATCH] Include cgal patch for nary union --- nix/build-all.py | 18 ++++++++++++++- nix/patches/cgal/cgal_4768.patch | 38 ++++++++++++++++++++++++++++++++ win/build-deps.cmd | 1 + win/patches/cgal_4768.patch | 38 ++++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 nix/patches/cgal/cgal_4768.patch create mode 100644 win/patches/cgal_4768.patch diff --git a/nix/build-all.py b/nix/build-all.py index 7473cc0580..5fd1b6922c 100644 --- a/nix/build-all.py +++ b/nix/build-all.py @@ -673,7 +673,23 @@ if "cgal" in targets: if BUILD_CFG != "Debug": # CGAL only supports Debug and Release for CMAKE_BUILD_TYPE BUILD_CFG = "Release" - build_dependency(name="cgal-{CGAL_VERSION}".format(**locals()), mode="cmake", build_tool_args=["-DGMP_LIBRARIES=%s/install/gmp-%s/lib/libgmp.a" % (DEPS_DIR, GMP_VERSION), "-DGMP_INCLUDE_DIR=%s/install/gmp-%s/include" % (DEPS_DIR, GMP_VERSION), "-DMPFR_LIBRARIES=%s/install/mpfr-%s/lib/libmpfr.a" % (DEPS_DIR, MPFR_VERSION), "-DMPFR_INCLUDE_DIR=%s/install/mpfr-%s/include" % (DEPS_DIR, MPFR_VERSION), "-DBoost_INCLUDE_DIR=%s/install/boost-%s" % (DEPS_DIR, BOOST_VERSION), "-DCMAKE_INSTALL_PREFIX=%s/install/cgal-%s/" % (DEPS_DIR, CGAL_VERSION), "-DBUILD_SHARED_LIBS=Off"], download_url="https://github.com/CGAL/cgal.git", download_name="cgal", download_tool=download_tool_git, revision="releases/CGAL-{CGAL_VERSION}".format(**locals())) + build_dependency( + name="cgal-{CGAL_VERSION}".format(**locals()), + mode="cmake", + patch="./patches/cgal/cgal_4768.patch", + build_tool_args=[ + "-DGMP_LIBRARIES=%s/install/gmp-%s/lib/libgmp.a" % (DEPS_DIR, GMP_VERSION), + "-DGMP_INCLUDE_DIR=%s/install/gmp-%s/include" % (DEPS_DIR, GMP_VERSION), + "-DMPFR_LIBRARIES=%s/install/mpfr-%s/lib/libmpfr.a" % (DEPS_DIR, MPFR_VERSION), + "-DMPFR_INCLUDE_DIR=%s/install/mpfr-%s/include" % (DEPS_DIR, MPFR_VERSION), + "-DBoost_INCLUDE_DIR=%s/install/boost-%s" % (DEPS_DIR, BOOST_VERSION), + "-DCMAKE_INSTALL_PREFIX=%s/install/cgal-%s/" % (DEPS_DIR, CGAL_VERSION), + "-DBUILD_SHARED_LIBS=Off"], + download_url="https://github.com/CGAL/cgal.git", + download_name="cgal", + download_tool=download_tool_git, + revision="releases/CGAL-{CGAL_VERSION}".format(**locals()) + ) BUILD_CFG = OLD_BUILD_CFG if "voxel" in targets: diff --git a/nix/patches/cgal/cgal_4768.patch b/nix/patches/cgal/cgal_4768.patch new file mode 100644 index 0000000000..7bad5f250b --- /dev/null +++ b/nix/patches/cgal/cgal_4768.patch @@ -0,0 +1,38 @@ +From a86712d1aae9a1a6d2004db3fc8fcdac6ef6b782 Mon Sep 17 00:00:00 2001 +From: Thomas Krijnen +Date: Sun, 7 Jun 2020 15:25:18 +0200 +Subject: [PATCH] Don't segfault on empty Nef_nary_x + +--- + Nef_3/include/CGAL/Nef_nary_intersection_3.h | 3 ++- + Nef_3/include/CGAL/Nef_nary_union_3.h | 3 ++- + 2 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/Nef_3/include/CGAL/Nef_nary_intersection_3.h b/Nef_3/include/CGAL/Nef_nary_intersection_3.h +index 70fc5791fae..5178705dc2f 100644 +--- a/Nef_3/include/CGAL/Nef_nary_intersection_3.h ++++ b/Nef_3/include/CGAL/Nef_nary_intersection_3.h +@@ -52,7 +52,8 @@ class Nef_nary_intersection_3 { + } + + Polyhedron get_intersection() { +- ++ if (queue.empty()) ++ return empty; + while(queue.size() > 1) + intersect(); + inserted = 0; +diff --git a/Nef_3/include/CGAL/Nef_nary_union_3.h b/Nef_3/include/CGAL/Nef_nary_union_3.h +index ecbbae2db59..c8663bb911b 100644 +--- a/Nef_3/include/CGAL/Nef_nary_union_3.h ++++ b/Nef_3/include/CGAL/Nef_nary_union_3.h +@@ -52,7 +52,8 @@ class Nef_nary_union_3 { + } + + Polyhedron get_union() { +- ++ if (queue.empty()) ++ return empty; + while(queue.size() > 1) + unite(); + inserted = 0; diff --git a/win/build-deps.cmd b/win/build-deps.cmd index 3392bcb3ad..ca1281311e 100644 --- a/win/build-deps.cmd +++ b/win/build-deps.cmd @@ -447,6 +447,7 @@ IF NOT %ERRORLEVEL%==0 GOTO :Error cd "%DEPENDENCY_DIR%" git reset --hard git apply "%~dp0patches\cgal_no_zlib.patch" +git apply "%~dp0patches\cgal_4768.patch" call :RunCMake -DCMAKE_INSTALL_PREFIX="%INSTALL_DIR%\cgal" ^ -DBOOST_ROOT="%DEPS_DIR%\boost_%BOOST_VER%" ^ -DGMP_INCLUDE_DIR="%INSTALL_DIR%\mpir" ^ diff --git a/win/patches/cgal_4768.patch b/win/patches/cgal_4768.patch new file mode 100644 index 0000000000..7bad5f250b --- /dev/null +++ b/win/patches/cgal_4768.patch @@ -0,0 +1,38 @@ +From a86712d1aae9a1a6d2004db3fc8fcdac6ef6b782 Mon Sep 17 00:00:00 2001 +From: Thomas Krijnen +Date: Sun, 7 Jun 2020 15:25:18 +0200 +Subject: [PATCH] Don't segfault on empty Nef_nary_x + +--- + Nef_3/include/CGAL/Nef_nary_intersection_3.h | 3 ++- + Nef_3/include/CGAL/Nef_nary_union_3.h | 3 ++- + 2 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/Nef_3/include/CGAL/Nef_nary_intersection_3.h b/Nef_3/include/CGAL/Nef_nary_intersection_3.h +index 70fc5791fae..5178705dc2f 100644 +--- a/Nef_3/include/CGAL/Nef_nary_intersection_3.h ++++ b/Nef_3/include/CGAL/Nef_nary_intersection_3.h +@@ -52,7 +52,8 @@ class Nef_nary_intersection_3 { + } + + Polyhedron get_intersection() { +- ++ if (queue.empty()) ++ return empty; + while(queue.size() > 1) + intersect(); + inserted = 0; +diff --git a/Nef_3/include/CGAL/Nef_nary_union_3.h b/Nef_3/include/CGAL/Nef_nary_union_3.h +index ecbbae2db59..c8663bb911b 100644 +--- a/Nef_3/include/CGAL/Nef_nary_union_3.h ++++ b/Nef_3/include/CGAL/Nef_nary_union_3.h +@@ -52,7 +52,8 @@ class Nef_nary_union_3 { + } + + Polyhedron get_union() { +- ++ if (queue.empty()) ++ return empty; + while(queue.size() > 1) + unite(); + inserted = 0;