#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_triangle_primitive_3.h>
#include <CGAL/AABB_trees/intersection.h>
#include <iostream>
#include <fstream>
typedef K::Point_3 Point;
typedef K::Triangle_3 Triangle;
typedef std::vector<Triangle>::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);
Point e(1.2, 0.2, 0.2);
Point f(0.2, 1.2, 0.2);
Point g(0.2, 0.2, 1.2);
Point h(0.2, 0.2, 0.2);
std::vector<Triangle> tetra1;
tetra1.push_back(Triangle(a,b,c));
tetra1.push_back(Triangle(a,b,d));
tetra1.push_back(Triangle(a,d,c));
tetra1.push_back(Triangle(b,c,d));
std::vector<Triangle> tetra2;
tetra2.push_back(Triangle(e,f,g));
tetra2.push_back(Triangle(e,f,h));
tetra2.push_back(Triangle(e,h,g));
tetra2.push_back(Triangle(f,g,h));
Tree tree1(tetra1.begin(),tetra1.end());
Tree tree2(tetra2.begin(),tetra2.end());
std::vector< std::pair<Iterator, Iterator> > intersections;
for(auto [id1, id2]: intersections)
std::cout << "ids: " << std::distance(tetra1.begin(), id1) << " " << std::distance(tetra2.begin(), id2) << std::endl;
return EXIT_SUCCESS;
}
This traits class handles any type of 3D geometric primitives provided that the proper intersection t...
Definition AABB_traits_3.h:514
Static data structure for efficient intersection and distance computations in 2D and 3D.
Definition AABB_tree.h:61
Primitive type that uses as identifier an iterator with a 3D triangle as value_type.
Definition AABB_triangle_primitive_3.h:86
void all_pairs_of_intersecting_primitives(const AABBTree1 &tree1, const AABBTree2 &tree2, OutputIterator out, const NamedParameters1 &np1=parameters::default_values(), const NamedParameters2 &np2=parameters::default_values())
Computes all intersecting primitive pairs between two AABB trees.
Definition intersection.h:122
bool do_intersect(const AABBTree1 &tree1, const AABBTree2 &tree2, const NamedParameters1 &np1=parameters::default_values(), const NamedParameters2 &np2=parameters::default_values())
Tests whether two AABB trees contain intersecting primitives.
Definition intersection.h:53