Browse Source

fix min/max value for config: now double, not int
fix some wrning

supermerill 4 years ago
parent
commit
fc1ec534ad

+ 2 - 2
src/libslic3r/Config.hpp

@@ -1502,8 +1502,8 @@ public:
     // <min, max> limit of a numeric input.
     // If not set, the <min, max> is set to <INT_MIN, INT_MAX>
     // By setting min=0, only nonnegative input is allowed.
-    int                                 min = INT_MIN;
-    int                                 max = INT_MAX;
+    double                              min = INT_MIN;
+    double                              max = INT_MAX;
     ConfigOptionMode                    mode = comSimple;
     // Legacy names for this configuration option.
     // Used when parsing legacy configuration file.

+ 12 - 12
src/libslic3r/EdgeGrid.cpp

@@ -714,11 +714,11 @@ void EdgeGrid::Grid::calculate_sdf()
 									// Set the signum depending on whether the vertex is convex or reflex.
 									int64_t det = int64_t(v_seg_prev(0)) * int64_t(v_seg(1)) - int64_t(v_seg_prev(1)) * int64_t(v_seg(0));
 									assert(det != 0);
-									d_min = dabs;
+									d_min = float(dabs);
 									// Fill in an unsigned vector towards the zero iso surface.
 									float *l = &L[(corner_r * ncols + corner_c) << 1];
-									l[0] = std::abs(v_pt(0));
-									l[1] = std::abs(v_pt(1));
+									l[0] = float(std::abs(v_pt(0)));
+									l[1] = float(std::abs(v_pt(1)));
 								#ifdef _DEBUG
 									double dabs2 = sqrt(l[0]*l[0]+l[1]*l[1]);
 									assert(std::abs(dabs-dabs2) < 1e-4 * std::max(dabs, dabs2));
