FIxed build errors caused by merge and flipped normals of the SLA pool walls.

This commit is contained in:
tamasmeszaros 2018-08-27 11:59:37 +02:00
parent d749080261
commit e667203825
3 changed files with 39 additions and 32 deletions

View File

@ -774,7 +774,7 @@ target_link_libraries(slic3r libslic3r libslic3r_gui admesh miniz ${Boost_LIBRAR
add_executable(slabasebed ${PROJECT_SOURCE_DIR}/src/slabasebed.cpp) add_executable(slabasebed ${PROJECT_SOURCE_DIR}/src/slabasebed.cpp)
target_include_directories(slabasebed PRIVATE src src/libslic3r) target_include_directories(slabasebed PRIVATE src src/libslic3r)
target_link_libraries(slabasebed libslic3r libslic3r_gui admesh miniz ${Boost_LIBRARIES} clipper ${EXPAT_LIBRARIES} ${GLEW_LIBRARIES} polypartition poly2tri ${TBB_LIBRARIES} ${wxWidgets_LIBRARIES}) target_link_libraries(slabasebed libslic3r libslic3r_gui qhull admesh miniz ${Boost_LIBRARIES} clipper ${EXPAT_LIBRARIES} ${GLEW_LIBRARIES} polypartition poly2tri ${TBB_LIBRARIES} ${wxWidgets_LIBRARIES})
if(SLIC3R_PROFILE) if(SLIC3R_PROFILE)
target_link_libraries(Shiny) target_link_libraries(Shiny)

View File

@ -237,6 +237,12 @@ public:
} }
}; };
// Let's shadow this eigen interface
inline coord_t px(const Point& p) { return p(0); }
inline coord_t py(const Point& p) { return p(1); }
inline coordf_t px(const Vec2d& p) { return p(0); }
inline coordf_t py(const Vec2d& p) { return p(1); }
template<FilePrinterFormat format, class...Args> template<FilePrinterFormat format, class...Args>
void print_to(Print& print, void print_to(Print& print,
std::string dirpath, std::string dirpath,
@ -247,10 +253,6 @@ void print_to(Print& print,
std::string& dir = dirpath; std::string& dir = dirpath;
// Let's shadow this eigen interface
auto px = [](const Point& p) { return p(0); };
auto py = [](const Point& p) { return p(1); };
// This map will hold the layers sorted by z coordinate. Layers on the // This map will hold the layers sorted by z coordinate. Layers on the
// same height (from different objects) will be mapped to the same key and // same height (from different objects) will be mapped to the same key and
// rasterized to the same image. // rasterized to the same image.
@ -272,13 +274,13 @@ void print_to(Print& print,
}); });
auto print_bb = print.bounding_box(); auto print_bb = print.bounding_box();
Vec2d punsc = unscale(print_bb.size());
// If the print does not fit into the print area we should cry about it. // If the print does not fit into the print area we should cry about it.
if(unscale(px(print_bb.size())) > width_mm || if(px(punsc) > width_mm || py(punsc) > height_mm) {
unscale(py(print_bb.size())) > height_mm) {
BOOST_LOG_TRIVIAL(warning) << "Warning: Print will not fit!" << "\n" BOOST_LOG_TRIVIAL(warning) << "Warning: Print will not fit!" << "\n"
<< "Width needed: " << unscale(px(print_bb.size())) << "\n" << "Width needed: " << px(punsc) << "\n"
<< "Height needed: " << unscale(py(print_bb.size())) << "\n"; << "Height needed: " << py(punsc) << "\n";
} }
// Offset for centering the print onto the print area // Offset for centering the print onto the print area
@ -306,7 +308,7 @@ void print_to(Print& print,
print.set_status(initstatus, jobdesc); print.set_status(initstatus, jobdesc);
// Method that prints one layer // Method that prints one layer
auto process_layer = [px, py, &layers, &keys, &printer, &st_prev, &m, auto process_layer = [&layers, &keys, &printer, &st_prev, &m,
&jobdesc, print_bb, dir, cx, cy, &print, initstatus] &jobdesc, print_bb, dir, cx, cy, &print, initstatus]
(unsigned layer_id) (unsigned layer_id)
{ {

View File

@ -24,25 +24,26 @@ inline coord_t y(const Point& p) { return p(1); }
inline coord_t& x(Point& p) { return p(0); } inline coord_t& x(Point& p) { return p(0); }
inline coord_t& y(Point& p) { return p(1); } inline coord_t& y(Point& p) { return p(1); }
inline coordf_t x(const Pointf3& p) { return p(0); } inline coordf_t x(const Vec3d& p) { return p(0); }
inline coordf_t y(const Pointf3& p) { return p(1); } inline coordf_t y(const Vec3d& p) { return p(1); }
inline coordf_t z(const Pointf3& p) { return p(2); } inline coordf_t z(const Vec3d& p) { return p(2); }
inline coordf_t& x(Pointf3& p) { return p(0); } inline coordf_t& x(Vec3d& p) { return p(0); }
inline coordf_t& y(Pointf3& p) { return p(1); } inline coordf_t& y(Vec3d& p) { return p(1); }
inline coordf_t& z(Pointf3& p) { return p(2); } inline coordf_t& z(Vec3d& p) { return p(2); }
inline coord_t& x(Point3& p) { return p(0); } inline coord_t& x(Vec3crd& p) { return p(0); }
inline coord_t& y(Point3& p) { return p(1); } inline coord_t& y(Vec3crd& p) { return p(1); }
inline coord_t& z(Point3& p) { return p(2); } inline coord_t& z(Vec3crd& p) { return p(2); }
inline coord_t x(const Point3& p) { return p(0); } inline coord_t x(const Vec3crd& p) { return p(0); }
inline coord_t y(const Point3& p) { return p(1); } inline coord_t y(const Vec3crd& p) { return p(1); }
inline coord_t z(const Point3& p) { return p(2); } inline coord_t z(const Vec3crd& p) { return p(2); }
using Indices = std::vector<Vec3crd>;
/// Intermediate struct for a 3D mesh /// Intermediate struct for a 3D mesh
struct Contour3D { struct Contour3D {
Pointf3s points; Pointf3s points;
std::vector<Point3> indices; Indices indices;
void merge(const Contour3D& ctr) { void merge(const Contour3D& ctr) {
auto s3 = coord_t(points.size()); auto s3 = coord_t(points.size());
@ -62,7 +63,7 @@ inline Contour3D convert(const Polygons& triangles, coord_t z, bool dir) {
Pointf3s points; Pointf3s points;
points.reserve(3*triangles.size()); points.reserve(3*triangles.size());
std::vector<Point3> indices; Indices indices;
indices.reserve(points.size()); indices.reserve(points.size());
for(auto& tr : triangles) { for(auto& tr : triangles) {
@ -70,7 +71,7 @@ inline Contour3D convert(const Polygons& triangles, coord_t z, bool dir) {
if(dir) indices.emplace_back(a, b, c); if(dir) indices.emplace_back(a, b, c);
else indices.emplace_back(c, b, a); else indices.emplace_back(c, b, a);
for(auto& p : tr.points) { for(auto& p : tr.points) {
points.emplace_back(Pointf3::new_unscale(x(p), y(p), z)); points.emplace_back(unscale(x(p), y(p), z));
} }
} }
@ -125,11 +126,12 @@ inline Contour3D walls(const ExPolygon& floor_plate, const ExPolygon& ceiling,
{ {
for(auto& p : pp.points) for(auto& p : pp.points)
if(is_upper(p)) if(is_upper(p))
rp.emplace_back(Pointf3::new_unscale(x(p), y(p), mm(cz))); rp.emplace_back(unscale(x(p), y(p), mm(cz)));
else rp.emplace_back(Pointf3::new_unscale(x(p), y(p), mm(fz))); else rp.emplace_back(unscale(x(p), y(p), mm(fz)));
coord_t a = idx++, b = idx++, c = idx++; coord_t a = idx++, b = idx++, c = idx++;
rpi.emplace_back(a, b, c); if(fz > cz) rpi.emplace_back(c, b, a);
else rpi.emplace_back(a, b, c);
}); });
return ret; return ret;
@ -217,6 +219,7 @@ inline Contour3D round_edges(const ExPolygon& base_plate,
const int portion = int(steps*degrees / 90); const int portion = int(steps*degrees / 90);
const double ystep_mm = radius_mm/steps; const double ystep_mm = radius_mm/steps;
coord_t s = dir? 1 : -1; coord_t s = dir? 1 : -1;
double xxprev = 0;
for(int i = 0; i < portion; i++) { for(int i = 0; i < portion; i++) {
ob = base_plate; ob = base_plate;
@ -235,11 +238,13 @@ inline Contour3D round_edges(const ExPolygon& base_plate,
wh = ceilheight_mm - i*ystep_mm; wh = ceilheight_mm - i*ystep_mm;
Contour3D pwalls; Contour3D pwalls;
pwalls = walls(ob, ob_prev, wh, wh_prev); if(xxprev < xx) pwalls = walls(ob, ob_prev, wh, wh_prev);
else pwalls = walls(ob_prev, ob, wh_prev, wh);
curvedwalls.merge(pwalls); curvedwalls.merge(pwalls);
ob_prev = ob; ob_prev = ob;
wh_prev = wh; wh_prev = wh;
xxprev = xx;
} }
last_offset = std::move(ob); last_offset = std::move(ob);
@ -264,7 +269,7 @@ inline Contour3D inner_bed(const ExPolygon& poly, double depth_mm,
// Generate outer walls // Generate outer walls
auto fp = [](const Point& p, Point::coord_type z) { auto fp = [](const Point& p, Point::coord_type z) {
return Pointf3::new_unscale(x(p), y(p), z); return unscale(x(p), y(p), z);
}; };
for(auto& l : lines) { for(auto& l : lines) {
@ -275,8 +280,8 @@ inline Contour3D inner_bed(const ExPolygon& poly, double depth_mm,
bottom.points.emplace_back(fp(l.a, begin_h)); bottom.points.emplace_back(fp(l.a, begin_h));
bottom.points.emplace_back(fp(l.b, begin_h)); bottom.points.emplace_back(fp(l.b, begin_h));
bottom.indices.emplace_back(s, s + 1, s + 3); bottom.indices.emplace_back(s + 3, s + 1, s);
bottom.indices.emplace_back(s, s + 3, s + 2); bottom.indices.emplace_back(s + 2, s + 3, s);
} }
return bottom; return bottom;