# BufferOp.h

    00001 /**********************************************************************
    00002  * $Id: BufferOp.h 1969 2007-02-06 01:57:23Z strk $
    00003  *
    00004  * GEOS - Geometry Engine Open Source
    00005  * http://geos.refractions.net
    00006  *
    00007  * Copyright (C) 2006 Refractions Research 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 #ifndef GEOS_OP_BUFFER_BUFFEROP_H
    00017 #define GEOS_OP_BUFFER_BUFFEROP_H
    00018
    00019 #include <geos/operation/buffer/OffsetCurveBuilder.h> // for enum values
    00020 #include <geos/util/TopologyException.h> // for composition
    00021
    00022 // Forward declarations
    00023 namespace geos {
    00024         namespace geom {
    00025                 class PrecisionModel;
    00026                 class Geometry;
    00027         }
    00028 }
    00029
    00030 namespace geos {
    00031 namespace operation { // geos.operation
    00032 namespace buffer { // geos.operation.buffer
    00033
    00066 class BufferOp {
    00067
    00068
    00069 private:
    00070
    00077         static const int MAX_PRECISION_DIGITS = 12;
    00078
    00095         static double precisionScaleFactor(const geom::Geometry *g,
    00096                         double distance, int maxPrecisionDigits);
    00097
    00098         const geom::Geometry *argGeom;
    00099
    00100         util::TopologyException saveException;
    00101
    00102         double distance;
    00103
    00104         int quadrantSegments;
    00105
    00106         int endCapStyle;
    00107
    00108         geom::Geometry* resultGeometry;
    00109
    00110         void computeGeometry();
    00111
    00112         void bufferOriginalPrecision();
    00113
    00114         void bufferReducedPrecision(int precisionDigits);
    00115
    00116         void bufferReducedPrecision();
    00117
    00118         void bufferFixedPrecision(const geom::PrecisionModel& fixedPM);
    00119
    00120 public:
    00121
    00122         enum {
    00124                 CAP_ROUND,
    00126                 CAP_BUTT,
    00128                 CAP_SQUARE
    00129         };
    00130
    00142         static geom::Geometry* bufferOp(const geom::Geometry *g,
    00143                 double distance,
    00144                 int quadrantSegments=
    00145                         OffsetCurveBuilder::DEFAULT_QUADRANT_SEGMENTS,
    00146                 int endCapStyle=BufferOp::CAP_ROUND);
    00147
    00153         BufferOp(const geom::Geometry *g)
    00154                 :
    00155                 argGeom(g),
    00156                 quadrantSegments(OffsetCurveBuilder::DEFAULT_QUADRANT_SEGMENTS),
    00157                 endCapStyle(BufferOp::CAP_ROUND),
    00158                 resultGeometry(NULL)
    00159         {}
    00160
    00168         inline void setEndCapStyle(int nEndCapStyle);
    00169
    00177         inline void setQuadrantSegments(int nQuadrantSegments);
    00178
    00187         geom::Geometry* getResultGeometry(double nDistance);
    00188
    00201         geom::Geometry* getResultGeometry(double nDistance, int nQuadrantSegments);
    00202 };
    00203
    00204 // BufferOp inlines
    00205 void BufferOp::setQuadrantSegments(int q) { quadrantSegments=q; }
    00206 void BufferOp::setEndCapStyle(int s) { endCapStyle=s; }
    00207
    00208
    00209 } // namespace geos::operation::buffer
    00210 } // namespace geos::operation
    00211 } // namespace geos
    00212
    00213 #endif // ndef GEOS_OP_BUFFER_BUFFEROP_H
    00214
    00215 /**********************************************************************
    00216  * $Log$
    00217  * Revision 1.1  2006/03/14 00:19:40  strk
    00218  * opBuffer.h split, streamlined headers in some (not all) files in operation/buffer/
    00219  *
    00220  **********************************************************************/
    00221