Merge pull request #5785 from maxGimeno/Google-readability-casting-maxGimeno

Clang-tidy: google-readability-casting
This commit is contained in:
Sebastien Loriot 2021-09-02 15:46:54 +02:00 committed by GitHub
commit fd94f61198
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 152 additions and 157 deletions

View File

@ -1,5 +1,5 @@
--- ---
Checks: '-clang-diagnostic*,-clang-analyzer*,modernize-use-nullptr' Checks: '-clang-diagnostic*,-clang-analyzer*,google-readability-casting'
HeaderFilterRegex: 'CGAL/*' HeaderFilterRegex: 'CGAL/*'
... ...

View File

@ -44,10 +44,10 @@ private:
int x2 = m_nodes[i+1]; int x2 = m_nodes[i+1];
int y1 = m_colors[k][x1]; int y1 = m_colors[k][x1];
int y2 = m_colors[k][x2]; int y2 = m_colors[k][x2];
float a = (float)(y2-y1) / (float)(x2-x1); float a = static_cast<float>(y2-y1) / static_cast<float>(x2-x1);
float b = (float)y1 - a*(float)x1; float b = static_cast<float>(y1) - a*static_cast<float>(x1);
for(int j=x1;j<x2;j++) for(int j=x1;j<x2;j++)
m_colors[k][j] = (unsigned char)(a*(float)j+b); m_colors[k][j] = static_cast<unsigned char>(a*static_cast<float>(j)+b);
} }
} }

View File

