Subject: CGAL users discussion list
List archive
- From: "Sebastien Loriot (GeometryFactory)" <>
- To:
- Subject: Re: [cgal-discuss] Re: squared_distance performance
- Date: Wed, 10 Oct 2012 10:34:38 +0200
- Organization: GeometryFactory
The benchmarks on the manual were done using the AABB_tree
demo (in demo/AABB_tree directory).
I remove the accelerate_distance_query calls and here is what I have on a model with 2390 facets:
Benchmark closest point
49413.6 queries/s
Benchmark squared distance
51131 queries/s
Benchmark closest point and primitive
49902.2 queries/s
while with the calls I had:
Benchmark closest point
142781 queries/s
Benchmark squared distance
146269 queries/s
Benchmark closest point and primitive
145366 queries/s
I invite you to try the demo and come back to us if you observe
something different.
Sebastien.
On 10/05/2012 09:09 PM, topotun wrote:
Hello Philipp.
Thank you for your response.
To address your questions:
- Optimization was enabled for the build (/O2) - my apologies, I was not
being clear.
- The provided code is the simplest application that demonstrates this
behaviour, and the one I started with when looking at the CGAL distance
functions for the first time. The actual timing results that were the cause
for my concern come from one of our research apps that computes distances to
polyhedral surface for a 3D grid of points, with the total number of points
ranging from 100k to 11M. I cannot provide that particular code at this
time; however, it utilizes identical CGAL data constructs and function calls
as the code sample I've listed here, and the timing is performed only on the
CGAL-specific operations.
-The complete version of my first code fragment is enclosed. As I had
mentioned, it is largely unchanged from the
/AABB_polyhedron_facet_distance_example.cpp /sample code.
Sincerely,
Denis
---
#include<iostream>
#include<fstream>
#include<omp.h>
#include<CGAL/Simple_cartesian.h>
#include<CGAL/Polyhedron_3.h>
#include<CGAL/IO/Polyhedron_iostream.h>
#include<CGAL/IO/Polyhedron_VRML_1_ostream.h>
#include<CGAL/AABB_tree.h>
#include<CGAL/AABB_traits.h>
#include<CGAL/AABB_polyhedron_triangle_primitive.h>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::FT FT;
typedef Kernel::Point_3 Point;
typedef Kernel::Segment_3 Segment;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef CGAL::AABB_polyhedron_triangle_primitive<Kernel,Polyhedron>
Primitive;
typedef CGAL::AABB_traits<Kernel, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef Tree::Object_and_primitive_id Object_and_primitive_id;
typedef Tree::Point_and_primitive_id Point_and_primitive_id;
int main() {
double timer_start = 0.0;
double timer_tree = 0.0;
double timer_squared_distance = 0.0;
double timer_closest_point = 0.0;
double timer_closest_point_and_primitive = 0.0;
Polyhedron polyhedron;
const char* input_filename = "C:/Users/dvd11003/Desktop/CDL/test
part/off/mushroom.off";
std::ifstream stream(input_filename);
stream>> polyhedron;
std::cout<< "\n"<<polyhedron.size_of_vertices()<<std::endl;
//---------- AABB distance check ----------------//
// constructs AABB tree and computes internal KD-tree
// data structure to accelerate distance queries
timer_start = omp_get_wtime();
Tree tree(polyhedron.facets_begin(),polyhedron.facets_end());
//tree.accelerate_distance_queries();
timer_tree = omp_get_wtime() - timer_start;
std::cout<< "Tree constructed in "<< timer_tree<< std::endl;
// query point
Point query(100.0, 56.0, 100.0);
// computes squared distance from query
timer_start = omp_get_wtime();
FT sqd = tree.squared_distance(query);
timer_squared_distance = omp_get_wtime() - timer_start;
std::cout<< "squared distance: "<< sqrt(sqd)<< " in "<<
timer_squared_distance<< std::endl;
// computes closest point
timer_start = omp_get_wtime();
Point closest = tree.closest_point(query);
timer_closest_point = omp_get_wtime() - timer_start;
std::cout<< "closest point: "<< closest<< " in "<<
timer_closest_point<< std::endl;
// computes closest point and primitive id
timer_start = omp_get_wtime();
Point_and_primitive_id pp = tree.closest_point_and_primitive(query);
timer_closest_point_and_primitive = omp_get_wtime() - timer_start;
std::cout<< "closest point: "<< pp.first<< " in "<<
timer_closest_point_and_primitive<< std::endl;
Polyhedron::Face_handle f = pp.second; // closest primitive id
//---------- end AABB distance check ----------------//
return EXIT_SUCCESS;
}
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/squared-distance-performance-tp4655960p4655993.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] squared_distance performance, topotun, 10/03/2012
- Re: [cgal-discuss] squared_distance performance, Sebastien Loriot (GeometryFactory), 10/03/2012
- [cgal-discuss] Re: squared_distance performance, topotun, 10/04/2012
- Re: [cgal-discuss] Re: squared_distance performance, Sebastien Loriot (GeometryFactory), 10/04/2012
- Re: [cgal-discuss] Re: squared_distance performance, Philipp Moeller, 10/04/2012
- [cgal-discuss] Re: squared_distance performance, topotun, 10/05/2012
- Re: [cgal-discuss] Re: squared_distance performance, Sebastien Loriot (GeometryFactory), 10/10/2012
- [cgal-discuss] Re: squared_distance performance, topotun, 10/05/2012
- [cgal-discuss] Re: squared_distance performance, topotun, 10/04/2012
- Re: [cgal-discuss] squared_distance performance, Sebastien Loriot (GeometryFactory), 10/03/2012
Archive powered by MHonArc 2.6.18.