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

# OffsetCurveBuilder.h

    00001 /**********************************************************************
    00002  * $Id: OffsetCurveBuilder.h 1959 2007-01-09 17:34:00Z strk $
    00003  *
    00004  * GEOS - Geometry Engine Open Source
    00005  * http://geos.refractions.net
    00006  *
    00007  * Copyright (C) 2006-2007 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  * Last port: operation/buffer/OffsetCurveBuilder.java rev 1.10
    00017  *
    00018  **********************************************************************/
    00019
    00020 #ifndef GEOS_OP_BUFFER_OFFSETCURVEBUILDER_H
    00021 #define GEOS_OP_BUFFER_OFFSETCURVEBUILDER_H
    00022
    00023 #include <vector>
    00024
    00025 #include <geos/algorithm/LineIntersector.h> // for composition
    00026 #include <geos/geom/Coordinate.h> // for composition
    00027 #include <geos/geom/LineSegment.h> // for composition
    00028
    00029 // Forward declarations
    00030 namespace geos {
    00031         namespace geom {
    00032                 class CoordinateSequence;
    00033                 class PrecisionModel;
    00034         }
    00035         namespace operation {
    00036                 namespace buffer {
    00037                         class OffsetCurveVertexList;
    00038                 }
    00039         }
    00040 }
    00041
    00042 namespace geos {
    00043 namespace operation { // geos.operation
    00044 namespace buffer { // geos.operation.buffer
    00045
    00062 class OffsetCurveBuilder {
    00063 public:
    00071         static const int DEFAULT_QUADRANT_SEGMENTS=8;
    00072
    00073         OffsetCurveBuilder(const geom::PrecisionModel *newPrecisionModel,
    00074                         int quadrantSegments=DEFAULT_QUADRANT_SEGMENTS);
    00075
    00076         ~OffsetCurveBuilder();
    00077
    00078         void setEndCapStyle(int newEndCapStyle);
    00079
    00088         void getLineCurve(const geom::CoordinateSequence* inputPts, double distance,
    00089                 std::vector<geom::CoordinateSequence*>& lineList);
    00090
    00098         void getRingCurve(const geom::CoordinateSequence *inputPts, int side,
    00099                 double distance, std::vector<geom::CoordinateSequence*>& lineList);
    00100
    00101
    00102 private:
    00103
    00104         static const double MIN_CURVE_VERTEX_FACTOR; //  1.0E-6;
    00105
    00106         static const double PI; //  3.14159265358979
    00107
    00108         static const double MAX_CLOSING_SEG_LEN; // 3.0
    00109
    00110         algorithm::LineIntersector li;
    00111
    00116         double filletAngleQuantum;
    00117
    00122         double maxCurveSegmentError;
    00123
    00125         //
    00132         OffsetCurveVertexList* vertexList;
    00133
    00134         double distance;
    00135
    00136         const geom::PrecisionModel* precisionModel;
    00137
    00138         int endCapStyle;
    00139
    00140         //int joinStyle;
    00141
    00142         geom::Coordinate s0, s1, s2;
    00143
    00144         geom::LineSegment seg0;
    00145
    00146         geom::LineSegment seg1;
    00147
    00148         geom::LineSegment offset0;
    00149
    00150         geom::LineSegment offset1;
    00151
    00152         int side;
    00153
    00154 //      static geom::CoordinateSequence* copyCoordinates(geom::CoordinateSequence *pts);
    00155
    00156         void init(double newDistance);
    00157
    00158         //geom::CoordinateSequence* getCoordinates();
    00159
    00160         void computeLineBufferCurve(const geom::CoordinateSequence& inputPts);
    00161
    00162         void computeRingBufferCurve(const geom::CoordinateSequence& inputPts, int side);
    00163
    00164         //void addPt(const geom::Coordinate &pt);
    00165
    00166         //void closePts();
    00167
    00168         void initSideSegments(const geom::Coordinate &nS1, const geom::Coordinate &nS2, int nSide);
    00169
    00170         void addNextSegment(const geom::Coordinate &p, bool addStartPoint);
    00171
    00173         void addLastSegment();
    00174
    00185         void computeOffsetSegment(const geom::LineSegment& seg, int side, double distance,
    00186                         geom::LineSegment& offset);
    00187
    00189         void addLineEndCap(const geom::Coordinate &p0,const geom::Coordinate &p1);
    00190
    00196         void addFillet(const geom::Coordinate &p, const geom::Coordinate &p0,
    00197                         const geom::Coordinate &p1, int direction, double distance);
    00198
    00206         void addFillet(const geom::Coordinate &p, double startAngle, double endAngle,
    00207                         int direction, double distance);
    00208
    00210         void addCircle(const geom::Coordinate &p, double distance);
    00211
    00213         void addSquare(const geom::Coordinate &p, double distance);
    00214
    00215         std::vector<OffsetCurveVertexList*> vertexLists;
    00216 };
    00217
    00218 // INLINES
    00219 inline void OffsetCurveBuilder::setEndCapStyle(int newEndCapStyle) {
    00220         endCapStyle=newEndCapStyle;
    00221 }
    00222
    00223
    00224 } // namespace geos::operation::buffer
    00225 } // namespace geos::operation
    00226 } // namespace geos
    00227
    00228 #endif // ndef GEOS_OP_BUFFER_OFFSETCURVEBUILDER_H
    00229
    00230 /**********************************************************************
    00231  * $Log$
    00232  * Revision 1.2  2006/03/27 17:04:17  strk
    00233  * Cleanups and explicit initializations
    00234  *
    00235  * Revision 1.1  2006/03/14 00:19:40  strk
    00236  * opBuffer.h split, streamlined headers in some (not all) files in operation/buffer/
    00237  *
    00238  **********************************************************************/
    00239