GEOS
3.3.9
|
00001 /********************************************************************** 00002 * $Id: BufferOp.h 3299 2011-04-27 09:42:02Z strk $ 00003 * 00004 * GEOS - Geometry Engine Open Source 00005 * http://geos.refractions.net 00006 * 00007 * Copyright (C) 2009-2011 Sandro Santilli <strk@keybit.net> 00008 * Copyright (C) 2005-2007 Refractions Research Inc. 00009 * Copyright (C) 2001-2002 Vivid Solutions Inc. 00010 * 00011 * This is free software; you can redistribute and/or modify it under 00012 * the terms of the GNU Lesser General Public Licence as published 00013 * by the Free Software Foundation. 00014 * See the COPYING file for more information. 00015 * 00016 ********************************************************************** 00017 * 00018 * Last port: operation/buffer/BufferOp.java r378 (JTS-1.12) 00019 * 00020 **********************************************************************/ 00021 00022 #ifndef GEOS_OP_BUFFER_BUFFEROP_H 00023 #define GEOS_OP_BUFFER_BUFFEROP_H 00024 00025 #include <geos/export.h> 00026 #include <geos/operation/buffer/BufferParameters.h> // for enum values 00027 00028 #include <geos/util/TopologyException.h> // for composition 00029 00030 #ifdef _MSC_VER 00031 #pragma warning(push) 00032 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class 00033 #endif 00034 00035 // Forward declarations 00036 namespace geos { 00037 namespace geom { 00038 class PrecisionModel; 00039 class Geometry; 00040 } 00041 } 00042 00043 namespace geos { 00044 namespace operation { // geos.operation 00045 namespace buffer { // geos.operation.buffer 00046 00079 class GEOS_DLL BufferOp { 00080 00081 00082 private: 00083 00090 static const int MAX_PRECISION_DIGITS = 12; 00091 00108 static double precisionScaleFactor(const geom::Geometry *g, 00109 double distance, int maxPrecisionDigits); 00110 00111 const geom::Geometry *argGeom; 00112 00113 util::TopologyException saveException; 00114 00115 double distance; 00116 00117 //int quadrantSegments; 00118 //int endCapStyle; 00119 BufferParameters bufParams; 00120 00121 geom::Geometry* resultGeometry; 00122 00123 void computeGeometry(); 00124 00125 void bufferOriginalPrecision(); 00126 00127 void bufferReducedPrecision(int precisionDigits); 00128 00129 void bufferReducedPrecision(); 00130 00131 void bufferFixedPrecision(const geom::PrecisionModel& fixedPM); 00132 00133 public: 00134 00135 enum { 00138 CAP_ROUND = BufferParameters::CAP_ROUND, 00139 00142 CAP_BUTT = BufferParameters::CAP_FLAT, 00143 00146 CAP_SQUARE = BufferParameters::CAP_SQUARE 00147 }; 00148 00160 static geom::Geometry* bufferOp(const geom::Geometry *g, 00161 double distance, 00162 int quadrantSegments= 00163 BufferParameters::DEFAULT_QUADRANT_SEGMENTS, 00164 int endCapStyle=BufferParameters::CAP_ROUND); 00165 00171 BufferOp(const geom::Geometry *g) 00172 : 00173 argGeom(g), 00174 bufParams(), 00175 resultGeometry(NULL) 00176 { 00177 } 00178 00187 BufferOp(const geom::Geometry* g, const BufferParameters& params) 00188 : 00189 argGeom(g), 00190 bufParams(params), 00191 resultGeometry(NULL) 00192 { 00193 } 00194 00202 inline void setEndCapStyle(int nEndCapStyle); 00203 00211 inline void setQuadrantSegments(int nQuadrantSegments); 00212 00221 geom::Geometry* getResultGeometry(double nDistance); 00222 00223 }; 00224 00225 // BufferOp inlines 00226 void 00227 BufferOp::setQuadrantSegments(int q) 00228 { 00229 bufParams.setQuadrantSegments(q); 00230 } 00231 00232 void 00233 BufferOp::setEndCapStyle(int s) 00234 { 00235 bufParams.setEndCapStyle((BufferParameters::EndCapStyle)s); 00236 } 00237 00238 } // namespace geos::operation::buffer 00239 } // namespace geos::operation 00240 } // namespace geos 00241 00242 #ifdef _MSC_VER 00243 #pragma warning(pop) 00244 #endif 00245 00246 #endif // ndef GEOS_OP_BUFFER_BUFFEROP_H 00247 00248 /********************************************************************** 00249 * $Log$ 00250 * Revision 1.1 2006/03/14 00:19:40 strk 00251 * opBuffer.h split, streamlined headers in some (not all) files in operation/buffer/ 00252 * 00253 **********************************************************************/ 00254