mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-12 20:31:48 +08:00

Renamed its_create_neighbors_index() / its_create_neighbors_index_par() to its_face_neighbors() / its_face_neighbors_par(). New variant of its_face_edge_ids() to create edge IDs from face neighbors. Fixed some incorrect use of _NDEBUG, it should be NDEBUG. PrintObject::slice_support_volumes() returns newly Polygons, which are cheaper than ExPolygons. Updated SeamPlacer and SupportMaterial to use regions defined as Polygons, not ExPolygons. TriangleSelector::get_facets_strict() returning a patch with T-joints retriangulated. New slice_mesh_slabs() - slicing projections of a triangle patch into top / bottom layers of slices, for MMU top / bottom segmentation. TriangleMeshSlicer - use 64 mutexes instead of one when scattering sliced triangles into layers. This makes a big difference on modern many core desktop computers. When applying MM segmented regions to input regions, the split regions are now re-merged with 10x higher positive offset epsilon to avoid creating gaps. When testing for existence of paint-on supports or seam, use a more efficient has_facets() test, which does not deserialize into the expensive TriangleSelector tree structure. GLIndexedVertexArray newly uses Eigen::AlignedBox<float, 3> for efficiency instead of our double based BoundingBoxf3. Improved MMU painting refresh speed by optimizing generation of the vertex buffers. Refactored MMU segmentation - projection of painted surfaces from top / bottom. 1) Parallelized. 2) Using the new slice_mesh_slabs() instead of projecting one triangle by the other and merging them with Clipper.
105 lines
4.1 KiB
C++
105 lines
4.1 KiB
C++
#ifndef slic3r_TriangleMeshSlicer_hpp_
|
|
#define slic3r_TriangleMeshSlicer_hpp_
|
|
|
|
#include <functional>
|
|
#include <vector>
|
|
#include "Polygon.hpp"
|
|
#include "ExPolygon.hpp"
|
|
|
|
namespace Slic3r {
|
|
|
|
struct MeshSlicingParams
|
|
{
|
|
enum class SlicingMode : uint32_t {
|
|
// Regular slicing, maintain all contours and their orientation.
|
|
// slice_mesh_ex() applies ClipperLib::pftNonZero rule to the result of slice_mesh().
|
|
Regular,
|
|
// For slicing 3DLabPrints plane models (aka to be compatible with S3D default strategy).
|
|
// slice_mesh_ex() applies ClipperLib::pftEvenOdd rule. slice_mesh() slices EvenOdd as Regular.
|
|
EvenOdd,
|
|
// Maintain all contours, orient all contours CCW.
|
|
// slice_mesh_ex() applies ClipperLib::pftNonZero rule, thus holes will be closed.
|
|
Positive,
|
|
// Orient all contours CCW and keep only the contour with the largest area.
|
|
// This mode is useful for slicing complex objects in vase mode.
|
|
PositiveLargestContour,
|
|
};
|
|
|
|
SlicingMode mode { SlicingMode::Regular };
|
|
// For vase mode: below this layer a different slicing mode will be used to produce a single contour.
|
|
// 0 = ignore.
|
|
size_t slicing_mode_normal_below_layer { 0 };
|
|
// Mode to apply below slicing_mode_normal_below_layer. Ignored if slicing_mode_nromal_below_layer == 0.
|
|
SlicingMode mode_below { SlicingMode::Regular };
|
|
// Transforming faces during the slicing.
|
|
Transform3d trafo { Transform3d::Identity() };
|
|
};
|
|
|
|
struct MeshSlicingParamsEx : public MeshSlicingParams
|
|
{
|
|
// Morphological closing operation when creating output expolygons, unscaled.
|
|
float closing_radius { 0 };
|
|
// Positive offset applied when creating output expolygons, unscaled.
|
|
float extra_offset { 0 };
|
|
// Resolution for contour simplification, unscaled.
|
|
// 0 = don't simplify.
|
|
double resolution { 0 };
|
|
};
|
|
|
|
std::vector<Polygons> slice_mesh(
|
|
const indexed_triangle_set &mesh,
|
|
const std::vector<float> &zs,
|
|
const MeshSlicingParams ¶ms,
|
|
std::function<void()> throw_on_cancel = []{});
|
|
|
|
std::vector<ExPolygons> slice_mesh_ex(
|
|
const indexed_triangle_set &mesh,
|
|
const std::vector<float> &zs,
|
|
const MeshSlicingParamsEx ¶ms,
|
|
std::function<void()> throw_on_cancel = []{});
|
|
|
|
inline std::vector<ExPolygons> slice_mesh_ex(
|
|
const indexed_triangle_set &mesh,
|
|
const std::vector<float> &zs,
|
|
std::function<void()> throw_on_cancel = []{})
|
|
{
|
|
return slice_mesh_ex(mesh, zs, MeshSlicingParamsEx{}, throw_on_cancel);
|
|
}
|
|
|
|
inline std::vector<ExPolygons> slice_mesh_ex(
|
|
const indexed_triangle_set &mesh,
|
|
const std::vector<float> &zs,
|
|
float closing_radius,
|
|
std::function<void()> throw_on_cancel = []{})
|
|
{
|
|
MeshSlicingParamsEx params;
|
|
params.closing_radius = closing_radius;
|
|
return slice_mesh_ex(mesh, zs, params, throw_on_cancel);
|
|
}
|
|
|
|
// Slice a triangle set with a set of Z slabs (thick layers).
|
|
// The effect is similar to producing the usual top / bottom layers from a sliced mesh by
|
|
// subtracting layer[i] from layer[i - 1] for the top surfaces resp.
|
|
// subtracting layer[i] from layer[i + 1] for the bottom surfaces,
|
|
// with the exception that the triangle set this function processes may not cover the whole top resp. bottom surface.
|
|
// top resp. bottom surfaces are calculated only if out_top resp. out_bottom is not null.
|
|
void slice_mesh_slabs(
|
|
const indexed_triangle_set &mesh,
|
|
// Unscaled Zs
|
|
const std::vector<float> &zs,
|
|
const Transform3d &trafo,
|
|
std::vector<Polygons> *out_top,
|
|
std::vector<Polygons> *out_bottom,
|
|
std::function<void()> throw_on_cancel);
|
|
|
|
void cut_mesh(
|
|
const indexed_triangle_set &mesh,
|
|
float z,
|
|
indexed_triangle_set *upper,
|
|
indexed_triangle_set *lower,
|
|
bool triangulate_caps = true);
|
|
|
|
}
|
|
|
|
#endif // slic3r_TriangleMeshSlicer_hpp_
|