QuadEdge.h

00001 /**********************************************************************
00002  *
00003  * GEOS - Geometry Engine Open Source
00004  * http://geos.osgeo.org
00005  *
00006  * Copyright (C) 2012 Excensus LLC.
00007  *
00008  * This is free software; you can redistribute and/or modify it under
00009  * the terms of the GNU Lesser General Licence as published
00010  * by the Free Software Foundation. 
00011  * See the COPYING file for more information.
00012  *
00013  **********************************************************************
00014  *
00015  * Last port: triangulate/quadedge/QuadEdge.java r524
00016  *
00017  **********************************************************************/
00018 
00019 #ifndef GEOS_TRIANGULATE_QUADEDGE_QUADEDGE_H
00020 #define GEOS_TRIANGULATE_QUADEDGE_QUADEDGE_H
00021 
00022 #include <memory>
00023 
00024 #include <geos/triangulate/quadedge/Vertex.h>
00025 #include <geos/geom/LineSegment.h>
00026 
00027 namespace geos {
00028 namespace triangulate { //geos.triangulate
00029 namespace quadedge { //geos.triangulate.quadedge
00030 
00051 class GEOS_DLL QuadEdge {
00052 public:
00063         static std::auto_ptr<QuadEdge> makeEdge(const Vertex &o, const Vertex &d);
00064 
00074         static std::auto_ptr<QuadEdge> connect(QuadEdge &a, QuadEdge &b);
00075 
00089         static void splice(QuadEdge &a, QuadEdge &b);
00090 
00096         static void swap(QuadEdge &e);
00097 
00098 private:
00100         QuadEdge *_rot;
00101         Vertex   vertex;                        // The vertex that this edge represents
00102         QuadEdge *next;                   // A reference to a connected edge
00103         void*   data;
00104         bool isAlive;
00105 
00110         QuadEdge();
00111 
00112 public:
00113         virtual ~QuadEdge();
00114 
00121         virtual void free();
00122 
00131         const QuadEdge& getPrimary() const;
00132         
00138         virtual void setData(void* data);
00139         
00145         virtual void* getData();
00146 
00157         void remove();
00158         
00164         inline bool isLive() {
00165                 return isAlive;
00166         }
00167 
00168 
00174         inline void setNext(QuadEdge *next) {
00175                 this->next = next;
00176         }
00177         
00178         /***************************************************************************
00179          * QuadEdge Algebra 
00180          ***************************************************************************
00181          */
00182 
00188          inline QuadEdge& rot() const {
00189           return *_rot;
00190         }
00191 
00197         inline QuadEdge& invRot() const  {
00198           return rot().sym();
00199         }
00200 
00206         inline QuadEdge& sym() const {
00207           return rot().rot();
00208         }
00209 
00215         inline QuadEdge& oNext() const {
00216                 return *next;
00217         }
00218 
00224         inline QuadEdge& oPrev() const {
00225                 return rot().oNext().rot();
00226         }
00227 
00233         inline QuadEdge& dNext() const {
00234                 return sym().oNext().sym();
00235         }
00236 
00242         inline QuadEdge& dPrev() const {
00243                 return invRot().oNext().invRot();
00244         }
00245 
00251         inline QuadEdge& lNext() const {
00252                 return invRot().oNext().rot();
00253         }
00254 
00260         inline QuadEdge& lPrev() const {
00261                 return oNext().sym();
00262         }
00263 
00269         inline QuadEdge& rNext() {
00270                 return rot().oNext().invRot();
00271         }
00272 
00278         inline QuadEdge& rPrev() {
00279                 return sym().oNext();
00280         }
00281 
00282         /***********************************************************************************************
00283          * Data Access
00284          **********************************************************************************************/
00290         inline void setOrig(const Vertex &o) {
00291                 vertex = o;
00292         }
00293 
00299         inline void setDest(const Vertex &d) {
00300                 sym().setOrig(d);
00301         }
00302 
00308         const Vertex& orig() const {
00309                 return vertex;
00310         }
00311 
00317         const Vertex& dest() const {
00318                 return sym().orig();
00319         }
00320 
00326         inline double getLength() const {
00327                 return orig().getCoordinate().distance(dest().getCoordinate());
00328         }
00329 
00337         bool equalsNonOriented(const QuadEdge &qe) const;
00338 
00346         bool equalsOriented(const QuadEdge &qe) const;
00347 
00354         std::auto_ptr<geom::LineSegment> toLineSegment() const;
00355 };
00356 
00357 } //namespace geos.triangulate.quadedge
00358 } //namespace geos.triangulate
00359 } //namespace goes
00360 
00361 #endif //GEOS_TRIANGULATE_QUADEDGE_QUADEDGE_H
00362 

Generated on 30 Dec 2015 for GEOS by  doxygen 1.4.7