
Barend Gehrels wrote:
Hi Fabio,
Hm, I tried:
#include <boost/ggl/ggl.hpp> #include <boost/ggl/geometries/cartesian3d.hpp> #include <boost/ggl/multi/geometries/multi_polygon.hpp> #include <boost/ggl/algorithms/union.hpp>
...
typedef multi_polygon<polygon_3d> polygon_set_3d; polygon_set_3d ps; polygon_3d poly1; polygon_3d poly2; union_inserter(poly1, poly2, std::back_inserter(ps));
There are two things:
- I forgot one thing, sorry, the inserter-versions always have their output type as a required template parameter. That one can, AFAIK, not be deduced from the output iterator. And it might be a different type of the input polygons. If someone knows if that is possible somehow, I would be happy to know. So it should be: union_inserter<polygon_2d>(p1, p2, std::back_inserter(ps1));
Ok, one more argument for both an example and a union_ function then ;)
- You're using the 3d polygons here. The union would make a 2D union-operation then of your 3D polygons (so polygons with for all vertices a height). It would ignore the third dimension (because it is not a polyhedron union). I just tried it, to not give you again wrong information. But it is not working yet like this, a.o. because the functions convert, area and point-in-polygon which should support 3D then. Especially area implementation would probably be different for 3D. Though it is used as a helper-function in the union, so its usage could be avoided.
I didn't really expect 3d union to work (i.e. create a polyhedron ) I wanted to find out what would happen. I'm not quite sure what I would expect (projection on the xy plane like you suggest or another projection most likely). But the docu said that 3d was not a focus of GGL yet, so its ok that there are missing pieces. I'm content that the design allows for both union_(poly3d_1, poly3d_2, poly3d_result) and union_(poly3d_1, poly3d_2, polyhedron) to do the right thing, once the building blocks are in place. Thanks and Regards Fabio