Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compatibility with CGAL-6.0 (and 5.6.x) #13081

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lrineau
Copy link

@lrineau lrineau commented Jul 12, 2024

This patch ensures that PrusaSlicer can be compile with CGAL-6.0, or a previous version (like CGAL-5.6.2).

The main breaking change for PruseSlicer was the return type of mesh.add_property_map.

@MrArborsexual
Copy link

This patch ensures that PrusaSlicer can be compile with CGAL-6.0, or a previous version (like CGAL-5.6.2).

The main breaking change for PruseSlicer was the return type of mesh.add_property_map.

I was having issues recompiling PrusaSlicer on Gentoo, and this fixed my issue. Hopefully it gets merged soon, because most Gentoo users running "~amd64" are likely to run into issues due to CGAL updating.

Copy link

@onitake onitake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some observations, maybe take a closer look (or ignore if inappropriate).

src/libslic3r/CutSurface.cpp Outdated Show resolved Hide resolved
@@ -4,6 +4,22 @@
///|/
#include "CutSurface.hpp"

template <typename T>
auto access_pmap(std::optional<T> opt) -> T {
return opt.value();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using value() could be problematic: This functions throws std::bad_optional_access when the optional value isn't set. Perhaps value_or(T()) is more appropriate, if a default value is acceptable. Or you could check if the value is set and act accordingly?

@onitake
Copy link

onitake commented Sep 29, 2024

I'm also getting these warnings, but maybe that's something that can't be fixed yet without breaking compatibility:

In file included from /usr/include/CGAL/AABB_traits.h:19,
                 from /build/slic3r-prusa/src/libslic3r/CutSurface.cpp:52:
/usr/include/CGAL/Installation/internal/deprecation_warning.h:80:6: warning: #warning "A deprecated header has been included." [-Wcpp]
   80 | #    warning "A deprecated header has been included."
      |      ^~~~~~~

/usr/include/CGAL/Installation/internal/deprecation_warning.h:81:54: note: ‘#pragma message: Warning: The header `<CGAL/AABB_traits.h>` is deprecated. Please use `<CGAL/AABB_traits_3.h>` instead. ’
   81 | #    pragma message (CGAL_INTERNAL_DEPRECATED_MESSAGE)
      |                                                      ^

@onitake
Copy link

onitake commented Sep 30, 2024

Slicer builds with the patch now, but there's still errors in a unit test:

/build/slic3r-prusa/tests/libslic3r/test_emboss.cpp: In function ‘void CATCH2_INTERNAL_TEST_28()’:
/build/slic3r-prusa/tests/libslic3r/test_emboss.cpp:907:90: error: ‘class std::optional<CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epick> >::Property_map<CGAL::SM_Face_index, int> >’ has no member named ‘first’
  907 |     auto face_map = cgal_object.property_map<MyMesh::Face_index, int32_t>(face_map_name).first;
      |                                                                                          ^~~~~
/build/slic3r-prusa/tests/libslic3r/test_emboss.cpp:916:112: error: ‘class std::optional<CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epick> >::Property_map<CGAL::SM_Edge_index, IntersectingElemnt> >’ has no member named ‘first’
  916 |     auto edge_shape_map = cgal_shape.property_map<MyMesh::Edge_index, IntersectingElemnt>(edge_shape_map_name).first;
      |                                                                                                                ^~~~~
/build/slic3r-prusa/tests/libslic3r/test_emboss.cpp:917:112: error: ‘class std::optional<CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epick> >::Property_map<CGAL::SM_Face_index, IntersectingElemnt> >’ has no member named ‘first’
  917 |     auto face_shape_map = cgal_shape.property_map<MyMesh::Face_index, IntersectingElemnt>(face_shape_map_name).first;
      |                                                                                                                ^~~~~
/build/slic3r-prusa/tests/libslic3r/test_emboss.cpp:1033:39: error: no matching function for call to ‘CATCH2_INTERNAL_TEST_28()::Visitor::Visitor(<brace-enclosed initializer list>)’
 1033 |               face_map, vert_shape_map};
      |                                       ^
