mirror of https://github.com/CGAL/cgal
Run on AABB_tree
This commit is contained in:
parent
91ca5a8add
commit
ea165d503f
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue