Subject: CGAL users discussion list
List archive
- From: schrodingersnewcat <>
- To:
- Subject: [cgal-discuss] Re: AABB tree Exact_predicates_exact_constructions_kernel
- Date: Tue, 10 May 2011 15:49:56 -0700 (PDT)
I took the example "AABB_polyhedron_facet_distance_example.cpp" and changed
the kernel and added some output statements.
#include <iostream>
#include <CGAL/AABB_tree.h> // must be inserted before kernel
#include <CGAL/AABB_traits.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/AABB_polyhedron_triangle_primitive.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
//typedef CGAL::Simple_cartesian<double> K;
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
typedef K::FT FT;
typedef K::Point_3 Point;
typedef K::Segment_3 Segment;
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::AABB_polyhedron_triangle_primitive<K,Polyhedron>
Primitive;
typedef CGAL::AABB_traits<K, 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()
{
Point p(1.0, 0.0, 0.0);
Point q(0.0, 1.0, 0.0);
Point r(0.0, 0.0, 1.0);
Point s(0.0, 0.0, 0.0);
Polyhedron polyhedron;
polyhedron.make_tetrahedron(p, q, r, s);
// constructs AABB tree and computes internal KD-tree
// data structure to accelerate distance queries
Tree tree(polyhedron.facets_begin(),polyhedron.facets_end());
std::cout << "tree.accelerate_distance_queries()" << std::endl;
tree.accelerate_distance_queries();
std::cout << "KD tree constructed" << std::endl;
// query point
Point query(0.0, 0.0, 3.0);
// computes squared distance from query
FT sqd = tree.squared_distance(query);
std::cout << "squared distance: " << sqd << std::endl;
// computes closest point
Point closest = tree.closest_point(query);
std::cout << "closest point: " << closest << std::endl;
// computes closest point and primitive id
Point_and_primitive_id pp = tree.closest_point_and_primitive(query);
std::cout << "closest point: " << pp.first << std::endl;
Polyhedron::Face_handle f = pp.second; // closest primitive id
return EXIT_SUCCESS;
}
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/AABB-tree-Exact-predicates-exact-constructions-kernel-tp3506553p3513225.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] AABB tree Exact_predicates_exact_constructions_kernel, schrodingersnewcat, 05/08/2011
- [cgal-discuss] Re: AABB tree Exact_predicates_exact_constructions_kernel, schrodingersnewcat, 05/08/2011
- Re: [cgal-discuss] Re: AABB tree Exact_predicates_exact_constructions_kernel, Sebastien Loriot (GeometryFactory), 05/09/2011
- [cgal-discuss] Re: AABB tree Exact_predicates_exact_constructions_kernel, schrodingersnewcat, 05/11/2011
- Re: [cgal-discuss] Re: AABB tree Exact_predicates_exact_constructions_kernel, Sebastien Loriot (GeometryFactory), 05/12/2011
- Re: [cgal-discuss] Re: AABB tree Exact_predicates_exact_constructions_kernel, Sebastien Loriot (GeometryFactory), 05/13/2011
- [cgal-discuss] Re: AABB tree Exact_predicates_exact_constructions_kernel, schrodingersnewcat, 05/13/2011
- [cgal-discuss] Re: AABB tree Exact_predicates_exact_constructions_kernel, schrodingersnewcat, 05/11/2011
- Re: [cgal-discuss] Re: AABB tree Exact_predicates_exact_constructions_kernel, Sebastien Loriot (GeometryFactory), 05/09/2011
- [cgal-discuss] Re: AABB tree Exact_predicates_exact_constructions_kernel, schrodingersnewcat, 05/08/2011
Archive powered by MHonArc 2.6.16.