/build/slic3r-prusa/tests/libslic3r/test_emboss.cpp:926:9: note: candidate: ‘CATCH2_INTERNAL_TEST_28()::Visitor::Visitor(const MyMesh&, const MyMesh&, CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epick> >::Property_map<CGAL::SM_Edge_index, IntersectingElemnt>, CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epick> >::Property_map<CGAL::SM_Face_index, IntersectingElemnt>, CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epick> >::Property_map<CGAL::SM_Face_index, int>, CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epick> >::Property_map<CGAL::SM_Vertex_index, IntersectingElemnt>)’
  926 |         Visitor(const MyMesh &object, const MyMesh &shape,
      |         ^~~~~~~
/build/slic3r-prusa/tests/libslic3r/test_emboss.cpp:926:9: note:   conversion of argument 3 would be ill-formed:
/build/slic3r-prusa/tests/libslic3r/test_emboss.cpp:925:12: note: candidate: ‘CATCH2_INTERNAL_TEST_28()::Visitor::Visitor(const CATCH2_INTERNAL_TEST_28()::Visitor&)’
  925 |     struct Visitor : public CGAL::Polygon_mesh_processing::Corefinement::Default_visitor<MyMesh> {
      |            ^~~~~~~
/build/slic3r-prusa/tests/libslic3r/test_emboss.cpp:925:12: note:   candidate expects 1 argument, 6 provided
/build/slic3r-prusa/tests/libslic3r/test_emboss.cpp:925:12: note: candidate: ‘CATCH2_INTERNAL_TEST_28()::Visitor::Visitor(CATCH2_INTERNAL_TEST_28()::Visitor&&)’
/build/slic3r-prusa/tests/libslic3r/test_emboss.cpp:925:12: note:   candidate expects 1 argument, 6 provided

The property map errors can be fixed easily enough, but I'm not so sure about the Catch2 initializer list...

Edit: I spoke too soon - after patching the property map accessors, everything built without error.

Here's a very basic patch, but it's probably better to move the accessor functions to a header file.

--- a/tests/libslic3r/test_emboss.cpp
+++ b/tests/libslic3r/test_emboss.cpp
@@ -9,8 +9,16 @@
 #include <libslic3r/IntersectionPoints.hpp>
 using namespace Slic3r;
 
+template <typename T>
+auto access_pmap(std::optional<T> opt) -> T {
+    return opt.value();
+}
+
+template <typename Pair>
+auto access_pmap(Pair pair) { return pair.first; }
+
 namespace Private{
-        
+
 // calculate multiplication of ray dir to intersect - inspired by
 // segment_segment_intersection when ray dir is normalized retur distance from
 // ray point to intersection No value mean no intersection
@@ -904,8 +912,8 @@
     // identify glyph for intersected vertex
     std::string vert_shape_map_name = "v:glyph_id";
     MyMesh cgal_object = MeshBoolean::cgal2::to_cgal(cube, face_map_name);
-    auto face_map = cgal_object.property_map<MyMesh::Face_index, int32_t>(face_map_name).first;
-    auto vert_shape_map = cgal_object.add_property_map<MyMesh::Vertex_index, IntersectingElemnt>(vert_shape_map_name).first;
+    auto face_map = access_pmap(cgal_object.property_map<MyMesh::Face_index, int32_t>(face_map_name));
+    auto vert_shape_map = access_pmap(cgal_object.add_property_map<MyMesh::Vertex_index, IntersectingElemnt>(vert_shape_map_name));
 
     std::string edge_shape_map_name = "e:glyph_id";
     std::string face_shape_map_name = "f:glyph_id";
@@ -913,8 +921,8 @@
 
     MyMesh cgal_shape = MeshBoolean::cgal2::to_cgal(shape, projection, 0, edge_shape_map_name, face_shape_map_name, glyph_contours);    
 
-    auto edge_shape_map = cgal_shape.property_map<MyMesh::Edge_index, IntersectingElemnt>(edge_shape_map_name).first;
-    auto face_shape_map = cgal_shape.property_map<MyMesh::Face_index, IntersectingElemnt>(face_shape_map_name).first;
+    auto edge_shape_map = access_pmap(cgal_shape.property_map<MyMesh::Edge_index, IntersectingElemnt>(edge_shape_map_name));
+    auto face_shape_map = access_pmap(cgal_shape.property_map<MyMesh::Face_index, IntersectingElemnt>(face_shape_map_name));
 
     // bool map for affected edge
     using d_prop_bool = CGAL::dynamic_edge_property_t<bool>;

@sl1pkn07
Copy link

Hi. a little rebase please?

greetings

@sl1pkn07
Copy link

sl1pkn07 commented Dec 19, 2024

[ 20%] Built target avrdude-slic3r
En el fichero incluido desde /usr/include/CGAL/AABB_traits.h:19,
                 desde /tmp/makepkg/prusa-slicer-git/src/PrusaSlicer/bundled_deps/libigl/igl/copyleft/cgal/closest_facet.h:17,
                 desde /tmp/makepkg/prusa-slicer-git/src/PrusaSlicer/bundled_deps/libigl/igl/copyleft/cgal/extract_cells.cpp:10,
                 desde /tmp/makepkg/prusa-slicer-git/src/PrusaSlicer/bundled_deps/libigl/igl/copyleft/cgal/extract_cells.h:114,
                 desde /tmp/makepkg/prusa-slicer-git/src/PrusaSlicer/bundled_deps/libigl/igl/copyleft/cgal/mesh_boolean.cpp:12,
                 desde /tmp/makepkg/prusa-slicer-git/src/PrusaSlicer/bundled_deps/libigl/igl/copyleft/cgal/mesh_boolean.h:226,
                 desde /tmp/makepkg/prusa-slicer-git/src/PrusaSlicer/src/libslic3r/MeshBoolean.cpp:14:
/usr/include/CGAL/Installation/internal/deprecation_warning.h:80:6: aviso: #warning "A deprecated header has been included." [-Wcpp]
   80 | #    warning "A deprecated header has been included."
      |      ^~~~~~~
En el fichero incluido desde /usr/include/CGAL/AABB_triangle_primitive.h:21,
                 desde /tmp/makepkg/prusa-slicer-git/src/PrusaSlicer/bundled_deps/libigl/igl/copyleft/cgal/closest_facet.h:18:
/usr/include/CGAL/Installation/internal/deprecation_warning.h:80:6: aviso: #warning "A deprecated header has been included." [-Wcpp]
   80 | #    warning "A deprecated header has been included."
      |      ^~~~~~~
En el fichero incluido desde /usr/include/CGAL/AABB_traits.h:19,
                 desde /tmp/makepkg/prusa-slicer-git/src/PrusaSlicer/src/libslic3r/CutSurface.cpp:43:
/usr/include/CGAL/Installation/internal/deprecation_warning.h:80:6: aviso: #warning "A deprecated header has been included." [-Wcpp]
   80 | #    warning "A deprecated header has been included."
      |      ^~~~~~~
/usr/include/CGAL/Installation/internal/deprecation_warning.h:81:54: nota: ‘#pragma message: Warning: The header `<CGAL/AABB_traits.h>` is deprecated. Please use `<CGAL/AABB_traits_3.h>` instead. ’
   81 | #    pragma message (CGAL_INTERNAL_DEPRECATED_MESSAGE)
      |                                                      ^
/usr/include/CGAL/Installation/internal/deprecation_warning.h:81:54: nota: ‘#pragma message: Warning: The header `<CGAL/AABB_triangle_primitive.h>` is deprecated. Please use `<CGAL/AABB_triangle_primitive_3.h>` instead. ’
   81 | #    pragma message (CGAL_INTERNAL_DEPRECATED_MESSAGE)
      |                                                      ^
/usr/include/CGAL/Installation/internal/deprecation_warning.h:81:54: nota: ‘#pragma message: Warning: The header `<CGAL/AABB_traits.h>` is deprecated. Please use `<CGAL/AABB_traits_3.h>` instead. ’
   81 | #    pragma message (CGAL_INTERNAL_DEPRECATED_MESSAGE)
      |                                                      ^
        [ 20%] Linking CXX static library liblibslic3r_cgal.a                                                  ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants