Subject: CGAL users discussion list
List archive
- From:
- To:
- Subject: Problem with Polygon_2 intersection
- Date: Mon, 12 Mar 2007 21:56:38 +0100
Hi,
I am currently having a problem computing an intersection of 2 polygons. My
program stops, and enven with visual debuger, I do not know what happen. My
current problem stands in a method from a class. Here is the prototype :
void Paving::ComputeCrops( const std::vector< CGAL::Polygon_2<CCd> >
&polygones )
I previously defined :
typedef CGAL::Cartesian<double> CCd;
Here is the (main) code in my method :
std::vector< CGAL::Polygon_2<CCd> >::const_iterator itb_pol =
polygones.begin(), ite_pol = polygones.end();
for (;itb_pol!=ite_pol;itb_pol++,cpt++)
{
CGAL::Polygon_2<CCd> poly_proj;
CGAL::Polygon_2<CCd>::Vertex_circulator circb =
(*itb_pol).vertices_circulator(), done = circb;
do
{
TPoint3D <double> p3d = mnt.GetPoint( (*circb).x() ,
(*circb).y() );
TPoint2D <double> p2d;
if ( strcmp(m_DEM_type,"ground") == 0 )
{
ori.GroundToPhoto(p3d,p2d);
}
else // type = "map"
{
ori.MapToPhoto(p3d,p2d);
}
CCd::Point_2 pi(p2d.x,p2d.y);
poly_proj.push_back( pi );
} while( (++circb)!=done ) ;
// on cree le polygone de l'image
CGAL::Polygon_2<CCd> poly_image;
{
CCd::Point_2 pi0(0.,0.);
CCd::Point_2 pi1(ori.GetNs().-1,0.);
CCd::Point_2 pi2(ori.GetNs().-1,ori.GetNl()-1.);
CCd::Point_2 pi3(0.,ori.GetNl()-1.);
poly_image.push_back( pi0 );
poly_image.push_back( pi1 );
poly_image.push_back( pi2 );
poly_image.push_back( pi3 );
}
// On fait l'intersection du polygone image et du polygone
projete
std::list< Polygon_2_WH_CCd > intR;
std::list< Polygon_2_WH_CCd >::iterator it;
CGAL::intersection(poly_proj,poly_image,std::back_inserter(intR));
/* ... */
I also have defined :
typedef CGAL::Polygon_2<CCd> Polygon_2_CCd;
typedef CGAL::Polygon_with_holes_2<CCd> Polygon_2_WH_CCd;
My programs suddenly stops (sometimes) in the CGAL::intersection(...)
function. I really do not understand what happen. The both polygons contain
always 4 points. The debuger did not helped me, that why I write to the list.
Is there any explanation for this behavior ?
Is there any way to test if there is a problem, like a try ... catch
statement ?
Thanks in advance for your answers.
Olivier Tournaire
PS : I have also tried the same code, remplacing CGAL::intersection(...) with
CGAL::do_intersect(...). Same result ...
- Problem with Polygon_2 intersection, olitour, 03/12/2007
- Re: [cgal-discuss] Problem with Polygon_2 intersection, Efi Fogel, 03/13/2007
- Re: [cgal-discuss] Problem with Polygon_2 intersection, Olivier Tournaire, 03/13/2007
- Re: [cgal-discuss] Problem with Polygon_2 intersection, Efi Fogel, 03/13/2007
Archive powered by MHonArc 2.6.16.