Subject: CGAL users discussion list
List archive
- From: "Sebastien Loriot (GeometryFactory)" <>
- To:
- Subject: Re: [cgal-discuss] Re: cGAL::join
- Date: Tue, 01 Feb 2011 08:37:26 +0100
Would be great if you could post a minimal and complete example
showing the problem. No one can guess for example what kernel you are using.
S.
sara123 wrote:
this function in my program should calculate the total area of these polygons
after union calculation:
the input factor to this function is a vector of polygon_2 and the output is
a number.
RT Union(std::vector<Polygon_2> pol_vector)
{//
std::vector<Polygon_2>::iterator mit;
//G_Polygon_set_2 S;
Polygon_set_2 S;
RT area_hole=0.0;
RT sum_area_hole=0.0;
RT area=0.0;
RT sum_area=0, area_bound;
Polygon_2 A;
for (mit = pol_vector.begin(); mit != pol_vector.end(); ++mit)
{
A=*mit;
S.join (A);
}
//S.join(pol_vector.begin(),pol_vector.end());
std::list<Polygon_with_holes_2> res;
std::list<Polygon_with_holes_2>::const_iterator it;
std::list<Polygon_with_holes_2> my;
Polygon_with_holes_2 mes;
CGAL::Polygon_with_holes_2<K>::Hole_const_iterator hit;
//std::cout << "The result contains " << S.number_of_polygons_with_holes()
<< " components:" << std::endl;
S.polygons_with_holes (std::back_inserter (res));
for (it = res.begin(); it != res.end(); ++it) {///
std::cout << "--> "<<*it<<std::endl;
mes=*it;
sum_area_hole=0;
for (hit=mes.holes_begin(); hit!=mes.holes_end(); ++hit)
{//// area_hole=(*hit).area();
sum_area_hole=area_hole+sum_area_hole;
/*std::cout <<"sum_area_hole="<<sum_area_hole<<std::endl;*/
}////
area_bound=(mes.outer_boundary()).area();
area=area_bound + sum_area_hole;//sum_area_hole manfi mibashad
sum_area=sum_area+area;
/*std::cout <<"area="<<area<<std::endl;
std::cout <<"sum_area="<<sum_area<<std::endl;*/ }///
return sum_area;
}//
the error is in calculating the area of two polygons that are RED and BLUE
in picture:
http://cgal-discuss.949826.n4.nabble.com/file/n3249230/22222.bmp
- Re: [cgal-discuss] Re: cGAL::join, Sebastien Loriot (GeometryFactory), 02/01/2011
- [cgal-discuss] Re: cGAL::join, sara123, 02/01/2011
- Re: [cgal-discuss] Re: cGAL::join, Sebastien Loriot (GeometryFactory), 02/01/2011
- [cgal-discuss] Re: cGAL::join, sara123, 02/01/2011
- Re: [cgal-discuss] Re: cGAL::join, Sebastien Loriot (GeometryFactory), 02/01/2011
- [cgal-discuss] Re: cGAL::join, sara123, 02/01/2011
- Re: [cgal-discuss] Re: cGAL::join, Sebastien Loriot (GeometryFactory), 02/01/2011
- [cgal-discuss] Re: cGAL::join, sara123, 02/01/2011
Archive powered by MHonArc 2.6.16.