@@ -737,7 +737,7 @@ void EdgeGrid::Grid::calculate_sdf()
 							double d = double(d_seg) / sqrt(double(l2_seg));
 							double dabs = std::abs(d);
 							if (dabs < d_min) {
-								d_min = dabs;
+								d_min = float(dabs);
 								// Fill in an unsigned vector towards the zero iso surface.
 								float *l = &L[(corner_r * ncols + corner_c) << 1];
 								float linv = float(d_seg) / float(l2_seg);
@@ -861,22 +861,22 @@ void EdgeGrid::Grid::calculate_sdf()
 	for (size_t r = 0; r < nrows; ++ r) {
 		if (r > 0)
 			for (size_t c = 0; c < ncols; ++ c)
-				danielsson_vstep(r, c, -int(ncols));
+				danielsson_vstep(int(r), int(c), -int(ncols));
 //				PROPAGATE_DANIELSSON_SINGLE_VSTEP3(-int(ncols), c != 0, c + 1 != ncols);
 		for (size_t c = 1; c < ncols; ++ c)
-			danielsson_hstep(r, c, -1);
+			danielsson_hstep(int(r), int(c), -1);
 		for (int c = int(ncols) - 2; c >= 0; -- c)
-			danielsson_hstep(r, c, +1);
+			danielsson_hstep(int(r), int(c), +1);
 	}
 	// Bottom to top propagation.
 	for (int r = int(nrows) - 2; r >= 0; -- r) {
 		for (size_t c = 0; c < ncols; ++ c)
-			danielsson_vstep(r, c, +ncols);
+			danielsson_vstep(int(r), int(c), +int(ncols));
 //			PROPAGATE_DANIELSSON_SINGLE_VSTEP3(+int(ncols), c != 0, c + 1 != ncols);
 		for (size_t c = 1; c < ncols; ++ c)
-			danielsson_hstep(r, c, -1);
+			danielsson_hstep(int(r), int(c), -1);
 		for (int c = int(ncols) - 2; c >= 0; -- c)
-			danielsson_hstep(r, c, +1);
+			danielsson_hstep(int(r), int(c), +1);
 	}
 
 	// Update signed distance field from absolte vectors to the iso-surface.
@@ -1076,8 +1076,8 @@ EdgeGrid::Grid::ClosestPointResult EdgeGrid::Grid::closest_point(const Point &pt
 	// Signum of the distance field at pt.
 	int sign_min = 0;
 	double l2_seg_min = 1.;
-	for (int r = bbox.min(1); r <= bbox.max(1); ++ r) {
-		for (int c = bbox.min(0); c <= bbox.max(0); ++ c) {
+	for (size_t r = bbox.min.y(); r <= bbox.max.y(); ++ r) {
+		for (size_t c = bbox.min.x(); c <= bbox.max.x(); ++ c) {
 			const Cell &cell = m_cells[r * m_cols + c];
 			for (size_t i = cell.begin; i < cell.end; ++ i) {
 				const size_t          contour_idx = m_cell_data[i].first;

+ 2 - 2
src/libslic3r/ExPolygon.cpp

@@ -531,7 +531,7 @@ void ExPolygon::triangulate_p2t(Polygons* polygons) const
         std::vector<p2t::Point*> ContourPoints;
         for (const Point &pt : ex->contour.points)
             // We should delete each p2t::Point object
-            ContourPoints.push_back(new p2t::Point(pt(0), pt(1)));
+            ContourPoints.push_back(new p2t::Point(double(pt.x()), double(pt.y())));
         p2t::CDT cdt(ContourPoints);
 
         // holes
@@ -539,7 +539,7 @@ void ExPolygon::triangulate_p2t(Polygons* polygons) const
             std::vector<p2t::Point*> points;
             for (const Point &pt : hole->points)
                 // will be destructed in SweepContext::~SweepContext
-                points.push_back(new p2t::Point(pt(0), pt(1)));
+                points.push_back(new p2t::Point(double(pt.x()), double(pt.y())));
             cdt.AddHole(points);
         }
         

+ 2 - 2
src/libslic3r/ExtrusionEntity.hpp

@@ -255,7 +255,7 @@ public:
     ExtrusionPath3D& operator=(ExtrusionPath3D &&rhs) { m_role = rhs.m_role; this->mm3_per_mm = rhs.mm3_per_mm; this->width = rhs.width; this->height = rhs.height; 
         this->polyline = std::move(rhs.polyline); z_offsets = std::move(rhs.z_offsets); return *this;
     }
-    virtual ExtrusionPath3D* clone() const { return new ExtrusionPath3D(*this); }
+    virtual ExtrusionPath3D* clone() const override { return new ExtrusionPath3D(*this); }
     virtual ExtrusionPath3D* clone_move() override { return new ExtrusionPath3D(std::move(*this)); }
     virtual void visit(ExtrusionVisitor &visitor) override { visitor.use(*this); };
     virtual void visit(ExtrusionVisitorConst &visitor) const override { visitor.use(*this); };
@@ -407,7 +407,7 @@ public:
     virtual bool can_reverse() const override { return false; }
     virtual ExtrusionEntity* clone() const override{ return new ExtrusionLoop (*this); }
     // Create a new object, initialize it with this object using the move semantics.
-    ExtrusionEntity* clone_move() override { return new ExtrusionLoop(std::move(*this)); }
+    virtual ExtrusionEntity* clone_move() override { return new ExtrusionLoop(std::move(*this)); }
     bool make_clockwise();
     bool make_counter_clockwise();
     virtual void reverse() override;

+ 7 - 6
src/libslic3r/Fill/Fill.cpp

@@ -61,7 +61,7 @@ void make_fill(LayerRegion &layerm, ExtrusionEntityCollection &out)
         //if internal infill can be dense, place it on his own group
         if (layerm.region()->config().infill_dense.getBool() && layerm.region()->config().fill_density<40) {
             SurfacesPtr *denseGroup = NULL;
-            const uint32_t nbGroups = groups.size();
+            const size_t nbGroups = groups.size();
             for (uint32_t num_group = 0; num_group < nbGroups; ++num_group) {
                 for (uint32_t num_srf = 0; num_srf < groups[num_group].size(); ++num_srf) {
                     Surface *srf = groups[num_group][num_srf];
@@ -244,11 +244,12 @@ void make_fill(LayerRegion &layerm, ExtrusionEntityCollection &out)
         params.dont_connect = layerm.region()->config().infill_not_connected.getBool();
         //adjust flow (to over-extrude when needed)
         float flow_percent = 1;
-        if (surface.has_pos_top()) flow_percent *= layerm.region()->config().fill_top_flow_ratio.get_abs_value(1);
+        if (surface.has_pos_top())
+            flow_percent *= float(layerm.region()->config().fill_top_flow_ratio.get_abs_value(1));
         params.flow_mult = flow_percent;
         //adjust spacing (to over-extrude when needed)
         if (surface.has_mod_overBridge()) {
-            params.density = layerm.region()->config().over_bridge_flow_ratio.get_abs_value(1);
+            params.density = float(layerm.region()->config().over_bridge_flow_ratio.get_abs_value(1));
         }
         params.config = &layerm.region()->config();
         
@@ -303,7 +304,7 @@ void make_fill(LayerRegion &layerm, ExtrusionEntityCollection &out)
         f->z = layerm.layer()->print_z;
         if (is_denser)f->angle = 0;
         else f->angle = float(Geometry::deg2rad(layerm.region()->config().fill_angle.value));
-        f->angle += PI * (layerm.region()->config().fill_angle_increment.value * layerm.layer()->id()) / 180.;
+        f->angle += float(PI * (layerm.region()->config().fill_angle_increment.value * layerm.layer()->id()) / 180.f);
         // Maximum length of the perimeter segment linking two infill lines.
         f->link_max_length = (coord_t)scale_(link_max_length);
         // Used by the concentric infill pattern to clip the loops to create extrusion paths.
@@ -329,13 +330,13 @@ void make_fill(LayerRegion &layerm, ExtrusionEntityCollection &out)
             // so we can safely ignore the slight variation that might have
             // been applied to $f->flow_spacing
         } else {
-            flow = Flow::new_from_spacing(f->get_spacing(), flow.nozzle_diameter, (float)h, is_bridge);
+            flow = Flow::new_from_spacing((float)f->get_spacing(), flow.nozzle_diameter, (float)h, is_bridge);
         }
         params.flow = &flow;
 
         //apply bridge_overlap if needed
         if (is_bridge && density > 99 && layerm.region()->config().bridge_overlap.get_abs_value(1) != 1) {
-            params.density *= layerm.region()->config().bridge_overlap.get_abs_value(1);
+            params.density *= float(layerm.region()->config().bridge_overlap.get_abs_value(1));
         }
 
         f->fill_surface_extrusion(&surface, params, out.entities);

+ 2 - 2
src/libslic3r/Fill/Fill3DHoneycomb.cpp

@@ -154,8 +154,8 @@ void Fill3DHoneycomb::_fill_surface_single(
     Polylines   polylines = makeGrid(
         scale_(this->z),
         distance,
-        ceil(bb.size().x() / distance) + 1,
-        ceil(bb.size().y() / distance) + 1,
+        (size_t)ceil(bb.size().x() / distance) + 1,
+        (size_t)ceil(bb.size().y() / distance) + 1,
 		size_t((this->layer_id / thickness_layers) % 2) + 1);
 	//makeGrid(coord_t z, coord_t gridSize, size_t gridWidth, size_t gridHeight, size_t curveType)
     

+ 8 - 8
src/libslic3r/Fill/FillBase.cpp

@@ -264,7 +264,7 @@ bool collision(const Points &pts_to_check, const Polylines &polylines_blocker, c
     //convert to double to allow ² operation 
     double min_dist_square = (double)width * (double)width * 0.9 - SCALED_EPSILON;
     Polyline better_polylines(pts_to_check);
-    Points better_pts = better_polylines.equally_spaced_points(width / 2);
+    Points better_pts = better_polylines.equally_spaced_points(double(width / 2));
     for (const Point &p : better_pts) {
         for (const Polyline &poly2 : polylines_blocker) {
             for (const Point &p2 : poly2.points) {
@@ -584,7 +584,7 @@ Fill::do_gap_fill(const ExPolygons &gapfill_areas, const FillParams &params, Ext
     double max = 2. * params.flow->scaled_width();
     // collapse 
     //be sure we don't gapfill where the perimeters are already touching each other (negative spacing).
-    min = std::max(min, double(Flow::new_from_spacing(EPSILON, params.flow->nozzle_diameter, params.flow->height, false).scaled_width()));
+    min = std::max(min, double(Flow::new_from_spacing((float)EPSILON, (float)params.flow->nozzle_diameter, (float)params.flow->height, false).scaled_width()));
     //ExPolygons gapfill_areas_collapsed = diff_ex(
     //    offset2_ex(gapfill_areas, double(-min / 2), double(+min / 2)),
     //    offset2_ex(gapfill_areas, double(-max / 2), double(+max / 2)),
@@ -813,7 +813,7 @@ void mark_boundary_segments_touching_infill(
 	EdgeGrid::Grid grid;
 	grid.set_bbox(boundary_bbox);
 	// Inflate the bounding box by a thick line width.
-	grid.create(boundary, clip_distance + scale_(10.));
+	grid.create(boundary, coord_t(clip_distance + scale_(10.)));
 
 	struct Visitor {
 		Visitor(const EdgeGrid::Grid &grid, const std::vector<Points> &boundary, std::vector<std::vector<ContourPointData>> &boundary_data, const double dist2_max) :
@@ -871,7 +871,7 @@ void mark_boundary_segments_touching_infill(
 	} visitor(grid, boundary, boundary_data, distance_colliding * distance_colliding);
 
 	BoundingBoxf bboxf(boundary_bbox.min.cast<double>(), boundary_bbox.max.cast<double>());
-	bboxf.offset(- SCALED_EPSILON);
+	bboxf.offset(coordf_t(-SCALED_EPSILON));
 
 	for (const Polyline &polyline : infill) {
 		// Clip the infill polyline by the Eucledian distance along the polyline.
@@ -940,7 +940,7 @@ void Fill::connect_infill(Polylines &&infill_ordered, const ExPolygon &boundary_
 	assert(! boundary_src.contour.points.empty());
 
 	BoundingBox bbox = get_extents(boundary_src.contour);
-	bbox.offset(SCALED_EPSILON);
+	bbox.offset(coordf_t(SCALED_EPSILON));
 
 	// 1) Add the end points of infill_ordered to boundary_src.
 	std::vector<Points>					   		boundary;
@@ -1019,7 +1019,7 @@ void Fill::connect_infill(Polylines &&infill_ordered, const ExPolygon &boundary_
 	// Connection from end of one infill line to the start of another infill line.
 	//const float length_max = scale_(spacing);
 //	const float length_max = scale_((2. / params.density) * spacing);
-	const float length_max = scale_((1000. / params.density) * spacing);
+	const coord_t length_max = scale_((1000. / params.density) * spacing);
 	std::vector<size_t> merged_with(infill_ordered.size());
 	for (size_t i = 0; i < merged_with.size(); ++ i)
 		merged_with[i] = i;
@@ -1049,10 +1049,10 @@ void Fill::connect_infill(Polylines &&infill_ordered, const ExPolygon &boundary_
 			}
 			assert(param_lo >= 0.f && param_lo <= param_end);
 			assert(param_hi >= 0.f && param_hi <= param_end);
-			double len = param_hi - param_lo;
+            coord_t len = coord_t(param_hi - param_lo);
 			if (len < length_max)
 				connections_sorted.emplace_back(idx_chain - 1, len, reversed);
-			len = param_lo + param_end - param_hi;
+			len = coord_t(param_lo + param_end - param_hi);
 			if (len < length_max)
 				connections_sorted.emplace_back(idx_chain - 1, len, ! reversed);
 		}

+ 3 - 3
src/libslic3r/Fill/FillConcentric.cpp

@@ -38,7 +38,7 @@ FillConcentric::_fill_surface_single(
     Polygons loops = (Polygons)expolygon;
     Polygons last  = loops;
     while (! last.empty()) {
-        last = offset2(last, -(distance + scale_(this->spacing) /2), +scale_(this->spacing) /2);
+        last = offset2(last, -double(distance + scale_(this->spacing) /2), +double(scale_(this->spacing) /2));
         loops.insert(loops.end(), last.begin(), last.end());
     }
 
@@ -58,7 +58,7 @@ FillConcentric::_fill_surface_single(
     // Keep valid paths only.
     size_t j = iPathFirst;
     for (size_t i = iPathFirst; i < polylines_out.size(); ++ i) {
-        polylines_out[i].clip_end(this->loop_clipping);
+        polylines_out[i].clip_end(double(this->loop_clipping));
         if (polylines_out[i].is_valid()) {
             if (j < i)
                 polylines_out[j] = std::move(polylines_out[i]);
@@ -105,7 +105,7 @@ FillConcentricWGapFill::fill_surface_extrusion(
         Polygons loops = (Polygons)expolygon;
         Polygons last = loops;
         while (!last.empty()) {
-            Polygons next_onion = offset2(last, -(distance + scale_(this->spacing) / 2), +scale_(this->spacing) / 2);
+            Polygons next_onion = offset2(last, -double(distance + scale_(this->spacing) / 2), +double(scale_(this->spacing) / 2));
             loops.insert(loops.end(), next_onion.begin(), next_onion.end());
             append(gaps, diff_ex(
                 offset(last, -0.5f * distance),

+ 5 - 5
src/libslic3r/Fill/FillGyroid.cpp

@@ -37,10 +37,10 @@ static inline Polyline make_wave(
     double period = points.back()(0);
     if (width != period) // do not extend if already truncated
     {
-        points.reserve(one_period.size() * floor(width / period));
+        points.reserve(one_period.size() * size_t(floor(width / period)));
         points.pop_back();
 
-        int n = points.size();
+        size_t n = points.size();
         do {
             points.emplace_back(Vec2d(points[points.size()-n](0) + period, points[points.size()-n](1)));
         } while (points.back()(0) < width - EPSILON);
@@ -67,7 +67,7 @@ static std::vector<Vec2d> make_one_period(double width, double scaleFactor, doub
     std::vector<Vec2d> points;
     double dx = M_PI_2; // exact coordinates on main inflexion lobes
     double limit = std::min(2*M_PI, width);
-    points.reserve(ceil(limit / tolerance / 3));
+    points.reserve(size_t(ceil(limit / tolerance / 3)));
 
     for (double x = 0.; x < limit - EPSILON; x += dx) {
         points.emplace_back(Vec2d(x, f(x, z_sin, z_cos, vertical, flip)));
@@ -155,7 +155,7 @@ void FillGyroid::_fill_surface_single(
     ExPolygon                       &expolygon, 
     Polylines                       &polylines_out) const
 {
-    float infill_angle = this->angle + (CorrectionAngle * 2*M_PI) / 360.;
+    float infill_angle = float(this->angle + (CorrectionAngle * 2 * M_PI) / 360.f);
     if(abs(infill_angle) >= EPSILON)
         expolygon.rotate(-infill_angle);
 
@@ -170,7 +170,7 @@ void FillGyroid::_fill_surface_single(
 
     // generate pattern
     Polylines polylines = make_gyroid_waves(
-        scale_(this->z),
+        (double)scale_(this->z),
         density_adjusted,
         this->spacing,
         ceil(bb.size()(0) / distance) + 1.,

+ 5 - 5
src/libslic3r/Fill/FillHoneycomb.cpp

@@ -22,14 +22,14 @@ void FillHoneycomb::_fill_surface_single(
         it_m = FillHoneycomb::cache.insert(it_m, std::pair<CacheID, CacheData>(cache_id, CacheData()));
         CacheData &m = it_m->second;
         coord_t min_spacing = scale_(this->spacing);
-        m.distance = min_spacing / params.density;
-        m.hex_side = m.distance / (sqrt(3)/2);
+        m.distance = coord_t(double(min_spacing) / params.density);
+        m.hex_side = coord_t(double(m.distance) / (sqrt(3)/2));
         m.hex_width = m.distance * 2; // $m->{hex_width} == $m->{hex_side} * sqrt(3);
         coord_t hex_height = m.hex_side * 2;
         m.pattern_height = hex_height + m.hex_side;
-        m.y_short = m.distance * sqrt(3)/3;
+        m.y_short = coord_t(double(m.distance) * sqrt(3)/3);
         m.x_offset = min_spacing / 2;
-        m.y_offset = m.x_offset * sqrt(3)/3;
+        m.y_offset = coord_t(double(m.x_offset) * sqrt(3)/3);
         m.hex_center = Point(m.hex_width/2, m.hex_side);
     }
     CacheData &m = it_m->second;
@@ -113,7 +113,7 @@ void FillHoneycomb::_fill_surface_single(
         }
         
         // clip paths again to prevent connection segments from crossing the expolygon boundaries
-        paths = intersection_pl(paths, to_polygons(offset_ex(expolygon, SCALED_EPSILON)));
+        paths = intersection_pl(paths, to_polygons(offset_ex(expolygon, (double)SCALED_EPSILON)));
         // Move the polylines to the output, avoid a deep copy.
         size_t j = polylines_out.size();
         polylines_out.resize(j + paths.size(), Polyline());

Some files were not shown because too many files changed in this diff