@ -153,9 +153,8 @@ void MainWindow::on_actionInside_points_triggered()
{ {
bool ok; bool ok;
const unsigned int nb_points = (unsigned) const unsigned int nb_points = static_cast<unsigned>(QInputDialog::getInt(nullptr, "#Points",
QInputDialog::getInt(nullptr, "#Points", "#Points:",10000,1,100000000,9,&ok));
"#Points:",10000,1,100000000,9,&ok);
if(!ok) if(!ok)
return; return;
@ -170,9 +169,8 @@ void MainWindow::on_actionPoints_in_interval_triggered()
{ {
bool ok; bool ok;
const unsigned int nb_points = (unsigned) const unsigned int nb_points = static_cast<unsigned>(QInputDialog::getInt(nullptr, "#Points",
QInputDialog::getInt(nullptr, "#Points", "#Points:",10000,1,100000000,9,&ok));
"#Points:",10000,1,100000000,9,&ok);
if(!ok) if(!ok)
return; return;
@ -198,9 +196,8 @@ void MainWindow::on_actionBoundary_segments_triggered()
{ {
bool ok; bool ok;
const unsigned int nb_slices = (unsigned) const unsigned int nb_slices = static_cast<unsigned>(QInputDialog::getInt(nullptr, "#Slices",
QInputDialog::getInt(nullptr, "#Slices", "Slices:",100,1,1000000,8,&ok));
"Slices:",100,1,1000000,8,&ok);
if(!ok) if(!ok)
return; return;
@ -215,9 +212,8 @@ void MainWindow::on_actionBoundary_points_triggered()
{ {
bool ok; bool ok;
const unsigned int nb_points = (unsigned) const unsigned int nb_points = static_cast<unsigned>(QInputDialog::getInt(nullptr, "#Points",
QInputDialog::getInt(nullptr, "#Points", "Points:",1000,1,10000000,8,&ok));
"Points:",1000,1,10000000,8,&ok);
if(!ok) if(!ok)
return; return;
@ -232,9 +228,8 @@ void MainWindow::on_actionEdge_points_triggered()
{ {
bool ok; bool ok;
const unsigned int nb_points = (unsigned) const unsigned int nb_points = static_cast<unsigned>(QInputDialog::getInt(nullptr, "#Points",
QInputDialog::getInt(nullptr, "#Points", "Points:",1000,1,10000000,8,&ok));
"Points:",1000,1,10000000,8,&ok);
if(!ok) if(!ok)
return; return;

View File

@ -43,7 +43,7 @@ Scene::Scene()
// distance function // distance function
m_red_ramp.build_red(); m_red_ramp.build_red();
m_blue_ramp.build_blue(); m_blue_ramp.build_blue();
m_max_distance_function = (FT)0.0; m_max_distance_function = static_cast<FT>(0.0);
texture = new Texture(m_grid_size,m_grid_size); texture = new Texture(m_grid_size,m_grid_size);
ready_to_cut = true; ready_to_cut = true;
are_buffers_initialized = false; 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; const FT& d00 = m_distance_function[i][j].second;
// determines grey level // determines grey level
unsigned int i00 = 255-(unsigned)(255.0 * (double)std::fabs(d00) / m_max_distance_function); unsigned int i00 = 255-static_cast<unsigned>(255.0 * std::fabs(d00) / m_max_distance_function);
if(d00 > 0.0) if(d00 > 0.0)
texture->setData(i,j,pos_ramp.r(i00),pos_ramp.g(i00),pos_ramp.b(i00)); 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); viewer->camera()->getModelViewProjectionMatrix(mat);
for(int i=0; i < 16; i++) for(int i=0; i < 16; i++)
{ {
mvpMatrix.data()[i] = (float)mat[i]; mvpMatrix.data()[i] = static_cast<float>(mat[i]);
} }
rendering_program.bind(); rendering_program.bind();
mvpLocation = rendering_program.uniformLocation("mvp_matrix"); mvpLocation = rendering_program.uniformLocation("mvp_matrix");
@ -717,8 +717,8 @@ void Scene::draw(CGAL::QGLViewer* viewer)
FT Scene::random_in(const double a, FT Scene::random_in(const double a,
const double b) const double b)
{ {
double r = rand() / (double)RAND_MAX; double r = rand() / static_cast<double>(RAND_MAX);
return (FT)(a + (b - a) * r); return static_cast<FT>(a + (b - a) * r);
} }
Point Scene::random_point(const CGAL::Bbox_3& bbox) 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 // measure sign
Ray ray(p,vec); Ray ray(p,vec);
int nb_intersections = (int)tree.number_of_intersected_primitives(ray); int nb_intersections = static_cast<int>(tree.number_of_intersected_primitives(ray));
if(nb_intersections % 2 != 0) if(nb_intersections % 2 != 0)
signed_distance *= -1.0; signed_distance *= -1.0;
@ -903,7 +903,7 @@ void Scene::generate_points_in(const unsigned int nb_points,
} }
nb_trials++; nb_trials++;
} }
double speed = (double)nb_trials / timer.time(); double speed = static_cast<double>(nb_trials) / timer.time();
std::cout << "done (" << nb_trials << " trials, " std::cout << "done (" << nb_trials << " trials, "
<< timer.time() << " s, " << timer.time() << " s, "
<< speed << " queries/s)" << std::endl; << 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()); Point p = random_point(tree.bbox());
Ray ray(p,vec); Ray ray(p,vec);
int nb_intersections = (int)tree.number_of_intersected_primitives(ray); int nb_intersections = static_cast<int>(tree.number_of_intersected_primitives(ray));
if(nb_intersections % 2 != 0) if(nb_intersections % 2 != 0)
{ {
m_points.push_back(p); m_points.push_back(p);
@ -946,7 +946,7 @@ void Scene::generate_inside_points(const unsigned int nb_points)
} }
nb_trials++; nb_trials++;
} }
double speed = (double)nb_trials / timer.time(); double speed = static_cast<double>(nb_trials) / timer.time();
std::cout << "done (" << nb_trials << " trials, " std::cout << "done (" << nb_trials << " trials, "
<< timer.time() << " s, " << timer.time() << " s, "
<< speed << " queries/s)" << std::endl; << speed << " queries/s)" << std::endl;
@ -974,14 +974,14 @@ void Scene::generate_boundary_segments(const unsigned int nb_slices)
timer.start(); timer.start();
std::cout << "Generate boundary segments from " << nb_slices << " slices: "; std::cout << "Generate boundary segments from " << nb_slices << " slices: ";
Vector normal((FT)0.0,(FT)0.0,(FT)1.0); Vector normal(static_cast<FT>(0.0),static_cast<FT>(0.0),static_cast<FT>(1.0));
unsigned int i; unsigned int i;
const double dz = m_bbox.zmax() - m_bbox.zmin(); const double dz = m_bbox.zmax() - m_bbox.zmin();
for(i=0;i<nb_slices;i++) for(i=0;i<nb_slices;i++)
{ {
FT z = m_bbox.zmin() + (FT)i / (FT)nb_slices * dz; FT z = m_bbox.zmin() + static_cast<FT>(i) / static_cast<FT>(nb_slices) * dz;
Point p((FT)0.0, (FT)0.0, z); Point p(static_cast<FT>(0.0), static_cast<FT>(0.0), z);
Plane plane(p,normal); Plane plane(p,normal);
std::list<Object_and_primitive_id> intersections; std::list<Object_and_primitive_id> intersections;

View File

@ -115,7 +115,7 @@ void Scene::bench_memory()
Refiner<Kernel,Polyhedron> refiner(m_pPolyhedron); Refiner<Kernel,Polyhedron> refiner(m_pPolyhedron);
std::size_t digits = nb_digits(m_pPolyhedron->size_of_facets()); std::size_t digits = nb_digits(m_pPolyhedron->size_of_facets());
unsigned int nb_splits = unsigned int nb_splits =
static_cast<unsigned int>(0.2 * std::pow(10.0,(double)digits - 1.0)); static_cast<unsigned int>(0.2 * std::pow(10.0,static_cast<double>(digits) - 1.0));
refiner.run_nb_splits(nb_splits); refiner.run_nb_splits(nb_splits);
// constructs tree and measure memory before then after // 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 after = CGAL::Memory_sizer().virtual_size();
size_type bytes = after - before; // in Bytes size_type bytes = after - before; // in Bytes
double mbytes = (double)bytes / (double)1048576; // in MBytes double mbytes = static_cast<double>(bytes) / static_cast<double>(1048576); // in MBytes
double bpp = (double)bytes / (double)m_pPolyhedron->size_of_facets(); double bpp = static_cast<double>(bytes) / static_cast<double>(m_pPolyhedron->size_of_facets());
std::cout << m_pPolyhedron->size_of_facets() << ", " std::cout << m_pPolyhedron->size_of_facets() << ", "
<< bytes << ", " << bytes << ", "
<< mbytes << ", " << mbytes << ", "
@ -152,7 +152,7 @@ void Scene::bench_construction()
Refiner<Kernel,Polyhedron> refiner(m_pPolyhedron); Refiner<Kernel,Polyhedron> refiner(m_pPolyhedron);
std::size_t digits = nb_digits(m_pPolyhedron->size_of_facets()); std::size_t digits = nb_digits(m_pPolyhedron->size_of_facets());
unsigned int nb_splits = unsigned int nb_splits =
static_cast<unsigned int>(0.2 * std::pow(10.0,(double)digits - 1.0)); static_cast<unsigned int>(0.2 * std::pow(10.0,static_cast<double>(digits) - 1.0));
refiner.run_nb_splits(nb_splits); refiner.run_nb_splits(nb_splits);
// constructs tree // constructs tree
@ -197,7 +197,7 @@ void Scene::bench_intersections_vs_nbt()
Refiner<Kernel,Polyhedron> refiner(m_pPolyhedron); Refiner<Kernel,Polyhedron> refiner(m_pPolyhedron);
std::size_t digits = nb_digits(m_pPolyhedron->size_of_facets()); std::size_t digits = nb_digits(m_pPolyhedron->size_of_facets());
unsigned int nb_splits = unsigned int nb_splits =
static_cast<unsigned int>(0.2 * std::pow(10.0,(double)digits - 1.0)); static_cast<unsigned int>(0.2 * std::pow(10.0,static_cast<double>(digits) - 1.0));
refiner.run_nb_splits(nb_splits); refiner.run_nb_splits(nb_splits);
// constructs tree (out of timing) // constructs tree (out of timing)
@ -210,7 +210,7 @@ void Scene::bench_intersections_vs_nbt()
for(int i=0;i<nb_queries;i++) for(int i=0;i<nb_queries;i++)
tree.all_intersections(queries[i],std::back_inserter(intersections)); tree.all_intersections(queries[i],std::back_inserter(intersections));
double duration = timer.time(); double duration = timer.time();
int speed = (int)((double)nb_queries / (double)duration); int speed = static_cast<int>(static_cast<double>(nb_queries) / duration);
std::cout << m_pPolyhedron->size_of_facets() << ", " << speed << std::endl; std::cout << m_pPolyhedron->size_of_facets() << ", " << speed << std::endl;
} }
@ -241,7 +241,7 @@ void Scene::bench_distances_vs_nbt()
Refiner<Kernel,Polyhedron> refiner(m_pPolyhedron); Refiner<Kernel,Polyhedron> refiner(m_pPolyhedron);
std::size_t digits = nb_digits(m_pPolyhedron->size_of_facets()); std::size_t digits = nb_digits(m_pPolyhedron->size_of_facets());
unsigned int nb_splits = unsigned int nb_splits =
static_cast<unsigned int>(0.2 * std::pow(10.0,(double)digits - 1.0)); static_cast<unsigned int>(0.2 * std::pow(10.0,static_cast<double>(digits) - 1.0));
refiner.run_nb_splits(nb_splits); refiner.run_nb_splits(nb_splits);
// constructs tree (out of timing) // constructs tree (out of timing)
@ -253,7 +253,7 @@ void Scene::bench_distances_vs_nbt()
for(int i=0;i<nb_queries;i++) for(int i=0;i<nb_queries;i++)
tree.closest_point(queries[i]); tree.closest_point(queries[i]);
double duration = timer.time(); double duration = timer.time();
int speed = (int)((double)nb_queries / (double)duration); int speed = static_cast<int>(static_cast<double>(nb_queries) / duration);
std::cout << m_pPolyhedron->size_of_facets() << ", " << speed << std::endl; std::cout << m_pPolyhedron->size_of_facets() << ", " << speed << std::endl;
} }
@ -298,7 +298,7 @@ void Scene::bench_intersection(Facet_tree& tree,
nb++; nb++;
} }
double speed = (double)nb / (double)timer.time(); double speed = static_cast<double>(nb) / timer.time();
std::cout << speed << " queries/s with " << query_name << std::endl; std::cout << speed << " queries/s with " << query_name << std::endl;
} }
@ -340,7 +340,7 @@ void Scene::bench_distance(Facet_tree& tree,
nb++; nb++;
} }
double speed = (double)nb / (double)timer.time(); double speed = static_cast<double>(nb) / timer.time();
std::cout << speed << " queries/s" << std::endl; std::cout << speed << " queries/s" << std::endl;
} }

View File

