Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
Checks: '-clang-diagnostic*,-clang-analyzer*,modernize-use-nullptr'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we remove modernize-use-nullptr?!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a mistake I'd say. I'll restore it (or you can do it) directly in master once I'm done with checks on another PR.

Checks: '-clang-diagnostic*,-clang-analyzer*,google-readability-casting'
HeaderFilterRegex: 'CGAL/*'
...

6 changes: 3 additions & 3 deletions AABB_tree/demo/AABB_tree/Color_ramp.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public :
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);
}
}

Expand Down
25 changes: 10 additions & 15 deletions AABB_tree/demo/AABB_tree/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
24 changes: 12 additions & 12 deletions AABB_tree/demo/AABB_tree/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand All @@ -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");
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
20 changes: 10 additions & 10 deletions AABB_tree/demo/AABB_tree/benchmarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 << ", "
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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;
}
Expand Down Expand Up @@ -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)
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions AABB_tree/test/AABB_tree/AABB_test_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Color_ramp

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;
}
Expand Down
2 changes: 1 addition & 1 deletion Generator/examples/Generator/grid_d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Mesh_2/test/Mesh_2/test_double_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion Mesh_3/examples/Mesh_3/random_labeled_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions Mesh_3/test/Mesh_3/test_c3t3_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ class Output_rep<MD_heterogeneous_types::Subdomain_index> {
//! 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;
}
Expand All @@ -109,7 +109,7 @@ class Input_rep<MD_heterogeneous_types::Subdomain_index> {
} else {
CGAL::read(in, i);
}
t = (T)i;
t = static_cast<T>(i);
return in;
}
};
Expand Down
14 changes: 7 additions & 7 deletions Point_set_3/examples/Point_set_3/point_set_property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down
Loading