Boost logo

Geometry :

Subject: [ggl] Difference / xor for multi polygons
From: Javier Gonzalez (xaviergonz)
Date: 2011-02-26 13:56:37


I have some test code like this:

  typedef point<double, 2, cs::cartesian> point_2d;
  typedef polygon<point_2d> polygon_2d;
  typedef vector<polygon_2d> polygon_2d_list;

  enum clip_type
  {
    clip_type_union,
    clip_type_difference,
    clip_type_intersection,
    clip_type_xor
  };

  class Helper
  {
  public:
    static polygon_2d_list Combine(polygon_2d_list subjectPoly,
polygon_2d_list clipPoly, clip_type clipType)
    {
      polygon_2d_list outputPoly;

      if (clipType == clip_type_intersection)
        intersection_inserter<polygon_2d>(subjectPoly, clipPoly,
back_inserter(outputPoly));
      else if (clipType == clip_type_union)
        union_inserter<polygon_2d>(subjectPoly, clipPoly,
back_inserter(outputPoly));
      else if (clipType == clip_type_difference)
        difference_inserter<polygon_2d>(subjectPoly, clipPoly,
back_inserter(outputPoly)); // ??? does not compile
      else // xor
        sym_difference_inserter<polygon_2d>(subjectPoly, clipPoly,
back_inserter(outputPoly)); // ??? does not compile

      return outputPoly;
    }
  };

But there seems to be no multi algorithms for difference and sym difference
(xor)
I'm trying to get a behaivour like GPC.

Any idea on what would be the right approach?

PS: I'm assuming a multi_polygon is needed for example for two separated
"donuts" (two separated polygons with an outer ring and an inner ring each)
Do I really need to use multi polygons or would a simple polygon be able to
hold both figures?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/ggl/attachments/20110226/adaad14a/attachment.html


Geometry list run by mateusz at loskot.net