Fixing corrupted SLA pad

fixes SPE-1157
This commit is contained in:
tamasmeszaros 2021-12-20 14:45:10 +01:00
parent 27ee53b9e3
commit ce81c02049
4 changed files with 38 additions and 39 deletions

View File

@ -47,7 +47,7 @@ inline indexed_triangle_set straight_walls(const Polygon &plate,
double lo_z, double lo_z,
double hi_z) double hi_z)
{ {
return walls(plate, plate, lo_z, hi_z); return wall_strip(plate, hi_z, lo_z); //walls(plate, plate, lo_z, hi_z);
} }
// Function to cut tiny connector cavities for a given polygon. The input poly // Function to cut tiny connector cavities for a given polygon. The input poly

View File

@ -2,7 +2,6 @@
#include "SlicesToTriangleMesh.hpp" #include "SlicesToTriangleMesh.hpp"
//#include "libslic3r/MTUtils.hpp"
#include "libslic3r/Execution/ExecutionTBB.hpp" #include "libslic3r/Execution/ExecutionTBB.hpp"
#include "libslic3r/ClipperUtils.hpp" #include "libslic3r/ClipperUtils.hpp"
#include "libslic3r/Tesselate.hpp" #include "libslic3r/Tesselate.hpp"
@ -12,39 +11,6 @@
namespace Slic3r { namespace Slic3r {
inline indexed_triangle_set wall_strip(const Polygon &poly,
double lower_z_mm,
double upper_z_mm)
{
indexed_triangle_set ret;
size_t startidx = ret.vertices.size();
size_t offs = poly.points.size();
ret.vertices.reserve(ret.vertices.size() + 2 *offs);
// The expression unscaled(p).cast<float>().eval() is important here
// as it ensures identical conversion of 2D scaled coordinates to float 3D
// to that used by the tesselation. This way, the duplicated vertices in the
// output mesh can be found with the == operator of the points.
// its_merge_vertices will then reliably remove the duplicates.
for (const Point &p : poly.points)
ret.vertices.emplace_back(to_3d(unscaled(p).cast<float>().eval(), float(lower_z_mm)));
for (const Point &p : poly.points)
ret.vertices.emplace_back(to_3d(unscaled(p).cast<float>().eval(), float(upper_z_mm)));
for (size_t i = startidx + 1; i < startidx + offs; ++i) {
ret.indices.emplace_back(i - 1, i, i + offs - 1);
ret.indices.emplace_back(i, i + offs, i + offs - 1);
}
ret.indices.emplace_back(startidx + offs - 1, startidx, startidx + 2 * offs - 1);
ret.indices.emplace_back(startidx, startidx + offs, startidx + 2 * offs - 1);
return ret;
}
// Same as walls() but with identical higher and lower polygons. // Same as walls() but with identical higher and lower polygons.
indexed_triangle_set inline straight_walls(const Polygon &plate, indexed_triangle_set inline straight_walls(const Polygon &plate,
double lo_z, double lo_z,

View File

@ -245,4 +245,35 @@ std::vector<Vec2f> triangulate_expolygons_2f(const ExPolygons &polys, bool flip)
return out; return out;
} }
indexed_triangle_set wall_strip(const Polygon &poly, double lower_z_mm, double upper_z_mm)
{
indexed_triangle_set ret;
size_t startidx = ret.vertices.size();
size_t offs = poly.points.size();
ret.vertices.reserve(ret.vertices.size() + 2 *offs);
// The expression unscaled(p).cast<float>().eval() is important here
// as it ensures identical conversion of 2D scaled coordinates to float 3D
// to that used by the tesselation. This way, the duplicated vertices in the
// output mesh can be found with the == operator of the points.
// its_merge_vertices will then reliably remove the duplicates.
for (const Point &p : poly.points)
ret.vertices.emplace_back(to_3d(unscaled(p).cast<float>().eval(), float(lower_z_mm)));
for (const Point &p : poly.points)
ret.vertices.emplace_back(to_3d(unscaled(p).cast<float>().eval(), float(upper_z_mm)));
for (size_t i = startidx + 1; i < startidx + offs; ++i) {
ret.indices.emplace_back(i - 1, i, i + offs - 1);
ret.indices.emplace_back(i, i + offs, i + offs - 1);
}
ret.indices.emplace_back(startidx + offs - 1, startidx, startidx + 2 * offs - 1);
ret.indices.emplace_back(startidx, startidx + offs, startidx + 2 * offs - 1);
return ret;
}
} // namespace Slic3r } // namespace Slic3r

View File

@ -2,14 +2,12 @@
#define slic3r_Tesselate_hpp_ #define slic3r_Tesselate_hpp_
#include <vector> #include <vector>
#include <admesh/stl.h>
#include "Point.hpp" #include "ExPolygon.hpp"
namespace Slic3r { namespace Slic3r {
class ExPolygon;
typedef std::vector<ExPolygon> ExPolygons;
const bool constexpr NORMALS_UP = false; const bool constexpr NORMALS_UP = false;
const bool constexpr NORMALS_DOWN = true; const bool constexpr NORMALS_DOWN = true;
@ -20,6 +18,10 @@ extern std::vector<Vec2d> triangulate_expolygons_2d(const ExPolygons &polys, boo
extern std::vector<Vec2f> triangulate_expolygon_2f (const ExPolygon &poly, bool flip = NORMALS_UP); extern std::vector<Vec2f> triangulate_expolygon_2f (const ExPolygon &poly, bool flip = NORMALS_UP);
extern std::vector<Vec2f> triangulate_expolygons_2f(const ExPolygons &polys, bool flip = NORMALS_UP); extern std::vector<Vec2f> triangulate_expolygons_2f(const ExPolygons &polys, bool flip = NORMALS_UP);
indexed_triangle_set wall_strip(const Polygon &poly,
double lower_z_mm,
double upper_z_mm);
} // namespace Slic3r } // namespace Slic3r
#endif /* slic3r_Tesselate_hpp_ */ #endif /* slic3r_Tesselate_hpp_ */