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/*'
...

View File

@ -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<float>(y2-y1) / static_cast<float>(x2-x1);
float b = static_cast<float>(y1) - a*static_cast<float>(x1);
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;
const unsigned int nb_points = (unsigned)
QInputDialog::getInt(nullptr, "#Points",
"#Points:",10000,1,100000000,9,&ok);
const unsigned int nb_points = static_cast<unsigned>(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<unsigned>(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<unsigned>(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<unsigned>(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<unsigned>(QInputDialog::getInt(nullptr, "#Points",
"Points:",1000,1,10000000,8,&ok));
if(!ok)
return;

View File

@ -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<FT>(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<unsigned>(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<float>(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<double>(RAND_MAX);
return static_cast<FT>(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<int>(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<double>(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<int>(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<double>(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<FT>(0.0),static_cast<FT>(0.0),static_cast<FT>(1.0));
unsigned int i;
const double dz = m_bbox.zmax() - m_bbox.zmin();
for(i=0;i<nb_slices;i++)
{
FT z = m_bbox.zmin() + (FT)i / (FT)nb_slices * dz;
Point p((FT)0.0, (FT)0.0, z);
FT z = m_bbox.zmin() + static_cast<FT>(i) / static_cast<FT>(nb_slices) * dz;
Point p(static_cast<FT>(0.0), static_cast<FT>(0.0), z);
Plane plane(p,normal);
std::list<Object_and_primitive_id> intersections;

View File

@ -115,7 +115,7 @@ void Scene::bench_memory()
Refiner<Kernel,Polyhedron> refiner(m_pPolyhedron);
std::size_t digits = nb_digits(m_pPolyhedron->size_of_facets());
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);
// 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<double>(bytes) / static_cast<double>(1048576); // in MBytes
double bpp = static_cast<double>(bytes) / static_cast<double>(m_pPolyhedron->size_of_facets());
std::cout << m_pPolyhedron->size_of_facets() << ", "
<< bytes << ", "
<< mbytes << ", "
@ -152,7 +152,7 @@ void Scene::bench_construction()
Refiner<Kernel,Polyhedron> refiner(m_pPolyhedron);
std::size_t digits = nb_digits(m_pPolyhedron->size_of_facets());
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);
// constructs tree
@ -197,7 +197,7 @@ void Scene::bench_intersections_vs_nbt()
Refiner<Kernel,Polyhedron> refiner(m_pPolyhedron);
std::size_t digits = nb_digits(m_pPolyhedron->size_of_facets());
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);
// constructs tree (out of timing)
@ -210,7 +210,7 @@ void Scene::bench_intersections_vs_nbt()
for(int i=0;i<nb_queries;i++)
tree.all_intersections(queries[i],std::back_inserter(intersections));
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;
}
@ -241,7 +241,7 @@ void Scene::bench_distances_vs_nbt()
Refiner<Kernel,Polyhedron> refiner(m_pPolyhedron);
std::size_t digits = nb_digits(m_pPolyhedron->size_of_facets());
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);
// constructs tree (out of timing)
@ -253,7 +253,7 @@ void Scene::bench_distances_vs_nbt()
for(int i=0;i<nb_queries;i++)
tree.closest_point(queries[i]);
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;
}
@ -298,7 +298,7 @@ void Scene::bench_intersection(Facet_tree& tree,
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;
}
@ -340,7 +340,7 @@ void Scene::bench_distance(Facet_tree& tree,
nb++;
}
double speed = (double)nb / (double)timer.time();
double speed = static_cast<double>(nb) / timer.time();
std::cout << speed << " queries/s" << std::endl;
}

View File

@ -33,7 +33,7 @@
double random_in(const double a,
const double b)
{
double r = rand() / (double)RAND_MAX;
double r = rand() / static_cast<double>(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<double>(nb) / timer.time();
std::cout << speed << " distance queries/s" << std::endl;
timer.stop();
}

View File

@ -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<unsigned int>(nb / timer.time());
std::cout.precision(10);
std::cout.width(15);
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::endl;
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;
}

View File

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

View File

@ -35,7 +35,7 @@ public:
Color out;
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;
}

View File

@ -18,7 +18,7 @@ int main ()
<<dim<<"D" << std::endl;
std::vector<Point> v;
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) );
for (int i = 0; i < nb_points; ++i) std::cout<<" "<<v[i]<<std::endl;
return 0;

View File

@ -70,7 +70,7 @@ int main(int argc, char** argv)
std::cerr << "Assignment f2=f...\n";
f2 = f; // check the assignment
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";
Map f3(f); // check the copy constructor

View File

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

View File

@ -11,7 +11,7 @@ CGAL::Image_3 random_labeled_image()
_image* image = _createImage(dim, dim, dim, 1,
1.f, 1.f, 1.f, 1,
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::ptrdiff_t center = dim / 2;

View File

@ -86,9 +86,9 @@ public:
//! perform the output, calls \c operator\<\< by default.
std::ostream& operator()( std::ostream& out) const {
if(IO::is_ascii(out)) {
out << (int)t;
out << static_cast<int>(t);
} else {
CGAL::write(out, (int)t);
CGAL::write(out, static_cast<int>(t));
}
return out;
}
@ -109,7 +109,7 @@ public:
} else {
CGAL::read(in, i);
}
t = (T)i;
t = static_cast<T>(i);
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)
{
std::cerr << "* Point " << point_set.point(*it) // or point_set[it]
<< " with color [" << (int)(color[*it][0])
<< " " << (int)(color[*it][1])
<< " " << (int)(color[*it][2])
<< " with color [" << static_cast<int>(color[*it][0])
<< " " << static_cast<int>(color[*it][1])
<< " " << static_cast<int>(color[*it][2])
<< "] and intensity " << intensity[*it]
<< std::endl;
}
@ -53,11 +53,11 @@ int main (int, char**)
for (std::size_t i = 0; i < 10; ++ 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)),
(unsigned char)(CGAL::get_default_random().get_int(0, 255)),
(unsigned char)(CGAL::get_default_random().get_int(0, 255)) }};
Color c = {{ static_cast<unsigned char>(CGAL::get_default_random().get_int(0, 255)),
static_cast<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;
intensity[*it] = rand() / (double)(RAND_MAX);
intensity[*it] = rand() / static_cast<double>(RAND_MAX);
}
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
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 "
<< 2. * average_spacing << std::endl;

View File

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

View File

@ -20,7 +20,7 @@ compute_color_map(QColor base_color,
Output_color_iterator out)
{
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
:hue;

View File

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

View File

@ -2496,15 +2496,15 @@ void MainWindow::viewerShowObject()
Scene_item* item = nullptr;
QAction* sender_action = qobject_cast<QAction*>(sender());
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) {
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),
max((float)bbox.xmax()+viewer->offset().x, (float)bbox.ymax()+viewer->offset().y, (float)bbox.zmax()+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(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);
viewerShow((float)min.x, (float)min.y, (float)min.z,
(float)max.x, (float)max.y, (float)max.z);
viewerShow(static_cast<float>(min.x), static_cast<float>(min.y), static_cast<float>(min.z),
static_cast<float>(max.x), static_cast<float>(max.y), static_cast<float>(max.z));
}
}
/* to check
@ -3599,9 +3599,9 @@ void SubViewer::lookat()
if (viewer->camera()->frame()->isSpinning())
viewer->camera()->frame()->stopSpinning();
mw->viewerShow(viewer,
(float)dialog.get_x() + viewer->offset().x,
(float)dialog.get_y() + viewer->offset().y,
(float)dialog.get_z() + viewer->offset().z);
static_cast<float>(dialog.get_x()) + viewer->offset().x,
static_cast<float>(dialog.get_y()) + viewer->offset().y,
static_cast<float>(dialog.get_z()) + viewer->offset().z);
}
}

View File

@ -302,7 +302,7 @@ public Q_SLOTS:
}
if(total == 0)
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 dir;
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*> depth_test;
QColor background = viewer->backgroundColor();
fbos.resize((int)viewer->total_pass());
depth_test.resize((int)viewer->total_pass()-1);
fbos.resize(static_cast<int>(viewer->total_pass()));
depth_test.resize(static_cast<int>(viewer->total_pass())-1);
//first pass
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
fbos[(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] = new QOpenGLFramebufferObject(viewer->width(), viewer->height(),QOpenGLFramebufferObject::Depth, GL_TEXTURE_2D, GL_RGBA32F);
fbos[static_cast<int>(viewer->total_pass())-1]->bind();
viewer->glDisable(GL_BLEND);
viewer->glEnable(GL_DEPTH_TEST);
viewer->glDepthFunc(GL_LESS);
@ -847,18 +847,18 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer)
0.0f);
viewer->glClearDepthf(1);
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(transparent_items, viewer, picked_item_IDs, false, (int)viewer->total_pass()-1, false, depth_test[(int)viewer->total_pass()-2]);
fbos[(int)viewer->total_pass()-1]->release();
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, static_cast<int>(viewer->total_pass())-1, false, depth_test[static_cast<int>(viewer->total_pass())-2]);
fbos[static_cast<int>(viewer->total_pass())-1]->release();
if(viewer->getStoredFrameBuffer() != nullptr)
viewer->getStoredFrameBuffer()->bind();
//blending
program.bind();
vaos[viewer]->bind();
viewer->glClearColor((GLclampf)background.redF(),
(GLclampf)background.greenF(),
(GLclampf)background.blueF(),
viewer->glClearColor(static_cast<GLclampf>(background.redF()),
static_cast<GLclampf>(background.greenF()),
static_cast<GLclampf>(background.blueF()),
0.0f);
viewer->glDisable(GL_DEPTH_TEST);
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.ortho(-1,1,-1,1,0,1);
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];
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->glDrawArrays(GL_TRIANGLES,0,static_cast<GLsizei>(6));

View File

@ -88,7 +88,7 @@ float Scene_item_rendering_helper::alpha() const
{
if(!priv->alphaSlider)
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

View File

@ -671,7 +671,7 @@ void Scene_points_with_normal_item::drawEdges(CGAL::Three::Viewer_interface* vie
double ratio_displayed = 1.0;
if (viewer->inFastDrawing () &&
(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))
initGL(viewer);
if ( getBuffersFilled() &&
@ -699,7 +699,7 @@ drawPoints(CGAL::Three::Viewer_interface* viewer) const
double ratio_displayed = 1.0;
if ((viewer->inFastDrawing () || d->isPointSliderMoving())
&&((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))
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());
if(!soup->fcolors.empty())
{
f_colors.push_back((float)color.red()/255);
f_colors.push_back((float)color.green()/255);
f_colors.push_back((float)color.blue()/255);
f_colors.push_back(static_cast<float>(color.red())/255);
f_colors.push_back(static_cast<float>(color.green())/255);
f_colors.push_back(static_cast<float>(color.blue())/255);
}
if(!soup->vcolors.empty())
{
CGAL::IO::Color vcolor = soup->vcolors[triangulation.v2v[ffit->vertex(i)]];
v_colors.push_back((float)vcolor.red()/255);
v_colors.push_back((float)vcolor.green()/255);
v_colors.push_back((float)vcolor.blue()/255);
v_colors.push_back(static_cast<float>(vcolor.red())/255);
v_colors.push_back(static_cast<float>(vcolor.green())/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())
{
const CGAL::IO::Color color = soup->fcolors[nb];
f_colors.push_back((float)color.red()/255);
f_colors.push_back((float)color.green()/255);
f_colors.push_back((float)color.blue()/255);
f_colors.push_back(static_cast<float>(color.red())/255);
f_colors.push_back(static_cast<float>(color.green())/255);
f_colors.push_back(static_cast<float>(color.blue())/255);
}
if(!soup->vcolors.empty())
{
const CGAL::IO::Color color = soup->vcolors[it->at(i)];
v_colors.push_back((float)color.red()/255);
v_colors.push_back((float)color.green()/255);
v_colors.push_back((float)color.blue()/255);
v_colors.push_back(static_cast<float>(color.red())/255);
v_colors.push_back(static_cast<float>(color.green())/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();
if(name.testFlag(Scene_item_rendering_helper::GEOMETRY))
{
flat_vertices.push_back((cgal_gl_data)(p.x()+offset[0]));
flat_vertices.push_back((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.x()+offset[0]));
flat_vertices.push_back(static_cast<cgal_gl_data>(p.y()+offset[1]));
flat_vertices.push_back(static_cast<cgal_gl_data>(p.z()+offset[2]));
}
if(name.testFlag(Scene_item_rendering_helper::NORMALS))
{
flat_normals.push_back((cgal_gl_data)n.x());
flat_normals.push_back((cgal_gl_data)n.y());
flat_normals.push_back((cgal_gl_data)n.z());
flat_normals.push_back(static_cast<cgal_gl_data>(n.x()));
flat_normals.push_back(static_cast<cgal_gl_data>(n.y()));
flat_normals.push_back(static_cast<cgal_gl_data>(n.z()));
}
if(c != nullptr && name.testFlag(Scene_item_rendering_helper::COLORS))
{
f_colors.push_back((float)c->red()/255);
f_colors.push_back((float)c->green()/255);
f_colors.push_back((float)c->blue()/255);
f_colors.push_back(static_cast<float>(c->red())/255);
f_colors.push_back(static_cast<float>(c->green())/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_))
{
CGAL::IO::Color c = vcolors[vd];
v_colors.push_back((float)c.red()/255);
v_colors.push_back((float)c.green()/255);
v_colors.push_back((float)c.blue()/255);
v_colors.push_back(static_cast<float>(c.red())/255);
v_colors.push_back(static_cast<float>(c.green())/255);
v_colors.push_back(static_cast<float>(c.blue())/255);
}
}
@ -1603,8 +1603,8 @@ void
Scene_surface_mesh_item_priv::
invalidate_stats()
{
number_of_degenerated_faces = (unsigned int)(-1);
number_of_null_length_edges = (unsigned int)(-1);
number_of_degenerated_faces = static_cast<unsigned int>(-1);
number_of_null_length_edges = static_cast<unsigned int>(-1);
has_nm_vertices = false;
volume = -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 (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_);
return QString::number(d->number_of_degenerated_faces);
}
@ -2370,7 +2370,7 @@ float Scene_surface_mesh_item::alpha() const
{
if(!d->alphaSlider)
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)

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("width", viewer->width()*1.0f);
getVao(viewer)->program->setUniformValue("height", viewer->height()*1.0f);
getVao(viewer)->program->setUniformValue("near", (float)viewer->camera()->zNear());
getVao(viewer)->program->setUniformValue("far", (float)viewer->camera()->zFar());
getVao(viewer)->program->setUniformValue("near", static_cast<float>(viewer->camera()->zNear()));
getVao(viewer)->program->setUniformValue("far", static_cast<float>(viewer->camera()->zFar()));
getVao(viewer)->program->setUniformValue("writing", viewer->isDepthWriting());
getVao(viewer)->program->setUniformValue("alpha", d->alpha);
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("width", viewer->width()*1.0f);
getVao(viewer)->program->setUniformValue("height", viewer->height()*1.0f);
getVao(viewer)->program->setUniformValue("near", (float)viewer->camera()->zNear());
getVao(viewer)->program->setUniformValue("far", (float)viewer->camera()->zFar());
getVao(viewer)->program->setUniformValue("near", static_cast<float>(viewer->camera()->zNear()));
getVao(viewer)->program->setUniformValue("far", static_cast<float>(viewer->camera()->zFar()));
getVao(viewer)->program->setUniformValue("writing", viewer->isDepthWriting());
getVao(viewer)->program->setUniformValue("alpha", d->alpha);
if( fbo)

View File

@ -502,7 +502,7 @@ void Viewer::init()
connect(d->logger, SIGNAL(messageLogged(QOpenGLDebugMessage)), this, SLOT(messageLogged(QOpenGLDebugMessage)));
d->logger->startLogging();
}
glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDARBPROC)this->context()->getProcAddress("glDrawArraysInstancedARB");
glDrawArraysInstanced = reinterpret_cast<PFNGLDRAWARRAYSINSTANCEDARBPROC>(this->context()->getProcAddress("glDrawArraysInstancedARB"));
if(!glDrawArraysInstanced)
{
qDebug()<<"glDrawArraysInstancedARB : extension not found. Spheres will be displayed as points.";
@ -511,7 +511,7 @@ void Viewer::init()
else
d->extension_is_found = true;
glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORARBPROC)this->context()->getProcAddress("glVertexAttribDivisorARB");
glVertexAttribDivisor = reinterpret_cast<PFNGLVERTEXATTRIBDIVISORARBPROC>(this->context()->getProcAddress("glVertexAttribDivisorARB"));
if(!glDrawArraysInstanced)
{
qDebug()<<"glVertexAttribDivisorARB : extension not found. Spheres will be displayed as points.";
@ -1092,7 +1092,7 @@ void Viewer::drawVisualHints()
camera()->getModelViewProjectionMatrix(mat);
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())
{
@ -1114,8 +1114,8 @@ void Viewer::drawVisualHints()
program->bind();
QVector2D vp(width(), height());
program->setUniformValue("viewport", vp);
program->setUniformValue("near",(GLfloat)camera()->zNear());
program->setUniformValue("far",(GLfloat)camera()->zFar());
program->setUniformValue("near",static_cast<GLfloat>(camera()->zNear()));
program->setUniformValue("far",static_cast<GLfloat>(camera()->zFar()));
program->setUniformValue("width", GLfloat(3.0f));
program->setAttributeValue("colors", QColor(Qt::black));
program->setUniformValue("mvp_matrix", mvpMatrix);
@ -1852,9 +1852,9 @@ void Viewer::setLighting()
//set ambient
connect(dialog, &LightingDialog::s_ambient_changed,
[this, dialog](){
d->ambient=QVector4D((float)dialog->ambient.redF(),
(float)dialog->ambient.greenF(),
(float)dialog->ambient.blueF(),
d->ambient=QVector4D(static_cast<float>(dialog->ambient.redF()),
static_cast<float>(dialog->ambient.greenF()),
static_cast<float>(dialog->ambient.blueF()),
1.0f);
update();
});
@ -1862,18 +1862,18 @@ void Viewer::setLighting()
//set diffuse
connect(dialog, &LightingDialog::s_diffuse_changed,
[this, dialog](){
d->diffuse=QVector4D((float)dialog->diffuse.redF(),
(float)dialog->diffuse.greenF(),
(float)dialog->diffuse.blueF(),
d->diffuse=QVector4D(static_cast<float>(dialog->diffuse.redF()),
static_cast<float>(dialog->diffuse.greenF()),
static_cast<float>(dialog->diffuse.blueF()),
1.0f);
update();
});
//set specular
connect(dialog, &LightingDialog::s_specular_changed,
[this, dialog](){
d->specular=QVector4D((float)dialog->specular.redF(),
(float)dialog->specular.greenF(),
(float)dialog->specular.blueF(),
d->specular=QVector4D(static_cast<float>(dialog->specular.redF()),
static_cast<float>(dialog->specular.greenF()),
static_cast<float>(dialog->specular.blueF()),
1.0f);
update();
@ -2035,8 +2035,8 @@ void Viewer::scaleScene()
else
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()),
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());
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((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()->setSceneBoundingBox(vmin, vmax);
camera()->fitBoundingBox(vmin, vmax);
@ -2132,8 +2132,8 @@ void Viewer::showEntireScene()
CGAL::QGLViewer::showEntireScene();
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()),
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());
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((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()->setSceneBoundingBox(vmin, vmax);
camera()->fitBoundingBox(vmin, vmax);

View File

@ -282,7 +282,7 @@ int main()
std::ifstream stream(if_name.c_str());
stream >> P;
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)
out_verb << "Polysurf with " << P.size_of_vertices()
<< " vertices and " << P.size_of_facets()

View File

@ -287,7 +287,7 @@ int main()
PolyhedralSurf P;
CGAL::IO::read_polygon_mesh(if_name.c_str(), P);
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)
out_verb << "Polysurf with " << num_vertices(P)
<< " vertices and " << num_faces(P)

View File

@ -272,7 +272,7 @@ int main()
std::ifstream stream(if_name.c_str());
stream >> P;
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)
out_verb << "Polysurf with " << num_vertices(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)
{
// Assign a random color to each region
unsigned char r = (unsigned char)(random.get_int(64, 192));
unsigned char g = (unsigned char)(random.get_int(64, 192));
unsigned char b = (unsigned char)(random.get_int(64, 192));
unsigned char r = static_cast<unsigned char>(random.get_int(64, 192));
unsigned char g = static_cast<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)
{
red[idx] = r;

View File

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

View File

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

View File

@ -21,7 +21,7 @@ int main(void)
int x = 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(y, x, value);

View File

@ -331,7 +331,7 @@ public Q_SLOTS:
//!This function is called by `Scene::changeGroup` and should not be
//!called manually.
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.
//!@see RenderingMode
virtual void setRenderingMode(RenderingMode m) {