00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GEOS_OP_BUFFER_OFFSETSEGMENTGENERATOR_H
00021 #define GEOS_OP_BUFFER_OFFSETSEGMENTGENERATOR_H
00022
00023 #include <geos/export.h>
00024
00025 #include <vector>
00026
00027 #include <geos/algorithm/LineIntersector.h>
00028 #include <geos/geom/Coordinate.h>
00029 #include <geos/geom/LineSegment.h>
00030 #include <geos/operation/buffer/BufferParameters.h>
00031 #include <geos/operation/buffer/OffsetSegmentString.h>
00032
00033 #ifdef _MSC_VER
00034 #pragma warning(push)
00035 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00036 #endif
00037
00038
00039 namespace geos {
00040 namespace geom {
00041 class CoordinateSequence;
00042 class PrecisionModel;
00043 }
00044 }
00045
00046 namespace geos {
00047 namespace operation {
00048 namespace buffer {
00049
00062 class GEOS_DLL OffsetSegmentGenerator {
00063
00064 public:
00065
00066
00067
00068
00069
00070
00071
00072
00073 OffsetSegmentGenerator(const geom::PrecisionModel *newPrecisionModel,
00074 const BufferParameters& bufParams, double distance);
00075
00088 bool hasNarrowConcaveAngle() const
00089 {
00090 return _hasNarrowConcaveAngle;
00091 }
00092
00093 void initSideSegments(const geom::Coordinate &nS1,
00094 const geom::Coordinate &nS2, int nSide);
00095
00097
00104 void getCoordinates(std::vector<geom::CoordinateSequence*>& to) {
00105 to.push_back(segList.getCoordinates());
00106 }
00107
00108 void closeRing() {
00109 segList.closeRing();
00110 }
00111
00113 void createCircle(const geom::Coordinate &p, double distance);
00114
00116 void createSquare(const geom::Coordinate &p, double distance);
00117
00119 void addFirstSegment()
00120 {
00121 segList.addPt(offset1.p0);
00122 }
00123
00125 void addLastSegment()
00126 {
00127 segList.addPt(offset1.p1);
00128 }
00129
00130 void addNextSegment(const geom::Coordinate &p, bool addStartPoint);
00131
00135 void addLineEndCap(const geom::Coordinate &p0,
00136 const geom::Coordinate &p1);
00137
00138 void addSegments(const geom::CoordinateSequence& pts, bool isForward)
00139 {
00140 segList.addPts(pts, isForward);
00141 }
00142
00143 private:
00144
00149 static const double OFFSET_SEGMENT_SEPARATION_FACTOR;
00150
00155 static const double INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR;
00156
00160 static const double CURVE_VERTEX_SNAP_DISTANCE_FACTOR;
00161
00165 static const int MAX_CLOSING_SEG_LEN_FACTOR = 80;
00166
00171 double maxCurveSegmentError;
00172
00177 double filletAngleQuantum;
00178
00196 int closingSegLengthFactor;
00197
00199
00206 OffsetSegmentString segList;
00207
00208 double distance;
00209
00210 const geom::PrecisionModel* precisionModel;
00211
00212 const BufferParameters& bufParams;
00213
00214 algorithm::LineIntersector li;
00215
00216 geom::Coordinate s0, s1, s2;
00217
00218 geom::LineSegment seg0;
00219
00220 geom::LineSegment seg1;
00221
00222 geom::LineSegment offset0;
00223
00224 geom::LineSegment offset1;
00225
00226 int side;
00227
00228 bool _hasNarrowConcaveAngle;
00229
00230 void addCollinear(bool addStartPoint);
00231
00233
00238 void addMitreJoin(const geom::Coordinate& p,
00239 const geom::LineSegment& offset0,
00240 const geom::LineSegment& offset1,
00241 double distance);
00242
00244
00253 void addLimitedMitreJoin(
00254 const geom::LineSegment& offset0,
00255 const geom::LineSegment& offset1,
00256 double distance, double mitreLimit);
00257
00261
00265 void addBevelJoin(const geom::LineSegment& offset0,
00266 const geom::LineSegment& offset1);
00267
00268 static const double PI;
00269
00270
00271 int endCapIndex;
00272
00273 void init(double newDistance);
00274
00282 static const double SIMPLIFY_FACTOR;
00283
00285
00289 void addOutsideTurn(int orientation, bool addStartPoint);
00290
00292
00296 void addInsideTurn(int orientation, bool addStartPoint);
00297
00310 void computeOffsetSegment(const geom::LineSegment& seg,
00311 int side, double distance,
00312 geom::LineSegment& offset);
00313
00325 void addFillet(const geom::Coordinate &p, const geom::Coordinate &p0,
00326 const geom::Coordinate &p1,
00327 int direction, double radius);
00328
00338 void addFillet(const geom::Coordinate &p, double startAngle,
00339 double endAngle, int direction, double radius);
00340
00341 };
00342
00343 }
00344 }
00345 }
00346
00347 #ifdef _MSC_VER
00348 #pragma warning(pop)
00349 #endif
00350
00351 #endif // ndef GEOS_OP_BUFFER_OFFSETSEGMENTGENERATOR_H
00352