@ -33,7 +33,7 @@
double random_in(const double a, double random_in(const double a,
const double b) const double b)
{ {
double r = rand() / (double)RAND_MAX; double r = rand() / static_cast<double>(RAND_MAX);
return a + (b - a) * r; return a + (b - a) * r;
} }
@ -165,7 +165,7 @@ void test_distance_speed(Tree& tree,
(void) closest; (void) closest;
nb++; nb++;
} }
double speed = (double)nb / timer.time(); double speed = static_cast<double>(nb) / timer.time();
std::cout << speed << " distance queries/s" << std::endl; std::cout << speed << " distance queries/s" << std::endl;
timer.stop(); timer.stop();
} }

View File

@ -79,7 +79,7 @@ void test_speed_for_query(const Tree& tree,
} }
nb++; nb++;
} }
unsigned int speed = (unsigned int)(nb / timer.time()); unsigned int speed = static_cast<unsigned int>(nb / timer.time());
std::cout.precision(10); std::cout.precision(10);
std::cout.width(15); std::cout.width(15);
std::cout << speed << " intersections/s with " << query_name << std::endl; std::cout << speed << " intersections/s with " << query_name << std::endl;

View File

@ -41,7 +41,7 @@ int main() {
std::cout << "The approximate probability that 3 spheres with radius 1" std::cout << "The approximate probability that 3 spheres with radius 1"
<< std::endl; << std::endl;
std::cout << "chosen (uniformly) randomly on a 5x5x5 box intersect is: " std::cout << "chosen (uniformly) randomly on a 5x5x5 box intersect is: "
<< ((double)count)/((double)(10000)) << std::endl; << (static_cast<double>(count))/(static_cast<double>(10000)) << std::endl;
return 0; return 0;
} }

View File

@ -556,7 +556,7 @@ int main (int argc, char** argv)
double height_ratio = (height_at_query - bbox.zmin()) / (bbox.zmax() - bbox.zmin()); double height_ratio = (height_at_query - bbox.zmin()) / (bbox.zmax() - bbox.zmin());
colors = color_ramp.get(height_ratio); colors = color_ramp.get(height_ratio);
} }
raster_ofile.write ((char*)(&colors), 3); raster_ofile.write (reinterpret_cast<char*>(&colors), 3);
} }
raster_ofile.close(); raster_ofile.close();

View File

@ -35,7 +35,7 @@ public:
Color out; Color out;
for (std::size_t i = 0; i < 3; ++ i) for (std::size_t i = 0; i < 3; ++ i)
out[i] = (unsigned char)((1 - ratio) * c0[i] + ratio * c1[i]); out[i] = static_cast<unsigned char>((1 - ratio) * c0[i] + ratio * c1[i]);
return out; return out;
} }

View File

@ -18,7 +18,7 @@ int main ()
<<dim<<"D" << std::endl; <<dim<<"D" << std::endl;
std::vector<Point> v; std::vector<Point> v;
v.reserve(nb_points); v.reserve(nb_points);
CGAL::points_on_cube_grid_d (dim, size, (std::size_t) nb_points, CGAL::points_on_cube_grid_d (dim, size, static_cast<std::size_t>(nb_points),
std::back_inserter(v), Creator_d(dim) ); std::back_inserter(v), Creator_d(dim) );
for (int i = 0; i < nb_points; ++i) std::cout<<" "<<v[i]<<std::endl; for (int i = 0; i < nb_points; ++i) std::cout<<" "<<v[i]<<std::endl;
return 0; return 0;

View File

@ -70,7 +70,7 @@ int main(int argc, char** argv)
std::cerr << "Assignment f2=f...\n"; std::cerr << "Assignment f2=f...\n";
f2 = f; // check the assignment f2 = f; // check the assignment
std::cerr << "Auto-assignment f=f...\n"; std::cerr << "Auto-assignment f=f...\n";
f2 = (Map&)f2; // check the auto-assignment f2 = const_cast<Map&>(f2); // check the auto-assignment
std::cerr << "Copy-construction...\n"; std::cerr << "Copy-construction...\n";
Map f3(f); // check the copy constructor Map f3(f); // check the copy constructor

View File

@ -53,7 +53,7 @@ int main()
domain, domain,
image, image,
criteria, criteria,
(unsigned char)0); static_cast<unsigned char>(0));
CGAL::refine_mesh_3(c3t3, domain, criteria); CGAL::refine_mesh_3(c3t3, domain, criteria);
/// [Meshing] /// [Meshing]

View File

@ -11,7 +11,7 @@ CGAL::Image_3 random_labeled_image()
_image* image = _createImage(dim, dim, dim, 1, _image* image = _createImage(dim, dim, dim, 1,
1.f, 1.f, 1.f, 1, 1.f, 1.f, 1.f, 1,
WK_FIXED, SGN_UNSIGNED); WK_FIXED, SGN_UNSIGNED);
unsigned char* ptr = (unsigned char*)(image->data); unsigned char* ptr = static_cast<unsigned char*>(image->data);
std::fill(ptr, ptr+dim*dim*dim, '\0'); std::fill(ptr, ptr+dim*dim*dim, '\0');
std::ptrdiff_t center = dim / 2; std::ptrdiff_t center = dim / 2;

View File

@ -86,9 +86,9 @@ public:
//! perform the output, calls \c operator\<\< by default. //! perform the output, calls \c operator\<\< by default.
std::ostream& operator()( std::ostream& out) const { std::ostream& operator()( std::ostream& out) const {
if(IO::is_ascii(out)) { if(IO::is_ascii(out)) {
out << (int)t; out << static_cast<int>(t);
} else { } else {
CGAL::write(out, (int)t); CGAL::write(out, static_cast<int>(t));
} }
return out; return out;
} }
@ -109,7 +109,7 @@ public:
} else { } else {
CGAL::read(in, i); CGAL::read(in, i);
} }
t = (T)i; t = static_cast<T>(i);
return in; return in;
} }
}; };

View File

@ -26,9 +26,9 @@ void print_point_set (const Point_set& point_set)
for (Point_set::const_iterator it = point_set.begin(); it != point_set.end(); ++ it) for (Point_set::const_iterator it = point_set.begin(); it != point_set.end(); ++ it)
{ {
std::cerr << "* Point " << point_set.point(*it) // or point_set[it] std::cerr << "* Point " << point_set.point(*it) // or point_set[it]
<< " with color [" << (int)(color[*it][0]) << " with color [" << static_cast<int>(color[*it][0])
<< " " << (int)(color[*it][1]) << " " << static_cast<int>(color[*it][1])
<< " " << (int)(color[*it][2]) << " " << static_cast<int>(color[*it][2])
<< "] and intensity " << intensity[*it] << "] and intensity " << intensity[*it]
<< std::endl; << std::endl;
} }
@ -53,11 +53,11 @@ int main (int, char**)
for (std::size_t i = 0; i < 10; ++ i) for (std::size_t i = 0; i < 10; ++ i)
{ {
Point_set::iterator it = point_set.insert (Point (double(i), double(i), double(i))); Point_set::iterator it = point_set.insert (Point (double(i), double(i), double(i)));
Color c = {{ (unsigned char)(CGAL::get_default_random().get_int(0, 255)), Color c = {{ static_cast<unsigned char>(CGAL::get_default_random().get_int(0, 255)),
(unsigned char)(CGAL::get_default_random().get_int(0, 255)), static_cast<unsigned char>(CGAL::get_default_random().get_int(0, 255)),
(unsigned char)(CGAL::get_default_random().get_int(0, 255)) }}; static_cast<unsigned char>(CGAL::get_default_random().get_int(0, 255)) }};
color[*it] = c; color[*it] = c;
intensity[*it] = rand() / (double)(RAND_MAX); intensity[*it] = rand() / static_cast<double>(RAND_MAX);
} }
print_point_set (point_set); print_point_set (point_set);

