#include <iostream>
#include <list>
 
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_segment_primitive_3.h>
 
 
typedef K::FT FT;
typedef K::Point_3 Point;
typedef K::Plane_3 Plane;
typedef K::Segment_3 Segment;
typedef K::Triangle_3 Triangle;
 
typedef std::list<Segment>::iterator 
Iterator;
 
 
int main()
{
    Point a(1.0, 0.0, 0.0);
    Point b(0.0, 1.0, 0.0);
    Point c(0.0, 0.0, 1.0);
    Point d(0.0, 0.0, 0.0);
 
    std::list<Segment> segments;
    segments.push_back(Segment(a,b));
    segments.push_back(Segment(a,c));
    segments.push_back(Segment(c,d));
 
    
    
    Tree tree(segments.begin(),segments.end());
 
    
    Plane plane_query(a,b,d);
    std::cout << tree.number_of_intersected_primitives(plane_query)
        << " intersections(s) with plane" << std::endl;
 
    
    Triangle triangle_query(a,b,c);
    std::cout << tree.number_of_intersected_primitives(triangle_query)
        << " intersections(s) with triangle" << std::endl;
 
    
    Point point_query(2.0, 2.0, 2.0);
    Point closest = tree.closest_point(point_query);
 
    std::cerr << "closest point is: " << closest << std::endl;
    return EXIT_SUCCESS;
}
Primitive type that uses as identifier an iterator with a 3D segment as value_type.
Definition: AABB_segment_primitive_3.h:85
 
This traits class handles any type of 3D geometric primitives provided that the proper intersection t...
Definition: AABB_traits_3.h:172
 
Static data structure for efficient intersection and distance computations in 2D and 3D.
Definition: AABB_tree.h:57