Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Re: AABB tree Exact_predicates_exact_constructions_kernel

Subject: CGAL users discussion list

List archive

[cgal-discuss] Re: AABB tree Exact_predicates_exact_constructions_kernel


Chronological Thread 
  • 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 &lt;CGAL/AABB_tree.h&gt; // must be inserted before kernel
#include &lt;CGAL/AABB_traits.h&gt;
#include &lt;CGAL/Polyhedron_3.h&gt;
#include &lt;CGAL/AABB_polyhedron_triangle_primitive.h&gt;

#include &lt;CGAL/Simple_cartesian.h&gt;
#include &lt;CGAL/Exact_predicates_exact_constructions_kernel.h&gt;

//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&lt;K,Polyhedron&gt;
Primitive;
typedef CGAL::AABB_traits&lt;K, Primitive&gt; 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.



Archive powered by MHonArc 2.6.16.

Top of Page