$include_dir="/home/hyper-archives/geometry/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [geometry] Use same object as input and output parameter?
From: Barend Gehrels (barend_at_[hidden])
Date: 2012-02-07 14:26:14
Hi Volker,
On 7-2-2012 19:06, Volker Schöch wrote:
>
> Hi,
>
> I would like to use algorithms like intersection or difference to 
> modify objects in-place.
>
Not really.
It is generally not possible - you have an input of two geometries 
(polygons) and a vector-of-output-objects (polygon), which can be empty, 
or have one or more polygons (intersection of two polygons can result in 
a dozen output polygons).
So for polygons, or any model which is not "multi", it is not applicable.
For multi-polygons it would be possible, and you could specify 
geometry::intersection(a,b,a) to get the output of the intersection in 
"a". But it will append to "a" and not clear it before. So that is not 
inplace-editing either.
So it is not really possible.
Actually I cannot remember that we agreed on appending - also not in the 
docs and might be considered as a bug, also because we've also an 
intersection_insert algorithm (though removed to detail). But I know the 
origin:- the output parameter of "intersection" does not have to be a 
multi-polygon, it can be anything which supports the output iterator...
> I cannot find any comment in the documentation whether it is 
> legitimate to provide one of the input parameters as output parameter 
> to these algorithms. Even if it would work with today's 
> implementation, it would be helpful to have confirmation that this is 
> not going to change in the future. If it is not allowed, I would have 
> to instantiate and then move an additional object, which I'd rather avoid.
>
So it does not work.
Regards, Barend