SweeplineNestedRingTester.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  * Last port: operation/valid/SweeplineNestedRingTester.java rev. 1.12 (JTS-1.10)
00017  *
00018  **********************************************************************/
00019 
00020 #ifndef GEOS_OP_SWEEPLINENESTEDRINGTESTER_H
00021 #define GEOS_OP_SWEEPLINENESTEDRINGTESTER_H
00022 
00023 #include <geos/export.h>
00024 #include <geos/geom/Envelope.h> // for inline
00025 //#include <geos/indexSweepline.h> // for inline and inheritance 
00026 #include <geos/index/sweepline/SweepLineOverlapAction.h> // for inheritance
00027 #include <geos/index/sweepline/SweepLineIndex.h> // for inlines
00028 
00029 #include <vector>
00030 
00031 #ifdef _MSC_VER
00032 #pragma warning(push)
00033 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00034 #endif
00035 
00036 // Forward declarations
00037 namespace geos {
00038         namespace geom {
00039                 class LinearRing;
00040                 class Envelope;
00041                 class Coordinate;
00042         }
00043         namespace index {
00044                 namespace sweepline {
00045                         class SweepLineIndex;
00046                 }
00047         }
00048         namespace geomgraph {
00049                 class GeometryGraph;
00050         }
00051 }
00052 
00053 namespace geos {
00054 namespace operation { // geos::operation
00055 namespace valid { // geos::operation::valid
00056 
00062 class GEOS_DLL SweeplineNestedRingTester {
00063 
00064 private:
00065         geomgraph::GeometryGraph *graph;  // used to find non-node vertices
00066         std::vector<geom::LinearRing*> rings;
00067         index::sweepline::SweepLineIndex *sweepLine;
00068         geom::Coordinate *nestedPt;
00069         void buildIndex();
00070 
00071 public:
00072 
00073         SweeplineNestedRingTester(geomgraph::GeometryGraph *newGraph)
00074                 :
00075                 graph(newGraph),
00076                 rings(),
00077                 sweepLine(new index::sweepline::SweepLineIndex()),
00078                 nestedPt(NULL)
00079         {}
00080 
00081         ~SweeplineNestedRingTester()
00082         {
00083                 delete sweepLine;
00084         }
00085 
00086         /*
00087          * Be aware that the returned Coordinate (if != NULL)
00088          * will point to storage owned by one of the LinearRing
00089          * previously added. If you destroy them, this
00090          * will point to an invalid memory address.
00091          */
00092         geom::Coordinate *getNestedPoint() { return nestedPt; }
00093 
00094         void add(geom::LinearRing* ring) {
00095                 rings.push_back(ring);
00096         }
00097 
00098         bool isNonNested();
00099         bool isInside(geom::LinearRing *innerRing, geom::LinearRing *searchRing);
00100         class OverlapAction: public index::sweepline::SweepLineOverlapAction {
00101         public:
00102                 bool isNonNested;
00103                 OverlapAction(SweeplineNestedRingTester *p);
00104                 void overlap(index::sweepline::SweepLineInterval *s0,
00105                                 index::sweepline::SweepLineInterval *s1);
00106         private:
00107                 SweeplineNestedRingTester *parent;
00108         };
00109 };
00110 
00111 } // namespace geos::operation::valid
00112 } // namespace geos::operation
00113 } // namespace geos
00114 
00115 #ifdef _MSC_VER
00116 #pragma warning(pop)
00117 #endif
00118 
00119 #endif // GEOS_OP_SWEEPLINENESTEDRINGTESTER_H

Generated on 10 Sep 2013 for GEOS by  doxygen 1.4.7