# SweeplineNestedRingTester.h

    00001 /**********************************************************************
    00002  * $Id: SweeplineNestedRingTester.h 1820 2006-09-06 16:54:23Z mloskot $
    00003  *
    00004  * GEOS - Geometry Engine Open Source
    00005  * http://geos.refractions.net
    00006  *
    00007  * Copyright (C) 2005-2006 Refractions Research Inc.
    00008  * Copyright (C) 2001-2002 Vivid Solutions Inc.
    00009  *
    00010  * This is free software; you can redistribute and/or modify it under
    00011  * the terms of the GNU Lesser General Public Licence as published
    00012  * by the Free Software Foundation.
    00013  * See the COPYING file for more information.
    00014  *
    00015  **********************************************************************/
    00016
    00017 #ifndef GEOS_OP_SWEEPLINENESTEDRINGTESTER_H
    00018 #define GEOS_OP_SWEEPLINENESTEDRINGTESTER_H
    00019
    00020 #include <vector>
    00021
    00022 #include <geos/geom/Envelope.h> // for inline
    00023 //#include <geos/indexSweepline.h> // for inline and inheritance
    00024 #include <geos/index/sweepline/SweepLineOverlapAction.h> // for inheritance
    00025 #include <geos/index/sweepline/SweepLineIndex.h> // for inlines
    00026
    00027 // Forward declarations
    00028 namespace geos {
    00029         namespace geom {
    00030                 class LinearRing;
    00031                 class Envelope;
    00032                 class Coordinate;
    00033         }
    00034         namespace index {
    00035                 namespace sweepline {
    00036                         class SweepLineIndex;
    00037                 }
    00038         }
    00039         namespace geomgraph {
    00040                 class GeometryGraph;
    00041         }
    00042 }
    00043
    00044 namespace geos {
    00045 namespace operation { // geos::operation
    00046 namespace valid { // geos::operation::valid
    00047
    00053 class SweeplineNestedRingTester {
    00054
    00055 private:
    00056         geomgraph::GeometryGraph *graph;  // used to find non-node vertices
    00057         std::vector<geom::LinearRing*> rings;
    00058         geom::Envelope *totalEnv;
    00059         index::sweepline::SweepLineIndex *sweepLine;
    00060         geom::Coordinate *nestedPt;
    00061         void buildIndex();
    00062
    00063 public:
    00064
    00065         SweeplineNestedRingTester(geomgraph::GeometryGraph *newGraph)
    00066                 :
    00067                 graph(newGraph),
    00068                 rings(),
    00069                 totalEnv(new geom::Envelope()),
    00070                 sweepLine(new index::sweepline::SweepLineIndex()),
    00071                 nestedPt(NULL)
    00072         {}
    00073
    00074         ~SweeplineNestedRingTester()
    00075         {
    00076                 delete totalEnv;
    00077                 delete sweepLine;
    00078         }
    00079
    00080         /*
    00081          * Be aware that the returned Coordinate (if != NULL)
    00082          * will point to storage owned by one of the LinearRing
    00083          * previously added. If you destroy them, this
    00084          * will point to an invalid memory address.
    00085          */
    00086         geom::Coordinate *getNestedPoint() { return nestedPt; }
    00087
    00088         void add(geom::LinearRing* ring) {
    00089                 rings.push_back(ring);
    00090         }
    00091
    00092         bool isNonNested();
    00093         bool isInside(geom::LinearRing *innerRing, geom::LinearRing *searchRing);
    00094         class OverlapAction: public index::sweepline::SweepLineOverlapAction {
    00095         public:
    00096                 bool isNonNested;
    00097                 OverlapAction(SweeplineNestedRingTester *p);
    00098                 void overlap(index::sweepline::SweepLineInterval *s0,
    00099                                 index::sweepline::SweepLineInterval *s1);
    00100         private:
    00101                 SweeplineNestedRingTester *parent;
    00102         };
    00103 };
    00104
    00105
    00106 } // namespace geos::operation::valid
    00107 } // namespace geos::operation
    00108 } // namespace geos
    00109
    00110 #endif // GEOS_OP_SWEEPLINENESTEDRINGTESTER_H
    00111
    00112 /**********************************************************************
    00113  * $Log$
    00114  * Revision 1.2  2006/06/01 10:28:47  strk
    00115  * Reduced number of installed headers for the geos::index namespace
    00116  *
    00117  * Revision 1.1  2006/03/20 16:57:44  strk
    00118  * spatialindex.h and opValid.h headers split
    00119  *
    00120  **********************************************************************/
    00121