View File

@ -44,7 +44,7 @@ int main(int argc, char*argv[])
CGAL::parameters::threshold_percent (100.). // No limit on the number of outliers to remove CGAL::parameters::threshold_percent (100.). // No limit on the number of outliers to remove
threshold_distance (2. * average_spacing)); // Point with distance above 2*average_spacing are considered outliers threshold_distance (2. * average_spacing)); // Point with distance above 2*average_spacing are considered outliers
std::cerr << (100. * std::distance(first_to_remove, points.end()) / (double)(points.size())) std::cerr << (100. * std::distance(first_to_remove, points.end()) / static_cast<double>(points.size()))
<< "% of the points are considered outliers when using a distance threshold of " << "% of the points are considered outliers when using a distance threshold of "
<< 2. * average_spacing << std::endl; << 2. * average_spacing << std::endl;

View File

@ -47,10 +47,10 @@ int main(int, char**)
for (int i = 0; i < 10; ++ i) for (int i = 0; i < 10; ++ i)
points.push_back (std::make_tuple (Point (i / 10., i / 20., i / 30.), points.push_back (std::make_tuple (Point (i / 10., i / 20., i / 30.),
CGAL::make_array ((unsigned char)(255 / (i + 1)), CGAL::make_array (static_cast<unsigned char>(255 / (i + 1)),
(unsigned char)(192 / (i + 1)), static_cast<unsigned char>(192 / (i + 1)),
(unsigned char)(128 / (i + 1)), static_cast<unsigned char>(128 / (i + 1)),
(unsigned char)(64 / (i + 1))), static_cast<unsigned char>(64 / (i + 1))),
i)); i));
std::ofstream f("out.ply", std::ios::binary); std::ofstream f("out.ply", std::ios::binary);

View File

