Skip to content

Commit b5d0652

Browse files
committed
fixes for newer CGAL
There were some API changes with the newer CGAL library. This updates the code accordingly.
1 parent 39a535c commit b5d0652

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

src/libslic3r/CutSurface.cpp

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,9 +1437,9 @@ priv::CutAOIs priv::cut_from_model(CutMesh &cgal_model,
14371437
// detect anomalities in visitor.
14381438
bool is_valid = true;
14391439
// NOTE: map are created when convert shapes to cgal model
1440-
const EdgeShapeMap& edge_shape_map = cgal_shape.property_map<EI, IntersectingElement>(edge_shape_map_name).first;
1441-
const FaceShapeMap& face_shape_map = cgal_shape.property_map<FI, IntersectingElement>(face_shape_map_name).first;
1442-
Visitor visitor{cgal_model, cgal_shape, edge_shape_map, face_shape_map, vert_shape_map, &is_valid};
1440+
auto edge_shape_map = cgal_shape.property_map<EI, IntersectingElement>(edge_shape_map_name);
1441+
auto face_shape_map = cgal_shape.property_map<FI, IntersectingElement>(face_shape_map_name);
1442+
Visitor visitor{cgal_model, cgal_shape, edge_shape_map.value(), face_shape_map.value(), vert_shape_map, &is_valid};
14431443

14441444
// a property map containing the constrained-or-not status of each edge
14451445
EdgeBoolMap ecm = cgal_model.add_property_map<EI, bool>(is_constrained_edge_name, false).first;
@@ -1587,8 +1587,10 @@ void priv::collect_surface_data(std::queue<FI> &process,
15871587

15881588
void priv::create_reduce_map(ReductionMap &reduction_map, const CutMesh &mesh)
15891589
{
1590-
const VertexShapeMap &vert_shape_map = mesh.property_map<VI, const IntersectingElement*>(vert_shape_map_name).first;
1591-
const EdgeBoolMap &ecm = mesh.property_map<EI, bool>(is_constrained_edge_name).first;
1590+
auto optional_vert_shape_map = mesh.property_map<VI, const IntersectingElement*>(vert_shape_map_name);
1591+
const VertexShapeMap &vert_shape_map = optional_vert_shape_map.value();
1592+
auto optional_ecm = mesh.property_map<EI, bool>(is_constrained_edge_name);
1593+
const EdgeBoolMap &ecm = optional_ecm.value();
15921594

15931595
// check if vertex was made by edge_2 which is diagonal of quad
15941596
auto is_reducible_vertex = [&vert_shape_map](VI reduction_from) -> bool {
@@ -1772,11 +1774,13 @@ priv::VDistances priv::calc_distances(const SurfacePatches &patches,
17721774
priv::VDistances result(count_shapes_points);
17731775
for (const SurfacePatch &patch : patches) {
17741776
// map is created during intersection by corefine visitor
1775-
const VertexShapeMap &vert_shape_map =
1776-
models[patch.model_id].property_map<VI, const IntersectingElement *>(vert_shape_map_name).first;
1777+
auto optional_vert_shape_map =
1778+
models[patch.model_id].property_map<VI, const IntersectingElement *>(vert_shape_map_name);
1779+
const VertexShapeMap &vert_shape_map = optional_vert_shape_map.value();
17771780
uint32_t patch_index = &patch - &patches.front();
17781781
// map is created during patch creation / dividing
1779-
const CvtVI2VI& cvt = patch.mesh.property_map<VI, VI>(patch_source_name).first;
1782+
auto optional_cvt = patch.mesh.property_map<VI, VI>(patch_source_name);
1783+
const CvtVI2VI& cvt = optional_cvt.value();
17801784
// for each point on outline
17811785
for (const Loop &loop : patch.loops)
17821786
for (const VI &vi_patch : loop) {
@@ -2785,7 +2789,7 @@ using BBS = std::vector<BoundingBoxf3>;
27852789
BBS create_bbs(const VCutAOIs &cuts, const CutMeshes &cut_models);
27862790

27872791
using Primitive = CGAL::AABB_face_graph_triangle_primitive<CutMesh>;
2788-
using Traits = CGAL::AABB_traits<EpicKernel, Primitive>;
2792+
using Traits = CGAL::AABB_traits_3<EpicKernel, Primitive>;
27892793
using Ray = EpicKernel::Ray_3;
27902794
using Tree = CGAL::AABB_tree<Traits>;
27912795
using Trees = std::vector<Tree>;
@@ -2939,7 +2943,8 @@ bool priv::is_patch_inside_of_model(const SurfacePatch &patch,
29392943
uint32_t priv::get_shape_point_index(const CutAOI &cut, const CutMesh &model)
29402944
{
29412945
// map is created during intersection by corefine visitor
2942-
const VertexShapeMap &vert_shape_map = model.property_map<VI, const IntersectingElement *>(vert_shape_map_name).first;
2946+
auto optional_vert_shape_map = model.property_map<VI, const IntersectingElement *>(vert_shape_map_name);
2947+
const VertexShapeMap &vert_shape_map = optional_vert_shape_map.value();
29432948
// for each half edge of outline
29442949
for (HI hi : cut.second) {
29452950
VI vi = model.source(hi);
@@ -2964,7 +2969,7 @@ priv::SurfacePatch priv::separate_patch(const std::vector<FI>& fis,
29642969
patch_new.model_id = patch.model_id;
29652970
patch_new.shape_id = patch.shape_id;
29662971
// fix cvt
2967-
CvtVI2VI cvt = patch_new.mesh.property_map<VI, VI>(patch_source_name).first;
2972+
CvtVI2VI cvt = patch_new.mesh.property_map<VI, VI>(patch_source_name).value();
29682973
for (VI &vi : cvt) {
29692974
if (!vi.is_valid()) continue;
29702975
vi = cvt_from[vi];
@@ -2984,7 +2989,8 @@ void priv::divide_patch(size_t i, SurfacePatchesEx &patches)
29842989
std::string patch_number_name = "f:patch_number";
29852990
CutMesh::Property_map<FI,bool> is_processed = cm.add_property_map<FI, bool>(patch_number_name, false).first;
29862991

2987-
const CvtVI2VI& cvt_from = patch.mesh.property_map<VI, VI>(patch_source_name).first;
2992+
auto optional_cvt_from = patch.mesh.property_map<VI, VI>(patch_source_name);
2993+
const CvtVI2VI& cvt_from = optional_cvt_from.value();
29882994

29892995
std::vector<FI> fis;
29902996
fis.reserve(cm.faces().size());
@@ -3171,7 +3177,8 @@ bool priv::is_over_whole_expoly(const CutAOI &cutAOI,
31713177
const CutMesh &mesh)
31723178
{
31733179
// NonInterupted contour is without other point and contain all from shape
3174-
const VertexShapeMap &vert_shape_map = mesh.property_map<VI, const IntersectingElement*>(vert_shape_map_name).first;
3180+
auto optional_vert_shape_map = mesh.property_map<VI, const IntersectingElement*>(vert_shape_map_name);
3181+
const VertexShapeMap &vert_shape_map = optional_vert_shape_map.value();
31753182
for (HI hi : cutAOI.second) {
31763183
const IntersectingElement *ie_s = vert_shape_map[mesh.source(hi)];
31773184
const IntersectingElement *ie_t = vert_shape_map[mesh.target(hi)];

tests/libslic3r/test_emboss.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ TEST_CASE("Emboss extrude cut", "[Emboss-Cut]")
906906
// identify glyph for intersected vertex
907907
std::string vert_shape_map_name = "v:glyph_id";
908908
MyMesh cgal_object = MeshBoolean::cgal2::to_cgal(cube, face_map_name);
909-
auto face_map = cgal_object.property_map<MyMesh::Face_index, int32_t>(face_map_name).first;
909+
auto face_map = cgal_object.property_map<MyMesh::Face_index, int32_t>(face_map_name).value();
910910
auto vert_shape_map = cgal_object.add_property_map<MyMesh::Vertex_index, IntersectingElemnt>(vert_shape_map_name).first;
911911

912912
std::string edge_shape_map_name = "e:glyph_id";
@@ -915,8 +915,8 @@ TEST_CASE("Emboss extrude cut", "[Emboss-Cut]")
915915

916916
MyMesh cgal_shape = MeshBoolean::cgal2::to_cgal(shape, projection, 0, edge_shape_map_name, face_shape_map_name, glyph_contours);
917917

918-
auto edge_shape_map = cgal_shape.property_map<MyMesh::Edge_index, IntersectingElemnt>(edge_shape_map_name).first;
919-
auto face_shape_map = cgal_shape.property_map<MyMesh::Face_index, IntersectingElemnt>(face_shape_map_name).first;
918+
auto edge_shape_map = cgal_shape.property_map<MyMesh::Edge_index, IntersectingElemnt>(edge_shape_map_name).value();
919+
auto face_shape_map = cgal_shape.property_map<MyMesh::Face_index, IntersectingElemnt>(face_shape_map_name).value();
920920

921921
// bool map for affected edge
922922
using d_prop_bool = CGAL::dynamic_edge_property_t<bool>;

0 commit comments

Comments
 (0)