Skip to content

Commit

Permalink
Fixing corrupted SLA pad
Browse files Browse the repository at this point in the history
fixes SPE-1157
  • Loading branch information
tamasmeszaros committed Jan 7, 2022
1 parent 27ee53b commit ce81c02
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/libslic3r/SLA/Pad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ inline indexed_triangle_set straight_walls(const Polygon &plate,
double lo_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
Expand Down
34 changes: 0 additions & 34 deletions src/libslic3r/SlicesToTriangleMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "SlicesToTriangleMesh.hpp"

//#include "libslic3r/MTUtils.hpp"
#include "libslic3r/Execution/ExecutionTBB.hpp"
#include "libslic3r/ClipperUtils.hpp"
#include "libslic3r/Tesselate.hpp"
Expand All @@ -12,39 +11,6 @@

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.
indexed_triangle_set inline straight_walls(const Polygon &plate,
double lo_z,
Expand Down
31 changes: 31 additions & 0 deletions src/libslic3r/Tesselate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,35 @@ std::vector<Vec2f> triangulate_expolygons_2f(const ExPolygons &polys, bool flip)
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
10 changes: 6 additions & 4 deletions src/libslic3r/Tesselate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
#define slic3r_Tesselate_hpp_

#include <vector>
#include <admesh/stl.h>

#include "Point.hpp"
#include "ExPolygon.hpp"

namespace Slic3r {

class ExPolygon;
typedef std::vector<ExPolygon> ExPolygons;

const bool constexpr NORMALS_UP = false;
const bool constexpr NORMALS_DOWN = true;

Expand All @@ -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_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

#endif /* slic3r_Tesselate_hpp_ */

0 comments on commit ce81c02

Please sign in to comment.