Apply google-readability-casting to the off_plugin

This commit is contained in:
Maxime Gimeno 2021-06-18 10:54:35 +02:00
parent 3613a94638
commit 1a9a578df8
13 changed files with 79 additions and 79 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

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

@ -2494,15 +2494,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
@ -3598,9 +3598,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

@ -764,8 +764,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);
@ -835,8 +835,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);
@ -846,18 +846,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);
@ -868,9 +868,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);
}
}
@ -1566,8 +1566,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();
@ -1675,7 +1675,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);
}
@ -2333,7 +2333,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

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