diff --git a/dxfdata.cc b/dxfdata.cc index 2a23f1f2..14c9c0e2 100644 --- a/dxfdata.cc +++ b/dxfdata.cc @@ -103,7 +103,7 @@ DxfData::DxfData(double fn, double fs, double fa, QString filename, QString laye int n = get_fragments_from_r(radius, fn, fs, fa); while (start_angle > stop_angle) stop_angle += 360.0; - n = ceil(n * (stop_angle-start_angle) / 360); + n = (int)ceil(n * (stop_angle-start_angle) / 360); for (int i = 0; i < n; i++) { double a1 = ((stop_angle-start_angle)*i)/n; double a2 = ((stop_angle-start_angle)*(i+1))/n; diff --git a/dxflinextrude.cc b/dxflinextrude.cc index ef54aa3c..4f2b0c4c 100644 --- a/dxflinextrude.cc +++ b/dxflinextrude.cc @@ -78,7 +78,7 @@ AbstractNode *DxfLinearExtrudeModule::evaluate(const Context *ctx, const ModuleI node->filename = file.text; node->layername = layer.text; node->height = height.num; - node->convexity = convexity.num; + node->convexity = (int)convexity.num; origin.getv2(node->origin_x, node->origin_y); node->scale = scale.num; @@ -97,9 +97,9 @@ AbstractNode *DxfLinearExtrudeModule::evaluate(const Context *ctx, const ModuleI if (twist.type == Value::NUMBER) { node->twist = twist.num; if (slices.type == Value::NUMBER) { - node->slices = slices.num; + node->slices = (int)slices.num; } else { - node->slices = fmax(2, fabs(get_fragments_from_r(node->height, + node->slices = (int)fmax(2, fabs(get_fragments_from_r(node->height, node->fn, node->fs, node->fa) * node->twist / 360)); } node->has_twist = true; diff --git a/dxfrotextrude.cc b/dxfrotextrude.cc index 7af70f30..e2aca988 100644 --- a/dxfrotextrude.cc +++ b/dxfrotextrude.cc @@ -71,7 +71,7 @@ AbstractNode *DxfRotateExtrudeModule::evaluate(const Context *ctx, const ModuleI node->filename = file.text; node->layername = layer.text; - node->convexity = convexity.num; + node->convexity = (int)convexity.num; origin.getv2(node->origin_x, node->origin_y); node->scale = scale.num; diff --git a/dxftess.cc b/dxftess.cc index 8aab35e6..ba62329e 100644 --- a/dxftess.cc +++ b/dxftess.cc @@ -228,7 +228,7 @@ void dxf_tesselate(PolySet *ps, DxfData *dxf, double rot, bool up, double h) QHash tri_by_atan2; for (int i = 0; i < tess_tri.count(); i++) for (int j = 0; j < 3; j++) { - int ai = round(atan2(fabs(tess_tri[i].p[(j+1)%3][0] - tess_tri[i].p[j][0]), + int ai = (int)round(atan2(fabs(tess_tri[i].p[(j+1)%3][0] - tess_tri[i].p[j][0]), fabs(tess_tri[i].p[(j+1)%3][1] - tess_tri[i].p[j][1])) / 0.001); tri_by_atan2.insertMulti(ai, QPair(i, j)); } @@ -242,7 +242,7 @@ void dxf_tesselate(PolySet *ps, DxfData *dxf, double rot, bool up, double h) for (int k = 0; k < 3; k++) { QHash possible_neigh; - int ai = floor(atan2(fabs(tess_tri[i].p[(k+1)%3][0] - tess_tri[i].p[k][0]), + int ai = (int)floor(atan2(fabs(tess_tri[i].p[(k+1)%3][0] - tess_tri[i].p[k][0]), fabs(tess_tri[i].p[(k+1)%3][1] - tess_tri[i].p[k][1])) / 0.001 - 0.5); for (int j = 0; j < 2; j++) { foreach (QPair_ii jl, tri_by_atan2.values(ai+j)) @@ -266,13 +266,13 @@ void dxf_tesselate(PolySet *ps, DxfData *dxf, double rot, bool up, double h) tess_tri.append(tess_triangle(tess_tri[j].p[l], tess_tri[i].p[(k+1)%3], tess_tri[i].p[(k+2)%3])); for (int m = 0; m < 2; m++) { - int ai = round(atan2(fabs(tess_tri.last().p[(m+1)%3][0] - tess_tri.last().p[m][0]), + int ai = (int)round(atan2(fabs(tess_tri.last().p[(m+1)%3][0] - tess_tri.last().p[m][0]), fabs(tess_tri.last().p[(m+1)%3][1] - tess_tri.last().p[m][1])) / 0.001 ); tri_by_atan2.insertMulti(ai, QPair(tess_tri.count()-1, m)); } tess_tri[i].p[(k+1)%3] = tess_tri[j].p[l]; for (int m = 0; m < 2; m++) { - int ai = round(atan2(fabs(tess_tri[i].p[(m+1)%3][0] - tess_tri[i].p[m][0]), + int ai = (int)round(atan2(fabs(tess_tri[i].p[(m+1)%3][0] - tess_tri[i].p[m][0]), fabs(tess_tri[i].p[(m+1)%3][1] - tess_tri[i].p[m][1])) / 0.001 ); tri_by_atan2.insertMulti(ai, QPair(i, m)); } diff --git a/mainwin.cc b/mainwin.cc index 2bfcf823..133fb5a9 100644 --- a/mainwin.cc +++ b/mainwin.cc @@ -228,7 +228,7 @@ void MainWindow::updatedFps() if (!fps_ok || fps <= 0) { animate_timer->stop(); } else { - animate_timer->setInterval(1000 / e_fps->text().toDouble()); + animate_timer->setInterval(int(1000 / e_fps->text().toDouble())); animate_timer->start(); } } diff --git a/openscad.h b/openscad.h index 716be372..e6add9cc 100644 --- a/openscad.h +++ b/openscad.h @@ -81,8 +81,8 @@ public: res = resolution; } T &align(double &x, double &y) { - int ix = round(x / res); - int iy = round(y / res); + int ix = (int)round(x / res); + int iy = (int)round(y / res); x = ix * res, y = iy * res; if (db.contains(QPair(ix, iy))) return db[QPair(ix, iy)]; @@ -103,14 +103,14 @@ public: return db[QPair(ix, iy)]; } bool has(double x, double y) { - int ix = round(x / res); - int iy = round(y / res); + int ix = (int)round(x / res); + int iy = (int)round(y / res); if (db.contains(QPair(ix, iy))) return true; for (int jx = ix - 1; jx <= ix + 1; jx++) for (int jy = iy - 1; jy <= iy + 1; jy++) { if (db.contains(QPair(jx, jy))) - true; + return true; } return false; } @@ -137,9 +137,9 @@ public: res = resolution; } T &align(double &x, double &y, double &z) { - int ix = round(x / res); - int iy = round(y / res); - int iz = round(z / res); + int ix = (int)round(x / res); + int iy = (int)round(y / res); + int iz = (int)round(z / res); x = ix * res, y = iy * res, z = iz * res; if (db.contains(QPair,int>(QPair(ix, iy), iz))) return db[QPair,int>(QPair(ix, iy), iz)]; @@ -162,9 +162,9 @@ public: } bool has(double x, double y, double z) { - int ix = round(x / res); - int iy = round(y / res); - int iz = round(z / res); + int ix = (int)round(x / res); + int iy = (int)round(y / res); + int iz = (int)round(z / res); if (db.contains(QPair,int>(QPair(ix, iy), iz))) return true; for (int jx = ix - 1; jx <= ix + 1; jx++) diff --git a/primitives.cc b/primitives.cc index c08e0a10..f93755c2 100644 --- a/primitives.cc +++ b/primitives.cc @@ -133,7 +133,7 @@ void register_builtin_primitives() int get_fragments_from_r(double r, double fn, double fs, double fa) { if (fn > 0.0) - return fn; + return (int)fn; return (int)ceil(fmax(fmin(360.0 / fa, r*M_PI / fs), 5)); } diff --git a/render.cc b/render.cc index b9359a5c..98a8ecbc 100644 --- a/render.cc +++ b/render.cc @@ -56,7 +56,7 @@ AbstractNode *RenderModule::evaluate(const Context *ctx, const ModuleInstanciati Value v = c.lookup_variable("convexity"); if (v.type == Value::NUMBER) - node->convexity = v.num; + node->convexity = (int)v.num; foreach (ModuleInstanciation *v, inst->children) { AbstractNode *n = v->evaluate(inst->ctx); diff --git a/surface.cc b/surface.cc index 17b859d3..5083c74b 100644 --- a/surface.cc +++ b/surface.cc @@ -63,7 +63,7 @@ AbstractNode *SurfaceModule::evaluate(const Context *ctx, const ModuleInstanciat Value convexity = c.lookup_variable("convexity", true); if (convexity.type == Value::NUMBER) { - node->convexity = convexity.num; + node->convexity = (int)convexity.num; } return node;