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

fix some wrning
This commit is contained in:
supermerill 2020-09-24 16:49:04 +02:00
parent 2b12360593
commit fc1ec534ad
23 changed files with 116 additions and 108 deletions

View File

@ -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.

View File

@ -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;

View File

@ -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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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)

View File

@ -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);
}

View File

@ -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),

View File

@ -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.,

View File

@ -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());

View File

@ -23,8 +23,8 @@ void FillPlanePath::_fill_surface_single(
Point shift = this->_centered() ?
bounding_box.center() :
bounding_box.min;
expolygon.translate(-shift(0), -shift(1));
bounding_box.translate(-shift(0), -shift(1));
expolygon.translate(-double(shift.x()), -double(shift.y()));
bounding_box.translate(-double(shift.x()), -double(shift.y()));
Pointfs pts = _generate(
coord_t(ceil(coordf_t(bounding_box.min(0)) / distance_between_lines)),
@ -61,7 +61,7 @@ void FillPlanePath::_fill_surface_single(
// paths must be repositioned and rotated back
for (Polylines::iterator it = polylines.begin(); it != polylines.end(); ++ it) {
it->translate(shift(0), shift(1));
it->translate(double(shift.x()), double(shift.y()));
it->rotate(direction.first);
}
}

View File

@ -1330,7 +1330,7 @@ void GCode::_do_export(Print &print, FILE *file)
BoundingBoxf3 m_bounding_box = print_instance.model_instance->transform_bounding_box(raw_bbox);
_write_format(file, "; object:{\"name\":\"%s\",\"id\":\"%s id:%d copy %d\",\"object_center\":[%f,%f,%f],\"boundingbox_center\":[%f,%f,%f],\"boundingbox_size\":[%f,%f,%f]}\n",
object_name.c_str(), print_object->model_object()->name.c_str(), this->m_ordered_objects.size() - 1, copy_id,
m_bounding_box.center().x(), m_bounding_box.center().y(), 0,
m_bounding_box.center().x(), m_bounding_box.center().y(), 0.,
m_bounding_box.center().x(), m_bounding_box.center().y(), m_bounding_box.center().z(),
m_bounding_box.size().x(), m_bounding_box.size().y(), m_bounding_box.size().z()
);

View File

@ -141,7 +141,7 @@ const Color GCodePreviewData::Extrusion::Default_Extrusion_Role_Colors[erCount]
Color(0.0f, 0.5f, 0.0f, 1.0f), // erSupportMaterial
Color(0.0f, 0.0f, 0.5f, 1.0f), // erSupportMaterialInterface
Color(0.7f, 0.89f, 0.67f, 1.0f), // erWipeTower
Color(0.7f, 0.7, 0.7, 1.0f), // erMilling
Color(0.7f, 0.7f, 0.7f, 1.0f), // erMilling
Color(1.0f, 1.0f, 0.0f, 1.0f), // erCustom
Color(0.0f, 0.0f, 0.0f, 1.0f) // erMixed
};

View File

@ -386,7 +386,7 @@ void PerimeterGenerator::process()
coord_t offset = scale_(config->overhangs_reverse_threshold.get_abs_value(this->perimeter_flow.width));
//version with °: scale_(std::tan(PI * (0.5f / 90) * config->overhangs_reverse_threshold.value ) * this->layer->height)
if (offset_ex(overhangs_unsupported, -offset / 2).size() > 0) {
if (offset_ex(overhangs_unsupported, -offset / 2.).size() > 0) {
//allow this loop to be printed in reverse
has_steep_overhang = true;
}
@ -433,7 +433,7 @@ void PerimeterGenerator::process()
// look for thin walls
if (this->config->thin_walls) {
// detect edge case where a curve can be split in multiple small chunks.
std::vector<float> divs = {2.2,1.75,1.5}; //don't go too far, it's not possible to print thinw wall after that
std::vector<float> divs = {2.2f,1.75f,1.5f}; //don't go too far, it's not possible to print thinw wall after that
size_t idx_div = 0;
while (next_onion.size() > last.size() && idx_div < divs.size()) {
float div = divs[idx_div];
@ -460,7 +460,7 @@ void PerimeterGenerator::process()
ExPolygons half_thins = offset_ex(thin_zones, double(-min_width / 2));
//simplify them
for (ExPolygon &half_thin : half_thins) {
half_thin.remove_point_too_near((float)SCALED_RESOLUTION);
half_thin.remove_point_too_near((coord_t)SCALED_RESOLUTION);
}
//we push the bits removed and put them into what we will use as our anchor
if (half_thins.size() > 0) {
@ -525,7 +525,7 @@ void PerimeterGenerator::process()
+(float)(min_spacing / 2 - 1));
ExPolygons no_thin_onion = offset_ex(last, double(-good_spacing));
std::vector<float> divs { 1.8, 1.6 }; //don't over-extrude, so don't use divider >2
std::vector<float> divs { 1.8f, 1.6f }; //don't over-extrude, so don't use divider >2
size_t idx_div = 0;
while (next_onion.size() > no_thin_onion.size() && idx_div < divs.size()) {
float div = divs[idx_div];
@ -590,13 +590,13 @@ void PerimeterGenerator::process()
//split the polygons with top/not_top
//get the offset from solid surface anchor
coord_t offset_top_surface = scale_(config->external_infill_margin.get_abs_value(
config->perimeters.value == 0 ? 0. : unscaled(ext_perimeter_width + perimeter_spacing * int(int(config->perimeters.value) - int(1)))));
config->perimeters.value == 0 ? 0. : unscaled(double(ext_perimeter_width + perimeter_spacing * int(int(config->perimeters.value) - int(1))))));
// if possible, try to not push the extra perimeters inside the sparse infill
if (offset_top_surface > 0.9 * (config->perimeters.value <= 1 ? 0. : (perimeter_spacing * (config->perimeters.value - 1))))
offset_top_surface -= 0.9 * (config->perimeters.value <= 1 ? 0. : (perimeter_spacing * (config->perimeters.value - 1)));
offset_top_surface -= coord_t(0.9 * (config->perimeters.value <= 1 ? 0. : (perimeter_spacing * (config->perimeters.value - 1))));
else offset_top_surface = 0;
//don't takes into account too thin areas
double min_width_top_surface = std::max(double(ext_perimeter_spacing / 2 + 10), this->config->min_width_top_surface.get_abs_value(perimeter_width));
double min_width_top_surface = std::max(double(ext_perimeter_spacing / 2 + 10), this->config->min_width_top_surface.get_abs_value(double(perimeter_width)));
ExPolygons grown_upper_slices = offset_ex(*this->upper_slices, min_width_top_surface);
//set the clip to a virtual "second perimeter"
fill_clip = offset_ex(last, -double(ext_perimeter_spacing));
@ -604,8 +604,8 @@ void PerimeterGenerator::process()
ExPolygons top_polygons = (!have_to_grow_for_miller)
? diff_ex(last, grown_upper_slices, true)
:(unmillable.empty())
? diff_ex(last, offset_ex(grown_upper_slices, mill_extra_size), true)
: diff_ex(last, diff_ex(offset_ex(grown_upper_slices, mill_extra_size), unmillable, true));
? diff_ex(last, offset_ex(grown_upper_slices, (double)mill_extra_size), true)
: diff_ex(last, diff_ex(offset_ex(grown_upper_slices, (double)mill_extra_size), unmillable, true));
//get the not-top surface, from the "real top" but enlarged by external_infill_margin (and the min_width_top_surface we removed a bit before)
@ -792,7 +792,7 @@ void PerimeterGenerator::process()
// collapse
double min = 0.2 * perimeter_width * (1 - INSET_OVERLAP_TOLERANCE);
//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, nozzle_diameter, this->layer->height, false).scaled_width()));
min = std::max(min, double(Flow::new_from_spacing(EPSILON, (float)nozzle_diameter, (float)this->layer->height, false).scaled_width()));
double max = 2.2 * perimeter_spacing;
//remove areas that are too big (shouldn't occur...)
ExPolygons gaps_ex_to_test = diff_ex(
@ -800,7 +800,7 @@ void PerimeterGenerator::process()
offset2_ex(gaps, double(-max / 2), double(+max / 2)),
true);
ExPolygons gaps_ex;
const double minarea = scale_(scale_(this->config->gap_fill_min_area.get_abs_value(unscaled(perimeter_width)*unscaled(perimeter_width))));
const double minarea = scale_(scale_(this->config->gap_fill_min_area.get_abs_value(unscaled((double)perimeter_width)*unscaled((double)perimeter_width))));
// check each gapfill area to see if it's printable.
for (const ExPolygon &expoly : gaps_ex_to_test) {
//remove too small gaps that are too hard to fill.
@ -900,12 +900,12 @@ void PerimeterGenerator::process()
// append infill areas to fill_surfaces
//auto it_surf = this->fill_surfaces->surfaces.end();
ExPolygons infill_exp = offset2_ex(not_filled_exp,
-inset - min_perimeter_infill_spacing / 2 + infill_peri_overlap - infill_gap,
(float)min_perimeter_infill_spacing / 2);
double(-inset - min_perimeter_infill_spacing / 2 + infill_peri_overlap - infill_gap),
double(min_perimeter_infill_spacing / 2));
//if any top_fills, grow them by ext_perimeter_spacing/2 to have the real un-anchored fill
ExPolygons top_infill_exp = intersection_ex(fill_clip, offset_ex(top_fills, ext_perimeter_spacing / 2));
ExPolygons top_infill_exp = intersection_ex(fill_clip, offset_ex(top_fills, double(ext_perimeter_spacing / 2)));
if (!top_fills.empty()) {
infill_exp = union_ex(infill_exp, offset_ex(top_infill_exp, infill_peri_overlap));
infill_exp = union_ex(infill_exp, offset_ex(top_infill_exp, double(infill_peri_overlap)));
}
this->fill_surfaces->append(infill_exp, stPosInternal | stDensSparse);
@ -914,12 +914,12 @@ void PerimeterGenerator::process()
if (min_perimeter_infill_spacing / 2 > infill_peri_overlap)
polyWithoutOverlap = offset2_ex(
not_filled_exp,
-inset - infill_gap - min_perimeter_infill_spacing / 2 + infill_peri_overlap,
(float)min_perimeter_infill_spacing / 2 - infill_peri_overlap);
double(-inset - infill_gap - min_perimeter_infill_spacing / 2 + infill_peri_overlap),
double(min_perimeter_infill_spacing / 2 - infill_peri_overlap));
else
polyWithoutOverlap = offset_ex(
not_filled_exp,
-inset - infill_gap);
double(-inset - infill_gap));
if (!top_fills.empty()) {
polyWithoutOverlap = union_ex(polyWithoutOverlap, top_infill_exp);
}
@ -1176,7 +1176,7 @@ void PerimeterGenerator::_merge_thin_walls(ExtrusionEntityCollection &extrusions
int idx = 0;
for (ThickPolyline &tw : thin_walls) {
searcher.thin_wall = &tw;
searcher.search_result.dist = max_width;
searcher.search_result.dist = double(max_width);
searcher.search_result.dist *= searcher.search_result.dist;
searcher.search_result.path = nullptr;
searcher.use(extrusions);
@ -1218,7 +1218,7 @@ void PerimeterGenerator::_merge_thin_walls(ExtrusionEntityCollection &extrusions
//first add the return path
ExtrusionEntityCollection tws_second = tws;
tws_second.reverse();
change_flow.percent_extrusion = 0.1;
change_flow.percent_extrusion = 0.1f;
change_flow.use(tws_second);
for (ExtrusionPath &path : change_flow.paths)
path.reverse();
@ -1226,7 +1226,7 @@ void PerimeterGenerator::_merge_thin_walls(ExtrusionEntityCollection &extrusions
searcher.search_result.loop->paths.insert(searcher.search_result.loop->paths.begin() + 1 + searcher.search_result.idx_path,
change_flow.paths.begin(), change_flow.paths.end());
//add the real extrusion path
change_flow.percent_extrusion = 0.9;
change_flow.percent_extrusion = 0.9f;
change_flow.paths = std::vector<ExtrusionPath>();
change_flow.use(tws);
searcher.search_result.loop->paths.insert(searcher.search_result.loop->paths.begin() + 1 + searcher.search_result.idx_path,
@ -1540,7 +1540,7 @@ PerimeterGenerator::_traverse_and_join_loops(const PerimeterGeneratorLoop &loop,
PerimeterGeneratorLoops childs = children;
while (!childs.empty()) {
child_idx++;
PerimeterIntersectionPoint nearest = this->_get_nearest_point(childs, my_loop, this->perimeter_flow.scaled_width(), this->perimeter_flow.scaled_width()* 1.42);
PerimeterIntersectionPoint nearest = this->_get_nearest_point(childs, my_loop, coord_t(this->perimeter_flow.scaled_width()), coord_t(this->perimeter_flow.scaled_width()* 1.42));
if (nearest.idx_children == (size_t)-1) {
//return ExtrusionEntityCollection();
break;
@ -1622,15 +1622,15 @@ PerimeterGenerator::_traverse_and_join_loops(const PerimeterGeneratorLoop &loop,
if (outer_start->polyline.points.size() == 1 && outer_end->polyline.points.size() == 1) {
//do nothing
} else if (outer_start->polyline.points.size() == 1) {
outer_end->polyline.clip_start(outer_end_spacing);
outer_end->polyline.clip_start(double(outer_end_spacing));
if (inner_end->polyline.length() > inner_child_spacing)
inner_end->polyline.clip_end(inner_child_spacing);
inner_end->polyline.clip_end(double(inner_child_spacing));
else
inner_end->polyline.clip_end(inner_end->polyline.length() / 2);
} else if (outer_end->polyline.points.size() == 1) {
outer_start->polyline.clip_end(outer_start_spacing);
outer_start->polyline.clip_end(double(outer_start_spacing));
if (inner_start->polyline.length() > inner_child_spacing)
inner_start->polyline.clip_start(inner_child_spacing);
inner_start->polyline.clip_start(double(inner_child_spacing));
else
inner_start->polyline.clip_start(inner_start->polyline.length()/2);
} else {
@ -1645,18 +1645,18 @@ PerimeterGenerator::_traverse_and_join_loops(const PerimeterGeneratorLoop &loop,
length_trim_1 = length_trim_1 + length_trim_2 - length_poly_2;
}
if (length_poly_1 > length_trim_1) {
outer_start->polyline.clip_end(length_trim_1);
outer_start->polyline.clip_end(double(length_trim_1));
} else {
outer_start->polyline.points.erase(outer_start->polyline.points.begin() + 1, outer_start->polyline.points.end());
}
if (length_poly_2 > length_trim_2) {
outer_end->polyline.clip_start(length_trim_2);
outer_end->polyline.clip_start(double(length_trim_2));
} else {
outer_end->polyline.points.erase(outer_end->polyline.points.begin(), outer_end->polyline.points.end() - 1);
}
length_poly_1 = inner_start->polyline.length();
length_poly_2 = inner_end->polyline.length();
length_poly_1 = coord_t(inner_start->polyline.length());
length_poly_2 = coord_t(inner_end->polyline.length());
length_trim_1 = inner_child_spacing / 2;
length_trim_2 = inner_child_spacing / 2;
if (length_poly_1 < length_trim_1) {
@ -1666,14 +1666,14 @@ PerimeterGenerator::_traverse_and_join_loops(const PerimeterGeneratorLoop &loop,
length_trim_1 = length_trim_1 + length_trim_2 - length_poly_2;
}
if (length_poly_1 > length_trim_1) {
inner_start->polyline.clip_start(length_trim_1);
inner_start->polyline.clip_start(double(length_trim_1));
} else {
inner_start->polyline.points.erase(
inner_start->polyline.points.begin(),
inner_start->polyline.points.end() - 1);
}
if (length_poly_2 > length_trim_2) {
inner_end->polyline.clip_end(length_trim_2);
inner_end->polyline.clip_end(double(length_trim_2));
} else {
inner_end->polyline.points.erase(
inner_end->polyline.points.begin() + 1,

View File

@ -83,12 +83,12 @@ int32_t Point::nearest_point_index(const PointConstPtrs &points) const
for (PointConstPtrs::const_iterator it = points.begin(); it != points.end(); ++it) {
/* If the X distance of the candidate is > than the total distance of the
best previous candidate, we know we don't want it */
double d = sqr<double>((*this)(0) - (*it)->x());
double d = sqr<double>(double((*this).x() - (*it)->x()));
if (distance != -1 && d > distance) continue;
/* If the Y distance of the candidate is > than the total distance of the
best previous candidate, we know we don't want it */
d += sqr<double>((*this)(1) - (*it)->y());
d += sqr<double>(double((*this).y() - (*it)->y()));
if (distance != -1 && d > distance) continue;
idx = (int32_t)(it - points.begin());
@ -103,8 +103,8 @@ int32_t Point::nearest_point_index(const PointConstPtrs &points) const
/* distance to the closest point of line */
double
Point::distance_to(const Line &line) const {
const double dx = line.b.x() - line.a.x();
const double dy = line.b.y() - line.a.y();
const double dx = double(line.b.x() - line.a.x());
const double dy = double(line.b.y() - line.a.y());
const double l2 = dx*dx + dy*dy; // avoid a sqrt
if (l2 == 0.0) return this->distance_to(line.a); // line.a == line.b case
@ -217,8 +217,8 @@ Point Point::projection_onto(const Line &line) const
Point Point::interpolate(const double percent, const Point &p2) const
{
Point p_out;
p_out.x() = this->x()*(1 - percent) + p2.x()*(percent);
p_out.y() = this->y()*(1 - percent) + p2.y()*(percent);
p_out.x() = coord_t(this->x()*(1 - percent) + p2.x()*(percent));
p_out.y() = coord_t(this->y()*(1 - percent) + p2.y()*(percent));
return p_out;
}

View File

@ -1267,7 +1267,9 @@ static inline bool sequential_print_horizontal_clearance_valid(const Print &prin
// Conver the shift from the PrintObject's coordinates into ModelObject's coordinates by removing the centering offset.
for(Polygon &poly : convex_hull)
poly.translate(instance.shift - print_object->center_offset());
if (! intersection(convex_hulls_other, offset(convex_hull[0], scale_(print.config().min_object_distance(&instance.print_object->config(),0.)) - SCALED_EPSILON, jtRound, float(scale_(0.1)))).empty())
if (! intersection(
convex_hulls_other,
offset(convex_hull[0], double(scale_(print.config().min_object_distance(&instance.print_object->config(),0.)) - SCALED_EPSILON), jtRound, scale_(0.1))).empty())
return false;
double extra_grow = print.config().min_object_distance(&instance.print_object->config(), 1.);
if (extra_grow > 0)

View File

@ -40,7 +40,7 @@ Contour3D::Contour3D(const EigenMesh3D &emesh) {
Contour3D &Contour3D::merge(const Contour3D &ctr)
{
auto N = coord_t(points.size());
int32_t N = int32_t(points.size());
auto N_f3 = faces3.size();
auto N_f4 = faces4.size();
@ -49,11 +49,16 @@ Contour3D &Contour3D::merge(const Contour3D &ctr)
faces4.insert(faces4.end(), ctr.faces4.begin(), ctr.faces4.end());
for(size_t n = N_f3; n < faces3.size(); n++) {
auto& idx = faces3[n]; idx.x() += N; idx.y() += N; idx.z() += N;
Vec3i32& idx = faces3[n];
idx.x() += N;
idx.y() += N;
idx.z() += N;
}
for(size_t n = N_f4; n < faces4.size(); n++) {
auto& idx = faces4[n]; for (int k = 0; k < 4; k++) idx(k) += N;
Vec4i& idx = faces4[n];
for (int k = 0; k < 4; k++)
idx(k) += int(N);
}
return *this;

View File

@ -103,7 +103,7 @@ void append_full_config(const DynamicPrintConfig &cfg, std::map<std::string, std
using namespace std::literals::string_view_literals;
// Sorted list of config keys, which shall not be stored into the ini.
static constexpr auto banned_keys = {
static const auto banned_keys = {
"compatible_printers"sv,
"compatible_prints"sv,
"print_host"sv,

View File

@ -342,7 +342,7 @@ inline std::string get_time_dhm(float time_in_secs)
{
char buffer[64];
int minutes = std::round(time_in_secs / 60.);
int minutes = (int)std::round(time_in_secs / 60.);
if (minutes <= 0) {
::sprintf(buffer, "%ds", (int)time_in_secs);
} else {

View File

@ -488,7 +488,7 @@ CopyFileResult check_copy(const std::string &origin, const std::string &copy)
} while (f1.good() && f2.good());
// All data has been read and compared equal.
return (f1.eof() && f2.eof() && fsize == 0) ? SUCCESS : FAIL_FILES_DIFFERENT;
return (f1.eof() && f2.eof() && size_t(fsize) == 0) ? SUCCESS : FAIL_FILES_DIFFERENT;
}
// Ignore system and hidden files, which may be created by the DropBox synchronisation process.

View File

@ -1851,7 +1851,7 @@ void qh_initialhull(qhT *qh, setT *vertices) {
}
}
if (minangle < qh_MAXnarrow && !qh->NOnarrow) {
realT diff= 1.0 + minangle;
realT diff= 1.0f + minangle;
qh->NARROWhull= True;
qh_option(qh, "_narrow-hull", NULL, &diff);

View File

@ -175,7 +175,7 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
if (label.Last() == ':') label.RemoveLast();
show_error(m_parent, from_u8((boost::format(_utf8(L("%s doesn't support percentage"))) % label).str()));
set_value(double_to_string(m_opt.min), true);
m_value = double(m_opt.min);
m_value = m_opt.min;
break;
}
double val;
@ -643,7 +643,7 @@ void SpinCtrl::BUILD() {
break;
}
const int min_val = m_opt.min == INT_MIN
const double min_val = m_opt.min == INT_MIN
#ifdef __WXOSX__
// We will forcibly set the input value for SpinControl, since the value
// inserted from the keyboard is not updated under OSX.
@ -652,8 +652,8 @@ void SpinCtrl::BUILD() {
// less then min_val.
|| m_opt.min > 0
#endif
? 0 : m_opt.min;
const int max_val = m_opt.max < 2147483647 ? m_opt.max : 2147483647;
? 0. : m_opt.min;
const double max_val = m_opt.max < 2147483647 ? m_opt.max : 2147483647.;
auto temp = new wxSpinCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size,
0|wxTE_PROCESS_ENTER, min_val, max_val, default_value);
@ -1386,9 +1386,9 @@ void SliderCtrl::BUILD()
auto temp = new wxBoxSizer(wxHORIZONTAL);
auto def_val = m_opt.get_default_value<ConfigOptionInt>()->value;
auto min = m_opt.min == INT_MIN ? 0 : m_opt.min;
auto max = m_opt.max == INT_MAX ? 100 : m_opt.max;
int def_val = m_opt.get_default_value<ConfigOptionInt>()->value;
int min = m_opt.min == INT_MIN ? 0 : int(m_opt.min);
int max = m_opt.max == INT_MAX ? 100 : int(m_opt.max);
m_slider = new wxSlider(m_parent, wxID_ANY, def_val * m_scale,
min * m_scale, max * m_scale,

View File

@ -716,9 +716,9 @@ void FreeCADDialog::createSTC()
m_text->StyleSetForeground(wxSTC_P_COMMENTLINE, wxColour(128u, 255u, 128u)); // comment, grennsish
m_text->StyleSetForeground(wxSTC_P_COMMENTBLOCK, wxColour(128u, 255u, 128u)); // comment, grennsish
m_text->StyleSetForeground(wxSTC_P_NUMBER, wxColour(255u, 128u, 0u)); // number red-orange
m_text->StyleSetForeground(wxSTC_P_STRING, wxColour(128u, 256u, 0u)); // string, light green
m_text->StyleSetForeground(wxSTC_P_STRING, wxColour(128u, 255u, 0u)); // string, light green
m_text->StyleSetBackground(wxSTC_P_STRINGEOL, wxColour(255u, 0u, 0u)); // End of line where string is not closed
m_text->StyleSetForeground(wxSTC_P_CHARACTER, wxColour(128u, 256u, 0u));
m_text->StyleSetForeground(wxSTC_P_CHARACTER, wxColour(128u, 255u, 0u));
m_text->StyleSetForeground(wxSTC_P_WORD, wxColour(0u, 0u, 128u));
m_text->StyleSetBold(wxSTC_P_WORD, true),
m_text->StyleSetForeground(wxSTC_P_WORD2, wxColour(0u, 0u, 128u));