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