Subject: Re: [geometry] union gives an empty multi-polygon
From: Barend Gehrels (barend_at_[hidden])
Date: 2012-12-27 11:48:41
Welcome to the list.
On 27-12-2012 15:11, Romain Texier wrote:
> I want to make real time union and clipping of many polygons.
> I have tried the clipper library and I would like to try the boost
> geometry library.
> But I have a problem: The union of two triangles is an empty
> Could you help me ?
> typedef boost::geometry::model::d2::point_xy<float> BoostPoint;
> typedef boost::geometry::model::polygon<BoostPoint,false>
> BoostPolygon; //false because my triangles are counter-clockwise.
> typedef boost::geometry::model::multi_polygon< BoostPolygon >
I did not (yet) test the code, because I don't have the definitions of
your triangles, but I'm pretty sure that your polygons are not closed.
You defined them counterclockwise, but you should also define them as
"open" if you want them to use this way. So the definition should be
BoostPoint, false, false>.
See also this link:
> void BoostShape::createNewPoly(Triangle2D const & NewTriangle,
> BoostPolygons& p_InOutPolygon)
> model::ring<BoostPoint,false> outerRingTriangle;
What also helps is calling boost::geometry::correct (which would close
them in this code).
Geometry list run by mateusz at loskot.net