Polygon.h

00001 /**********************************************************************
00002  * $Id: Polygon.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  * Last port: geom/Polygon.java rev. 1.47
00018  *
00019  **********************************************************************/
00020 
00021 #ifndef GEOS_GEOM_POLYGON_H
00022 #define GEOS_GEOM_POLYGON_H
00023 
00024 #include <string>
00025 #include <vector>
00026 #include <geos/platform.h>
00027 #include <geos/geom/Geometry.h>
00028 #include <geos/geom/Envelope.h> // for proper use of auto_ptr<>
00029 #include <geos/geom/Dimension.h> // for Dimension::DimensionType
00030 
00031 #include <geos/inline.h>
00032 
00033 #include <memory> // for auto_ptr
00034 
00035 // Forward declarations
00036 namespace geos {
00037         namespace geom { // geos::geom
00038                 class Coordinate;
00039                 class CoordinateArraySequence;
00040                 class LinearRing;
00041                 class LineString;
00042         }
00043 }
00044 
00045 namespace geos {
00046 namespace geom { // geos::geom
00047 
00063 class Polygon: public Geometry{
00064 
00065 public:
00066 
00067         friend class GeometryFactory;
00068 
00070         typedef std::vector<const Polygon *> ConstVect;
00071 
00072         virtual ~Polygon();
00073 
00074         virtual Geometry *clone() const { return new Polygon(*this); }
00075 
00076         CoordinateSequence* getCoordinates() const;
00077 
00078         size_t getNumPoints() const;
00079 
00081         Dimension::DimensionType getDimension() const;
00082 
00084         int getBoundaryDimension() const;
00085 
00092         Geometry* getBoundary() const;
00093 
00094         bool isEmpty() const;
00095 
00102         bool isSimple() const;
00103         
00105         const LineString* getExteriorRing() const;
00106 
00108         size_t getNumInteriorRing() const;
00109 
00111         const LineString* getInteriorRingN(size_t n) const;
00112 
00113         std::string getGeometryType() const;
00114         virtual GeometryTypeId getGeometryTypeId() const;
00115         bool equalsExact(const Geometry *other, double tolerance=0) const;
00116         void apply_rw(const CoordinateFilter *filter);
00117         void apply_ro(CoordinateFilter *filter) const;
00118         void apply_rw(GeometryFilter *filter);
00119         void apply_ro(GeometryFilter *filter) const;
00120 
00121         Geometry* convexHull() const;
00122 
00123         void normalize();
00124 
00125         int compareToSameClass(const Geometry *p) const; //was protected
00126 
00127         const Coordinate* getCoordinate() const;
00128 
00129         double getArea() const;
00130 
00132         double getLength() const;
00133 
00134         void apply_rw(GeometryComponentFilter *filter);
00135 
00136         void apply_ro(GeometryComponentFilter *filter) const;
00137 
00138         bool isRectangle() const;
00139 
00140 protected:
00141 
00142 
00143         Polygon(const Polygon &p);
00144 
00163         Polygon(LinearRing *newShell, std::vector<Geometry *> *newHoles,
00164                 const GeometryFactory *newFactory);
00165 
00166         LinearRing *shell;
00167 
00168         std::vector<Geometry *> *holes; //Actually vector<LinearRing *>
00169 
00170         Envelope::AutoPtr computeEnvelopeInternal() const;
00171 
00172 private:
00173 
00174         void normalize(LinearRing *ring, bool clockwise);
00175 };
00176 
00177 } // namespace geos::geom
00178 } // namespace geos
00179 
00180 //#ifdef GEOS_INLINE
00181 //# include "geos/geom/Polygon.inl"
00182 //#endif
00183 
00184 #endif // ndef GEOS_GEOM_POLYGON_H
00185 
00186 /**********************************************************************
00187  * $Log$
00188  * Revision 1.7  2006/06/08 17:58:57  strk
00189  * Polygon::getNumInteriorRing() return size_t, Polygon::interiorRingN() takes size_t.
00190  *
00191  * Revision 1.6  2006/05/04 15:49:39  strk
00192  * updated all Geometry::getDimension() methods to return Dimension::DimensionType (closes bug#93)
00193  *
00194  * Revision 1.5  2006/04/28 10:55:39  strk
00195  * Geometry constructors made protected, to ensure all constructions use GeometryFactory,
00196  * which has been made friend of all Geometry derivates. getNumPoints() changed to return
00197  * size_t.
00198  *
00199  * Revision 1.4  2006/04/10 18:15:09  strk
00200  * Changed Geometry::envelope member to be of type auto_ptr<Envelope>.
00201  * Changed computeEnvelopeInternal() signater to return auto_ptr<Envelope>
00202  *
00203  * Revision 1.3  2006/03/24 09:52:41  strk
00204  * USE_INLINE => GEOS_INLINE
00205  *
00206  * Revision 1.2  2006/03/15 09:12:45  strk
00207  * isSimple doc
00208  *
00209  * Revision 1.1  2006/03/09 16:46:49  strk
00210  * geos::geom namespace definition, first pass at headers split
00211  *
00212  **********************************************************************/

Generated on Fri Mar 27 04:52:57 2009 for GEOS by  doxygen 1.5.4