[geos-devel] Envelope of empty Polygon

strk at refractions.net strk at refractions.net
Wed Apr 5 10:05:07 EDT 2006


Copy ctor fixed, assignment operator added.
Profited to remove init(Envelope&) method,
add proper doxygen comments and various cleanups.

--strk;

On Wed, Apr 05, 2006 at 10:52:14AM +0200, Mateusz Å?oskot wrote:
> strk at refractions.net wrote:
> > Mateusz Ã
oskot wrote:
> > 
> >> As you see above, copy ctor calls init() passing 'env' - a null 
> >> Envelope returned from getEnvelopeInternal() call.
> >> 
> >> But the Envelope::init(double x1, double x2, double y1, double y2)
> >>  call reorganizes min/max values of corners to make Envelope 
> >> properly oriented. This reorganizations brokes the state of 
> >> Envelope - null state. So, null Envelope stops to be null with some
> >>  magic :-)
> > 
> > Good report Mateus! I guess the solution here is to just remove 
> > explicit definition of the copy ctor and let compiler syntetize it 
> > for us (Envelope doesn't contain any pointer). What do you think ?
> 
> Yes, this approach would be better.
> Now, copy constructor causes a kind of side effect - Envelope
> normalization. But it should just make a copy, even if Envelope is not
> normalized/oriented correctly.
> 
> I see two choices:
> 1. Let compiler to generate copy ctor for us. It should work because it
> have to copy 4 members field-by-field.
> 2. We can define this copy ctor, even if it's a bit trivial. This will
> help us to have it under control for debugging, etc.
> 
> Additional suggestion:
> Copy contructor is a kind of twin with assignment operator, so it is a
> good practice to define them both (rule: if there is copy ctor,
> assignment op should be defined, and vice versa).
> This will make the type well copyable.
> 
> Assignment operator (mostly) has the same semantic as copy ctor (same
> implementation).
> 
> Cheers
> -- 
> Mateusz Łoskot
> http://mateusz.loskot.net
> _______________________________________________
> geos-devel mailing list
> geos-devel at geos.refractions.net
> http://geos.refractions.net/mailman/listinfo/geos-devel

-- 

 /"\    ASCII Ribbon Campaign
 \ /    Respect for low technology.
  X     Keep e-mail messages readable by any computer system.
 / \    Keep it ASCII. 




More information about the geos-devel mailing list