BufferOp.h

00001 /**********************************************************************
00002  *
00003  * GEOS - Geometry Engine Open Source
00004  * http://geos.osgeo.org
00005  *
00006  * Copyright (C) 2009-2011 Sandro Santilli <strk@keybit.net>
00007  * Copyright (C) 2005-2007 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: operation/buffer/BufferOp.java r378 (JTS-1.12)
00018  *
00019  **********************************************************************/
00020 
00021 #ifndef GEOS_OP_BUFFER_BUFFEROP_H
00022 #define GEOS_OP_BUFFER_BUFFEROP_H
00023 
00024 #include <geos/export.h>
00025 #include <geos/operation/buffer/BufferParameters.h> // for enum values 
00026 
00027 #include <geos/util/TopologyException.h> // for composition
00028 
00029 #ifdef _MSC_VER
00030 #pragma warning(push)
00031 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00032 #endif
00033 
00034 // Forward declarations
00035 namespace geos {
00036         namespace geom {
00037                 class PrecisionModel;
00038                 class Geometry;
00039         }
00040 }
00041 
00042 namespace geos {
00043 namespace operation { // geos.operation
00044 namespace buffer { // geos.operation.buffer
00045 
00078 class GEOS_DLL BufferOp {
00079 
00080 
00081 private:
00082 
00089         static const int MAX_PRECISION_DIGITS = 12;
00090 
00107         static double precisionScaleFactor(const geom::Geometry *g,
00108                         double distance, int maxPrecisionDigits);
00109 
00110         const geom::Geometry *argGeom;
00111 
00112         util::TopologyException saveException;
00113 
00114         double distance;
00115 
00116         //int quadrantSegments;
00117         //int endCapStyle;
00118         BufferParameters bufParams;
00119 
00120         geom::Geometry* resultGeometry;
00121 
00122         void computeGeometry();
00123 
00124         void bufferOriginalPrecision();
00125 
00126         void bufferReducedPrecision(int precisionDigits);
00127 
00128         void bufferReducedPrecision();
00129 
00130         void bufferFixedPrecision(const geom::PrecisionModel& fixedPM);
00131 
00132 public:
00133 
00134         enum {
00137                 CAP_ROUND = BufferParameters::CAP_ROUND,
00138 
00141                 CAP_BUTT = BufferParameters::CAP_FLAT,
00142 
00145                 CAP_SQUARE = BufferParameters::CAP_SQUARE
00146         };
00147 
00159         static geom::Geometry* bufferOp(const geom::Geometry *g,
00160                 double distance,
00161                 int quadrantSegments=
00162                         BufferParameters::DEFAULT_QUADRANT_SEGMENTS,
00163                 int endCapStyle=BufferParameters::CAP_ROUND);
00164 
00170         BufferOp(const geom::Geometry *g)
00171                 :
00172                 argGeom(g),
00173                 bufParams(),
00174                 resultGeometry(NULL)
00175         {
00176         }
00177 
00186         BufferOp(const geom::Geometry* g, const BufferParameters& params)
00187                 :
00188                 argGeom(g),
00189                 bufParams(params),
00190                 resultGeometry(NULL)
00191         {
00192         }
00193 
00201         inline void setEndCapStyle(int nEndCapStyle);
00202 
00210         inline void setQuadrantSegments(int nQuadrantSegments);
00211 
00232         inline void setSingleSided(bool isSingleSided);
00233 
00242         geom::Geometry* getResultGeometry(double nDistance);
00243 
00244 };
00245 
00246 // BufferOp inlines
00247 void
00248 BufferOp::setQuadrantSegments(int q)
00249 {
00250         bufParams.setQuadrantSegments(q);
00251 }
00252 
00253 void
00254 BufferOp::setEndCapStyle(int s)
00255 {
00256         bufParams.setEndCapStyle((BufferParameters::EndCapStyle)s);
00257 }
00258 
00259 void
00260 BufferOp::setSingleSided(bool isSingleSided)
00261 {
00262    bufParams.setSingleSided(isSingleSided);
00263 }
00264 
00265 } // namespace geos::operation::buffer
00266 } // namespace geos::operation
00267 } // namespace geos
00268 
00269 #ifdef _MSC_VER
00270 #pragma warning(pop)
00271 #endif
00272 
00273 #endif // ndef GEOS_OP_BUFFER_BUFFEROP_H
00274 

Generated on 23 Sep 2013 for GEOS by  doxygen 1.4.7