mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-07-22 07:44:26 +08:00
remove some warnings change some scale/unscale for better types.
This commit is contained in:
parent
dfab9c5b18
commit
e1e4f34f0a
@ -528,10 +528,10 @@ inline coord_t width(const BoundingBox& box) { return box.max.x() - box.min.x();
|
||||
inline coord_t height(const BoundingBox& box) { return box.max.y() - box.min.y(); }
|
||||
inline double area(const BoundingBox& box) { return double(width(box)) * height(box); }
|
||||
inline double poly_area(const Points &pts) { return std::abs(Polygon::area(pts)); }
|
||||
inline double distance_to(const Point& p1, const Point& p2)
|
||||
inline coordf_t distance_to(const Point& p1, const Point& p2)
|
||||
{
|
||||
double dx = p2.x() - p1.x();
|
||||
double dy = p2.y() - p1.y();
|
||||
coordf_t dx = coordf_t(p2.x() - p1.x());
|
||||
coordf_t dy = coordf_t(p2.y() - p1.y());
|
||||
return std::sqrt(dx*dx + dy*dy);
|
||||
}
|
||||
|
||||
|
@ -161,11 +161,11 @@ BoundingBox3Base<PointClass>::size() const
|
||||
template Vec3f BoundingBox3Base<Vec3f>::size() const;
|
||||
template Vec3d BoundingBox3Base<Vec3d>::size() const;
|
||||
|
||||
template <class PointClass> double BoundingBoxBase<PointClass>::radius() const
|
||||
template <class PointClass> coordf_t BoundingBoxBase<PointClass>::radius() const
|
||||
{
|
||||
assert(this->defined);
|
||||
double x = this->max(0) - this->min(0);
|
||||
double y = this->max(1) - this->min(1);
|
||||
coordf_t x = coordf_t(this->max(0) - this->min(0));
|
||||
coordf_t y = coordf_t(this->max(1) - this->min(1));
|
||||
return 0.5 * sqrt(x*x+y*y);
|
||||
}
|
||||
template double BoundingBoxBase<Point>::radius() const;
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
void merge(const BoundingBoxBase<PointClass> &bb);
|
||||
void scale(double factor);
|
||||
PointClass size() const;
|
||||
double radius() const;
|
||||
coordf_t radius() const;
|
||||
void translate(coordf_t x, coordf_t y) { assert(this->defined); PointClass v(x, y); this->min += v; this->max += v; }
|
||||
void translate(const Vec2d &v) { this->min += v; this->max += v; }
|
||||
void offset(coordf_t delta);
|
||||
|
@ -1230,7 +1230,7 @@ ExPolygons variable_offset_inner_ex(const ExPolygon &expoly, const std::vector<s
|
||||
append(holes, fix_after_outer_offset(mittered_offset_path_scaled(hole.points, deltas[1 + &hole - expoly.holes.data()], miter_limit), ClipperLib::pftNegative, false));
|
||||
//tiny holes can be reduced to giberish, get rid of them.
|
||||
for (auto it = holes.begin(); it != holes.end();)
|
||||
if (ClipperLib::Area(*it) < CLIPPER_OFFSET_SCALE*CLIPPER_OFFSET_SCALE) {
|
||||
if (ClipperLib::Area(*it) < double(CLIPPER_OFFSET_SCALE) * double(CLIPPER_OFFSET_SCALE)) {
|
||||
it = holes.erase(it);
|
||||
}
|
||||
else ++it;
|
||||
|
@ -1213,8 +1213,8 @@ bool EdgeGrid::Grid::signed_distance_edges(const Point &pt, coord_t search_radiu
|
||||
// Signum of the distance field at pt.
|
||||
int sign_min = 0;
|
||||
bool on_segment = false;
|
||||
for (int r = bbox.min(1); r <= bbox.max(1); ++ r) {
|
||||
for (int c = bbox.min(0); c <= bbox.max(0); ++ c) {
|
||||
for (coord_t r = bbox.min(1); r <= bbox.max(1); ++ r) {
|
||||
for (coord_t c = bbox.min(0); c <= bbox.max(0); ++ c) {
|
||||
const Cell &cell = m_cells[r * m_cols + c];
|
||||
for (size_t i = cell.begin; i < cell.end; ++ i) {
|
||||
const Slic3r::Points &pts = *m_contours[m_cell_data[i].first];
|
||||
@ -1301,7 +1301,7 @@ Polygons EdgeGrid::Grid::contours_simplified(coord_t offset, bool fill_holes) co
|
||||
std::vector<char> cell_inside2(cell_inside);
|
||||
for (int r = 1; r + 1 < int(cell_rows); ++ r) {
|
||||
for (int c = 1; c + 1 < int(cell_cols); ++ c) {
|
||||
int addr = r * cell_cols + c;
|
||||
int addr = r * int(cell_cols) + c;
|
||||
if ((cell_inside2[addr - 1] && cell_inside2[addr + 1]) ||
|
||||
(cell_inside2[addr - cell_cols] && cell_inside2[addr + cell_cols]))
|
||||
cell_inside[addr] = true;
|
||||
@ -1483,8 +1483,8 @@ bool EdgeGrid::Grid::has_intersecting_edges() const
|
||||
|
||||
void EdgeGrid::save_png(const EdgeGrid::Grid &grid, const BoundingBox &bbox, coord_t resolution, const char *path, size_t scale)
|
||||
{
|
||||
unsigned int w = (bbox.max(0) - bbox.min(0) + resolution - 1) / resolution;
|
||||
unsigned int h = (bbox.max(1) - bbox.min(1) + resolution - 1) / resolution;
|
||||
uint32_t w = uint32_t((bbox.max(0) - bbox.min(0) + resolution - 1) / resolution);
|
||||
uint32_t h = uint32_t((bbox.max(1) - bbox.min(1) + resolution - 1) / resolution);
|
||||
|
||||
std::vector<uint8_t> pixels(w * h * 3, 0);
|
||||
|
||||
@ -1501,7 +1501,7 @@ void EdgeGrid::save_png(const EdgeGrid::Grid &grid, const BoundingBox &bbox, coo
|
||||
#else
|
||||
if (grid.signed_distance(pt, search_radius, min_dist)) {
|
||||
#endif
|
||||
float s = 255 * std::abs(min_dist) / float(display_blend_radius);
|
||||
float s = float(255 * std::abs(min_dist)) / float(display_blend_radius);
|
||||
int is = std::max(0, std::min(255, int(floor(s + 0.5f))));
|
||||
if (min_dist < 0) {
|
||||
if (on_segment) {
|
||||
@ -1548,7 +1548,7 @@ void EdgeGrid::save_png(const EdgeGrid::Grid &grid, const BoundingBox &bbox, coo
|
||||
}
|
||||
}
|
||||
|
||||
float dgrid = fabs(min_dist) / float(grid.resolution());
|
||||
float dgrid = fabs(float(min_dist)) / float(grid.resolution());
|
||||
float igrid = floor(dgrid + 0.5f);
|
||||
dgrid = std::abs(dgrid - igrid) * float(grid.resolution()) / float(resolution);
|
||||
if (dgrid < 1.f) {
|
||||
@ -1559,7 +1559,7 @@ void EdgeGrid::save_png(const EdgeGrid::Grid &grid, const BoundingBox &bbox, coo
|
||||
pxl[2] = (unsigned char)(t * pxl[2]);
|
||||
if (igrid > 0.f) {
|
||||
// Other than zero iso contour.
|
||||
int g = pxl[1] + 255.f * (1.f - t);
|
||||
int g = int(pxl[1] + 255.f * (1.f - t));
|
||||
pxl[1] = std::min(g, 255);
|
||||
}
|
||||
}
|
||||
@ -1572,7 +1572,7 @@ void EdgeGrid::save_png(const EdgeGrid::Grid &grid, const BoundingBox &bbox, coo
|
||||
// Find all pairs of intersectiong edges from the set of polygons.
|
||||
std::vector<std::pair<EdgeGrid::Grid::ContourEdge, EdgeGrid::Grid::ContourEdge>> intersecting_edges(const Polygons &polygons)
|
||||
{
|
||||
double len = 0;
|
||||
coordf_t len = 0;
|
||||
size_t cnt = 0;
|
||||
BoundingBox bbox;
|
||||
for (const Polygon &poly : polygons) {
|
||||
@ -1592,7 +1592,7 @@ std::vector<std::pair<EdgeGrid::Grid::ContourEdge, EdgeGrid::Grid::ContourEdge>>
|
||||
bbox.offset(20);
|
||||
EdgeGrid::Grid grid;
|
||||
grid.set_bbox(bbox);
|
||||
grid.create(polygons, len);
|
||||
grid.create(polygons, coord_t(len));
|
||||
out = grid.intersecting_edges();
|
||||
}
|
||||
return out;
|
||||
@ -1612,7 +1612,7 @@ void export_intersections_to_svg(const std::string &filename, const Polygons &po
|
||||
intersecting_contours.insert(ie.second.first);
|
||||
}
|
||||
// Highlight the contours with intersections.
|
||||
coord_t line_width = coord_t(scale_(0.01));
|
||||
coord_t line_width = scale_t(0.01);
|
||||
for (const Points *ic : intersecting_contours) {
|
||||
svg.draw_outline(Polygon(*ic), "green");
|
||||
svg.draw_outline(Polygon(*ic), "black", line_width);
|
||||
|
@ -88,10 +88,10 @@ public:
|
||||
assert(m_bbox.contains(p2));
|
||||
p1 -= m_bbox.min;
|
||||
p2 -= m_bbox.min;
|
||||
assert(p1.x() >= 0 && p1.x() < m_cols * m_resolution);
|
||||
assert(p1.y() >= 0 && p1.y() < m_rows * m_resolution);
|
||||
assert(p2.x() >= 0 && p2.x() < m_cols * m_resolution);
|
||||
assert(p2.y() >= 0 && p2.y() < m_rows * m_resolution);
|
||||
assert(p1.x() >= 0 && p1.x() < coord_t(m_cols) * m_resolution);
|
||||
assert(p1.y() >= 0 && p1.y() < coord_t(m_rows) * m_resolution);
|
||||
assert(p2.x() >= 0 && p2.x() < coord_t(m_cols) * m_resolution);
|
||||
assert(p2.y() >= 0 && p2.y() < coord_t(m_rows) * m_resolution);
|
||||
// Get the cells of the end points.
|
||||
coord_t ix = p1(0) / m_resolution;
|
||||
coord_t iy = p1(1) / m_resolution;
|
||||
@ -248,9 +248,9 @@ public:
|
||||
std::pair<std::vector<std::pair<size_t, size_t>>::const_iterator, std::vector<std::pair<size_t, size_t>>::const_iterator> cell_data_range(coord_t row, coord_t col) const
|
||||
{
|
||||
assert(row >= 0);
|
||||
assert(row < m_rows);
|
||||
assert(row < (coord_t)m_rows);
|
||||
assert(col >= 0);
|
||||
assert(col < m_cols);
|
||||
assert(col < (coord_t)m_cols);
|
||||
const EdgeGrid::Grid::Cell &cell = m_cells[row * m_cols + col];
|
||||
return std::make_pair(m_cell_data.begin() + cell.begin, m_cell_data.begin() + cell.end);
|
||||
}
|
||||
|
@ -539,11 +539,11 @@ ExPolygon elephant_foot_compensation(const ExPolygon &input_expoly, double min_c
|
||||
{
|
||||
assert(validate_expoly_orientation(input_expoly));
|
||||
|
||||
double scaled_compensation = scale_(compensation);
|
||||
min_contour_width = scale_(min_contour_width);
|
||||
double min_contour_width_compensated = min_contour_width + 2. * scaled_compensation;
|
||||
coordf_t scaled_compensation = scale_d(compensation);
|
||||
coordf_t scaled_min_contour_width = scale_d(min_contour_width);
|
||||
coordf_t min_contour_width_compensated = scaled_min_contour_width + 2. * scaled_compensation;
|
||||
// Make the search radius a bit larger for the averaging in contour_distance over a fan of rays to work.
|
||||
double search_radius = min_contour_width_compensated + min_contour_width * 0.5;
|
||||
coordf_t search_radius = min_contour_width_compensated + scaled_min_contour_width * 0.5;
|
||||
|
||||
BoundingBox bbox = get_extents(input_expoly.contour);
|
||||
Point bbox_size = bbox.size();
|
||||
@ -578,12 +578,12 @@ ExPolygon elephant_foot_compensation(const ExPolygon &input_expoly, double min_c
|
||||
for (float &d : dists) {
|
||||
// printf("Point %d, Distance: %lf\n", int(&d - dists.data()), unscale<double>(d));
|
||||
// Convert contour width to available compensation distance.
|
||||
if (d < min_contour_width)
|
||||
if (d < scaled_min_contour_width)
|
||||
d = 0.f;
|
||||
else if (d > min_contour_width_compensated)
|
||||
d = - float(scaled_compensation);
|
||||
else
|
||||
d = - (d - float(min_contour_width)) / 2.f;
|
||||
d = - (d - float(scaled_min_contour_width)) / 2.f;
|
||||
assert(d >= - float(scaled_compensation) && d <= 0.f);
|
||||
}
|
||||
// smooth_compensation(dists, 0.4f, 10);
|
||||
|
@ -202,10 +202,10 @@ inline Polylines to_polylines(ExPolygon &&src)
|
||||
Polyline &pl = polylines[idx ++];
|
||||
pl.points = std::move(src.contour.points);
|
||||
pl.points.push_back(pl.points.front());
|
||||
for (Polygons::const_iterator ith = src.holes.begin(); ith != src.holes.end(); ++ith) {
|
||||
for (Polygon& ith : src.holes) {
|
||||
Polyline &pl = polylines[idx ++];
|
||||
pl.points = std::move(ith->points);
|
||||
pl.points.push_back(ith->points.front());
|
||||
pl.points = std::move(ith.points);
|
||||
pl.points.push_back(pl.points.front());
|
||||
}
|
||||
assert(idx == polylines.size());
|
||||
return polylines;
|
||||
@ -216,14 +216,14 @@ inline Polylines to_polylines(ExPolygons &&src)
|
||||
Polylines polylines;
|
||||
polylines.assign(number_polygons(src), Polyline());
|
||||
size_t idx = 0;
|
||||
for (ExPolygons::const_iterator it = src.begin(); it != src.end(); ++it) {
|
||||
for (ExPolygon& ex_poly : src) {
|
||||
Polyline &pl = polylines[idx ++];
|
||||
pl.points = std::move(it->contour.points);
|
||||
pl.points = std::move(ex_poly.contour.points);
|
||||
pl.points.push_back(pl.points.front());
|
||||
for (Polygons::const_iterator ith = it->holes.begin(); ith != it->holes.end(); ++ith) {
|
||||
for (Polygon& ith : ex_poly.holes) {
|
||||
Polyline &pl = polylines[idx ++];
|
||||
pl.points = std::move(ith->points);
|
||||
pl.points.push_back(ith->points.front());
|
||||
pl.points = std::move(ith.points);
|
||||
pl.points.push_back(pl.points.front());
|
||||
}
|
||||
}
|
||||
assert(idx == polylines.size());
|
||||
@ -243,9 +243,9 @@ inline Polygons to_polygons(const ExPolygons &src)
|
||||
{
|
||||
Polygons polygons;
|
||||
polygons.reserve(number_polygons(src));
|
||||
for (ExPolygons::const_iterator it = src.begin(); it != src.end(); ++it) {
|
||||
polygons.push_back(it->contour);
|
||||
polygons.insert(polygons.end(), it->holes.begin(), it->holes.end());
|
||||
for (const ExPolygon& ex_poly : src) {
|
||||
polygons.push_back(ex_poly.contour);
|
||||
polygons.insert(polygons.end(), ex_poly.holes.begin(), ex_poly.holes.end());
|
||||
}
|
||||
return polygons;
|
||||
}
|
||||
|
@ -221,12 +221,12 @@ double Extruder::retract_restart_extra_toolchange() const
|
||||
|
||||
int16_t Extruder::temp_offset() const
|
||||
{
|
||||
return m_config->extruder_temperature_offset.get_at(m_id);
|
||||
return int16_t(m_config->extruder_temperature_offset.get_at(m_id));
|
||||
}
|
||||
|
||||
int8_t Extruder::fan_offset() const
|
||||
{
|
||||
return m_config->extruder_fan_offset.get_at(m_id);
|
||||
return int8_t(m_config->extruder_fan_offset.get_at(m_id));
|
||||
}
|
||||
|
||||
double Mill::retract_lift() const {
|
||||
|
@ -435,7 +435,7 @@ public:
|
||||
ExtrusionLoop(ExtrusionPaths &&paths, ExtrusionLoopRole role = elrDefault) : paths(std::move(paths)), m_loop_role(role) { assert(this->first_point() == this->paths.back().polyline.points.back()); }
|
||||
ExtrusionLoop(const ExtrusionPath &path, ExtrusionLoopRole role = elrDefault) : m_loop_role(role)
|
||||
{ this->paths.push_back(path); }
|
||||
ExtrusionLoop(const ExtrusionPath &&path, ExtrusionLoopRole role = elrDefault) : m_loop_role(role)
|
||||
ExtrusionLoop(ExtrusionPath &&path, ExtrusionLoopRole role = elrDefault) : m_loop_role(role)
|
||||
{ this->paths.emplace_back(std::move(path)); }
|
||||
virtual bool is_loop() const override{ return true; }
|
||||
virtual bool can_reverse() const override { return false; }
|
||||
|
@ -638,11 +638,11 @@ static inline Intersection* get_nearest_intersection(std::vector<std::pair<Inter
|
||||
|
||||
// Create a line representing the anchor aka hook extrusion based on line_to_offset
|
||||
// translated in the direction of the intersection line (intersection.intersect_line).
|
||||
static Line create_offset_line(Line offset_line, const Intersection &intersection, const double scaled_offset)
|
||||
static Line create_offset_line(Line offset_line, const Intersection &intersection, const coordf_t scaled_offset)
|
||||
{
|
||||
offset_line.translate((perp(intersection.closest_line->vector().cast<double>().normalized()) * (intersection.left ? scaled_offset : - scaled_offset)).cast<coord_t>());
|
||||
// Extend the line by a small value to guarantee a collision with adjacent lines
|
||||
offset_line.extend(coord_t(scaled_offset * 1.16)); // / cos(PI/6)
|
||||
offset_line.extend(coordf_t(coord_t(scaled_offset * 1.16))); // / cos(PI/6)
|
||||
return offset_line;
|
||||
}
|
||||
|
||||
@ -1385,8 +1385,8 @@ void Filler::_fill_surface_single(
|
||||
}
|
||||
#endif /* ADAPTIVE_CUBIC_INFILL_DEBUG_OUTPUT */
|
||||
|
||||
const auto hook_length = coordf_t(std::min<float>(std::numeric_limits<coord_t>::max(), scale_(params.anchor_length)));
|
||||
const auto hook_length_max = coordf_t(std::min<float>(std::numeric_limits<coord_t>::max(), scale_(params.anchor_length_max)));
|
||||
const coordf_t hook_length = std::min<coordf_t>((coordf_t)std::numeric_limits<coord_t>::max(), scale_d(params.anchor_length));
|
||||
const coordf_t hook_length_max = std::min<coordf_t>((coordf_t)std::numeric_limits<coord_t>::max(), scale_d(params.anchor_length_max));
|
||||
|
||||
Polylines all_polylines_with_hooks = all_polylines.size() > 1 ? connect_lines_using_hooks(std::move(all_polylines), expolygon, this->get_spacing(), hook_length, hook_length_max) : std::move(all_polylines);
|
||||
|
||||
|
@ -243,8 +243,8 @@ Fill::do_gap_fill(const ExPolygons& gapfill_areas, const FillParams& params, Ext
|
||||
// offset2_ex(gapfill_areas, double(-max / 2), double(+max / 2)),
|
||||
// true);
|
||||
ExPolygons gapfill_areas_collapsed = offset2_ex(gapfill_areas, double(-min / 2), double(+min / 2));
|
||||
double minarea = params.flow.scaled_width() * params.flow.scaled_width();
|
||||
if (params.config != nullptr) minarea = scale_(params.config->gap_fill_min_area.get_abs_value(params.flow.width)) * params.flow.scaled_width();
|
||||
double minarea = double(params.flow.scaled_width()) * double(params.flow.scaled_width());
|
||||
if (params.config != nullptr) minarea = scale_d(params.config->gap_fill_min_area.get_abs_value(params.flow.width)) * double(params.flow.scaled_width());
|
||||
for (const ExPolygon& ex : gapfill_areas_collapsed) {
|
||||
//remove too small gaps that are too hard to fill.
|
||||
//ie one that are smaller than an extrusion with width of min and a length of max.
|
||||
@ -2109,8 +2109,8 @@ void connect_infill(Polylines&& infill_ordered, const std::vector<const Polygon*
|
||||
assert(params.anchor_length >= 0.);
|
||||
assert(params.anchor_length_max >= 0.01f);
|
||||
assert(params.anchor_length_max >= params.anchor_length);
|
||||
const double anchor_length = scale_(params.anchor_length);
|
||||
const double anchor_length_max = scale_(params.anchor_length_max);
|
||||
const coordf_t anchor_length = scale_d(params.anchor_length);
|
||||
const coordf_t anchor_length_max = scale_d(params.anchor_length_max);
|
||||
|
||||
#if 0
|
||||
append(polylines_out, infill_ordered);
|
||||
|
@ -174,8 +174,8 @@ FillConcentricWGapFill::fill_surface_extrusion(
|
||||
ExPolygons gapfill_areas = diff_ex({ surface->expolygon }, offset_ex(expp, double(scale_(0.5 * this->get_spacing()))));
|
||||
gapfill_areas = union_ex(gapfill_areas, true);
|
||||
if (gapfill_areas.size() > 0) {
|
||||
double minarea = params.flow.scaled_width() * params.flow.scaled_width();
|
||||
if (params.config != nullptr) minarea = scale_(params.config->gap_fill_min_area.get_abs_value(params.flow.width)) * params.flow.scaled_width();
|
||||
double minarea = double(params.flow.scaled_width()) * double(params.flow.scaled_width());
|
||||
if (params.config != nullptr) minarea = scale_d(params.config->gap_fill_min_area.get_abs_value(params.flow.width)) * double(params.flow.scaled_width());
|
||||
for (int i = 0; i < gapfill_areas.size(); i++) {
|
||||
if (gapfill_areas[i].area() < minarea) {
|
||||
gapfill_areas.erase(gapfill_areas.begin() + i);
|
||||
|
@ -184,7 +184,7 @@ void FillGyroid::_fill_surface_single(
|
||||
if (! polylines.empty()) {
|
||||
// Remove very small bits, but be careful to not remove infill lines connecting thin walls!
|
||||
// The infill perimeter lines should be separated by around a single infill line width.
|
||||
const double minlength = scale_(0.8 * this->get_spacing());
|
||||
const coordf_t minlength = scale_d(0.8 * this->get_spacing());
|
||||
polylines.erase(
|
||||
std::remove_if(polylines.begin(), polylines.end(), [minlength](const Polyline &pl) { return pl.length() < minlength; }),
|
||||
polylines.end());
|
||||
|
@ -94,7 +94,7 @@ void FillLine::_fill_surface_single(
|
||||
// offset the expolygon by max(min_spacing/2, extra)
|
||||
ExPolygon expolygon_off;
|
||||
{
|
||||
ExPolygons expolygons_off = offset_ex(expolygon, this->_min_spacing/2);
|
||||
ExPolygons expolygons_off = offset_ex(expolygon, coordf_t(this->_min_spacing / 2));
|
||||
if (! expolygons_off.empty()) {
|
||||
// When expanding a polygon, the number of islands could only shrink. Therefore the offset_ex shall generate exactly one expanded island for one input island.
|
||||
assert(expolygons_off.size() == 1);
|
||||
|
@ -2819,8 +2819,8 @@ bool FillRectilinear::fill_surface_by_lines(const Surface *surface, const FillPa
|
||||
ExPolygonWithOffset poly_with_offset(
|
||||
surface->expolygon,
|
||||
- rotate_vector.first,
|
||||
float(scale_(0 /*this->overlap*/ - (0.5 - INFILL_OVERLAP_OVER_SPACING) * this->get_spacing())),
|
||||
float(scale_(0 /*this->overlap*/ - 0.5f * this->get_spacing())));
|
||||
(scale_t(0 /*this->overlap*/ - (0.5 - INFILL_OVERLAP_OVER_SPACING) * this->get_spacing())),
|
||||
(scale_t(0 /*this->overlap*/ - 0.5f * this->get_spacing())));
|
||||
if (poly_with_offset.n_contours_inner == 0) {
|
||||
// Not a single infill line fits.
|
||||
//Prusa: maybe one shall trigger the gap fill here?
|
||||
@ -2956,24 +2956,24 @@ bool FillRectilinear::fill_surface_by_multilines(const Surface* surface, FillPar
|
||||
{
|
||||
assert(sweep_params.size() > 1);
|
||||
assert(!params.full_infill());
|
||||
params.density /= double(sweep_params.size());
|
||||
params.density /= float(sweep_params.size());
|
||||
assert(params.density > 0.0001f && params.density <= 1.f);
|
||||
|
||||
ExPolygonWithOffset poly_with_offset_base(surface->expolygon, 0, float(scale_(this->overlap - 0.5 * this->get_spacing())));
|
||||
ExPolygonWithOffset poly_with_offset_base(surface->expolygon, 0, scale_t(this->overlap - 0.5 * this->get_spacing()));
|
||||
if (poly_with_offset_base.n_contours == 0)
|
||||
// Not a single infill line fits.
|
||||
return true;
|
||||
|
||||
Polylines fill_lines;
|
||||
coord_t line_width = coord_t(scale_(this->get_spacing()));
|
||||
coord_t line_spacing = coord_t(scale_(this->get_spacing()) / params.density);
|
||||
coord_t line_width = scale_t(this->get_spacing());
|
||||
coord_t line_spacing = scale_t(this->get_spacing() / params.density);
|
||||
std::pair<float, Point> rotate_vector = this->_infill_direction(surface);
|
||||
for (const SweepParams& sweep : sweep_params) {
|
||||
size_t n_fill_lines_initial = fill_lines.size();
|
||||
|
||||
// Rotate polygons so that we can work with vertical lines here
|
||||
double angle = rotate_vector.first + sweep.angle_base;
|
||||
ExPolygonWithOffset poly_with_offset(poly_with_offset_base, -angle);
|
||||
ExPolygonWithOffset poly_with_offset(poly_with_offset_base, float(-angle));
|
||||
BoundingBox bounding_box = poly_with_offset.bounding_box_src();
|
||||
// Don't produce infill lines, which fully overlap with the infill perimeter.
|
||||
coord_t x_min = bounding_box.min.x() + line_width + coord_t(SCALED_EPSILON);
|
||||
@ -3096,10 +3096,10 @@ FillRectilinearPeri::fill_surface_extrusion(const Surface *surface, const FillPa
|
||||
Polylines polylines_1;
|
||||
//generate perimeter:
|
||||
ExPolygons path_perimeter = offset2_ex(surface->expolygon,
|
||||
scale_(-this->get_spacing()), scale_(this->get_spacing() / 2),
|
||||
ClipperLib::jtMiter, scale_(this->get_spacing()) * 10);
|
||||
scale_d(-this->get_spacing()), scale_d(this->get_spacing() / 2),
|
||||
ClipperLib::jtMiter, scale_d(this->get_spacing()) * 10);
|
||||
//fix a bug that can happens when (positive) offsetting with a big miter limit and two island merge. See https://github.com/supermerill/SuperSlicer/issues/609
|
||||
path_perimeter = intersection_ex(path_perimeter, offset_ex(surface->expolygon, scale_(-this->get_spacing() / 2)));
|
||||
path_perimeter = intersection_ex(path_perimeter, offset_ex(surface->expolygon, scale_d(-this->get_spacing() / 2)));
|
||||
for (ExPolygon &expolygon : path_perimeter) {
|
||||
expolygon.contour.make_counter_clockwise();
|
||||
polylines_1.push_back(expolygon.contour.split_at_index(0));
|
||||
@ -3133,7 +3133,7 @@ FillRectilinearPeri::fill_surface_extrusion(const Surface *surface, const FillPa
|
||||
Polylines polylines_2;
|
||||
bool canFill = true;
|
||||
//50% overlap with the new perimeter
|
||||
ExPolygons path_inner = offset2_ex(surface->expolygon, scale_(-this->get_spacing() * 1.5), scale_(this->get_spacing()));
|
||||
ExPolygons path_inner = offset2_ex(surface->expolygon, scale_d(-this->get_spacing() * 1.5), scale_d(this->get_spacing()));
|
||||
for (ExPolygon &expolygon : path_inner) {
|
||||
Surface surfInner(*surface, expolygon);
|
||||
if (!fill_surface_by_lines(&surfInner, params, 0.f, 0.f, polylines_2)) {
|
||||
@ -3203,7 +3203,7 @@ Polylines FillScatteredRectilinear::fill_surface(const Surface *surface, const F
|
||||
Polylines polylines_out;
|
||||
|
||||
// Offset the pattern randomly using the current layer index as the generator
|
||||
float offset = randomFloatFromSeed((uint32_t) layer_id) * 0.5f * this->get_spacing();
|
||||
float offset = (float)randomFloatFromSeed((uint32_t) layer_id) * 0.5f * this->get_spacing();
|
||||
|
||||
if (!fill_surface_by_lines(surface, params, 0.f, offset, polylines_out)) {
|
||||
printf("FillScatteredRectilinear::fill_surface() failed to fill a region.\n");
|
||||
@ -3307,7 +3307,7 @@ FillRectilinearSawtooth::fill_surface_extrusion(const Surface *surface, const Fi
|
||||
current_extrusion->push_back(last, tooth_zhop);
|
||||
|
||||
// add new extrusion that go down with no nozzle_flow / sqrt(2)
|
||||
extrusions->paths.push_back(ExtrusionPath3D(good_role, params.flow.mm3_per_mm() / std::sqrt(2), params.flow.width / std::sqrt(2), params.flow.height));
|
||||
extrusions->paths.push_back(ExtrusionPath3D(good_role, params.flow.mm3_per_mm() / std::sqrt(2), float(params.flow.width / std::sqrt(2)), params.flow.height));
|
||||
current_extrusion = &(extrusions->paths.back());
|
||||
current_extrusion->push_back(last, tooth_zhop);
|
||||
//add next point
|
||||
@ -3438,7 +3438,7 @@ FillRectilinearWGapFill::fill_surface_extrusion(const Surface *surface, const Fi
|
||||
eec->entities, polylines_rectilinear,
|
||||
good_role,
|
||||
params.flow.mm3_per_mm() * params.flow_mult * flow_mult_exact_volume,
|
||||
params.flow.width * params.flow_mult * flow_mult_exact_volume,
|
||||
params.flow.width * params.flow_mult * float(flow_mult_exact_volume),
|
||||
params.flow.height);
|
||||
|
||||
coll_nosort->entities.push_back(eec);
|
||||
@ -3452,7 +3452,7 @@ FillRectilinearWGapFill::fill_surface_extrusion(const Surface *surface, const Fi
|
||||
gapfill_areas.insert(gapfill_areas.end(), unextruded_areas.begin(), unextruded_areas.end());
|
||||
gapfill_areas = union_ex(gapfill_areas, true);
|
||||
if (gapfill_areas.size() > 0) {
|
||||
const double minarea = scale_(params.config->gap_fill_min_area.get_abs_value(params.flow.width)) * params.flow.scaled_width();
|
||||
const double minarea = scale_d(params.config->gap_fill_min_area.get_abs_value(params.flow.width)) * double(params.flow.scaled_width());
|
||||
for (int i = 0; i < gapfill_areas.size(); i++) {
|
||||
if (gapfill_areas[i].area() < minarea) {
|
||||
gapfill_areas.erase(gapfill_areas.begin() + i);
|
||||
|
@ -175,7 +175,7 @@ std::string Wipe::wipe(GCode& gcodegen, bool toolchange)
|
||||
/* Calculate how long we need to travel in order to consume the required
|
||||
amount of retraction. In other words, how far do we move in XY at wipe_speed
|
||||
for the time needed to consume retract_length at retract_speed? */
|
||||
double wipe_dist = scale_(length / gcodegen.writer().tool()->retract_speed() * wipe_speed);
|
||||
coordf_t wipe_dist = scale_d(length / gcodegen.writer().tool()->retract_speed() * wipe_speed);
|
||||
|
||||
/* Take the stored wipe path and replace first point with the current actual position
|
||||
(they might be different, for example, in case of loop clipping). */
|
||||
@ -2875,8 +2875,8 @@ std::string GCode::extrude_loop_vase(const ExtrusionLoop &original_loop, const s
|
||||
// apply the small/external? perimeter speed
|
||||
if (speed == -1 && is_perimeter(paths.front().role()) && loop.length() <=
|
||||
scale_(this->m_config.small_perimeter_max_length.get_abs_value(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0)))) {
|
||||
double min_length = scale_(this->m_config.small_perimeter_min_length.get_abs_value(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0)));
|
||||
double max_length = scale_(this->m_config.small_perimeter_max_length.get_abs_value(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0)));
|
||||
coordf_t min_length = scale_d(this->m_config.small_perimeter_min_length.get_abs_value(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0)));
|
||||
coordf_t max_length = scale_d(this->m_config.small_perimeter_max_length.get_abs_value(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0)));
|
||||
if (loop.length() <= min_length) {
|
||||
speed = m_config.small_perimeter_speed.get_abs_value(m_config.perimeter_speed);
|
||||
} else {
|
||||
@ -2923,7 +2923,7 @@ std::string GCode::extrude_loop_vase(const ExtrusionLoop &original_loop, const s
|
||||
Vec2d p1 = paths.front().polyline.points.front().cast<double>();
|
||||
Vec2d p2 = paths.front().polyline.points[1].cast<double>();
|
||||
Vec2d v = p2 - p1;
|
||||
double nd = scale_(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, paths.front().width));
|
||||
double nd = scale_d(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, paths.front().width));
|
||||
double l2 = v.squaredNorm();
|
||||
// Shift by no more than a nozzle diameter.
|
||||
//FIXME Hiding the seams will not work nicely for very densely discretized contours!
|
||||
@ -3071,7 +3071,7 @@ std::string GCode::extrude_loop_vase(const ExtrusionLoop &original_loop, const s
|
||||
Vec2d p1 = paths.front().polyline.points.front().cast<double>();
|
||||
Vec2d p2 = paths.front().polyline.points[1].cast<double>();
|
||||
Vec2d v = p2 - p1;
|
||||
double nd = scale_(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, paths.front().width));
|
||||
coordf_t nd = scale_d(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, paths.front().width));
|
||||
double l2 = v.squaredNorm();
|
||||
// Shift by no more than a nozzle diameter.
|
||||
//FIXME Hiding the seams will not work nicely for very densely discretized contours!
|
||||
@ -3192,8 +3192,8 @@ std::string GCode::extrude_loop(const ExtrusionLoop &original_loop, const std::s
|
||||
// apply the small perimeter speed
|
||||
if (speed == -1 && is_perimeter(paths.front().role()) && loop.length() <=
|
||||
scale_(this->m_config.small_perimeter_max_length.get_abs_value(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0)))) {
|
||||
double min_length = scale_(this->m_config.small_perimeter_min_length.get_abs_value(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0)));
|
||||
double max_length = scale_(this->m_config.small_perimeter_max_length.get_abs_value(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0)));
|
||||
double min_length = scale_d(this->m_config.small_perimeter_min_length.get_abs_value(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0)));
|
||||
double max_length = scale_d(this->m_config.small_perimeter_max_length.get_abs_value(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0)));
|
||||
if (loop.length() <= min_length) {
|
||||
speed = m_config.small_perimeter_speed.get_abs_value(m_config.perimeter_speed);
|
||||
} else {
|
||||
@ -3228,7 +3228,7 @@ std::string GCode::extrude_loop(const ExtrusionLoop &original_loop, const std::s
|
||||
|
||||
//extra wipe before the little move.
|
||||
if (EXTRUDER_CONFIG_WITH_DEFAULT(wipe_extra_perimeter, 0) > 0) {
|
||||
coord_t wipe_dist = scale_(EXTRUDER_CONFIG_WITH_DEFAULT(wipe_extra_perimeter,0));
|
||||
coordf_t wipe_dist = scale_(EXTRUDER_CONFIG_WITH_DEFAULT(wipe_extra_perimeter,0));
|
||||
ExtrusionPaths paths_wipe;
|
||||
for (int i = 0; i < paths.size(); i++) {
|
||||
ExtrusionPath& path = paths[i];
|
||||
@ -3286,7 +3286,7 @@ std::string GCode::extrude_loop(const ExtrusionLoop &original_loop, const std::s
|
||||
Vec2d current_pos = current_point.cast<double>();
|
||||
Vec2d next_pos = next_point.cast<double>();
|
||||
Vec2d vec_dist = next_pos - current_pos;
|
||||
double nd = scale_(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter,0));
|
||||
double nd = scale_d(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter,0));
|
||||
double l2 = vec_dist.squaredNorm();
|
||||
// Shift by no more than a nozzle diameter.
|
||||
//FIXME Hiding the seams will not work nicely for very densely discretized contours!
|
||||
@ -3379,7 +3379,7 @@ void GCode::use(const ExtrusionEntityCollection &collection) {
|
||||
std::string GCode::extrude_path(const ExtrusionPath &path, const std::string &description, double speed_mm_per_sec) {
|
||||
|
||||
ExtrusionPath simplifed_path = path;
|
||||
const double scaled_min_length = scale_(this->config().min_length.value);
|
||||
const coordf_t scaled_min_length = scale_d(this->config().min_length.value);
|
||||
const double max_gcode_per_second = this->config().max_gcode_per_second.value;
|
||||
double current_scaled_min_length = scaled_min_length;
|
||||
if (max_gcode_per_second > 0) {
|
||||
@ -3390,7 +3390,7 @@ std::string GCode::extrude_path(const ExtrusionPath &path, const std::string &de
|
||||
//ensure that it's a continous thing
|
||||
if (m_last_too_small.last_point().distance_to_square(path.first_point()) < current_scaled_min_length * current_scaled_min_length /*&& m_last_too_small.first_point().distance_to_square(path.first_point()) > EPSILON*/) {
|
||||
//descr += " ! fusion " + std::to_string(simplifed_path.polyline.points.size());
|
||||
simplifed_path.height = (m_last_too_small.height * m_last_too_small.length() + simplifed_path.height * simplifed_path.length()) / (m_last_too_small.length() + simplifed_path.length());
|
||||
simplifed_path.height = float(m_last_too_small.height * m_last_too_small.length() + simplifed_path.height * simplifed_path.length()) / float(m_last_too_small.length() + simplifed_path.length());
|
||||
simplifed_path.mm3_per_mm = (m_last_too_small.mm3_per_mm * m_last_too_small.length() + simplifed_path.mm3_per_mm * simplifed_path.length()) / (m_last_too_small.length() + simplifed_path.length());
|
||||
simplifed_path.polyline.points.insert(simplifed_path.polyline.points.begin(), m_last_too_small.polyline.points.begin(), m_last_too_small.polyline.points.end()-1);
|
||||
assert(simplifed_path.height == simplifed_path.height);
|
||||
@ -3560,11 +3560,11 @@ void GCode::_post_process(std::string& what, bool flush) {
|
||||
if (this->m_fan_mover.get() == nullptr)
|
||||
this->m_fan_mover.reset(new Slic3r::FanMover(
|
||||
this->m_writer,
|
||||
std::abs(this->config().fan_speedup_time.value),
|
||||
std::abs((float)this->config().fan_speedup_time.value),
|
||||
this->config().fan_speedup_time.value > 0,
|
||||
this->config().use_relative_e_distances.value,
|
||||
this->config().fan_speedup_overhangs.value,
|
||||
this->config().fan_kickstart.value));
|
||||
(float)this->config().fan_kickstart.value));
|
||||
what = this->m_fan_mover->process_gcode(what, flush);
|
||||
}
|
||||
|
||||
@ -3695,7 +3695,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, const std::string &descri
|
||||
double mult2 = 1 - coeff;
|
||||
double sum = 0;
|
||||
//Create a point
|
||||
Point inter_point1 = line.point_at(scale_(length1));
|
||||
Point inter_point1 = line.point_at(scale_d(length1));
|
||||
//extrude very reduced
|
||||
gcode += m_writer.extrude_to_xy(
|
||||
this->point_to_gcode(inter_point1),
|
||||
@ -3704,7 +3704,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, const std::string &descri
|
||||
sum += e_per_mm * (length1) * mult1;
|
||||
|
||||
if (line_length - length1 > length2) {
|
||||
Point inter_point2 = line.point_at(scale_(length2));
|
||||
Point inter_point2 = line.point_at(scale_d(length2));
|
||||
//extrude reduced
|
||||
gcode += m_writer.extrude_to_xy(
|
||||
this->point_to_gcode(inter_point2),
|
||||
@ -3758,7 +3758,7 @@ double_t GCode::_compute_speed_mm_per_sec(const ExtrusionPath& path, double spee
|
||||
if (speed < 0) {
|
||||
//if speed == -1, then it's means "choose yourself, but if it's -1 < speed <0 , then it's a scaling from small_periemter.
|
||||
//it's a bit hacky, so if you want to rework it, help yourself.
|
||||
float factor = (-speed);
|
||||
float factor = float(-speed);
|
||||
if (path.role() == erPerimeter) {
|
||||
speed = m_config.get_abs_value("perimeter_speed");
|
||||
} else if (path.role() == erExternalPerimeter) {
|
||||
@ -3790,7 +3790,7 @@ double_t GCode::_compute_speed_mm_per_sec(const ExtrusionPath& path, double spee
|
||||
}
|
||||
//don't modify bridge speed
|
||||
if (factor < 1 && !(is_bridge(path.role()))) {
|
||||
float small_speed = m_config.small_perimeter_speed.get_abs_value(m_config.perimeter_speed);
|
||||
float small_speed = (float)m_config.small_perimeter_speed.get_abs_value(m_config.perimeter_speed);
|
||||
//apply factor between feature speed and small speed
|
||||
speed = (speed * factor) + double((1.f - factor) * small_speed);
|
||||
}
|
||||
@ -3885,7 +3885,7 @@ std::string GCode::_before_extrude(const ExtrusionPath &path, const std::string
|
||||
coordf_t length = poly_start.length();
|
||||
if (length > SCALED_EPSILON) {
|
||||
Polyline poly_end;
|
||||
coordf_t min_length = scale_(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0.5)) * 20;
|
||||
coordf_t min_length = scale_d(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0.5)) * 20;
|
||||
if (poly_start.size() > 2 && length > min_length * 3) {
|
||||
//if complex travel, try to deccelerate only at the end, unless it's less than ~ 20 nozzle
|
||||
if (poly_start.lines().back().length() < min_length) {
|
||||
@ -4304,9 +4304,9 @@ Vec2d GCode::point_to_gcode(const Point &point) const
|
||||
// convert a model-space scaled point into G-code coordinates
|
||||
Vec3d GCode::point_to_gcode(const Point &point, const coord_t z_offset) const {
|
||||
Vec2d extruder_offset = EXTRUDER_CONFIG_WITH_DEFAULT(extruder_offset, Vec2d(0, 0)); //FIXME : mill ofsset
|
||||
Vec3d ret_vec(unscale_(point.x()) + m_origin.x() - extruder_offset.x(),
|
||||
unscale_(point.y()) + m_origin.y() - extruder_offset.y(),
|
||||
unscale_(z_offset));
|
||||
Vec3d ret_vec(unscaled(point.x()) + m_origin.x() - extruder_offset.x(),
|
||||
unscaled(point.y()) + m_origin.y() - extruder_offset.y(),
|
||||
unscaled(z_offset));
|
||||
return ret_vec;
|
||||
}
|
||||
|
||||
|
@ -1955,7 +1955,7 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line)
|
||||
|
||||
// time estimate section
|
||||
auto move_length = [](const AxisCoords& delta_pos) {
|
||||
float sq_xyz_length = (float)sqr(delta_pos[X]) + sqr(delta_pos[Y]) + sqr(delta_pos[Z]);
|
||||
float sq_xyz_length = (float)sqr(delta_pos[X]) + (float)sqr(delta_pos[Y]) + (float)sqr(delta_pos[Z]);
|
||||
return (sq_xyz_length > 0.0f) ? std::sqrt(sq_xyz_length) : std::abs(delta_pos[E]);
|
||||
};
|
||||
|
||||
|
@ -27,7 +27,7 @@ std::string to_string_nozero(double value, int32_t max_precision) {
|
||||
//first, get the int part, to see how many digit it takes
|
||||
int long10 = 0;
|
||||
if (intpart > 9)
|
||||
long10 = std::floor(std::log10(std::abs(intpart)));
|
||||
long10 = (int)std::floor(std::log10(std::abs(intpart)));
|
||||
//set the usable precision: there is only 15-16 decimal digit in a double
|
||||
ss << std::fixed << std::setprecision(int(std::min(15 - long10, int(max_precision)))) << value;
|
||||
std::string ret = ss.str();
|
||||
|
@ -354,9 +354,9 @@ remove_point_too_near(ThickPolyline* to_reduce)
|
||||
void
|
||||
add_point_same_percent(ThickPolyline* pattern, ThickPolyline* to_modify)
|
||||
{
|
||||
const double to_modify_length = to_modify->length();
|
||||
const coordf_t to_modify_length = to_modify->length();
|
||||
const double percent_epsilon = SCALED_EPSILON / to_modify_length;
|
||||
const double pattern_length = pattern->length();
|
||||
const coordf_t pattern_length = pattern->length();
|
||||
|
||||
double percent_length = 0;
|
||||
for (size_t idx_point = 1; idx_point < pattern->points.size() - 1; ++idx_point) {
|
||||
@ -394,10 +394,10 @@ add_point_same_percent(ThickPolyline* pattern, ThickPolyline* to_modify)
|
||||
/// return 1 for an angle of 90° and 0 for an angle of 0° or 180°
|
||||
double
|
||||
get_coeff_from_angle_countour(Point &point, const ExPolygon &contour, coord_t min_dist_between_point) {
|
||||
double nearest_dist = point.distance_to(contour.contour.points.front());
|
||||
coordf_t nearest_dist = point.distance_to(contour.contour.points.front());
|
||||
Point point_nearest = contour.contour.points.front();
|
||||
size_t id_nearest = 0;
|
||||
double near_dist = nearest_dist;
|
||||
coordf_t near_dist = nearest_dist;
|
||||
Point point_near = point_nearest;
|
||||
size_t id_near = 0;
|
||||
for (size_t id_point = 1; id_point < contour.contour.points.size(); ++id_point) {
|
||||
@ -585,8 +585,8 @@ MedialAxis::remove_bits(ThickPolylines &pp)
|
||||
if (polyline.width.back() > 0) continue;
|
||||
|
||||
//check my length is small
|
||||
coord_t length = (coord_t)polyline.length();
|
||||
if (length > max_width*1.5) {
|
||||
coordf_t length = polyline.length();
|
||||
if (length > coordf_t(max_width) * 1.5) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -613,11 +613,11 @@ MedialAxis::remove_bits(ThickPolylines &pp)
|
||||
if (nb_better_than_me < 2) continue;
|
||||
|
||||
//check if the length of the polyline is small vs width of the other lines
|
||||
double max_width = 0;
|
||||
coord_t max_width = 0;
|
||||
for (int i = 0; i < crosspoint.size(); i++) {
|
||||
max_width = std::max(max_width, pp[crosspoint[i]].width[0]);
|
||||
}
|
||||
if (length > max_width + min_width)
|
||||
if (length > coordf_t(max_width + min_width))
|
||||
continue;
|
||||
|
||||
//delete the now unused polyline
|
||||
@ -823,10 +823,10 @@ MedialAxis::extends_line(ThickPolyline& polyline, const ExPolygons& anchors, con
|
||||
}*/
|
||||
// find anchor
|
||||
Point best_anchor;
|
||||
double shortest_dist = (double)max_width;
|
||||
coordf_t shortest_dist = (coordf_t)max_width;
|
||||
for (const ExPolygon& a : anchors) {
|
||||
Point p_maybe_inside = a.contour.centroid();
|
||||
double test_dist = new_bound.distance_to(p_maybe_inside) + new_back.distance_to(p_maybe_inside);
|
||||
coordf_t test_dist = new_bound.distance_to(p_maybe_inside) + new_back.distance_to(p_maybe_inside);
|
||||
//if (test_dist < max_width / 2 && (test_dist < shortest_dist || shortest_dist < 0)) {
|
||||
double angle_test = new_back.ccw_angle(p_maybe_inside, line.a);
|
||||
if (angle_test > PI) angle_test = 2 * PI - angle_test;
|
||||
@ -1096,12 +1096,12 @@ MedialAxis::main_fusion(ThickPolylines& pp)
|
||||
polyline.width[idx_point] = max_width;
|
||||
//failsafe: try to not go out of the radius of the section, take the width of the merging point for that. (and with some offset)
|
||||
coord_t main_branch_width = pp[biggest_main_branch_id].width.front();
|
||||
coord_t main_branch_dist = pp[biggest_main_branch_id].points.front().distance_to(polyline.points[idx_point]);
|
||||
coord_t max_width_from_main = std::sqrt(main_branch_width*main_branch_width + main_branch_dist*main_branch_dist);
|
||||
coordf_t main_branch_dist = pp[biggest_main_branch_id].points.front().distance_to(polyline.points[idx_point]);
|
||||
coord_t max_width_from_main = (coord_t)std::sqrt(main_branch_width*main_branch_width + main_branch_dist*main_branch_dist);
|
||||
if (find_main_branch && polyline.width[idx_point] > max_width_from_main)
|
||||
polyline.width[idx_point] = max_width_from_main;
|
||||
if (find_main_branch && polyline.width[idx_point] > pp[biggest_main_branch_id].width.front() * 1.1)
|
||||
polyline.width[idx_point] = pp[biggest_main_branch_id].width.front() * 1.1;
|
||||
polyline.width[idx_point] = coord_t(pp[biggest_main_branch_id].width.front() * 1.1);
|
||||
//std::cout << "main fusion, max dist : " << max_width_from_main << "\n";
|
||||
|
||||
++idx_point;
|
||||
@ -1381,7 +1381,7 @@ MedialAxis::remove_too_short_polylines(ThickPolylines& pp, const coord_t min_siz
|
||||
while (changes) {
|
||||
changes = false;
|
||||
|
||||
double shortest_size = min_size;
|
||||
coordf_t shortest_size = (coordf_t) min_size;
|
||||
size_t shortest_idx = -1;
|
||||
for (size_t i = 0; i < pp.size(); ++i) {
|
||||
ThickPolyline& polyline = pp[i];
|
||||
@ -1407,19 +1407,19 @@ MedialAxis::remove_too_short_polylines(ThickPolylines& pp, const coord_t min_siz
|
||||
}
|
||||
|
||||
void
|
||||
MedialAxis::check_width(ThickPolylines& pp, double max_width, std::string msg)
|
||||
MedialAxis::check_width(ThickPolylines& pp, coord_t max_width, std::string msg)
|
||||
{
|
||||
//remove empty polyline
|
||||
int nb = 0;
|
||||
for (size_t i = 0; i < pp.size(); ++i) {
|
||||
for (size_t j = 0; j < pp[i].width.size(); ++j) {
|
||||
if (pp[i].width[j] > max_width * 1.01) {
|
||||
std::cout << "Error " << msg << " width " << unscaled(pp[i].width[j]) << "(" << i << ":" << j << ") > " << unscaled(max_width) << "\n";
|
||||
if (pp[i].width[j] > coord_t(max_width * 1.01)) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Error " << msg << " width " << unscaled(pp[i].width[j]) << "(" << i << ":" << j << ") > " << unscaled(max_width) << "\n";
|
||||
nb++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nb > 0) std::cout << "== nbBig = " << nb << " ==\n";
|
||||
if (nb > 0) BOOST_LOG_TRIVIAL(error) << "== nbBig = " << nb << " ==\n";
|
||||
}
|
||||
|
||||
void
|
||||
@ -1432,7 +1432,7 @@ MedialAxis::ensure_not_overextrude(ThickPolylines& pp)
|
||||
for (ThickPolyline& polyline : pp) {
|
||||
for (ThickLine &l : polyline.thicklines()) {
|
||||
surface += l.length() * (l.a_width + l.b_width) / 2;
|
||||
double width_mean = (l.a_width + l.b_width) / 2;
|
||||
coord_t width_mean = (l.a_width + l.b_width) / 2;
|
||||
volume += height * (width_mean - height * (1. - 0.25 * PI)) * l.length();
|
||||
}
|
||||
}
|
||||
@ -1453,8 +1453,8 @@ MedialAxis::ensure_not_overextrude(ThickPolylines& pp)
|
||||
//reduce width
|
||||
double reduce_by = boundsVolume / volume;
|
||||
for (ThickPolyline& polyline : pp) {
|
||||
for (coordf_t &width : polyline.width) {
|
||||
width *= reduce_by;
|
||||
for (coord_t &width : polyline.width) {
|
||||
width = coord_t( double(width) * reduce_by);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1515,9 +1515,10 @@ MedialAxis::grow_to_nozzle_diameter(ThickPolylines& pp, const ExPolygons& anchor
|
||||
//compute the min width
|
||||
coord_t min_width = this->nozzle_diameter;
|
||||
if (this->height > 0) min_width = Flow::new_from_spacing(
|
||||
float(unscale_(this->nozzle_diameter)),
|
||||
float(unscale_(this->nozzle_diameter)),
|
||||
float(unscale_(this->height)), false).scaled_width();
|
||||
float(unscaled(this->nozzle_diameter)),
|
||||
float(unscaled(this->nozzle_diameter)),
|
||||
float(unscaled(this->height)),
|
||||
false).scaled_width();
|
||||
//ensure the width is not lower than min_width.
|
||||
for (ThickPolyline& polyline : pp) {
|
||||
for (int i = 0; i < polyline.points.size(); ++i) {
|
||||
@ -1538,8 +1539,8 @@ void
|
||||
MedialAxis::taper_ends(ThickPolylines& pp)
|
||||
{
|
||||
// minimum size of the taper: be sure to extrude at least the "round edges" of the extrusion (0-spacing extrusion).
|
||||
const coord_t min_size = std::max(this->nozzle_diameter * 0.1, this->height * (1. - 0.25 * PI));
|
||||
const coordf_t length = std::min(this->taper_size, (this->nozzle_diameter - min_size) / 2);
|
||||
const coord_t min_size = (coord_t) std::max(this->nozzle_diameter * 0.1, this->height * (1. - 0.25 * PI));
|
||||
const coordf_t length = (coordf_t) std::min(this->taper_size, (this->nozzle_diameter - min_size) / 2);
|
||||
if (length <= SCALED_RESOLUTION) return;
|
||||
//ensure the width is not lower than min_size.
|
||||
for (ThickPolyline& polyline : pp) {
|
||||
@ -1593,9 +1594,9 @@ check_circular(ExPolygon& expolygon, coord_t max_variation) {
|
||||
if (expolygon.contour.concave_points().empty() && expolygon.contour.points.size() > 3) {
|
||||
// Computing circle center
|
||||
Point center = expolygon.contour.centroid();
|
||||
double radius_min = std::numeric_limits<float>::max(), radius_max = 0;
|
||||
coordf_t radius_min = std::numeric_limits<float>::max(), radius_max = 0;
|
||||
for (int i = 0; i < expolygon.contour.points.size(); ++i) {
|
||||
double dist = expolygon.contour.points[i].distance_to(center);
|
||||
coordf_t dist = expolygon.contour.points[i].distance_to(center);
|
||||
radius_min = std::min(radius_min, dist);
|
||||
radius_max = std::max(radius_max, dist);
|
||||
}
|
||||
@ -1634,7 +1635,7 @@ MedialAxis::build(ThickPolylines &polylines_out)
|
||||
if (this->expolygon.area() < this->min_width * this->min_width) return;
|
||||
|
||||
//check for circular shape
|
||||
double radius = check_circular(this->expolygon, this->min_width/4);
|
||||
coordf_t radius = check_circular(this->expolygon, this->min_width/4);
|
||||
if (radius > 0 && this->expolygon.contour.points.size() > 4) {
|
||||
ExPolygons miniPeri = offset_ex(this->expolygon.contour, -radius / 2);
|
||||
if (miniPeri.size() == 1 && miniPeri[0].holes.size() == 0) {
|
||||
@ -1742,9 +1743,9 @@ MedialAxis::build(ThickPolylines &polylines_out)
|
||||
|
||||
/* Find the maximum width returned; we're going to use this for validating and
|
||||
filtering the output segments. */
|
||||
double max_w = 0;
|
||||
coord_t max_w = 0;
|
||||
for (ThickPolylines::const_iterator it = pp.begin(); it != pp.end(); ++it)
|
||||
max_w = std::max(max_w, *std::max_element(it->width.begin(), it->width.end()));
|
||||
max_w = std::max(max_w, (coord_t)*std::max_element(it->width.begin(), it->width.end()));
|
||||
|
||||
//for (auto &p : pp) {
|
||||
// std::cout << "Start polyline : ";
|
||||
@ -1847,7 +1848,7 @@ MedialAxis::build(ThickPolylines &polylines_out)
|
||||
// svg.Close();
|
||||
//}
|
||||
|
||||
remove_too_short_polylines(pp, (coord_t)max_w * 2);
|
||||
remove_too_short_polylines(pp, max_w * 2);
|
||||
//{
|
||||
// std::stringstream stri;
|
||||
// stri << "medial_axis_8_tooshort_" << id << ".svg";
|
||||
@ -1907,7 +1908,7 @@ thin_variable_width(const ThickPolylines &polylines, ExtrusionRole role, Flow fl
|
||||
// this value determines granularity of adaptive width, as G-code does not allow
|
||||
// variable extrusion within a single move; this value shall only affect the amount
|
||||
// of segments, and any pruning shall be performed before we apply this tolerance
|
||||
const double tolerance = 4*SCALED_RESOLUTION;//scale_(0.05);
|
||||
const coord_t tolerance = 4 * SCALED_RESOLUTION;//scale_(0.05);
|
||||
|
||||
ExtrusionEntityCollection coll;
|
||||
for (const ThickPolyline &p : polylines) {
|
||||
@ -1923,9 +1924,9 @@ thin_variable_width(const ThickPolylines &polylines, ExtrusionRole role, Flow fl
|
||||
|
||||
assert(line.a_width >= 0);
|
||||
assert(line.b_width >= 0);
|
||||
double thickness_delta = fabs(line.a_width - line.b_width);
|
||||
if (thickness_delta > tolerance && ceil(thickness_delta / tolerance) > 2) {
|
||||
const uint16_t segments = 1+(uint16_t) std::min(16000.0, ceil(thickness_delta / tolerance));
|
||||
coord_t thickness_delta = std::abs(line.a_width - line.b_width);
|
||||
if (thickness_delta > tolerance && ceil(float(thickness_delta) / float(tolerance)) > 2) {
|
||||
const uint16_t segments = 1 + (uint16_t) std::min((uint32_t)16000, (uint32_t)ceil(float(thickness_delta) / float(tolerance)));
|
||||
Points pp;
|
||||
std::vector<coordf_t> width;
|
||||
{
|
||||
|
@ -109,7 +109,7 @@ class MedialAxis {
|
||||
/// taper the ends of polylines (don't activate that for gapfill)
|
||||
void taper_ends(ThickPolylines& pp);
|
||||
//cleaning method
|
||||
void check_width(ThickPolylines& pp, double max_width, std::string msg);
|
||||
void check_width(ThickPolylines& pp, coord_t max_width, std::string msg);
|
||||
//removing small extrusion that won't be useful and will harm print. A bit like fusion_corners but more lenient and with just del.
|
||||
void remove_bits(ThickPolylines& pp);
|
||||
};
|
||||
|
@ -8,7 +8,7 @@ namespace Slic3r {
|
||||
void MillingPostProcess::getExtrusionLoop(const Layer* layer, Polygon& poly, Polylines& entrypoints, ExtrusionEntityCollection& out_coll) {
|
||||
|
||||
|
||||
const double milling_diameter = scale_(this->print_config->milling_diameter.get_at(0));
|
||||
const coord_t milling_diameter = scale_t(this->print_config->milling_diameter.get_at(0));
|
||||
|
||||
//get the longest polyline
|
||||
Polyline best_polyline;
|
||||
@ -22,8 +22,8 @@ namespace Slic3r {
|
||||
//get two pair of points that are at less than max_dist.
|
||||
int32_t first_point_extract_idx = 1;
|
||||
int32_t first_point_idx = -1;
|
||||
const double dist_max_square = milling_diameter * milling_diameter / 4;
|
||||
double best_dist = dist_max_square;
|
||||
const coordf_t dist_max_square = coordf_t(milling_diameter) * coordf_t(milling_diameter / 4);
|
||||
coordf_t best_dist = dist_max_square;
|
||||
for (int32_t idx = 0; idx < poly.points.size(); idx++) {
|
||||
if (poly.points[idx].distance_to_square(best_polyline.points[first_point_extract_idx]) < best_dist) {
|
||||
best_dist = poly.points[idx].distance_to_square(best_polyline.points[first_point_extract_idx]);
|
||||
@ -91,7 +91,7 @@ namespace Slic3r {
|
||||
if (contour.polyline.points.size() > 3)
|
||||
contour.polyline.points.push_back(contour.polyline.points[1]);
|
||||
contour.mm3_per_mm = 0;
|
||||
contour.width = this->print_config->milling_diameter.get_at(0);
|
||||
contour.width = (float)this->print_config->milling_diameter.get_at(0);
|
||||
contour.height = (float)layer->height;
|
||||
out_coll.append(std::move(contour));
|
||||
return;
|
||||
@ -102,18 +102,18 @@ namespace Slic3r {
|
||||
{
|
||||
if (!can_be_milled(layer)) return ExtrusionEntityCollection();
|
||||
|
||||
const double milling_diameter = scale_(this->print_config->milling_diameter.get_at(0));
|
||||
const coord_t milling_diameter = scale_t(this->print_config->milling_diameter.get_at(0));
|
||||
|
||||
ExPolygons milling_lines;
|
||||
for (const Surface& surf : slices->surfaces) {
|
||||
ExPolygons surf_milling = offset_ex(surf.expolygon, milling_diameter/2, ClipperLib::jtRound);
|
||||
ExPolygons surf_milling = offset_ex(surf.expolygon, double(milling_diameter / 2), ClipperLib::jtRound);
|
||||
for (const ExPolygon& expoly : surf_milling)
|
||||
// expoly.simplify(SCALED_RESOLUTION, &milling_lines); // should already be done
|
||||
milling_lines.push_back(expoly);
|
||||
}
|
||||
milling_lines = union_ex(milling_lines);
|
||||
|
||||
ExPolygons secured_points = offset_ex(milling_lines, milling_diameter / 3);
|
||||
ExPolygons secured_points = offset_ex(milling_lines, double(milling_diameter / 3));
|
||||
ExPolygons entrypoints;
|
||||
for (const ExPolygon& expoly : secured_points)
|
||||
// expoly.simplify(SCALED_RESOLUTION, &entrypoints); // should already be done
|
||||
|
@ -154,7 +154,7 @@ class ThickPolyline : public Polyline {
|
||||
public:
|
||||
enum StartPos : int8_t{tpspBegin = -1, tpspBoth = 0, tpspEnd = 1};
|
||||
/// width size must be == point size
|
||||
std::vector<coordf_t> width;
|
||||
std::vector<coord_t> width;
|
||||
/// if true => it's an endpoint, if false it join an other ThickPolyline. first is at front(), second is at back()
|
||||
std::pair<bool, bool> endpoints;
|
||||
//if it's important to begin at a specific bit.
|
||||
|
@ -99,11 +99,10 @@ extern Semver SEMVER;
|
||||
template<typename T, typename Q>
|
||||
inline T unscale(Q v) { return T(v) * T(SCALING_FACTOR); }
|
||||
|
||||
inline double unscaled(double v) { return v * SCALING_FACTOR; }
|
||||
inline coordf_t unscale_(coord_t v) { return v * SCALING_FACTOR; }
|
||||
inline coord_t scale_t(coordf_t v) { return (coord_t)(v * UNSCALING_FACTOR); }
|
||||
inline double scale_d(coordf_t v) { return (v * UNSCALING_FACTOR); }
|
||||
inline double scale_d(coord_t v) { return (double(v) * UNSCALING_FACTOR); }
|
||||
inline double unscaled(coord_t v) { return double(v) * SCALING_FACTOR; }
|
||||
inline double unscaled(coordf_t v) { return v * SCALING_FACTOR; }
|
||||
inline coord_t scale_t(double v) { return coord_t(v * UNSCALING_FACTOR); }
|
||||
inline coordf_t scale_d(double v) { return coordf_t(v * UNSCALING_FACTOR); }
|
||||
|
||||
enum Axis {
|
||||
X=0,
|
||||
|
Loading…
x
Reference in New Issue
Block a user