cleaning warnings, add % for support interface gap

This commit is contained in:
supermerill 2019-01-30 15:52:30 +01:00
parent cfab40943f
commit f49af26123
8 changed files with 60 additions and 69 deletions

View File

@ -578,7 +578,10 @@ MedialAxis::fusion_corners(ThickPolylines &pp)
//FIXME: also pull (a bit less) points that are near to this one.
// if true, pull it a bit, depends on my size, the dot?, and the coeff at my 0-end (~14% for a square, almost 0 for a gentle curve)
coord_t length_pull = (coord_t)polyline.length();
length_pull *= (coord_t) 0.144 * get_coeff_from_angle_countour(polyline.points.back(), this->expolygon, std::min(min_width, (coord_t)(polyline.length() / 2)));
length_pull *= (coord_t)( 0.144 * get_coeff_from_angle_countour(
polyline.points.back(),
this->expolygon,
std::min(min_width, (coord_t)(polyline.length() / 2))));
//compute dir
Vec2d pull_direction(polyline.points[1].x() - polyline.points[0].x(), polyline.points[1].y() - polyline.points[0].y());
@ -610,7 +613,7 @@ MedialAxis::fusion_corners(ThickPolylines &pp)
void
MedialAxis::extends_line_both_side(ThickPolylines& pp) {
const ExPolygons anchors = offset2_ex(diff_ex(this->bounds, this->expolygon), -SCALED_RESOLUTION, SCALED_RESOLUTION);
const ExPolygons anchors = offset2_ex(diff_ex(this->bounds, this->expolygon), (float)-SCALED_RESOLUTION, (float)SCALED_RESOLUTION);
for (size_t i = 0; i < pp.size(); ++i) {
ThickPolyline& polyline = pp[i];
this->extends_line(polyline, anchors, this->min_width);
@ -816,7 +819,7 @@ MedialAxis::main_fusion(ThickPolylines& pp)
//compute angle to see if it's better than previous ones (straighter = better).
//we need to add how strait we are from our main.
float test_dot = dot(polyline.lines().front(), other.lines().front());
float test_dot = (float)(dot(polyline.lines().front(), other.lines().front()));
// Get the branch/line in wich we may merge, if possible
// with that, we can decide what is important, and how we can merge that.
@ -837,14 +840,14 @@ MedialAxis::main_fusion(ThickPolylines& pp)
find_main_branch = true;
else if (biggest_main_branch_length < main.length()) {
biggest_main_branch_id = k;
biggest_main_branch_length = main.length();
biggest_main_branch_length = (coord_t)main.length();
}
} else if (polyline.first_point().coincides_with(main.first_point())) {
if (!main.endpoints.second)
find_main_branch = true;
else if (biggest_main_branch_length < main.length()) {
biggest_main_branch_id = k;
biggest_main_branch_length = main.length();
biggest_main_branch_length = (coord_t)main.length();
}
}
if (find_main_branch) {
@ -871,7 +874,7 @@ MedialAxis::main_fusion(ThickPolylines& pp)
if (dot_poly_branch < 0) dot_poly_branch = 0;
if (dot_candidate_branch < 0) dot_candidate_branch = 0;
if (pp[biggest_main_branch_id].width.back()>0)
test_dot += 2 * dot_poly_branch ;
test_dot += 2 * (float)dot_poly_branch;
}
//test if it's useful to merge or not
//ie, don't merge 'T' but ok for 'Y', merge only lines of not disproportionate different length (ratio max: 4) (or they are both with 0-width end)
@ -956,7 +959,7 @@ MedialAxis::main_fusion(ThickPolylines& pp)
//failsafes
if (polyline.width[idx_point] > max_width)
polyline.width[idx_point] = max_width;
const coord_t max_width_contour = bounds.contour.closest_point(polyline.points[idx_point])->distance_to(polyline.points[idx_point]) * 2.1;
const coord_t max_width_contour = (coord_t) bounds.contour.closest_point(polyline.points[idx_point])->distance_to(polyline.points[idx_point]) * 2.1;
if (polyline.width[idx_point] > max_width_contour)
polyline.width[idx_point] = max_width_contour;
@ -1145,7 +1148,7 @@ MedialAxis::concatenate_polylines_with_crossing(ThickPolylines& pp)
v_poly *= (1 / std::sqrt(v_poly.x()*v_poly.x() + v_poly.y()*v_poly.y()));
Vec2d v_other(other.lines().front().vector().x(), other.lines().front().vector().y());
v_other *= (1 / std::sqrt(v_other.x()*v_other.x() + v_other.y()*v_other.y()));
float other_dot = v_poly.x()*v_other.x() + v_poly.y()*v_other.y();
float other_dot = (float)( v_poly.x()*v_other.x() + v_poly.y()*v_other.y() );
if (other_dot > best_dot) {
best_candidate = &other;
best_idx = j;
@ -1327,7 +1330,7 @@ MedialAxis::simplify_polygon_frontier()
}
if (!simplified_poly.contour.points.empty())
simplified_poly.remove_point_too_near(SCALED_RESOLUTION);
simplified_poly.remove_point_too_near((coord_t)SCALED_RESOLUTION);
return simplified_poly;
}
@ -1377,7 +1380,7 @@ MedialAxis::build(ThickPolylines* polylines_out) {
filtering the output segments. */
double max_w = 0;
for (ThickPolylines::const_iterator it = pp.begin(); it != pp.end(); ++it)
max_w = fmaxf(max_w, *std::max_element(it->width.begin(), it->width.end()));
max_w = std::max(max_w, *std::max_element(it->width.begin(), it->width.end()));
fusion_curve(pp);
@ -1464,7 +1467,7 @@ MedialAxis::build(ThickPolylines* polylines_out) {
// svg.Close();
//}
remove_too_short_polylines(pp, max_w * 2);
remove_too_short_polylines(pp, (coord_t)max_w * 2);
//{
// stringstream stri;
// stri << "medial_axis_8_tooshort_" << id << ".svg";
@ -1522,7 +1525,7 @@ MedialAxis::taper_ends(ThickPolylines& pp) {
polyline.width[0] = min_width;
coord_t current_dist = min_width;
for (size_t i = 1; i<polyline.width.size(); ++i) {
current_dist += polyline.points[i - 1].distance_to(polyline.points[i]);
current_dist += (coord_t) polyline.points[i - 1].distance_to(polyline.points[i]);
if (current_dist > polyline.width[i]) break;
polyline.width[i] = current_dist;
}
@ -1532,7 +1535,7 @@ MedialAxis::taper_ends(ThickPolylines& pp) {
polyline.width[last_idx] = min_width;
coord_t current_dist = min_width;
for (size_t i = 1; i<polyline.width.size(); ++i) {
current_dist += polyline.points[last_idx - i + 1].distance_to(polyline.points[last_idx - i]);
current_dist += (coord_t) polyline.points[last_idx - i + 1].distance_to(polyline.points[last_idx - i]);
if (current_dist > polyline.width[last_idx - i]) break;
polyline.width[last_idx - i] = current_dist;
}
@ -1562,7 +1565,7 @@ ExtrusionEntityCollection thin_variable_width(const ThickPolylines &polylines, E
double thickness_delta = fabs(line.a_width - line.b_width);
if (thickness_delta > tolerance) {
const unsigned short segments = ceil(thickness_delta / tolerance);
const uint16_t segments = (uint16_t) std::min(16000.0, ceil(thickness_delta / tolerance));
const coordf_t seg_len = line_len / segments;
Points pp;
std::vector<coordf_t> width;
@ -1602,7 +1605,7 @@ ExtrusionEntityCollection thin_variable_width(const ThickPolylines &polylines, E
path.polyline.append(line.b);
// Convert from spacing to extrusion width based on the extrusion model
// of a square extrusion ended with semi circles.
flow.width = unscaled(w) + flow.height * (1. - 0.25 * PI);
flow.width = (float)unscaled(w) + flow.height * (1. - 0.25 * PI);
#ifdef SLIC3R_DEBUG
printf(" filling %f gap\n", flow.width);
#endif

View File

@ -61,11 +61,11 @@ Polyline MotionPlanner::shortest_path(const Point &from, const Point &to)
return Polyline(from, to);
// Are both points in the same island?
int island_idx_from = -1;
int island_idx_to = -1;
int island_idx = -1;
int32_t island_idx_from = -1;
int32_t island_idx_to = -1;
int32_t island_idx = -1;
for (MotionPlannerEnv &island : m_islands) {
int idx = &island - m_islands.data();
int32_t idx = (int32_t)( &island - m_islands.data() );
if (island.island_contains(from))
island_idx_from = idx;
if (island.island_contains(to))

View File

@ -61,8 +61,8 @@ void PerimeterGenerator::process()
// which is the spacing between external and internal, which is not correct
// and would make the collapsing (thus the details resolution) dependent on
// internal flow which is unrelated.
coord_t min_spacing = (coord_t)perimeter_spacing * (1 - INSET_OVERLAP_TOLERANCE);
coord_t ext_min_spacing = (coord_t)ext_perimeter_spacing * (1 - INSET_OVERLAP_TOLERANCE);
coord_t min_spacing = (coord_t)( perimeter_spacing * (1 - INSET_OVERLAP_TOLERANCE) );
coord_t ext_min_spacing = (coord_t)( ext_perimeter_spacing * (1 - INSET_OVERLAP_TOLERANCE) );
// prepare grown lower layer slices for overhang detection
if (this->lower_slices != NULL && this->config->overhangs) {
@ -131,8 +131,8 @@ void PerimeterGenerator::process()
//it's not dangerous as it will be intersected by 'unsupported' later
//FIXME: add overlap in this->fill_surfaces->append
// add overlap (perimeter_spacing/4 was good in test, ie 25%)
coord_t overlap = scale_(this->config->get_abs_value("infill_overlap", unscale<double>(perimeter_spacing)));
unsupported_filtered = intersection_ex(unsupported_filtered, offset_ex(bridgeable_simplified, overlap));
double overlap = scale_(this->config->get_abs_value("infill_overlap", unscale<double>(perimeter_spacing)));
unsupported_filtered = intersection_ex(unsupported_filtered, offset_ex(bridgeable_simplified, (float) overlap));
} else {
unsupported_filtered.clear();
}
@ -152,7 +152,7 @@ void PerimeterGenerator::process()
ExPolygons bridge = unsupported_filtered;
unsupported_filtered = intersection_ex(offset_ex(unsupported_filtered, (float)(perimeter_spacing)), last);
// remove from the bridge & support the small imperfections of the union
ExPolygons bridge_and_support = offset2_ex(union_ex(bridge, support, true), perimeter_spacing/2, -perimeter_spacing/2);
ExPolygons bridge_and_support = offset2_ex(union_ex(bridge, support, true), (float)perimeter_spacing / 2, (float)-perimeter_spacing / 2);
// make him flush with perimeter area
unsupported_filtered = intersection_ex(offset_ex(unsupported_filtered, (float)(perimeter_spacing / 2)), bridge_and_support);
@ -207,7 +207,7 @@ void PerimeterGenerator::process()
}
if (!bridgeable_simplified.empty())
bridgeable_simplified = offset_ex(bridgeable_simplified, perimeter_spacing/1.9);
bridgeable_simplified = offset_ex(bridgeable_simplified, (float) perimeter_spacing / 1.9f);
if (!bridgeable_simplified.empty()) {
//offset by perimeter spacing because the simplify may have reduced it a bit.
unsupported = diff_ex(unsupported, bridgeable_simplified, true);
@ -215,10 +215,10 @@ void PerimeterGenerator::process()
}
}
} else {
ExPolygonCollection coll_last(intersection_ex(last, offset_ex(this->lower_slices->expolygons, -perimeter_spacing / 2)));
ExPolygonCollection coll_last(intersection_ex(last, offset_ex(this->lower_slices->expolygons, (float)-perimeter_spacing / 2)));
ExPolygon hull;
hull.contour = coll_last.convex_hull();
unsupported = diff_ex(offset_ex(unsupported, perimeter_spacing), ExPolygons() = { hull });
unsupported = diff_ex(offset_ex(unsupported, (float)perimeter_spacing), ExPolygons() = { hull });
}
if (!unsupported.empty()) {
//add fake perimeters here
@ -274,11 +274,11 @@ void PerimeterGenerator::process()
ExPolygons half_thins = offset_ex(thin_zones, (float)(-min_width / 2));
//simplify them
for (ExPolygon &half_thin : half_thins) {
half_thin.remove_point_too_near(SCALED_RESOLUTION);
half_thin.remove_point_too_near((float)SCALED_RESOLUTION);
}
//we push the bits removed and put them into what we will use as our anchor
if (half_thins.size() > 0) {
no_thin_zone = diff_ex(last, offset_ex(half_thins, (float)(min_width / 2) - SCALED_EPSILON), true);
no_thin_zone = diff_ex(last, offset_ex(half_thins, (float)(min_width / 2) - (float) SCALED_EPSILON), true);
}
// compute a bit of overlap to anchor thin walls inside the print.
ExPolygons thin_zones_extruded;
@ -292,9 +292,9 @@ void PerimeterGenerator::process()
for (ExPolygon &bound : bounds) {
if (!intersection_ex(thin[0], bound).empty()) {
//be sure it's not too small to extrude reliably
thin[0].remove_point_too_near(SCALED_RESOLUTION);
thin[0].remove_point_too_near((coord_t)SCALED_RESOLUTION);
if (thin[0].area() > min_width*(ext_perimeter_width + ext_perimeter_spacing2)) {
bound.remove_point_too_near(SCALED_RESOLUTION);
bound.remove_point_too_near((coord_t)SCALED_RESOLUTION);
// the maximum thickness of our thin wall area is equal to the minimum thickness of a single loop
Slic3r::MedialAxis ma(thin[0], bound, ext_perimeter_width + ext_perimeter_spacing2, min_width, this->layer_height);
ma.nozzle_diameter = (coord_t)scale_(this->ext_perimeter_flow.nozzle_diameter);
@ -476,8 +476,8 @@ void PerimeterGenerator::process()
double min = 0.2 * perimeter_width * (1 - INSET_OVERLAP_TOLERANCE);
double max = 2. * perimeter_spacing;
ExPolygons gaps_ex = diff_ex(
offset2_ex(gaps, -min/2, +min/2),
offset2_ex(gaps, -max/2, +max/2),
offset2_ex(gaps, (float)-min / 2, (float)+min / 2),
offset2_ex(gaps, (float)-max / 2, (float)+max / 2),
true);
ThickPolylines polylines;
for (const ExPolygon &ex : gaps_ex) {
@ -517,27 +517,27 @@ void PerimeterGenerator::process()
// only apply infill overlap if we actually have one perimeter
coord_t overlap = 0;
if (inset > 0) {
overlap = scale_(this->config->get_abs_value("infill_overlap", unscale<double>(inset + solid_infill_spacing / 2)));
overlap = scale_(this->config->get_abs_value("infill_overlap", unscale<coord_t>(inset + solid_infill_spacing / 2)));
}
// simplify infill contours according to resolution
Polygons pp;
for (ExPolygon &ex : last)
ex.simplify_p(SCALED_RESOLUTION, &pp);
// collapse too narrow infill areas
coord_t min_perimeter_infill_spacing = solid_infill_spacing * (1. - INSET_OVERLAP_TOLERANCE);
coord_t min_perimeter_infill_spacing = (coord_t)( solid_infill_spacing * (1. - INSET_OVERLAP_TOLERANCE) );
// append infill areas to fill_surfaces
//auto it_surf = this->fill_surfaces->surfaces.end();
this->fill_surfaces->append(
offset2_ex(
union_ex(pp),
-inset - min_perimeter_infill_spacing / 2 + overlap,
min_perimeter_infill_spacing / 2),
(float) min_perimeter_infill_spacing / 2),
stInternal);
if (overlap != 0) {
ExPolygons polyWithoutOverlap = offset2_ex(
union_ex(pp),
-inset - min_perimeter_infill_spacing / 2,
min_perimeter_infill_spacing / 2);
(float) min_perimeter_infill_spacing / 2);
this->fill_no_overlap.insert(this->fill_no_overlap.end(), polyWithoutOverlap.begin(), polyWithoutOverlap.end());
}
} // for each island
@ -577,7 +577,7 @@ ExtrusionEntityCollection PerimeterGenerator::_traverse_loops(
role,
is_external ? this->_ext_mm3_per_mm : this->_mm3_per_mm,
is_external ? this->ext_perimeter_flow.width : this->perimeter_flow.width,
this->layer_height);
(float) this->layer_height);
// get overhang paths by checking what parts of this loop fall
// outside the grown lower slices (thus where the distance between
@ -599,7 +599,7 @@ ExtrusionEntityCollection PerimeterGenerator::_traverse_loops(
path.polyline = loop->polygon.split_at_first_point();
path.mm3_per_mm = is_external ? this->_ext_mm3_per_mm : this->_mm3_per_mm;
path.width = is_external ? this->ext_perimeter_flow.width : this->perimeter_flow.width;
path.height = this->layer_height;
path.height = (float) this->layer_height;
paths.push_back(path);
}
@ -847,7 +847,7 @@ PerimeterGenerator::_extrude_and_cut_loop(const PerimeterGeneratorLoop &loop, co
role,
is_external ? this->_ext_mm3_per_mm : this->_mm3_per_mm,
is_external ? this->ext_perimeter_flow.width : this->perimeter_flow.width,
this->layer_height);
(float) this->layer_height);
// get overhang paths by checking what parts of this loop fall
// outside the grown lower slices (thus where the distance between
@ -1049,8 +1049,8 @@ PerimeterGenerator::_traverse_and_join_loops(const PerimeterGeneratorLoop &loop,
else
inner_start->polyline.clip_start(inner_start->polyline.length()/2);
} else {
double length_poly_1 = outer_start->polyline.length();
double length_poly_2 = outer_end->polyline.length();
coord_t length_poly_1 = (coord_t)outer_start->polyline.length();
coord_t length_poly_2 = (coord_t)outer_end->polyline.length();
coord_t length_trim_1 = outer_start_spacing / 2;
coord_t length_trim_2 = outer_end_spacing / 2;
if (length_poly_1 < length_trim_1) {
@ -1207,10 +1207,10 @@ PerimeterGenerator::_traverse_and_join_loops(const PerimeterGeneratorLoop &loop,
outer_end->extruder_id = -1;
}*/
//add paths into my_loop => after that all ref are wrong!
for (int i = travel_path_end.size() - 1; i >= 0; i--) {
for (int32_t i = travel_path_end.size() - 1; i >= 0; i--) {
my_loop.paths.insert(my_loop.paths.begin() + nearest.idx_polyline_outter + child_paths_size + 1, travel_path_end[i]);
}
for (int i = travel_path_begin.size() - 1; i >= 0; i--) {
for (int32_t i = travel_path_begin.size() - 1; i >= 0; i--) {
my_loop.paths.insert(my_loop.paths.begin() + nearest.idx_polyline_outter + 1, travel_path_begin[i]);
}
}

View File

@ -66,7 +66,7 @@ void Point::rotate(double angle, const Point &center)
(*this)(1) = (coord_t)round( (double)center(1) + c * dy + s * dx );
}
int Point::nearest_point_index(const Points &points) const
int32_t Point::nearest_point_index(const Points &points) const
{
PointConstPtrs p;
p.reserve(points.size());
@ -75,9 +75,9 @@ int Point::nearest_point_index(const Points &points) const
return this->nearest_point_index(p);
}
int Point::nearest_point_index(const PointConstPtrs &points) const
int32_t Point::nearest_point_index(const PointConstPtrs &points) const
{
int idx = -1;
int32_t idx = -1;
double distance = -1; // double because long is limited to 2147483647 on some platforms and it's not enough
for (PointConstPtrs::const_iterator it = points.begin(); it != points.end(); ++it) {
@ -91,7 +91,7 @@ int Point::nearest_point_index(const PointConstPtrs &points) const
d += sqr<double>((*this)(1) - (*it)->y());
if (distance != -1 && d > distance) continue;
idx = it - points.begin();
idx = (int32_t)(it - points.begin());
distance = d;
if (distance < EPSILON) break;
@ -123,7 +123,7 @@ Point::distance_to(const Line &line) const {
}
int Point::nearest_point_index(const PointPtrs &points) const
int32_t Point::nearest_point_index(const PointPtrs &points) const
{
PointConstPtrs p;
p.reserve(points.size());

View File

@ -112,9 +112,9 @@ public:
void rotate(double angle, const Point &center);
Point rotated(double angle) const { Point res(*this); res.rotate(angle); return res; }
Point rotated(double angle, const Point &center) const { Point res(*this); res.rotate(angle, center); return res; }
int nearest_point_index(const Points &points) const;
int nearest_point_index(const PointConstPtrs &points) const;
int nearest_point_index(const PointPtrs &points) const;
int32_t nearest_point_index(const Points &points) const;
int32_t nearest_point_index(const PointConstPtrs &points) const;
int32_t nearest_point_index(const PointPtrs &points) const;
bool nearest_point(const Points &points, Point* point) const;
double ccw(const Point &p1, const Point &p2) const;
double ccw(const Line &line) const;

View File

@ -53,7 +53,7 @@ Polygon::split_at_vertex(const Point &point) const
// Split a closed polygon into an open polyline, with the split point duplicated at both ends.
Polyline
Polygon::split_at_index(int index) const
Polygon::split_at_index(size_t index) const
{
Polyline polyline;
polyline.points.reserve(this->points.size() + 1);

View File

@ -38,7 +38,7 @@ public:
virtual Lines lines() const;
Polyline split_at_vertex(const Point &point) const;
// Split a closed polygon into an open polyline, with the split point duplicated at both ends.
Polyline split_at_index(int index) const;
Polyline split_at_index(size_t index) const;
// Split a closed polygon into an open polyline, with the split point duplicated at both ends.
Polyline split_at_first_point() const;
Points equally_spaced_points(double distance) const;

View File

@ -2215,10 +2215,9 @@ void PrintConfigDef::init_fff_params()
def->enum_labels.push_back("From plane");
def->enum_labels.push_back("None");
def->mode = comAdvanced;
def->default_value = new ConfigOptionEnum<SupportZDistanceType>(zdFilament);
def->default_value = new ConfigOptionEnum<SupportZDistanceType>(zdPlane);
def = this->add("support_material_contact_distance_top", coFloatOrPercent);
def->gui_type = "f_enum_open";
def->label = L("Top");
def->category = L("Support material");
def->tooltip = L("The vertical distance between support material interface and the object"
@ -2227,30 +2226,19 @@ void PrintConfigDef::init_fff_params()
"for the first object layer. Can be a % of the extruder size used for the interface layers.");
def->sidetext = L("mm");
def->cli = "support-material-contact-distance-top=f";
// def->min = 0;
def->enum_values.push_back("0");
def->enum_values.push_back("0.2");
def->enum_labels.push_back((boost::format("0 (%1%)") % L("bad bond")).str());
def->enum_labels.push_back((boost::format("0.2 (%1%)") % L("ordinary")).str());
def->mode = comAdvanced;
def->aliases = { "support_material_contact_distance" };
def->default_value = new ConfigOptionFloatOrPercent(50,true);
def->default_value = new ConfigOptionFloatOrPercent(100,true);
def = this->add("support_material_contact_distance_bottom", coFloatOrPercent);
def->gui_type = "f_enum_open";
def->label = L("Bottom");
def->category = L("Support material");
def->tooltip = L("The vertical distance between object and support material interface"
"(when the support is printed on top of the object). Can be a % of the extruder size used for the interface layers.");
def->sidetext = L("mm");
def->cli = "support-material-contact-distance-bottom=f";
// def->min = 0;
def->enum_values.push_back("0");
def->enum_values.push_back("0.2");
def->enum_labels.push_back((boost::format("0 (%1%)") % L("bad bond")).str());
def->enum_labels.push_back((boost::format("0.2 (%1%)") % L("ordinary")).str());
def->mode = comAdvanced;
def->default_value = new ConfigOptionFloatOrPercent(50,true);
def->default_value = new ConfigOptionFloatOrPercent(100,true);
def = this->add("support_material_enforce_layers", coInt);
def->label = L("Enforce support for the first");