Boost logo

Geometry :

Subject: Re: [geometry] Boost.Geometry boolean operation usage on many polygons.
From: josh kim (josh.kim0323_at_[hidden])
Date: 2012-11-26 14:37:10


what about the problems that I was having? overlay polygon problems and
the one that I described with pictures in the first thread? To me,
correctness of the library is more important than the performance.

On Sat, Nov 24, 2012 at 3:57 AM, Bruno Lalande [via Boost Geometry] <
ml-node+s203548n4025153h90_at_[hidden]> wrote:

> Hi Josh,
>
> I was talking about the vector::swap function, which swaps 2 vectors
> by swapping their respective internal pointer. It's a costless
> operation.
>
> My point was : tmpPolySet is only a temporary multipolygon in which
> you store the result of union(polyset1, polygon). Then you assign it
> back to polyset1 so that the result iteratively accumulates into
> polyset1. Since tmpPolyset is a temporary intermediate result, you
> clear it at the end of the loop. So rather than assigning it to
> polyset1, which involves a per-point copy, you might as well swap
> them. polyset1 would then have the contents of tmpPolySet (which is
> what you want) and tmpPolySet would have the contents of polyset1
> (which is something you don't need but you get rid of it just after
> anyway). This way you achieve the same result without a per_point
> copy.
>
> So, replace this:
>
> boostG::assign(polyset1, tmpPolySet);
>
> by:
>
> polyset1.swap(tmpPolySet);
>
> and see if performances improve.
>
> To advise further I'd also need to have the declarations of all the
> variables you're using and what they're supposed to contain, it's hard
> to read the code without having the preconditions.
>
> Regards
> Bruno
>
>
> On Mon, Nov 19, 2012 at 12:26 AM, josh kim <[hidden email]<http://user/SendEmail.jtp?type=node&node=4025153&i=0>>
> wrote:
>
> > 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 mailing list
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=4025153&i=1>
> > http://lists.boost.org/mailman/listinfo.cgi/geometry
> _______________________________________________
> Geometry mailing list
> [hidden email] <http://user/SendEmail.jtp?type=node&node=4025153&i=2>
> http://lists.boost.org/mailman/listinfo.cgi/geometry
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://boost-geometry.203548.n3.nabble.com/Boost-Geometry-boolean-operation-usage-on-many-polygons-tp4025139p4025153.html
> To unsubscribe from Boost.Geometry boolean operation usage on many
> polygons., click here<http://boost-geometry.203548.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4025139&code=am9zaC5raW0wMzIzQGdtYWlsLmNvbXw0MDI1MTM5fDIxNDQ4NjY3NjQ=>
> .
> NAML<http://boost-geometry.203548.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>

--
View this message in context: http://boost-geometry.203548.n3.nabble.com/Boost-Geometry-boolean-operation-usage-on-many-polygons-tp4025139p4025156.html
Sent from the Boost Geometry mailing list archive at Nabble.com.


Geometry list run by mateusz at loskot.net