Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

OffsetCurveBuilder.h

00001 /**********************************************************************
00002  * $Id: OffsetCurveBuilder.h 2559 2009-06-08 10:07:05Z strk $
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 
00089         void getLineCurve(const geom::CoordinateSequence* inputPts,
00090                           double distance,
00091                           std::vector<geom::CoordinateSequence*>& lineList);
00092 
00108         void getSingleSidedLineCurve(const geom::CoordinateSequence* inputPts, 
00109              double distance, std::vector<geom::CoordinateSequence*>& lineList,
00110              bool leftSide, bool rightSide ) ;
00111 
00119         void getRingCurve(const geom::CoordinateSequence *inputPts, int side,
00120                           double distance,
00121                           std::vector<geom::CoordinateSequence*>& lineList);
00122 
00123 
00124 private:
00125 
00127         //
00132         void addMitreJoin(const geom::Coordinate& p,
00133                           const geom::LineSegment& offset0,
00134                           const geom::LineSegment& offset1,
00135                           double distance);
00136 
00138         //
00147         void addLimitedMitreJoin(
00148                           const geom::LineSegment& offset0,
00149                           const geom::LineSegment& offset1,
00150                           double distance, double mitreLimit);
00151 
00155         // 
00159         void addBevelJoin(const geom::LineSegment& offset0,
00160                           const geom::LineSegment& offset1);
00161 
00162    
00166         static const double CURVE_VERTEX_SNAP_DISTANCE_FACTOR; //  1.0E-6;
00167 
00168         static const double PI; //  3.14159265358979
00169 
00170         static const double MAX_CLOSING_SEG_LEN; // 3.0
00171 
00176         static const double OFFSET_SEGMENT_SEPARATION_FACTOR; // 1.0E-3;
00177 
00182         static const double INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR; // 1.0E-3;
00183 
00188         static const int MAX_CLOSING_SEG_FRACTION = 80;
00189 
00190         algorithm::LineIntersector li;
00191 
00196         double filletAngleQuantum;
00197 
00202         double maxCurveSegmentError;
00203 
00205         //
00212         OffsetCurveVertexList* vertexList;
00213 
00214         double distance;
00215 
00216         const geom::PrecisionModel* precisionModel;
00217 
00218         const BufferParameters& bufParams; 
00219 
00237         int closingSegFactor; // 1;
00238 
00239         geom::Coordinate s0, s1, s2;
00240 
00241         geom::LineSegment seg0;
00242 
00243         geom::LineSegment seg1;
00244 
00245         geom::LineSegment offset0;
00246 
00247         geom::LineSegment offset1;
00248 
00249         int side;
00250 
00251         // Not in JTS, used for single-sided buffers
00252         int endCapIndex;
00253 
00254         void init(double newDistance);
00255 
00263         static const double SIMPLIFY_FACTOR; // 100.0;
00264 
00272         double simplifyTolerance(double bufDistance);
00273 
00274         void computeLineBufferCurve(const geom::CoordinateSequence& inputPts);
00275 
00276         void computeRingBufferCurve(const geom::CoordinateSequence& inputPts,
00277                                     int side);
00278 
00279         void initSideSegments(const geom::Coordinate &nS1,
00280                               const geom::Coordinate &nS2, int nSide);
00281 
00282         void addNextSegment(const geom::Coordinate &p, bool addStartPoint);
00283 
00284         void addCollinear(bool addStartPoint);
00285 
00287         //
00291         void addOutsideTurn(int orientation, bool addStartPoint);
00292 
00294         //
00298         void addInsideTurn(int orientation, bool addStartPoint);
00299 
00301         void addLastSegment();
00302 
00315         void computeOffsetSegment(const geom::LineSegment& seg,
00316                                   int side, double distance,
00317                                   geom::LineSegment& offset);
00318 
00322         void addLineEndCap(const geom::Coordinate &p0,
00323                            const geom::Coordinate &p1);
00324 
00336         void addFillet(const geom::Coordinate &p, const geom::Coordinate &p0,
00337                        const geom::Coordinate &p1,
00338                        int direction, double radius);
00339 
00349         void addFillet(const geom::Coordinate &p, double startAngle,
00350                        double endAngle, int direction, double radius);
00351 
00353         void addCircle(const geom::Coordinate &p, double distance);
00354 
00356         void addSquare(const geom::Coordinate &p, double distance);
00357 
00358         std::vector<OffsetCurveVertexList*> vertexLists;
00359 };
00360 
00361 } // namespace geos::operation::buffer
00362 } // namespace geos::operation
00363 } // namespace geos
00364 
00365 #endif // ndef GEOS_OP_BUFFER_OFFSETCURVEBUILDER_H
00366 
00367 /**********************************************************************
00368  * $Log$
00369  * Revision 1.2  2006/03/27 17:04:17  strk
00370  * Cleanups and explicit initializations
00371  *
00372  * Revision 1.1  2006/03/14 00:19:40  strk
00373  * opBuffer.h split, streamlined headers in some (not all) files in operation/buffer/
00374  *
00375  **********************************************************************/
00376 

Generated on Thu Jun 11 06:17:01 2009 for GEOS by  doxygen 1.4.4