Subject: CGAL users discussion list
List archive
- From: gupta61 <>
- To:
- Subject: [cgal-discuss] CGAL "intersection" bug - URGENT
- Date: Thu, 5 Apr 2012 14:44:27 -0700 (PDT)
Hi,
I am reporting a problem with the "Segment-Triangle" intersection. If you
look at the code below I am trying to find a intersection between a Segment
and a Triangle. The answer should be that they do not intersect. When I use
"do_intersect" to find if they intersect, it gives me the correct result.
However when I ask "intersection" to tell me if it has an intersection, then
it gives me a segment as the intersection which is obviously wrong. Let me
know if I am missing something. I am mentioning the various things I have
tried.
I have tried with this problem with three versions of CGAL (3.8, 3.9,
4.0-beta1).
I also tried these kernels:
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
#include <CGAL/Simple_cartesian.h>
typedef CGAL::Simple_cartesian<double> Kernel;
and got the same wrong results...
I am also mentioning the code which we used for this.
#include <cstdlib>
#include <string>
#include <cstdio>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
//#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
//typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
//#include <CGAL/Simple_cartesian.h>
//typedef CGAL::Simple_cartesian<double> Kernel;
#include <CGAL/intersections.h>
#include <CGAL/Bbox_3.h>
typedef CGAL::Point_3<Kernel> CGALPoint3;
typedef CGAL::Segment_3<Kernel> CGALSegment3;
typedef CGAL::Triangle_3<Kernel> CGALTriangle3;
int main(int argc, char** argv) {
CGALSegment3 segment_query( CGALPoint3(0.125, 0, -0.125),
CGALPoint3(0.25, 0, -0.125) );
CGALTriangle3 triangle( CGALPoint3(0.2500001, 0, -0.125) /* vertex 6*/,
CGALPoint3(1.0278171, 0, -0.125) /* vertex 10*/,
CGALPoint3(1.0278171, 0, -0.250001) /* vertex 9*/ );
std::cout << std::setw(12) << std::setprecision( 15 )
<< "\nSegment query: " << segment_query << std::endl;
std::cout << std::setw(12) << std::setprecision( 15 )
<< "\nTriangle: " << triangle << std::endl;
bool do_intersect = CGAL::do_intersect(segment_query, triangle);
std::cout << "\nCGAL::do_intersect (0/1) = " << do_intersect << std::endl;
// Compute actual intersection(s)
CGAL::Object object = CGAL::intersection(segment_query, triangle);
// check if it is a point
const CGALPoint3* p_point=0;
const CGALSegment3* p_segm=0;
if( (p_point = CGAL::object_cast<CGALPoint3>(&object)) ) {
std::cout << "\nEncountered intersection object is a point" <<
std::endl;
std::cout << std::setw(12) << std::setprecision( 15 ) << (*p_point) <<
std::endl;
}
else if ( (p_segm = CGAL::object_cast<CGALSegment3>(&object)) ) {
// Check if it is a segment otherwise error out
std::cout << "\nEncountered intersection object is a segment" <<
std::endl;
std::cout << std::setw(12) << std::setprecision( 15 ) << (*p_segm) <<
std::endl;
}
else {
std::cerr << "\nInvalid object returned by aaa_bb tree" << std::endl;
}
return 0;
}
We got the following result which is obviously wrong as explained before.
Segment query: 0.125 0 -0.125 0.25 0 -0.125
Triangle: 0.2500001 0 -0.125 1.0278171 0 -0.125 1.0278171 0 -0.250001
CGAL::do_intersect (0/1) = 0
Encountered intersection object is a segment
0.125 0 -0.125 0.25 0 -0.125
Can you explain why I am getting this result or if you can confirm if it is
a bug ?
Thanks,
Piyush Gupta
UIUC
-----
Piyush Gupta
UIUC
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/CGAL-intersection-bug-URGENT-tp4536168p4536168.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] CGAL "intersection" bug - URGENT, gupta61, 04/05/2012
- Re: [cgal-discuss] CGAL "intersection" bug - URGENT, Sebastien Loriot (GeometryFactory), 04/06/2012
- [cgal-discuss] Re: CGAL "intersection" bug - URGENT, gupta61, 04/06/2012
- Re: [cgal-discuss] CGAL "intersection" bug - URGENT, Sebastien Loriot (GeometryFactory), 04/06/2012
Archive powered by MHonArc 2.6.16.