Fix for release mode

PropertyMap can't be created into reference !!!
This commit is contained in:
Filip Sykala - NTB T15p 2022-07-13 08:26:59 +02:00
parent 84215eb136
commit 3e7b0506c3
2 changed files with 23 additions and 23 deletions

View File

@ -20,7 +20,7 @@
/// patches/patch{O}.off /// patches/patch{O}.off
/// result.obj - Merged result its /// result.obj - Merged result its
/// result_contours/{O}.obj - visualization of contours for result patches /// result_contours/{O}.obj - visualization of contours for result patches
//#define DEBUG_OUTPUT_DIR std::string("C:/data/temp/cutSurface/") #define DEBUG_OUTPUT_DIR std::string("C:/data/temp/cutSurface/")
using namespace Slic3r; using namespace Slic3r;
@ -943,11 +943,11 @@ priv::CutMesh priv::to_cgal(const indexed_triangle_set &its,
priv::CutMesh priv::to_cgal(const ExPolygons &shapes, priv::CutMesh priv::to_cgal(const ExPolygons &shapes,
const Project &projection) const Project &projection)
{ {
CutMesh result; if (shapes.empty()) return {};
if (shapes.empty()) return result;
EdgeShapeMap& edge_shape_map = result.add_property_map<EI, IntersectingElement>(edge_shape_map_name).first; CutMesh result;
FaceShapeMap& face_shape_map = result.add_property_map<FI, IntersectingElement>(face_shape_map_name).first; EdgeShapeMap edge_shape_map = result.add_property_map<EI, IntersectingElement>(edge_shape_map_name).first;
FaceShapeMap face_shape_map = result.add_property_map<FI, IntersectingElement>(face_shape_map_name).first;
std::vector<VI> indices; std::vector<VI> indices;
auto insert_contour = [&projection, &indices, &result, auto insert_contour = [&projection, &indices, &result,
@ -956,18 +956,17 @@ priv::CutMesh priv::to_cgal(const ExPolygons &shapes,
indices.clear(); indices.clear();
indices.reserve(polygon.points.size() * 2); indices.reserve(polygon.points.size() * 2);
size_t num_vertices_old = result.number_of_vertices(); size_t num_vertices_old = result.number_of_vertices();
for (const Point &p2 : polygon.points) { for (const Point &polygon_point : polygon.points) {
auto p = projection.create_front_back(p2); auto [front, back] = projection.create_front_back(polygon_point);
CutMesh::Point v_first{p.first.x(), p.first.y(), p.first.z()}; P3 v_front{front.x(), front.y(), front.z()};
CutMesh::Point v_second{p.second.x(), p.second.y(), p.second.z()}; VI vi1 = result.add_vertex(v_front);
assert(vi1.idx() == (indices.size() + num_vertices_old));
indices.push_back(vi1);
VI reduction_from = result.add_vertex(v_first); P3 v_back{back.x(), back.y(), back.z()};
assert(size_t(reduction_from) == (indices.size() + num_vertices_old)); VI vi2 = result.add_vertex(v_back);
indices.emplace_back(reduction_from); assert(vi2.idx() == (indices.size() + num_vertices_old));
indices.push_back(vi2);
reduction_from = result.add_vertex(v_second);
assert(size_t(reduction_from) == (indices.size() + num_vertices_old));
indices.emplace_back(reduction_from);
} }
auto find_edge = [&result](FI fi, VI from, VI to) { auto find_edge = [&result](FI fi, VI from, VI to) {
@ -2603,7 +2602,7 @@ priv::SurfacePatch priv::create_reduced_patch(CutAOI &cut,
assert(count_edges >= cm.edges().size()); assert(count_edges >= cm.edges().size());
// convert VI from this patch to source VI, when exist // convert VI from this patch to source VI, when exist
CvtVI2VI &cvt = cm.add_property_map<VI, VI>(patch_source_name).first; CvtVI2VI cvt = cm.add_property_map<VI, VI>(patch_source_name).first;
// vi_s .. VertexIndex into mesh (source) // vi_s .. VertexIndex into mesh (source)
// vi_d .. new VertexIndex in cm (destination) // vi_d .. new VertexIndex in cm (destination)
for (uint32_t vi_s = 0; vi_s < v_cvt.size(); ++vi_s) { for (uint32_t vi_s = 0; vi_s < v_cvt.size(); ++vi_s) {
@ -2658,7 +2657,7 @@ priv::SurfacePatch priv::create_surface_patch(const std::vector<FI> &fis, const
assert(count_edges >= cm.edges().size()); assert(count_edges >= cm.edges().size());
// convert VI from this patch to source VI, when exist // convert VI from this patch to source VI, when exist
CvtVI2VI& cvt = cm.add_property_map<VI, VI>(patch_source_name).first; CvtVI2VI cvt = cm.add_property_map<VI, VI>(patch_source_name).first;
// vi_s .. VertexIndex into mesh (source) // vi_s .. VertexIndex into mesh (source)
// vi_d .. new VertexIndex in cm (destination) // vi_d .. new VertexIndex in cm (destination)
for (uint32_t vi_s = 0; vi_s < v_cvt.size(); ++vi_s) { for (uint32_t vi_s = 0; vi_s < v_cvt.size(); ++vi_s) {
@ -2756,7 +2755,7 @@ void priv::divide_patch(size_t i, SurfacePatches &patches) {
CutMesh& cm = patch.mesh; CutMesh& cm = patch.mesh;
std::string patch_number_name = "f:patch_number"; std::string patch_number_name = "f:patch_number";
PatchNumber& patch_number = cm.add_property_map<FI, size_t>(patch_number_name, {def_value}).first; PatchNumber patch_number = cm.add_property_map<FI, size_t>(patch_number_name, {def_value}).first;
size_t number = 0; size_t number = 0;
std::vector<FI> queue; std::vector<FI> queue;
@ -2889,7 +2888,7 @@ priv::SurfacePatches priv::diff_models(VCutAOIs &cuts,
CutAOIs &model_cuts = cuts[model_index]; CutAOIs &model_cuts = cuts[model_index];
CutMesh &cut_model_ = cut_models[model_index]; CutMesh &cut_model_ = cut_models[model_index];
const CutMesh &cut_model = cut_model_; const CutMesh &cut_model = cut_model_;
ReductionMap& vertex_reduction_map = cut_model_.add_property_map<VI, VI>(vertex_reduction_map_name).first; ReductionMap vertex_reduction_map = cut_model_.add_property_map<VI, VI>(vertex_reduction_map_name).first;
create_reduce_map(vertex_reduction_map, cut_model); create_reduce_map(vertex_reduction_map, cut_model);
for (size_t cut_index = 0; cut_index < model_cuts.size(); ++cut_index, ++index) { for (size_t cut_index = 0; cut_index < model_cuts.size(); ++cut_index, ++index) {

View File

@ -18,8 +18,8 @@ TEST_CASE("Cut character from surface", "[]")
std::optional<Emboss::Glyph> glyph = std::optional<Emboss::Glyph> glyph =
Emboss::letter2glyph(*font, font_index, letter, flatness); Emboss::letter2glyph(*font, font_index, letter, flatness);
REQUIRE(glyph.has_value()); REQUIRE(glyph.has_value());
ExPolygons shape = glyph->shape; ExPolygons shapes = glyph->shape;
REQUIRE(!shape.empty()); REQUIRE(!shapes.empty());
Transform3d tr = Transform3d::Identity(); Transform3d tr = Transform3d::Identity();
tr.translate(Vec3d(0., 0., -z_depth)); tr.translate(Vec3d(0., 0., -z_depth));
@ -32,8 +32,9 @@ TEST_CASE("Cut character from surface", "[]")
its_translate(cube2, Vec3f(100, -40, 7.5)); its_translate(cube2, Vec3f(100, -40, 7.5));
its_merge(object, std::move(cube2)); its_merge(object, std::move(cube2));
std::vector<indexed_triangle_set> objects{object};
// Call core function for cut surface // Call core function for cut surface
auto surfaces = cut_surface(shape, {object}, cut_projection, 0); auto surfaces = cut_surface(shapes, objects, cut_projection, 0.5);
CHECK(!surfaces.empty()); CHECK(!surfaces.empty());
Emboss::OrthoProject projection(Transform3d::Identity(), Emboss::OrthoProject projection(Transform3d::Identity(),