00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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>
00029 #include <geos/geom/Coordinate.h>
00030 #include <geos/geom/LineSegment.h>
00031 #include <geos/operation/buffer/BufferParameters.h>
00032
00033
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 {
00048 namespace buffer {
00049
00066 class GEOS_DLL OffsetCurveBuilder {
00067 public:
00068
00069
00070
00071
00072
00073
00074
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;
00167
00168 static const double PI;
00169
00170 static const double MAX_CLOSING_SEG_LEN;
00171
00176 static const double OFFSET_SEGMENT_SEPARATION_FACTOR;
00177
00182 static const double INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR;
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;
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
00252 int endCapIndex;
00253
00254 void init(double newDistance);
00255
00263 static const double SIMPLIFY_FACTOR;
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 }
00362 }
00363 }
00364
00365 #endif // ndef GEOS_OP_BUFFER_OFFSETCURVEBUILDER_H
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376