SweepLineEvent.h

00001 /**********************************************************************
00002  *
00003  * GEOS - Geometry Engine Open Source
00004  * http://geos.osgeo.org
00005  *
00006  * Copyright (C) 2005-2006 Refractions Research Inc.
00007  * Copyright (C) 2001-2002 Vivid Solutions Inc.
00008  *
00009  * This is free software; you can redistribute and/or modify it under
00010  * the terms of the GNU Lesser General Public Licence as published
00011  * by the Free Software Foundation. 
00012  * See the COPYING file for more information.
00013  *
00014  **********************************************************************/
00015 
00016 #ifndef GEOS_GEOMGRAPH_INDEX_SWEEPLINEEVENT_H
00017 #define GEOS_GEOMGRAPH_INDEX_SWEEPLINEEVENT_H
00018 
00019 
00020 #include <geos/export.h>
00021 #include <string>
00022 
00023 // Forward declarations
00024 namespace geos {
00025         namespace geomgraph {
00026                 namespace index {
00027                         class SweepLineEventOBJ;
00028                 }
00029         }
00030 }
00031 
00032 namespace geos {
00033 namespace geomgraph { // geos::geomgraph
00034 namespace index { // geos::geomgraph::index
00035 
00036 //class SweepLineEventLessThen; // needed ??
00037 
00038 class GEOS_DLL SweepLineEvent{
00039 friend class SweepLineEventLessThen;
00040 
00041 public:
00042 
00043         enum {
00044                 INSERT_EVENT = 1,
00045                 DELETE_EVENT
00046         };
00047 
00048         SweepLineEvent(void* newEdgeSet, double x,
00049                         SweepLineEvent *newInsertEvent,
00050                         SweepLineEventOBJ *newObj);
00051 
00052         virtual ~SweepLineEvent();
00053 
00054         bool isInsert() { return insertEvent==NULL; }
00055 
00056         bool isDelete() { return insertEvent!=NULL; }
00057 
00058         SweepLineEvent* getInsertEvent() { return insertEvent; }
00059 
00060         int getDeleteEventIndex() { return deleteEventIndex; }
00061 
00062         void setDeleteEventIndex(int newDeleteEventIndex) {
00063                 deleteEventIndex=newDeleteEventIndex;
00064         }
00065 
00066         SweepLineEventOBJ* getObject() const { return obj; }
00067 
00068         int compareTo(SweepLineEvent *sle);
00069 
00070         std::string print();
00071 
00072         void* edgeSet;    // used for red-blue intersection detection
00073 
00074 protected:
00075 
00076         SweepLineEventOBJ* obj;
00077 
00078 private:
00079 
00080         double xValue;
00081 
00082         int eventType;
00083 
00084         SweepLineEvent *insertEvent; // null if this is an INSERT_EVENT event
00085 
00086         int deleteEventIndex;
00087 };
00088 
00089 class GEOS_DLL SweepLineEventLessThen {
00090 public:
00091         bool operator()(const SweepLineEvent *f, const SweepLineEvent *s) const
00092         {
00093                 if (f->xValue<s->xValue) return true;
00094                 if (f->xValue>s->xValue) return false;
00095                 if (f->eventType<s->eventType) return true;
00096                 return false;
00097         }
00098 };
00099 
00100 
00101 
00102 } // namespace geos.geomgraph.index
00103 } // namespace geos.geomgraph
00104 } // namespace geos
00105 
00106 #endif
00107 

Generated on 15 May 2014 for GEOS by  doxygen 1.4.7