[geos-devel] Comparing two QuadEdge objects

vishal tiwari hi.vishal123 at gmail.com
Fri Jul 12 08:22:24 PDT 2013


This part of code in getVoronoiCellPolygon, :

QuadEdge startQE = qe;
    do {
//      Coordinate cc = circumcentre(qe);
        // use previously computed circumcentre
        Coordinate cc = qe.rot().orig().getCoordinate();
      cellPts.add(cc);

      // move to next triangle CW around vertex
      qe = qe.oPrev();
    } while (qe != startQE);

The while condition is comparing two QuadEdge objects for not being equal.
So i need to override the != operator. How do it do it?

Thanks,
Vishal





On 12 July 2013 20:09, Sandro Santilli <strk at keybit.net> wrote:

> On Fri, Jul 12, 2013 at 07:20:54PM +0530, vishal tiwari wrote:
> > The method quadedge::QuadEdgeSubdivision::getVoronoiCellPolygon,
> requires a
> > comparison between two QuadEdge objects for not being equal, that's y i
> > need a comparison operator. I think CompareTo is implemented in
> > Coordinate[1]. And the code is trying to compare the origin and
> destination
> > coordinates of two QuadEdge. Should i compare the origin and destination
> > coordinates to be same, in order to say the QuadEdges are the same?
>
> You should strictly follow the JTS implementation, which is comparing
> Vertex objects, not QuadEdge nor Coordinates.
> It is getVertexUniqueEdges that you're talking about, right ?
> Vertex class has an `equals` method (with an override accepting a
> tolerance).
>
> --strk;
>
> >
> > [1]
> >
> https://jts-topo-suite.svn.sourceforge.net/svnroot/jts-topo-suite/trunk/jts/java/src/com/vividsolutions/jts/geom/Coordinate.java
> >
> > Thanks,
> > Vishal
> >
> >
> > On 12 July 2013 18:12, Sandro Santilli <strk at keybit.net> wrote:
> >
> > > On Fri, Jul 12, 2013 at 05:45:14PM +0530, vishal tiwari wrote:
> > > > Hey,
> > > >
> > > > If i want to compare two QuadEdge objects, then i am comparing the
> > > elements
> > > > _rot , next , isAlive, data and vertex. As _rot and next are also
> > > > QuadEdges, it goes into a recursion, so i am using the break
> condition as
> > > > when both objects are NULL.
> > > >
> > > > I just want to know if this is the correct way to do it? I am asking
> this
> > > > because i am having troubles in overloading the != operator for
> QuadEdge.
> > >
> > > What do you need comparison operator for ?
> > > When needsd JTS implements a compareTo method, but I don't see any
> here:
> > >
> > >
> https://jts-topo-suite.svn.sourceforge.net/svnroot/jts-topo-suite/trunk/jts/java/src/com/vividsolutions/jts/triangulate/quadedge/QuadEdge.java
> > >
> > > --strk;
> _______________________________________________
> geos-devel mailing list
> geos-devel at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/geos-devel
>



-- 
Vishal Tiwari
Undergraduate
Computer Science and Engineering
Lab for Spatial Informatics
IIIT-Hyderabad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geos-devel/attachments/20130712/ab8b57ed/attachment-0001.html>


More information about the geos-devel mailing list