Warning hunt session followup

This commit is contained in:
tamasmeszaros 2019-06-17 10:05:46 +02:00
parent 9ffd294f07
commit ce22251707
4 changed files with 37 additions and 82 deletions

View file

@ -62,9 +62,10 @@ Contour3D walls(const Polygon& lower, const Polygon& upper,
// Copy the points into the mesh, convert them from 2D to 3D
rpts.reserve(upoints.size() + lpoints.size());
ind.reserve(2 * upoints.size() + 2 * lpoints.size());
const double sf = SCALING_FACTOR;
for(auto& p : upoints) rpts.emplace_back(p.x()*sf, p.y()*sf, upper_z_mm);
for(auto& p : lpoints) rpts.emplace_back(p.x()*sf, p.y()*sf, lower_z_mm);
for (auto &p : upoints)
rpts.emplace_back(unscaled(p.x()), unscaled(p.y()), upper_z_mm);
for (auto &p : lpoints)
rpts.emplace_back(unscaled(p.x()), unscaled(p.y()), lower_z_mm);
// Create pointing indices into vertex arrays. u-upper, l-lower
size_t uidx = 0, lidx = offs, unextidx = 1, lnextidx = offs + 1;
@ -202,7 +203,7 @@ void offset(ExPolygon& sh, coord_t distance) {
}
ClipperOffset offs;
offs.ArcTolerance = 0.01*mm(1);
offs.ArcTolerance = 0.01*scaled(1.0);
Paths result;
offs.AddPath(ctour, jtRound, etClosedPolygon);
offs.AddPaths(holes, jtRound, etClosedPolygon);
@ -305,16 +306,6 @@ ExPolygons unify(const ExPolygons& shapes) {
return retv;
}
/// Only a debug function to generate top and bottom plates from a 2D shape.
/// It is not used in the algorithm directly.
inline Contour3D roofs(const ExPolygon& poly, coord_t z_distance) {
auto lower = triangulate_expolygon_3d(poly);
auto upper = triangulate_expolygon_3d(poly, z_distance*SCALING_FACTOR, true);
Contour3D ret;
ret.merge(lower); ret.merge(upper);
return ret;
}
/// This method will create a rounded edge around a flat polygon in 3d space.
/// 'base_plate' parameter is the target plate.
/// 'radius' is the radius of the edges.
@ -360,7 +351,7 @@ Contour3D round_edges(const ExPolygon& base_plate,
double x2 = xx*xx;
double stepy = std::sqrt(r2 - x2);
offset(ob, s*mm(xx));
offset(ob, s*scaled(xx));
wh = ceilheight_mm - radius_mm + stepy;
Contour3D pwalls;
@ -384,7 +375,7 @@ Contour3D round_edges(const ExPolygon& base_plate,
double xx = radius_mm - i*stepx;
double x2 = xx*xx;
double stepy = std::sqrt(r2 - x2);
offset(ob, s*mm(xx));
offset(ob, s*scaled(xx));
wh = ceilheight_mm - radius_mm - stepy;
Contour3D pwalls;
@ -404,41 +395,6 @@ Contour3D round_edges(const ExPolygon& base_plate,
return curvedwalls;
}
/// Generating the concave part of the 3D pool with the bottom plate and the
/// side walls.
Contour3D inner_bed(const ExPolygon& poly,
double depth_mm,
double begin_h_mm = 0)
{
Contour3D bottom;
Pointf3s triangles = triangulate_expolygon_3d(poly, -depth_mm + begin_h_mm);
bottom.merge(triangles);
coord_t depth = mm(depth_mm);
coord_t begin_h = mm(begin_h_mm);
auto lines = poly.lines();
// Generate outer walls
auto fp = [](const Point& p, Point::coord_type z) {
return unscale(x(p), y(p), z);
};
for(auto& l : lines) {
auto s = coord_t(bottom.points.size());
bottom.points.emplace_back(fp(l.a, -depth + begin_h));
bottom.points.emplace_back(fp(l.b, -depth + begin_h));
bottom.points.emplace_back(fp(l.a, begin_h));
bottom.points.emplace_back(fp(l.b, begin_h));
bottom.indices.emplace_back(s + 3, s + 1, s);
bottom.indices.emplace_back(s + 2, s + 3, s);
}
return bottom;
}
inline Point centroid(Points& pp) {
Point c;
switch(pp.size()) {
@ -520,7 +476,7 @@ ExPolygons concave_hull(const ExPolygons& polys, double max_dist_mm = 50,
double dx = x(c) - x(cc), dy = y(c) - y(cc);
double l = std::sqrt(dx * dx + dy * dy);
double nx = dx / l, ny = dy / l;
double max_dist = mm(max_dist_mm);
double max_dist = scaled(max_dist_mm);
ExPolygon& expo = punion[idx++];
BoundingBox querybb(expo);
@ -536,10 +492,10 @@ ExPolygons concave_hull(const ExPolygons& polys, double max_dist_mm = 50,
ctour.reserve(3);
ctour.emplace_back(cc);
Point d(coord_t(mm(1)*nx), coord_t(mm(1)*ny));
Point d(coord_t(scaled(1.)*nx), coord_t(scaled(1.)*ny));
ctour.emplace_back(c + Point( -y(d), x(d) ));
ctour.emplace_back(c + Point( y(d), -x(d) ));
offset(r, mm(1));
offset(r, scaled(1.));
return r;
});
@ -571,15 +527,16 @@ void base_plate(const TriangleMesh &mesh, ExPolygons &output, float h,
// Now we have to unify all slice layers which can be an expensive operation
// so we will try to simplify the polygons
ExPolygons tmp; tmp.reserve(count);
for(ExPolygons& o : out) for(ExPolygon& e : o) {
auto&& exss = e.simplify(0.1/SCALING_FACTOR);
for(ExPolygons& o : out)
for(ExPolygon& e : o) {
auto&& exss = e.simplify(scaled(0.1));
for(ExPolygon& ep : exss) tmp.emplace_back(std::move(ep));
}
ExPolygons utmp = unify(tmp);
for(auto& o : utmp) {
auto&& smp = o.simplify(0.1/SCALING_FACTOR);
auto&& smp = o.simplify(scaled(0.1));
output.insert(output.end(), smp.begin(), smp.end());
}
}
@ -609,11 +566,11 @@ Contour3D create_base_pool(const ExPolygons &ground_layer,
const double bottom_offs = (thickness + wingheight) / std::tan(slope);
// scaled values
const coord_t s_thickness = mm(thickness);
const coord_t s_eradius = mm(cfg.edge_radius_mm);
const coord_t s_thickness = scaled(thickness);
const coord_t s_eradius = scaled(cfg.edge_radius_mm);
const coord_t s_safety_dist = 2*s_eradius + coord_t(0.8*s_thickness);
const coord_t s_wingdist = mm(wingdist);
const coord_t s_bottom_offs = mm(bottom_offs);
const coord_t s_wingdist = scaled(wingdist);
const coord_t s_bottom_offs = scaled(bottom_offs);
auto& thrcl = cfg.throw_on_cancel;

View file

@ -11,11 +11,6 @@
namespace Slic3r {
namespace sla {
using coord_t = Point::coord_type;
/// get the scaled clipper units for a millimeter value
inline coord_t mm(double v) { return coord_t(v/SCALING_FACTOR); }
/// Get x and y coordinates (because we are eigenizing...)
inline coord_t x(const Point& p) { return p(0); }
inline coord_t y(const Point& p) { return p(1); }

View file

@ -49,29 +49,31 @@ typedef double coordf_t;
//inline coord_t scale_(coordf_t v) { return coord_t(floor(v / SCALING_FACTOR + 0.5f)); }
#define scale_(val) ((val) / SCALING_FACTOR)
#if defined(_MSC_VER) && (_MSC_VER < 1910)
template<class Tf> inline coord_t scaled(Tf val)
#define SCALED_EPSILON scale_(EPSILON)
#define SLIC3R_DEBUG_OUT_PATH_PREFIX "out/"
#if defined(_MSC_VER) && _MSC_VER < 1900
# define SLIC3R_CONSTEXPR
# define SLIC3R_NOEXCEPT
#else
template<class Tf> inline constexpr coord_t scaled(Tf val)
#endif // _MSC_VER
#define SLIC3R_CONSTEXPR constexpr
#define SLIC3R_NOEXCEPT noexcept
#endif
template<class Tf> inline SLIC3R_CONSTEXPR coord_t scaled(Tf val)
{
static_assert (std::is_floating_point<Tf>::value, "Floating point only");
return coord_t(val / Tf(SCALING_FACTOR));
}
#if defined(_MSC_VER) && (_MSC_VER < 1910)
template<class Tf> inline Tf unscaled(coord_t val)
#else
template<class Tf> inline constexpr Tf unscaled(coord_t val)
#endif // _MSC_VER
template<class Tf = double> inline SLIC3R_CONSTEXPR Tf unscaled(coord_t val)
{
static_assert (std::is_floating_point<Tf>::value, "Floating point only");
return Tf(val * Tf(SCALING_FACTOR));
}
#define SCALED_EPSILON scale_(EPSILON)
#define SLIC3R_DEBUG_OUT_PATH_PREFIX "out/"
inline SLIC3R_CONSTEXPR float unscaledf(coord_t val) { return unscaled<float>(val); }
inline std::string debug_out_path(const char *name, ...)
{

View file

@ -976,6 +976,7 @@ void MainFrame::load_config(const DynamicPrintConfig& config)
if (! boost::algorithm::ends_with(opt_key, "_settings_id"))
tab->get_config()->option(opt_key)->set(config.option(opt_key));
}
wxGetApp().load_current_presets();
#endif
}