GEOS: OffsetCurveBuilder.h Source File

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

# OffsetCurveBuilder.h

    00001 /**********************************************************************
    00002  * $Id: OffsetCurveBuilder.h 2779 2009-12-03 19:45:53Z mloskot $
    00003  *
    00004  * GEOS - Geometry Engine Open Source
    00005  * http://geos.refractions.net
    00006  *
    00007  * Copyright (C) 2009  Sandro Santilli <strk@keybit.net>
    00008  * Copyright (C) 2006-2007 Refractions Research 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/OffsetCurveBuilder.java rev. 1.30 (JTS-1.10)
    00018  *
    00019  **********************************************************************/
    00020
    00021 #ifndef GEOS_OP_BUFFER_OFFSETCURVEBUILDER_H
    00022 #define GEOS_OP_BUFFER_OFFSETCURVEBUILDER_H
    00023
    00024 #include <geos/export.h>
    00025
    00026 #include <vector>
    00027
    00028 #include <geos/algorithm/LineIntersector.h> // for composition
    00029 #include <geos/geom/Coordinate.h> // for composition
    00030 #include <geos/geom/LineSegment.h> // for composition
    00031 #include <geos/operation/buffer/BufferParameters.h> // for composition
    00032
    00033 // Forward declarations
    00034 namespace geos {
    00035         namespace geom {
    00036                 class CoordinateSequence;
    00037                 class PrecisionModel;
    00038         }
    00039         namespace operation {
    00040                 namespace buffer {
    00041                         class OffsetCurveVertexList;
    00042                 }
    00043         }
    00044 }
    00045
    00046 namespace geos {
    00047 namespace operation { // geos.operation
    00048 namespace buffer { // geos.operation.buffer
    00049
    00066 class GEOS_DLL OffsetCurveBuilder {
    00067 public:
    00068
    00069         /*
    00070          * @param nBufParams buffer parameters, this object will
    00071          *                   keep a reference to the passed parameters
    00072          *                   so caller must make sure the object is
    00073          *                   kept alive for the whole lifetime of
    00074          *                   the buffer builder.
    00075          */
    00076         OffsetCurveBuilder(const geom::PrecisionModel *newPrecisionModel,
    00077                         const BufferParameters& bufParams);
    00078
    00079         ~OffsetCurveBuilder();
    00080
    00090         void getLineCurve(const geom::CoordinateSequence* inputPts,
    00091                           double distance,
    00092                           std::vector<geom::CoordinateSequence*>& lineList);
    00093
    00110         void getSingleSidedLineCurve(const geom::CoordinateSequence* inputPts,
    00111              double distance, std::vector<geom::CoordinateSequence*>& lineList,
    00112              bool leftSide, bool rightSide ) ;
    00113
    00121         void getRingCurve(const geom::CoordinateSequence *inputPts, int side,
    00122                           double distance,
    00123                           std::vector<geom::CoordinateSequence*>& lineList);
    00124
    00125
    00126 private:
    00127
    00129         //
    00134         void addMitreJoin(const geom::Coordinate& p,
    00135                           const geom::LineSegment& offset0,
    00136                           const geom::LineSegment& offset1,
    00137                           double distance);
    00138
    00140         //
    00149         void addLimitedMitreJoin(
    00150                           const geom::LineSegment& offset0,
    00151                           const geom::LineSegment& offset1,
    00152                           double distance, double mitreLimit);
    00153
    00157         //
    00161         void addBevelJoin(const geom::LineSegment& offset0,
    00162                           const geom::LineSegment& offset1);
    00163
    00164
    00168         static const double CURVE_VERTEX_SNAP_DISTANCE_FACTOR; //  1.0E-6;
    00169
    00170         static const double PI; //  3.14159265358979
    00171
    00172         static const double MAX_CLOSING_SEG_LEN; // 3.0
    00173
    00178         static const double OFFSET_SEGMENT_SEPARATION_FACTOR; // 1.0E-3;
    00179
    00184         static const double INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR; // 1.0E-3;
    00185
    00190         static const int MAX_CLOSING_SEG_FRACTION = 80;
    00191
    00192         algorithm::LineIntersector li;
    00193
    00198         double filletAngleQuantum;
    00199
    00204         double maxCurveSegmentError;
    00205
    00207         //
    00214         OffsetCurveVertexList* vertexList;
    00215
    00216         double distance;
    00217
    00218         const geom::PrecisionModel* precisionModel;
    00219
    00220         const BufferParameters& bufParams;
    00221
    00239         int closingSegFactor; // 1;
    00240
    00241         geom::Coordinate s0, s1, s2;
    00242
    00243         geom::LineSegment seg0;
    00244
    00245         geom::LineSegment seg1;
    00246
    00247         geom::LineSegment offset0;
    00248
    00249         geom::LineSegment offset1;
    00250
    00251         int side;
    00252
    00253         // Not in JTS, used for single-sided buffers
    00254         int endCapIndex;
    00255
    00256         void init(double newDistance);
    00257
    00265         static const double SIMPLIFY_FACTOR; // 100.0;
    00266
    00274         double simplifyTolerance(double bufDistance);
    00275
    00276         void computeLineBufferCurve(const geom::CoordinateSequence& inputPts);
    00277
    00278         void computeRingBufferCurve(const geom::CoordinateSequence& inputPts,
    00279                                     int side);
    00280
    00281         void initSideSegments(const geom::Coordinate &nS1,
    00282                               const geom::Coordinate &nS2, int nSide);
    00283
    00284         void addNextSegment(const geom::Coordinate &p, bool addStartPoint);
    00285
    00286         void addCollinear(bool addStartPoint);
    00287
    00289         //
    00293         void addOutsideTurn(int orientation, bool addStartPoint);
    00294
    00296         //
    00300         void addInsideTurn(int orientation, bool addStartPoint);
    00301
    00303         void addLastSegment();
    00304
    00317         void computeOffsetSegment(const geom::LineSegment& seg,
    00318                                   int side, double distance,
    00319                                   geom::LineSegment& offset);
    00320
    00324         void addLineEndCap(const geom::Coordinate &p0,
    00325                            const geom::Coordinate &p1);
    00326
    00338         void addFillet(const geom::Coordinate &p, const geom::Coordinate &p0,
    00339                        const geom::Coordinate &p1,
    00340                        int direction, double radius);
    00341
    00351         void addFillet(const geom::Coordinate &p, double startAngle,
    00352                        double endAngle, int direction, double radius);
    00353
    00355         void addCircle(const geom::Coordinate &p, double distance);
    00356
    00358         void addSquare(const geom::Coordinate &p, double distance);
    00359
    00360     std::vector<OffsetCurveVertexList*> vertexLists;
    00361
    00362     // Declare type as noncopyable
    00363     OffsetCurveBuilder(const OffsetCurveBuilder& other);
    00364     OffsetCurveBuilder& operator=(const OffsetCurveBuilder& rhs);
    00365 };
    00366
    00367 } // namespace geos::operation::buffer
    00368 } // namespace geos::operation
    00369 } // namespace geos
    00370
    00371 #endif // ndef GEOS_OP_BUFFER_OFFSETCURVEBUILDER_H
    00372
    00373 /**********************************************************************
    00374  * $Log$
    00375  * Revision 1.2  2006/03/27 17:04:17  strk
    00376  * Cleanups and explicit initializations
    00377  *
    00378  * Revision 1.1  2006/03/14 00:19:40  strk
    00379  * opBuffer.h split, streamlined headers in some (not all) files in operation/buffer/
    00380  *
    00381  **********************************************************************/
    00382