@ -20,7 +20,7 @@ compute_color_map(QColor base_color,
Output_color_iterator out) Output_color_iterator out)
{ {
qreal hue = base_color.hueF(); qreal hue = base_color.hueF();
const qreal step = ((qreal)1) / nb_of_colors; const qreal step = (static_cast<qreal>(1)) / nb_of_colors;
qreal h = hue==-1 ? 0 qreal h = hue==-1 ? 0
:hue; :hue;

View File

@ -167,8 +167,8 @@ void Edge_container::draw(Viewer_interface *viewer,
if(getVao(viewer)->program->property("hasViewport").toBool()) if(getVao(viewer)->program->property("hasViewport").toBool())
{ {
getVao(viewer)->program->setUniformValue("viewport", getViewport()); getVao(viewer)->program->setUniformValue("viewport", getViewport());
getVao(viewer)->program->setUniformValue("near",(GLfloat)viewer->camera()->zNear()); getVao(viewer)->program->setUniformValue("near",static_cast<GLfloat>(viewer->camera()->zNear()));
getVao(viewer)->program->setUniformValue("far",(GLfloat)viewer->camera()->zFar()); getVao(viewer)->program->setUniformValue("far",static_cast<GLfloat>(viewer->camera()->zFar()));
} }
if(getVao(viewer)->program->property("hasWidth").toBool()) if(getVao(viewer)->program->property("hasWidth").toBool())
getVao(viewer)->program->setUniformValue("width", getWidth()); getVao(viewer)->program->setUniformValue("width", getWidth());

View File

@ -2496,15 +2496,15 @@ void MainWindow::viewerShowObject()
Scene_item* item = nullptr; Scene_item* item = nullptr;
QAction* sender_action = qobject_cast<QAction*>(sender()); QAction* sender_action = qobject_cast<QAction*>(sender());
if(sender_action && !sender_action->data().isNull()) { if(sender_action && !sender_action->data().isNull()) {
item = (Scene_item*)sender_action->data().value<void*>(); item = static_cast<Scene_item*>(sender_action->data().value<void*>());
} }
if(item) { if(item) {
const Scene::Bbox bbox = item->bbox(); const Scene::Bbox bbox = item->bbox();
CGAL::qglviewer::Vec min((float)bbox.xmin()+viewer->offset().x, (float)bbox.ymin()+viewer->offset().y, (float)bbox.zmin()+viewer->offset().z), CGAL::qglviewer::Vec min(static_cast<float>(bbox.xmin())+viewer->offset().x, static_cast<float>(bbox.ymin())+viewer->offset().y, static_cast<float>(bbox.zmin())+viewer->offset().z),
max((float)bbox.xmax()+viewer->offset().x, (float)bbox.ymax()+viewer->offset().y, (float)bbox.zmax()+viewer->offset().z); max(static_cast<float>(bbox.xmax())+viewer->offset().x, static_cast<float>(bbox.ymax())+viewer->offset().y, static_cast<float>(bbox.zmax())+viewer->offset().z);
viewer->setSceneBoundingBox(min, max); viewer->setSceneBoundingBox(min, max);
viewerShow((float)min.x, (float)min.y, (float)min.z, viewerShow(static_cast<float>(min.x), static_cast<float>(min.y), static_cast<float>(min.z),
(float)max.x, (float)max.y, (float)max.z); static_cast<float>(max.x), static_cast<float>(max.y), static_cast<float>(max.z));
} }
} }
/* to check /* to check
@ -3599,9 +3599,9 @@ void SubViewer::lookat()
if (viewer->camera()->frame()->isSpinning()) if (viewer->camera()->frame()->isSpinning())
viewer->camera()->frame()->stopSpinning(); viewer->camera()->frame()->stopSpinning();
mw->viewerShow(viewer, mw->viewerShow(viewer,
(float)dialog.get_x() + viewer->offset().x, static_cast<float>(dialog.get_x()) + viewer->offset().x,
(float)dialog.get_y() + viewer->offset().y, static_cast<float>(dialog.get_y()) + viewer->offset().y,
(float)dialog.get_z() + viewer->offset().z); static_cast<float>(dialog.get_z()) + viewer->offset().z);
} }
} }

View File

@ -302,7 +302,7 @@ public Q_SLOTS:
} }
if(total == 0) if(total == 0)
continue; continue;
CGAL::qglviewer::Vec center(x/(double)total, y/(double)total, z/(double)total); CGAL::qglviewer::Vec center(x/static_cast<double>(total), y/static_cast<double>(total), z/static_cast<double>(total));
CGAL::qglviewer::Vec orig; CGAL::qglviewer::Vec orig;
CGAL::qglviewer::Vec dir; CGAL::qglviewer::Vec dir;
if(camera->type() == CGAL::qglviewer::Camera::PERSPECTIVE) if(camera->type() == CGAL::qglviewer::Camera::PERSPECTIVE)

View File

@ -765,8 +765,8 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer)
std::vector<QOpenGLFramebufferObject*> fbos; std::vector<QOpenGLFramebufferObject*> fbos;
std::vector<QOpenGLFramebufferObject*> depth_test; std::vector<QOpenGLFramebufferObject*> depth_test;
QColor background = viewer->backgroundColor(); QColor background = viewer->backgroundColor();
fbos.resize((int)viewer->total_pass()); fbos.resize(static_cast<int>(viewer->total_pass()));
depth_test.resize((int)viewer->total_pass()-1); depth_test.resize(static_cast<int>(viewer->total_pass())-1);
//first pass //first pass
fbos[0] = new QOpenGLFramebufferObject(viewer->width(), viewer->height(),QOpenGLFramebufferObject::Depth, GL_TEXTURE_2D, GL_RGBA32F); fbos[0] = new QOpenGLFramebufferObject(viewer->width(), viewer->height(),QOpenGLFramebufferObject::Depth, GL_TEXTURE_2D, GL_RGBA32F);
@ -836,8 +836,8 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer)
//last pass //last pass
fbos[(int)viewer->total_pass()-1] = new QOpenGLFramebufferObject(viewer->width(), viewer->height(),QOpenGLFramebufferObject::Depth, GL_TEXTURE_2D, GL_RGBA32F); fbos[static_cast<int>(viewer->total_pass())-1] = new QOpenGLFramebufferObject(viewer->width(), viewer->height(),QOpenGLFramebufferObject::Depth, GL_TEXTURE_2D, GL_RGBA32F);
fbos[(int)viewer->total_pass()-1]->bind(); fbos[static_cast<int>(viewer->total_pass())-1]->bind();
viewer->glDisable(GL_BLEND); viewer->glDisable(GL_BLEND);
viewer->glEnable(GL_DEPTH_TEST); viewer->glEnable(GL_DEPTH_TEST);
viewer->glDepthFunc(GL_LESS); viewer->glDepthFunc(GL_LESS);
@ -847,18 +847,18 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer)
0.0f); 0.0f);
viewer->glClearDepthf(1); viewer->glClearDepthf(1);
viewer->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); viewer->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
renderScene(opaque_items , viewer, picked_item_IDs, false, (int)viewer->total_pass()-1, false, depth_test[(int)viewer->total_pass()-2]); renderScene(opaque_items , viewer, picked_item_IDs, false, static_cast<int>(viewer->total_pass())-1, false, depth_test[static_cast<int>(viewer->total_pass())-2]);
renderScene(transparent_items, viewer, picked_item_IDs, false, (int)viewer->total_pass()-1, false, depth_test[(int)viewer->total_pass()-2]); renderScene(transparent_items, viewer, picked_item_IDs, false, static_cast<int>(viewer->total_pass())-1, false, depth_test[static_cast<int>(viewer->total_pass())-2]);
fbos[(int)viewer->total_pass()-1]->release(); fbos[static_cast<int>(viewer->total_pass())-1]->release();
if(viewer->getStoredFrameBuffer() != nullptr) if(viewer->getStoredFrameBuffer() != nullptr)
viewer->getStoredFrameBuffer()->bind(); viewer->getStoredFrameBuffer()->bind();
//blending //blending
program.bind(); program.bind();
vaos[viewer]->bind(); vaos[viewer]->bind();
viewer->glClearColor((GLclampf)background.redF(), viewer->glClearColor(static_cast<GLclampf>(background.redF()),
(GLclampf)background.greenF(), static_cast<GLclampf>(background.greenF()),
(GLclampf)background.blueF(), static_cast<GLclampf>(background.blueF()),
0.0f); 0.0f);
viewer->glDisable(GL_DEPTH_TEST); viewer->glDisable(GL_DEPTH_TEST);
viewer->glClear(GL_COLOR_BUFFER_BIT); viewer->glClear(GL_COLOR_BUFFER_BIT);
@ -869,9 +869,9 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer)
proj_mat.setToIdentity(); proj_mat.setToIdentity();
proj_mat.ortho(-1,1,-1,1,0,1); proj_mat.ortho(-1,1,-1,1,0,1);
program.setUniformValue("projection_matrix", proj_mat); program.setUniformValue("projection_matrix", proj_mat);
for(int i=0; i< (int)viewer->total_pass()-1; ++i) for(int i=0; i< static_cast<int>(viewer->total_pass())-1; ++i)
delete depth_test[i]; delete depth_test[i];
for(int i = (int)viewer->total_pass()-1; i>=0; --i) for(int i = static_cast<int>(viewer->total_pass())-1; i>=0; --i)
{ {
viewer->glBindTexture(GL_TEXTURE_2D, fbos[i]->texture()); viewer->glBindTexture(GL_TEXTURE_2D, fbos[i]->texture());
viewer->glDrawArrays(GL_TRIANGLES,0,static_cast<GLsizei>(6)); viewer->glDrawArrays(GL_TRIANGLES,0,static_cast<GLsizei>(6));

View File

@ -88,7 +88,7 @@ float Scene_item_rendering_helper::alpha() const
{ {
if(!priv->alphaSlider) if(!priv->alphaSlider)
return 1.0f; return 1.0f;
return (float)priv->alphaSlider->value() / 255.0f; return static_cast<float>(priv->alphaSlider->value()) / 255.0f;
} }
void Scene_item_rendering_helper::initGL(CGAL::Three::Viewer_interface* viewer) const void Scene_item_rendering_helper::initGL(CGAL::Three::Viewer_interface* viewer) const

View File

@ -671,7 +671,7 @@ void Scene_points_with_normal_item::drawEdges(CGAL::Three::Viewer_interface* vie
double ratio_displayed = 1.0; double ratio_displayed = 1.0;
if (viewer->inFastDrawing () && if (viewer->inFastDrawing () &&
(d->nb_lines/6 > limit_fast_drawing)) // arbitrary large value (d->nb_lines/6 > limit_fast_drawing)) // arbitrary large value
ratio_displayed = 6 * limit_fast_drawing / (double)(d->nb_lines); ratio_displayed = 6 * limit_fast_drawing / static_cast<double>(d->nb_lines);
if(!isInit(viewer)) if(!isInit(viewer))
initGL(viewer); initGL(viewer);
if ( getBuffersFilled() && if ( getBuffersFilled() &&
@ -699,7 +699,7 @@ drawPoints(CGAL::Three::Viewer_interface* viewer) const
double ratio_displayed = 1.0; double ratio_displayed = 1.0;
if ((viewer->inFastDrawing () || d->isPointSliderMoving()) if ((viewer->inFastDrawing () || d->isPointSliderMoving())
&&((d->nb_points )/3 > limit_fast_drawing)) // arbitrary large value &&((d->nb_points )/3 > limit_fast_drawing)) // arbitrary large value
ratio_displayed = 3 * limit_fast_drawing / (double)(d->nb_points); ratio_displayed = 3 * limit_fast_drawing / static_cast<double>(d->nb_points);
if(!isInit(viewer)) if(!isInit(viewer))
initGL(viewer); initGL(viewer);

View File

@ -196,16 +196,16 @@ Scene_polygon_soup_item_priv::triangulate_polygon(Polygons_iterator pit, int pol
normals.push_back(normal.z()); normals.push_back(normal.z());
if(!soup->fcolors.empty()) if(!soup->fcolors.empty())
{ {
f_colors.push_back((float)color.red()/255); f_colors.push_back(static_cast<float>(color.red())/255);
f_colors.push_back((float)color.green()/255); f_colors.push_back(static_cast<float>(color.green())/255);
f_colors.push_back((float)color.blue()/255); f_colors.push_back(static_cast<float>(color.blue())/255);
} }
if(!soup->vcolors.empty()) if(!soup->vcolors.empty())
{ {
CGAL::IO::Color vcolor = soup->vcolors[triangulation.v2v[ffit->vertex(i)]]; CGAL::IO::Color vcolor = soup->vcolors[triangulation.v2v[ffit->vertex(i)]];
v_colors.push_back((float)vcolor.red()/255); v_colors.push_back(static_cast<float>(vcolor.red())/255);
v_colors.push_back((float)vcolor.green()/255); v_colors.push_back(static_cast<float>(vcolor.green())/255);
v_colors.push_back((float)vcolor.blue()/255); v_colors.push_back(static_cast<float>(vcolor.blue())/255);
} }
} }
} }
@ -263,17 +263,17 @@ Scene_polygon_soup_item_priv::compute_normals_and_vertices() const{
if(!soup->fcolors.empty()) if(!soup->fcolors.empty())
{ {
const CGAL::IO::Color color = soup->fcolors[nb]; const CGAL::IO::Color color = soup->fcolors[nb];
f_colors.push_back((float)color.red()/255); f_colors.push_back(static_cast<float>(color.red())/255);
f_colors.push_back((float)color.green()/255); f_colors.push_back(static_cast<float>(color.green())/255);
f_colors.push_back((float)color.blue()/255); f_colors.push_back(static_cast<float>(color.blue())/255);
} }
if(!soup->vcolors.empty()) if(!soup->vcolors.empty())
{ {
const CGAL::IO::Color color = soup->vcolors[it->at(i)]; const CGAL::IO::Color color = soup->vcolors[it->at(i)];
v_colors.push_back((float)color.red()/255); v_colors.push_back(static_cast<float>(color.red())/255);
v_colors.push_back((float)color.green()/255); v_colors.push_back(static_cast<float>(color.green())/255);
v_colors.push_back((float)color.blue()/255); v_colors.push_back(static_cast<float>(color.blue())/255);
} }
} }
} }

View File

@ -389,21 +389,21 @@ void Scene_surface_mesh_item_priv::addFlatData(Point p, EPICK::Vector_3 n, CGAL:
const CGAL::qglviewer::Vec offset = static_cast<CGAL::Three::Viewer_interface*>(CGAL::QGLViewer::QGLViewerPool().first())->offset(); const CGAL::qglviewer::Vec offset = static_cast<CGAL::Three::Viewer_interface*>(CGAL::QGLViewer::QGLViewerPool().first())->offset();
if(name.testFlag(Scene_item_rendering_helper::GEOMETRY)) if(name.testFlag(Scene_item_rendering_helper::GEOMETRY))
{ {
flat_vertices.push_back((cgal_gl_data)(p.x()+offset[0])); flat_vertices.push_back(static_cast<cgal_gl_data>(p.x()+offset[0]));
flat_vertices.push_back((cgal_gl_data)(p.y()+offset[1])); flat_vertices.push_back(static_cast<cgal_gl_data>(p.y()+offset[1]));
flat_vertices.push_back((cgal_gl_data)(p.z()+offset[2])); flat_vertices.push_back(static_cast<cgal_gl_data>(p.z()+offset[2]));
} }
if(name.testFlag(Scene_item_rendering_helper::NORMALS)) if(name.testFlag(Scene_item_rendering_helper::NORMALS))
{ {
flat_normals.push_back((cgal_gl_data)n.x()); flat_normals.push_back(static_cast<cgal_gl_data>(n.x()));
flat_normals.push_back((cgal_gl_data)n.y()); flat_normals.push_back(static_cast<cgal_gl_data>(n.y()));
flat_normals.push_back((cgal_gl_data)n.z()); flat_normals.push_back(static_cast<cgal_gl_data>(n.z()));
} }
if(c != nullptr && name.testFlag(Scene_item_rendering_helper::COLORS)) if(c != nullptr && name.testFlag(Scene_item_rendering_helper::COLORS))
{ {
f_colors.push_back((float)c->red()/255); f_colors.push_back(static_cast<float>(c->red())/255);
f_colors.push_back((float)c->green()/255); f_colors.push_back(static_cast<float>(c->green())/255);
f_colors.push_back((float)c->blue()/255); f_colors.push_back(static_cast<float>(c->blue())/255);
} }
} }
@ -649,9 +649,9 @@ void Scene_surface_mesh_item_priv::compute_elements(Scene_item_rendering_helper:
for(vertex_descriptor vd : vertices(*smesh_)) for(vertex_descriptor vd : vertices(*smesh_))
{ {
CGAL::IO::Color c = vcolors[vd]; CGAL::IO::Color c = vcolors[vd];
v_colors.push_back((float)c.red()/255); v_colors.push_back(static_cast<float>(c.red())/255);
v_colors.push_back((float)c.green()/255); v_colors.push_back(static_cast<float>(c.green())/255);
v_colors.push_back((float)c.blue()/255); v_colors.push_back(static_cast<float>(c.blue())/255);
} }
} }
@ -1603,8 +1603,8 @@ void
Scene_surface_mesh_item_priv:: Scene_surface_mesh_item_priv::
invalidate_stats() invalidate_stats()
{ {
number_of_degenerated_faces = (unsigned int)(-1); number_of_degenerated_faces = static_cast<unsigned int>(-1);
number_of_null_length_edges = (unsigned int)(-1); number_of_null_length_edges = static_cast<unsigned int>(-1);
has_nm_vertices = false; has_nm_vertices = false;
volume = -std::numeric_limits<double>::infinity(); volume = -std::numeric_limits<double>::infinity();
area = -std::numeric_limits<double>::infinity(); area = -std::numeric_limits<double>::infinity();
@ -1712,7 +1712,7 @@ QString Scene_surface_mesh_item::computeStats(int type)
{ {
if(is_triangle_mesh(*d->smesh_)) if(is_triangle_mesh(*d->smesh_))
{ {
if (d->number_of_degenerated_faces == (unsigned int)(-1)) if (d->number_of_degenerated_faces == static_cast<unsigned int>(-1))
d->number_of_degenerated_faces = nb_degenerate_faces(d->smesh_); d->number_of_degenerated_faces = nb_degenerate_faces(d->smesh_);
return QString::number(d->number_of_degenerated_faces); return QString::number(d->number_of_degenerated_faces);
} }
@ -2370,7 +2370,7 @@ float Scene_surface_mesh_item::alpha() const
{ {
if(!d->alphaSlider) if(!d->alphaSlider)
return 1.0f; return 1.0f;
return (float)d->alphaSlider->value() / 255.0f; return static_cast<float>(d->alphaSlider->value()) / 255.0f;
} }
void Scene_surface_mesh_item::setAlpha(int alpha) void Scene_surface_mesh_item::setAlpha(int alpha)

View File

@ -165,8 +165,8 @@ void Triangle_container::draw(Viewer_interface* viewer,
getVao(viewer)->program->setUniformValue("comparing", viewer->currentPass() > 0); getVao(viewer)->program->setUniformValue("comparing", viewer->currentPass() > 0);
getVao(viewer)->program->setUniformValue("width", viewer->width()*1.0f); getVao(viewer)->program->setUniformValue("width", viewer->width()*1.0f);
getVao(viewer)->program->setUniformValue("height", viewer->height()*1.0f); getVao(viewer)->program->setUniformValue("height", viewer->height()*1.0f);
getVao(viewer)->program->setUniformValue("near", (float)viewer->camera()->zNear()); getVao(viewer)->program->setUniformValue("near", static_cast<float>(viewer->camera()->zNear()));
getVao(viewer)->program->setUniformValue("far", (float)viewer->camera()->zFar()); getVao(viewer)->program->setUniformValue("far", static_cast<float>(viewer->camera()->zFar()));
getVao(viewer)->program->setUniformValue("writing", viewer->isDepthWriting()); getVao(viewer)->program->setUniformValue("writing", viewer->isDepthWriting());
getVao(viewer)->program->setUniformValue("alpha", d->alpha); getVao(viewer)->program->setUniformValue("alpha", d->alpha);
if( fbo) if( fbo)
@ -205,8 +205,8 @@ void Triangle_container::draw(Viewer_interface* viewer,
getVao(viewer)->program->setUniformValue("comparing", viewer->currentPass() > 0); getVao(viewer)->program->setUniformValue("comparing", viewer->currentPass() > 0);
getVao(viewer)->program->setUniformValue("width", viewer->width()*1.0f); getVao(viewer)->program->setUniformValue("width", viewer->width()*1.0f);
getVao(viewer)->program->setUniformValue("height", viewer->height()*1.0f); getVao(viewer)->program->setUniformValue("height", viewer->height()*1.0f);
getVao(viewer)->program->setUniformValue("near", (float)viewer->camera()->zNear()); getVao(viewer)->program->setUniformValue("near", static_cast<float>(viewer->camera()->zNear()));
getVao(viewer)->program->setUniformValue("far", (float)viewer->camera()->zFar()); getVao(viewer)->program->setUniformValue("far", static_cast<float>(viewer->camera()->zFar()));
getVao(viewer)->program->setUniformValue("writing", viewer->isDepthWriting()); getVao(viewer)->program->setUniformValue("writing", viewer->isDepthWriting());
getVao(viewer)->program->setUniformValue("alpha", d->alpha); getVao(viewer)->program->setUniformValue("alpha", d->alpha);
if( fbo) if( fbo)

View File

@ -502,7 +502,7 @@ void Viewer::init()
connect(d->logger, SIGNAL(messageLogged(QOpenGLDebugMessage)), this, SLOT(messageLogged(QOpenGLDebugMessage))); connect(d->logger, SIGNAL(messageLogged(QOpenGLDebugMessage)), this, SLOT(messageLogged(QOpenGLDebugMessage)));
d->logger->startLogging(); d->logger->startLogging();
} }
glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDARBPROC)this->context()->getProcAddress("glDrawArraysInstancedARB"); glDrawArraysInstanced = reinterpret_cast<PFNGLDRAWARRAYSINSTANCEDARBPROC>(this->context()->getProcAddress("glDrawArraysInstancedARB"));
if(!glDrawArraysInstanced) if(!glDrawArraysInstanced)
{ {
qDebug()<<"glDrawArraysInstancedARB : extension not found. Spheres will be displayed as points."; qDebug()<<"glDrawArraysInstancedARB : extension not found. Spheres will be displayed as points.";
@ -511,7 +511,7 @@ void Viewer::init()
else else
d->extension_is_found = true; d->extension_is_found = true;
glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORARBPROC)this->context()->getProcAddress("glVertexAttribDivisorARB"); glVertexAttribDivisor = reinterpret_cast<PFNGLVERTEXATTRIBDIVISORARBPROC>(this->context()->getProcAddress("glVertexAttribDivisorARB"));
if(!glDrawArraysInstanced) if(!glDrawArraysInstanced)
{ {
qDebug()<<"glVertexAttribDivisorARB : extension not found. Spheres will be displayed as points."; qDebug()<<"glVertexAttribDivisorARB : extension not found. Spheres will be displayed as points.";
@ -1092,7 +1092,7 @@ void Viewer::drawVisualHints()
camera()->getModelViewProjectionMatrix(mat); camera()->getModelViewProjectionMatrix(mat);
for(int i=0; i < 16; i++) for(int i=0; i < 16; i++)
{ {
mvpMatrix.data()[i] = (float)mat[i]; mvpMatrix.data()[i] = static_cast<float>(mat[i]);
} }
if(!isOpenGL_4_3()) if(!isOpenGL_4_3())
{ {
@ -1114,8 +1114,8 @@ void Viewer::drawVisualHints()
program->bind(); program->bind();
QVector2D vp(width(), height()); QVector2D vp(width(), height());
program->setUniformValue("viewport", vp); program->setUniformValue("viewport", vp);
program->setUniformValue("near",(GLfloat)camera()->zNear()); program->setUniformValue("near",static_cast<GLfloat>(camera()->zNear()));
program->setUniformValue("far",(GLfloat)camera()->zFar()); program->setUniformValue("far",static_cast<GLfloat>(camera()->zFar()));
program->setUniformValue("width", GLfloat(3.0f)); program->setUniformValue("width", GLfloat(3.0f));
program->setAttributeValue("colors", QColor(Qt::black)); program->setAttributeValue("colors", QColor(Qt::black));
program->setUniformValue("mvp_matrix", mvpMatrix); program->setUniformValue("mvp_matrix", mvpMatrix);
@ -1852,9 +1852,9 @@ void Viewer::setLighting()
//set ambient //set ambient
connect(dialog, &LightingDialog::s_ambient_changed, connect(dialog, &LightingDialog::s_ambient_changed,
[this, dialog](){ [this, dialog](){
d->ambient=QVector4D((float)dialog->ambient.redF(), d->ambient=QVector4D(static_cast<float>(dialog->ambient.redF()),
(float)dialog->ambient.greenF(), static_cast<float>(dialog->ambient.greenF()),
(float)dialog->ambient.blueF(), static_cast<float>(dialog->ambient.blueF()),
1.0f); 1.0f);
update(); update();
}); });
@ -1862,18 +1862,18 @@ void Viewer::setLighting()
//set diffuse //set diffuse
connect(dialog, &LightingDialog::s_diffuse_changed, connect(dialog, &LightingDialog::s_diffuse_changed,
[this, dialog](){ [this, dialog](){
d->diffuse=QVector4D((float)dialog->diffuse.redF(), d->diffuse=QVector4D(static_cast<float>(dialog->diffuse.redF()),
(float)dialog->diffuse.greenF(), static_cast<float>(dialog->diffuse.greenF()),
(float)dialog->diffuse.blueF(), static_cast<float>(dialog->diffuse.blueF()),
1.0f); 1.0f);
update(); update();
}); });
//set specular //set specular
connect(dialog, &LightingDialog::s_specular_changed, connect(dialog, &LightingDialog::s_specular_changed,
[this, dialog](){ [this, dialog](){
d->specular=QVector4D((float)dialog->specular.redF(), d->specular=QVector4D(static_cast<float>(dialog->specular.redF()),
(float)dialog->specular.greenF(), static_cast<float>(dialog->specular.greenF()),
(float)dialog->specular.blueF(), static_cast<float>(dialog->specular.blueF()),
1.0f); 1.0f);
update(); update();
@ -2035,8 +2035,8 @@ void Viewer::scaleScene()
else else
d->scaler = QVector3D(1,1,1); d->scaler = QVector3D(1,1,1);
CGAL::qglviewer::Vec vmin(((float)bbox.xmin()+offset().x)*d->scaler.x(), ((float)bbox.ymin()+offset().y)*d->scaler.y(), ((float)bbox.zmin()+offset().z)*d->scaler.z()), CGAL::qglviewer::Vec vmin((static_cast<float>(bbox.xmin())+offset().x)*d->scaler.x(), (static_cast<float>(bbox.ymin())+offset().y)*d->scaler.y(), (static_cast<float>(bbox.zmin())+offset().z)*d->scaler.z()),
vmax(((float)bbox.xmax()+offset().x)*d->scaler.x(), ((float)bbox.ymax()+offset().y)*d->scaler.y(), ((float)bbox.zmax()+offset().z)*d->scaler.z()); vmax((static_cast<float>(bbox.xmax())+offset().x)*d->scaler.x(), (static_cast<float>(bbox.ymax())+offset().y)*d->scaler.y(), (static_cast<float>(bbox.zmax())+offset().z)*d->scaler.z());
camera()->setPivotPoint((vmin+vmax)*0.5); camera()->setPivotPoint((vmin+vmax)*0.5);
camera()->setSceneBoundingBox(vmin, vmax); camera()->setSceneBoundingBox(vmin, vmax);
camera()->fitBoundingBox(vmin, vmax); camera()->fitBoundingBox(vmin, vmax);
@ -2132,8 +2132,8 @@ void Viewer::showEntireScene()
CGAL::QGLViewer::showEntireScene(); CGAL::QGLViewer::showEntireScene();
CGAL::Bbox_3 bbox = CGAL::Three::Three::scene()->bbox(); CGAL::Bbox_3 bbox = CGAL::Three::Three::scene()->bbox();
CGAL::qglviewer::Vec vmin(((float)bbox.xmin()+offset().x)*d->scaler.x(), ((float)bbox.ymin()+offset().y)*d->scaler.y(), ((float)bbox.zmin()+offset().z)*d->scaler.z()), CGAL::qglviewer::Vec vmin((static_cast<float>(bbox.xmin())+offset().x)*d->scaler.x(), (static_cast<float>(bbox.ymin())+offset().y)*d->scaler.y(), (static_cast<float>(bbox.zmin())+offset().z)*d->scaler.z()),
vmax(((float)bbox.xmax()+offset().x)*d->scaler.x(), ((float)bbox.ymax()+offset().y)*d->scaler.y(), ((float)bbox.zmax()+offset().z)*d->scaler.z()); vmax((static_cast<float>(bbox.xmax())+offset().x)*d->scaler.x(), (static_cast<float>(bbox.ymax())+offset().y)*d->scaler.y(), (static_cast<float>(bbox.zmax())+offset().z)*d->scaler.z());
camera()->setPivotPoint((vmin+vmax)*0.5); camera()->setPivotPoint((vmin+vmax)*0.5);
camera()->setSceneBoundingBox(vmin, vmax); camera()->setSceneBoundingBox(vmin, vmax);
camera()->fitBoundingBox(vmin, vmax); camera()->fitBoundingBox(vmin, vmax);

View File

@ -282,7 +282,7 @@ int main()
std::ifstream stream(if_name.c_str()); std::ifstream stream(if_name.c_str());
stream >> P; stream >> P;
fprintf(stderr, "loadMesh %d Ves %d Facets\n", fprintf(stderr, "loadMesh %d Ves %d Facets\n",
(int)P.size_of_vertices(), (int)P.size_of_facets()); static_cast<int>(P.size_of_vertices()), static_cast<int>(P.size_of_facets()));
if(verbose) if(verbose)
out_verb << "Polysurf with " << P.size_of_vertices() out_verb << "Polysurf with " << P.size_of_vertices()
<< " vertices and " << P.size_of_facets() << " vertices and " << P.size_of_facets()

View File

@ -287,7 +287,7 @@ int main()
PolyhedralSurf P; PolyhedralSurf P;
CGAL::IO::read_polygon_mesh(if_name.c_str(), P); CGAL::IO::read_polygon_mesh(if_name.c_str(), P);
fprintf(stderr, "loadMesh %d Ves %d Facets\n", fprintf(stderr, "loadMesh %d Ves %d Facets\n",
(int)num_vertices(P), (int)num_faces(P)); static_cast<int>(num_vertices(P)), static_cast<int>(num_faces(P)));
if(verbose) if(verbose)
out_verb << "Polysurf with " << num_vertices(P) out_verb << "Polysurf with " << num_vertices(P)
<< " vertices and " << num_faces(P) << " vertices and " << num_faces(P)

View File

@ -272,7 +272,7 @@ int main()
std::ifstream stream(if_name.c_str()); std::ifstream stream(if_name.c_str());
stream >> P; stream >> P;
fprintf(stderr, "loadMesh %d Ves %d Facets\n", fprintf(stderr, "loadMesh %d Ves %d Facets\n",
(int)num_vertices(P), (int)num_faces(P)); static_cast<int>(num_vertices(P)), static_cast<int>(num_faces(P)));
if(verbose) if(verbose)
out_verb << "Polysurf with " << num_vertices(P) out_verb << "Polysurf with " << num_vertices(P)
<< " vertices and " << num_faces(P) << " vertices and " << num_faces(P)

View File

@ -91,9 +91,9 @@ int main (int argc, char** argv)
([&](const std::vector<std::size_t>& region) ([&](const std::vector<std::size_t>& region)
{ {
// Assign a random color to each region // Assign a random color to each region
unsigned char r = (unsigned char)(random.get_int(64, 192)); unsigned char r = static_cast<unsigned char>(random.get_int(64, 192));
unsigned char g = (unsigned char)(random.get_int(64, 192)); unsigned char g = static_cast<unsigned char>(random.get_int(64, 192));
unsigned char b = (unsigned char)(random.get_int(64, 192)); unsigned char b = static_cast<unsigned char>(random.get_int(64, 192));
for (const std::size_t& idx : region) for (const std::size_t& idx : region)
{ {
red[idx] = r; red[idx] = r;

View File

@ -72,9 +72,9 @@ int main (int argc, char** argv)
([&](const std::vector<std::size_t>& region) ([&](const std::vector<std::size_t>& region)
{ {
// Assign a random color to each region // Assign a random color to each region
unsigned char r = (unsigned char)(random.get_int(64, 192)); unsigned char r = static_cast<unsigned char>(random.get_int(64, 192));
unsigned char g = (unsigned char)(random.get_int(64, 192)); unsigned char g = static_cast<unsigned char>(random.get_int(64, 192));
unsigned char b = (unsigned char)(random.get_int(64, 192)); unsigned char b = static_cast<unsigned char>(random.get_int(64, 192));
for (const std::size_t& idx : region) for (const std::size_t& idx : region)
{ {
red[idx] = r; red[idx] = r;

View File

@ -72,9 +72,9 @@ int main (int argc, char** argv)
([&](const std::vector<std::size_t>& region) ([&](const std::vector<std::size_t>& region)
{ {
// Assign a random color to each region // Assign a random color to each region
unsigned char r = (unsigned char)(random.get_int(64, 192)); unsigned char r = static_cast<unsigned char>(random.get_int(64, 192));
unsigned char g = (unsigned char)(random.get_int(64, 192)); unsigned char g = static_cast<unsigned char>(random.get_int(64, 192));
unsigned char b = (unsigned char)(random.get_int(64, 192)); unsigned char b = static_cast<unsigned char>(random.get_int(64, 192));
for (const std::size_t& idx : region) for (const std::size_t& idx : region)
{ {
red[idx] = r; red[idx] = r;

View File

@ -21,7 +21,7 @@ int main(void)
int x = rand() % degree; int x = rand() % degree;
int y = rand() % degree; int y = rand() % degree;
FT value = rand() / (FT)RAND_MAX; FT value = rand() / static_cast<FT>(RAND_MAX);
A.add_coef(x, y, value); A.add_coef(x, y, value);
A.add_coef(y, x, value); A.add_coef(y, x, value);

View File

@ -331,7 +331,7 @@ public Q_SLOTS:
//!This function is called by `Scene::changeGroup` and should not be //!This function is called by `Scene::changeGroup` and should not be
//!called manually. //!called manually.
virtual void moveToGroup(Scene_group_item* group); virtual void moveToGroup(Scene_group_item* group);
void setRenderingMode(int m) { setRenderingMode((RenderingMode)m);} void setRenderingMode(int m) { setRenderingMode(static_cast<RenderingMode>(m));}
//!Sets the rendering mode of the item. //!Sets the rendering mode of the item.
//!@see RenderingMode //!@see RenderingMode
virtual void setRenderingMode(RenderingMode m) { virtual void setRenderingMode(RenderingMode m) {