Boost::Polygon : Get list of polygons from polygon_set

449 views Asked by At

I'm building program which outputs complex mesh of an object. To reduce number of adjacent polygons facing the same direction I decided to use Boost::Polygon. Now I have a trouble - first, program doesn't want to output proper data of trapezoids, which was promised in documentation (or maybe I do it in a wrong way). Second, Boost library also makes trouble in representing polygon_set_data (set of polygons with holes) as a set of simple polygons. I would like to get a working solution - first I add simple polygons (without holes) together into boost::polygon_set type, after this (assuming that Boost computed all operations and I have few big polygons) I want to get simple boost::polygon data.

#include "SomeLibrary.h"
#include <boost/polygon/polygon.hpp>
#include <cassert>

using namespace boost::polygon::operators;
using namespace boost::polygon;
using namespace std;


typedef point_data<float> point;
typedef polygon_set_data<float> polygon_set;
typedef polygon_with_holes_data<float> polygon;
typedef pair<point, point> edge;


void FracturePolygon::Dissolve() {
    polygon_set BPolygon;

    for (auto p : OutMesh.Faces()) { //p is simple polygon data, list of vertices
        vector<point> pts;
        for (int i = 0; i < p.NumVertices(); i++) {
            auto v = InPolygon.MapTo2D(p.Vertex(i)); //i get 2d point data
            pts.push_back(point(v.x, v.y)); //now i have boost::point data
        }
        polygon poly;
        set_points(poly, pts.begin(), pts.end()); //i get boost::polygon type
        BPolygon += poly; //i add this simple polygon to polygon_set container
    }

//now i expect some magic which will give me list of polygons from polygon_set type.
...
}
0

There are 0 answers