Subject: CGAL users discussion list
List archive
- From: placebo <>
- To:
- Subject: [cgal-discuss] triangle_query to AABB_triangle_tree fails.
- Date: Thu, 9 May 2013 13:05:32 -0700 (PDT)
Hello,
I am trying to find all intersections between a "triangle" and a "triangle
soup" using AABB trees. I have posted a simple example here to illustrate my
problem:
Consider 6 triangles arranged in a hexagonal pattern. 5 of the triangles
make up the soup. The 6th triangle is the query.
The "all_intersections" function should return:
3 point intersection objects
and
2 segment intersection objects
However, when I execute the script (see below), I get the following output:
5 intersection(s) with triangle query
intersection object is a point
intersection object is a point
intersection object is a point
intersection object is a point
intersection object is a point
Finished
Do AABB triangle trees not work with "triangle" queries?
I am using:
Windows 7
boost 1.53.0 (32 bit)
mingw with gcc-4.7.2 (32 bit)
CGAL-4.2 (32 bit)
Thanks,
-Willie B. Maddox Ph.D.
// BEGIN "AABB_triangle_3_example2.cpp"
#include <iostream>
#include <list>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_triangle_primitive.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::Point_3 Point;
typedef K::Triangle_3 Triangle;
typedef K::Segment_3 Segment;
typedef std::list<Triangle>::iterator Iterator;
typedef CGAL::AABB_triangle_primitive<K,Iterator> Primitive;
typedef CGAL::AABB_traits<K, Primitive> AABB_triangle_traits;
typedef CGAL::AABB_tree<AABB_triangle_traits> Tree;
typedef Tree::Object_and_primitive_id Object_and_primitive_id;
int main()
{
Point p0( 0.0, 0.0, 0.00);
Point p1( 1.0, 0.5, 0.05);
Point p2( 0.0, 1.0, 0.05);
Point p3(-1.0, 0.5, 0.05);
Point p4(-1.0,-0.5, 0.05);
Point p5( 0.0,-1.0, 0.05);
Point p6( 1.0,-0.5, 0.05);
std::list<Triangle> triangles;
triangles.push_back(Triangle(p0,p2,p3));
triangles.push_back(Triangle(p0,p3,p4));
triangles.push_back(Triangle(p0,p4,p5));
triangles.push_back(Triangle(p0,p5,p6));
triangles.push_back(Triangle(p0,p6,p1));
// constructs AABB tree
Tree tree(triangles.begin(),triangles.end());
// counts #intersections
Triangle triangle_query(p0,p1,p2);
std::cout << tree.number_of_intersected_primitives(triangle_query)
<< " intersections(s) with triangle query" << std::endl;
// computes all intersections with segment query (as pairs object -
primitive_id)
std::list<Object_and_primitive_id> isects;
tree.all_intersections(triangle_query, std::back_inserter(isects));
for (std::list<Object_and_primitive_id>::iterator isect =
isects.begin(); isect != isects.end(); isect++)
{
// get intersection objects
Object_and_primitive_id op = *isect;
CGAL::Object object = op.first;
Segment segment;
Point point;
if(CGAL::assign(segment,object))
std::cout << "intersection object is a segment" << std::endl;
else if(CGAL::assign(point,object))
std::cout << "intersection object is a point" << std::endl;
else std::cout << "intersection object is unknown" << std::endl;
}
std::cout << "Finished" << std::endl;
return EXIT_SUCCESS;
}
// END "AABB_triangle_3_example2.cpp"
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/triangle-query-to-AABB-triangle-tree-fails-tp4657400.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] triangle_query to AABB_triangle_tree fails., placebo, 05/09/2013
- [cgal-discuss] Re: triangle_query to AABB_triangle_tree returns incorrect intersection objects, placebo, 05/09/2013
- Re: [cgal-discuss] triangle_query to AABB_triangle_tree fails., Philipp Moeller, 05/10/2013
- [cgal-discuss] Re: triangle_query to AABB_triangle_tree fails., placebo, 05/13/2013
- Re: [cgal-discuss] Re: triangle_query to AABB_triangle_tree fails., Sebastien Loriot (GeometryFactory), 05/14/2013
- [cgal-discuss] Re: triangle_query to AABB_triangle_tree fails., placebo, 05/14/2013
- Re: [cgal-discuss] Re: triangle_query to AABB_triangle_tree fails., Sebastien Loriot (GeometryFactory), 05/14/2013
- [cgal-discuss] Re: triangle_query to AABB_triangle_tree fails., placebo, 05/14/2013
- Re: [cgal-discuss] Re: triangle_query to AABB_triangle_tree fails., Sebastien Loriot (GeometryFactory), 05/15/2013
- [cgal-discuss] Re: triangle_query to AABB_triangle_tree fails., placebo, 05/14/2013
- Re: [cgal-discuss] Re: triangle_query to AABB_triangle_tree fails., Sebastien Loriot (GeometryFactory), 05/14/2013
- [cgal-discuss] Re: triangle_query to AABB_triangle_tree fails., placebo, 05/14/2013
- [cgal-discuss] Re: triangle_query to AABB_triangle_tree fails., ChaoM, 05/14/2013
- Re: [cgal-discuss] Re: triangle_query to AABB_triangle_tree fails., Sebastien Loriot (GeometryFactory), 05/14/2013
- [cgal-discuss] Re: triangle_query to AABB_triangle_tree fails., placebo, 05/13/2013
Archive powered by MHonArc 2.6.18.