diff --git a/AABB_tree/demo/AABB_tree/Color_ramp.h b/AABB_tree/demo/AABB_tree/Color_ramp.h index c626c8ee99b..830ba38ead2 100644 --- a/AABB_tree/demo/AABB_tree/Color_ramp.h +++ b/AABB_tree/demo/AABB_tree/Color_ramp.h @@ -44,10 +44,10 @@ private: int x2 = m_nodes[i+1]; int y1 = m_colors[k][x1]; int y2 = m_colors[k][x2]; - float a = (float)(y2-y1) / (float)(x2-x1); - float b = (float)y1 - a*(float)x1; + float a = static_cast(y2-y1) / static_cast(x2-x1); + float b = static_cast(y1) - a*static_cast(x1); for(int j=x1;j(a*static_cast(j)+b); } } diff --git a/AABB_tree/demo/AABB_tree/MainWindow.cpp b/AABB_tree/demo/AABB_tree/MainWindow.cpp index 8b111b61f01..95fc4056bf7 100644 --- a/AABB_tree/demo/AABB_tree/MainWindow.cpp +++ b/AABB_tree/demo/AABB_tree/MainWindow.cpp @@ -153,9 +153,8 @@ void MainWindow::on_actionInside_points_triggered() { bool ok; - const unsigned int nb_points = (unsigned) - QInputDialog::getInt(nullptr, "#Points", - "#Points:",10000,1,100000000,9,&ok); + const unsigned int nb_points = static_cast(QInputDialog::getInt(nullptr, "#Points", + "#Points:",10000,1,100000000,9,&ok)); if(!ok) return; @@ -170,9 +169,8 @@ void MainWindow::on_actionPoints_in_interval_triggered() { bool ok; - const unsigned int nb_points = (unsigned) - QInputDialog::getInt(nullptr, "#Points", - "#Points:",10000,1,100000000,9,&ok); + const unsigned int nb_points = static_cast(QInputDialog::getInt(nullptr, "#Points", + "#Points:",10000,1,100000000,9,&ok)); if(!ok) return; @@ -198,9 +196,8 @@ void MainWindow::on_actionBoundary_segments_triggered() { bool ok; - const unsigned int nb_slices = (unsigned) - QInputDialog::getInt(nullptr, "#Slices", - "Slices:",100,1,1000000,8,&ok); + const unsigned int nb_slices = static_cast(QInputDialog::getInt(nullptr, "#Slices", + "Slices:",100,1,1000000,8,&ok)); if(!ok) return; @@ -215,9 +212,8 @@ void MainWindow::on_actionBoundary_points_triggered() { bool ok; - const unsigned int nb_points = (unsigned) - QInputDialog::getInt(nullptr, "#Points", - "Points:",1000,1,10000000,8,&ok); + const unsigned int nb_points = static_cast(QInputDialog::getInt(nullptr, "#Points", + "Points:",1000,1,10000000,8,&ok)); if(!ok) return; @@ -232,9 +228,8 @@ void MainWindow::on_actionEdge_points_triggered() { bool ok; - const unsigned int nb_points = (unsigned) - QInputDialog::getInt(nullptr, "#Points", - "Points:",1000,1,10000000,8,&ok); + const unsigned int nb_points = static_cast(QInputDialog::getInt(nullptr, "#Points", + "Points:",1000,1,10000000,8,&ok)); if(!ok) return; diff --git a/AABB_tree/demo/AABB_tree/Scene.cpp b/AABB_tree/demo/AABB_tree/Scene.cpp index 6ae939bfc38..793adcd71ef 100644 --- a/AABB_tree/demo/AABB_tree/Scene.cpp +++ b/AABB_tree/demo/AABB_tree/Scene.cpp @@ -43,7 +43,7 @@ Scene::Scene() // distance function m_red_ramp.build_red(); m_blue_ramp.build_blue(); - m_max_distance_function = (FT)0.0; + m_max_distance_function = static_cast(0.0); texture = new Texture(m_grid_size,m_grid_size); ready_to_cut = true; are_buffers_initialized = false; @@ -481,7 +481,7 @@ void Scene::compute_texture(int i, int j,Color_ramp pos_ramp ,Color_ramp neg_ram const FT& d00 = m_distance_function[i][j].second; // determines grey level - unsigned int i00 = 255-(unsigned)(255.0 * (double)std::fabs(d00) / m_max_distance_function); + unsigned int i00 = 255-static_cast(255.0 * std::fabs(d00) / m_max_distance_function); if(d00 > 0.0) texture->setData(i,j,pos_ramp.r(i00),pos_ramp.g(i00),pos_ramp.b(i00)); @@ -498,7 +498,7 @@ void Scene::attrib_buffers(CGAL::QGLViewer* viewer) viewer->camera()->getModelViewProjectionMatrix(mat); for(int i=0; i < 16; i++) { - mvpMatrix.data()[i] = (float)mat[i]; + mvpMatrix.data()[i] = static_cast(mat[i]); } rendering_program.bind(); mvpLocation = rendering_program.uniformLocation("mvp_matrix"); @@ -717,8 +717,8 @@ void Scene::draw(CGAL::QGLViewer* viewer) FT Scene::random_in(const double a, const double b) { - double r = rand() / (double)RAND_MAX; - return (FT)(a + (b - a) * r); + double r = rand() / static_cast(RAND_MAX); + return static_cast(a + (b - a) * r); } Point Scene::random_point(const CGAL::Bbox_3& bbox) @@ -890,7 +890,7 @@ void Scene::generate_points_in(const unsigned int nb_points, // measure sign Ray ray(p,vec); - int nb_intersections = (int)tree.number_of_intersected_primitives(ray); + int nb_intersections = static_cast(tree.number_of_intersected_primitives(ray)); if(nb_intersections % 2 != 0) signed_distance *= -1.0; @@ -903,7 +903,7 @@ void Scene::generate_points_in(const unsigned int nb_points, } nb_trials++; } - double speed = (double)nb_trials / timer.time(); + double speed = static_cast(nb_trials) / timer.time(); std::cout << "done (" << nb_trials << " trials, " << timer.time() << " s, " << speed << " queries/s)" << std::endl; @@ -937,7 +937,7 @@ void Scene::generate_inside_points(const unsigned int nb_points) { Point p = random_point(tree.bbox()); Ray ray(p,vec); - int nb_intersections = (int)tree.number_of_intersected_primitives(ray); + int nb_intersections = static_cast(tree.number_of_intersected_primitives(ray)); if(nb_intersections % 2 != 0) { m_points.push_back(p); @@ -946,7 +946,7 @@ void Scene::generate_inside_points(const unsigned int nb_points) } nb_trials++; } - double speed = (double)nb_trials / timer.time(); + double speed = static_cast(nb_trials) / timer.time(); std::cout << "done (" << nb_trials << " trials, " << timer.time() << " s, " << speed << " queries/s)" << std::endl; @@ -974,14 +974,14 @@ void Scene::generate_boundary_segments(const unsigned int nb_slices) timer.start(); std::cout << "Generate boundary segments from " << nb_slices << " slices: "; - Vector normal((FT)0.0,(FT)0.0,(FT)1.0); + Vector normal(static_cast(0.0),static_cast(0.0),static_cast(1.0)); unsigned int i; const double dz = m_bbox.zmax() - m_bbox.zmin(); for(i=0;i(i) / static_cast(nb_slices) * dz; + Point p(static_cast(0.0), static_cast(0.0), z); Plane plane(p,normal); std::list intersections; diff --git a/AABB_tree/demo/AABB_tree/benchmarks.cpp b/AABB_tree/demo/AABB_tree/benchmarks.cpp index 0b51ef6de2a..c337e43efe7 100644 --- a/AABB_tree/demo/AABB_tree/benchmarks.cpp +++ b/AABB_tree/demo/AABB_tree/benchmarks.cpp @@ -115,7 +115,7 @@ void Scene::bench_memory() Refiner refiner(m_pPolyhedron); std::size_t digits = nb_digits(m_pPolyhedron->size_of_facets()); unsigned int nb_splits = - static_cast(0.2 * std::pow(10.0,(double)digits - 1.0)); + static_cast(0.2 * std::pow(10.0,static_cast(digits) - 1.0)); refiner.run_nb_splits(nb_splits); // constructs tree and measure memory before then after @@ -126,8 +126,8 @@ void Scene::bench_memory() size_type after = CGAL::Memory_sizer().virtual_size(); size_type bytes = after - before; // in Bytes - double mbytes = (double)bytes / (double)1048576; // in MBytes - double bpp = (double)bytes / (double)m_pPolyhedron->size_of_facets(); + double mbytes = static_cast(bytes) / static_cast(1048576); // in MBytes + double bpp = static_cast(bytes) / static_cast(m_pPolyhedron->size_of_facets()); std::cout << m_pPolyhedron->size_of_facets() << ", " << bytes << ", " << mbytes << ", " @@ -152,7 +152,7 @@ void Scene::bench_construction() Refiner refiner(m_pPolyhedron); std::size_t digits = nb_digits(m_pPolyhedron->size_of_facets()); unsigned int nb_splits = - static_cast(0.2 * std::pow(10.0,(double)digits - 1.0)); + static_cast(0.2 * std::pow(10.0,static_cast(digits) - 1.0)); refiner.run_nb_splits(nb_splits); // constructs tree @@ -197,7 +197,7 @@ void Scene::bench_intersections_vs_nbt() Refiner refiner(m_pPolyhedron); std::size_t digits = nb_digits(m_pPolyhedron->size_of_facets()); unsigned int nb_splits = - static_cast(0.2 * std::pow(10.0,(double)digits - 1.0)); + static_cast(0.2 * std::pow(10.0,static_cast(digits) - 1.0)); refiner.run_nb_splits(nb_splits); // constructs tree (out of timing) @@ -210,7 +210,7 @@ void Scene::bench_intersections_vs_nbt() for(int i=0;i(static_cast(nb_queries) / duration); std::cout << m_pPolyhedron->size_of_facets() << ", " << speed << std::endl; } @@ -241,7 +241,7 @@ void Scene::bench_distances_vs_nbt() Refiner refiner(m_pPolyhedron); std::size_t digits = nb_digits(m_pPolyhedron->size_of_facets()); unsigned int nb_splits = - static_cast(0.2 * std::pow(10.0,(double)digits - 1.0)); + static_cast(0.2 * std::pow(10.0,static_cast(digits) - 1.0)); refiner.run_nb_splits(nb_splits); // constructs tree (out of timing) @@ -253,7 +253,7 @@ void Scene::bench_distances_vs_nbt() for(int i=0;i(static_cast(nb_queries) / duration); std::cout << m_pPolyhedron->size_of_facets() << ", " << speed << std::endl; } @@ -298,7 +298,7 @@ void Scene::bench_intersection(Facet_tree& tree, nb++; } - double speed = (double)nb / (double)timer.time(); + double speed = static_cast(nb) / timer.time(); std::cout << speed << " queries/s with " << query_name << std::endl; } @@ -340,7 +340,7 @@ void Scene::bench_distance(Facet_tree& tree, nb++; } - double speed = (double)nb / (double)timer.time(); + double speed = static_cast(nb) / timer.time(); std::cout << speed << " queries/s" << std::endl; } diff --git a/AABB_tree/test/AABB_tree/AABB_test_util.h b/AABB_tree/test/AABB_tree/AABB_test_util.h index 0d09ce81f42..f8f7c4d4461 100644 --- a/AABB_tree/test/AABB_tree/AABB_test_util.h +++ b/AABB_tree/test/AABB_tree/AABB_test_util.h @@ -33,7 +33,7 @@ double random_in(const double a, const double b) { - double r = rand() / (double)RAND_MAX; + double r = rand() / static_cast(RAND_MAX); return a + (b - a) * r; } @@ -165,7 +165,7 @@ void test_distance_speed(Tree& tree, (void) closest; nb++; } - double speed = (double)nb / timer.time(); + double speed = static_cast(nb) / timer.time(); std::cout << speed << " distance queries/s" << std::endl; timer.stop(); } diff --git a/AABB_tree/test/AABB_tree/aabb_intersection_triangle_test.cpp b/AABB_tree/test/AABB_tree/aabb_intersection_triangle_test.cpp index 49da548f08d..b683450cd03 100644 --- a/AABB_tree/test/AABB_tree/aabb_intersection_triangle_test.cpp +++ b/AABB_tree/test/AABB_tree/aabb_intersection_triangle_test.cpp @@ -79,7 +79,7 @@ void test_speed_for_query(const Tree& tree, } nb++; } - unsigned int speed = (unsigned int)(nb / timer.time()); + unsigned int speed = static_cast(nb / timer.time()); std::cout.precision(10); std::cout.width(15); std::cout << speed << " intersections/s with " << query_name << std::endl;