diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 68cb0f6be9..befa80233b 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -2798,6 +2798,10 @@ static void project_triangles_to_slabs(ConstLayerPtrsAdaptor layers, const index void PrintObject::project_and_append_custom_facets( bool seam, EnforcerBlockerType type, std::vector& out) const { + // BBS: Approve adding enforcer support on vertical faces + SlabSlicingConfig config; + config.isVertical = true; + for (const ModelVolume* mv : this->model_object()->volumes) if (mv->is_model_part()) { const indexed_triangle_set custom_facets = seam @@ -2811,7 +2815,7 @@ void PrintObject::project_and_append_custom_facets( else { std::vector projected; // Support blockers or enforcers. Project downward facing painted areas upwards to their respective slicing plane. - slice_mesh_slabs(custom_facets, zs_from_layers(this->layers()), this->trafo_centered() * mv->get_matrix(), nullptr, &projected, [](){}); + slice_mesh_slabs(custom_facets, zs_from_layers(this->layers()), this->trafo_centered() * mv->get_matrix(), nullptr, &projected, [](){}, config); // Merge these projections with the output, layer by layer. assert(! projected.empty()); assert(out.empty() || out.size() == projected.size()); diff --git a/src/libslic3r/TriangleMeshSlicer.cpp b/src/libslic3r/TriangleMeshSlicer.cpp index 6182dfe641..29f6a8f856 100644 --- a/src/libslic3r/TriangleMeshSlicer.cpp +++ b/src/libslic3r/TriangleMeshSlicer.cpp @@ -753,7 +753,9 @@ inline std::pair slice_slabs_make_lines( const std::vector &zs, bool top, bool bottom, - const ThrowOnCancel throw_on_cancel_fn) + const ThrowOnCancel throw_on_cancel_fn, + // BBS: solve conflicts (see declaration) and most elegant way I can get + SlabSlicingConfig config) { std::pair out; SlabLines &lines_top = out.first; @@ -772,7 +774,7 @@ inline std::pair slice_slabs_make_lines( tbb::parallel_for( tbb::blocked_range(0, int(indices.size())), - [&vertices, &indices, &face_neighbors, &face_edge_ids, num_edges, &face_orientation, &zs, top, bottom, &lines_top, &lines_bottom, &lines_mutex_top, &lines_mutex_bottom, throw_on_cancel_fn] + [&vertices, &indices, &face_neighbors, &face_edge_ids, num_edges, &face_orientation, &zs, top, bottom, &lines_top, &lines_bottom, &lines_mutex_top, &lines_mutex_bottom, throw_on_cancel_fn, &config] (const tbb::blocked_range &range) { for (int face_idx = range.begin(); face_idx < range.end(); ++ face_idx) { if ((face_idx & 0x0ffff) == 0) @@ -790,7 +792,8 @@ inline std::pair slice_slabs_make_lines( } slice_facet_with_slabs(vertices, indices, face_idx, neighbors, edge_ids, num_edges, zs, lines_top, lines_mutex_top); } - if (bottom && (fo == FaceOrientation::Down || fo == FaceOrientation::Degenerate)) { + // BBS: add vertical faces option + if (bottom && (fo == FaceOrientation::Down || (config.isVertical && fo == FaceOrientation::Vertical) || fo == FaceOrientation::Degenerate)) { Vec3i neighbors = face_neighbors[face_idx]; // Reset neighborship of this triangle in case the other triangle is oriented backwards from this one. for (int i = 0; i < 3; ++ i) @@ -1895,7 +1898,8 @@ void slice_mesh_slabs( const Transform3d &trafo, std::vector *out_top, std::vector *out_bottom, - std::function throw_on_cancel) + std::function throw_on_cancel, + SlabSlicingConfig config) { BOOST_LOG_TRIVIAL(debug) << "slice_mesh_slabs to polygons"; @@ -1974,7 +1978,7 @@ void slice_mesh_slabs( std::vector face_edge_ids = its_face_edge_ids(mesh, face_neighbors, true, &num_edges); std::pair lines = slice_slabs_make_lines( vertices_transformed, mesh.indices, face_neighbors, face_edge_ids, num_edges, face_orientation, zs, - out_top != nullptr, out_bottom != nullptr, throw_on_cancel); + out_top != nullptr, out_bottom != nullptr, throw_on_cancel, config); throw_on_cancel(); diff --git a/src/libslic3r/TriangleMeshSlicer.hpp b/src/libslic3r/TriangleMeshSlicer.hpp index 1a8b643629..603e95e78e 100644 --- a/src/libslic3r/TriangleMeshSlicer.hpp +++ b/src/libslic3r/TriangleMeshSlicer.hpp @@ -46,6 +46,19 @@ struct MeshSlicingParamsEx : public MeshSlicingParams double resolution { 0 }; }; +// BBS: MusangKing - NEW: add paint-on support on vertical-faces +// this SlabSlicingConfig aiming to distinguish if slice_slabs_make_lines() outputs lines by slab_slicing on vertical faces +// e.g., for support enforcer operation: isVertical = true; for other color painting operations: isVertical = false (default). +// solve conflicts STUDIO-1183/970/1285 +struct SlabSlicingConfig +{ + SlabSlicingConfig() + : isVertical(false) + {} + + bool isVertical; +}; + // All the following slicing functions shall produce consistent results with the same mesh, same transformation matrix and slicing parameters. // Namely, slice_mesh_slabs() shall produce consistent results with slice_mesh() and slice_mesh_ex() in the sense, that projections made by // slice_mesh_slabs() shall fall onto slicing planes produced by slice_mesh(). @@ -107,7 +120,9 @@ void slice_mesh_slabs( const Transform3d &trafo, std::vector *out_top, std::vector *out_bottom, - std::function throw_on_cancel); + std::function throw_on_cancel, + // BBS: MusangKing + SlabSlicingConfig config = SlabSlicingConfig()); // Project mesh upwards pointing surfaces / downwards pointing surfaces into 2D polygons. void project_mesh(