Boost logo

Geometry :

Subject: [ggl] combine
From: Adam Wulkiewicz (adam.wulkiewicz)
Date: 2011-03-30 11:44:39


Bruno Lalande wrote:
> Hi,
>
> inline OutputIterator intersection_inserter(
> Geometry1 const& geometry1,
> Geometry2 const& geometry2,
> OutputIterator out);
>
> is a function.
>
>
> Yes but my point was to focus on how it's used (as a functor) rather
> than on what it is (a function). But I'm not totally sure how it's used,
> precisely. Can you give the most simple example of use?

 From http://geometrylibrary.geodan.nl/group__intersection.html:

Example showing clipping of polygon with box

{
   typedef boost::geometry::point_xy<double> P;
   typedef std::vector<boost::geometry::polygon<P> > PV;

   boost::geometry::box<P> cb(P(1.5, 1.5), P(4.5, 2.5));
   boost::geometry::polygon<P> poly;
   boost::geometry::read_wkt(
     "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,"
     "4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3)"
     ",(4 2,4.2 1.4,4.8 1.9,4.4 2.2,4 2))", poly);

   PV v;

   boost::geometry::intersection_inserter<
     boost::geometry::polygon<P>
>(cb, poly, std::back_inserter(v));

   std::cout << "Clipped polygon(s) " << std::endl;
   for (PV::const_iterator it = v.begin(); it != v.end(); it++)
   {
     std::cout << boost::geometry::dsv(*it) << std::endl;
   }
}

It all depends on what this function/functor does. Berend, what is the
difference between intersection inserter and copying of the result of
geometry::intersection by hand? Is it another level of abstraction? I
saw it can handle std::vectors<Geometry>.

Regards,
Adam


Geometry list run by mateusz at loskot.net