|
Geometry : |
Subject: Re: [geometry] Boost.Geometry boolean operation usage on many polygons.
From: josh kim (josh.kim0323_at_[hidden])
Date: 2012-11-18 19:26:46
I apologize for not being specific enough. I am using polygon type provided
by Boost Geometry.
typedef boostG::model::d2::point_xy<int> BGPoint;
typedef boostG::model::polygon< BGPoint, false, true > BGPolygon;
typedef boostG::model::multi_polygon< BGPolygon > multi_polygon;
typedef boostG::model::ring<BGPoint, false, true> BGRing;
typedef vector<BGPolygon> BGPolygonSet;
these are the types I use that are provided by boost geometry.
I first used BGPolygonSet to pass two sets of polygons to booleanizing
operation, however, I figured that I should use multi_polygon type for doing
that.
and no. everything is in the for loop.
Here's my code :
for (i = 0; i < pnum1; i++) {
for (j = 0; j < vnumList1[i] - 1; j++) {
poly_x = polygonList1[i][j*2];
poly_y = polygonList1[i][j*2+1];
polyPoints.push_back(make<BGPoint>(poly_x, poly_y));
}
boostG::assign_points(polygon, polyPoints);
boostG::correct(polygon);
boostG::union_(polyset1, polygon, tmpPolySet);
boostG::correct(tmpPolySet);
boostG::assign(polyset1, tmpPolySet);
boostG::correct(polyset1);
boostG::clear(tmpPolySet);
polyPoints.clear();
}
I'm using correct polygon just to make sure I can avoid having overlay
problem issue.
and using assign(polyset1, tmpPolySet) to recursively add one polygon to the
list (multipolygon) at a time.
and what does swap function actually do? it doesn't seem to add a polygon to
the multipolygon data type.
and what about the overlay polygon issues I'm having? and the unionizing
problem that I explained with pictures? The last picture is what I expect.
And thank you very much for answering my question!
-- View this message in context: http://boost-geometry.203548.n3.nabble.com/Boost-Geometry-boolean-operation-usage-on-many-polygons-tp4025139p4025145.html Sent from the Boost Geometry mailing list archive at Nabble.com.
Geometry list run by mateusz at loskot.net