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
00090 void getLineCurve(const geom::CoordinateSequence* inputPts,
00091 double distance,
00092 std::vector<geom::CoordinateSequence*>& lineList);
00093
00110 void getSingleSidedLineCurve(const geom::CoordinateSequence* inputPts,
00111 double distance, std::vector<geom::CoordinateSequence*>& lineList,
00112 bool leftSide, bool rightSide ) ;
00113
00121 void getRingCurve(const geom::CoordinateSequence *inputPts, int side,
00122 double distance,
00123 std::vector<geom::CoordinateSequence*>& lineList);
00124
00125
00126 private:
00127
00129
00134 void addMitreJoin(const geom::Coordinate& p,
00135 const geom::LineSegment& offset0,
00136 const geom::LineSegment& offset1,
00137 double distance);
00138
00140
00149 void addLimitedMitreJoin(
00150 const geom::LineSegment& offset0,
00151 const geom::LineSegment& offset1,
00152 double distance, double mitreLimit);
00153
00157
00161 void addBevelJoin(const geom::LineSegment& offset0,
00162 const geom::LineSegment& offset1);
00163
00164
00168 static const double CURVE_VERTEX_SNAP_DISTANCE_FACTOR;
00169
00170 static const double PI;
00171
00172 static const double MAX_CLOSING_SEG_LEN;
00173
00178 static const double OFFSET_SEGMENT_SEPARATION_FACTOR;
00179
00184 static const double INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR;
00185
00190 static const int MAX_CLOSING_SEG_FRACTION = 80;
00191
00192 algorithm::LineIntersector li;
00193
00198 double filletAngleQuantum;
00199
00204 double maxCurveSegmentError;
00205
00207
00214 OffsetCurveVertexList* vertexList;
00215
00216 double distance;
00217
00218 const geom::PrecisionModel* precisionModel;
00219
00220 const BufferParameters& bufParams;
00221
00239 int closingSegFactor;
00240
00241 geom::Coordinate s0, s1, s2;
00242
00243 geom::LineSegment seg0;
00244
00245 geom::LineSegment seg1;
00246
00247 geom::LineSegment offset0;
00248
00249 geom::LineSegment offset1;
00250
00251 int side;
00252
00253
00254 int endCapIndex;
00255
00256 void init(double newDistance);
00257
00265 static const double SIMPLIFY_FACTOR;
00266
00274 double simplifyTolerance(double bufDistance);
00275
00276 void computeLineBufferCurve(const geom::CoordinateSequence& inputPts);
00277
00278 void computeRingBufferCurve(const geom::CoordinateSequence& inputPts,
00279 int side);
00280
00281 void initSideSegments(const geom::Coordinate &nS1,
00282 const geom::Coordinate &nS2, int nSide);
00283
00284 void addNextSegment(const geom::Coordinate &p, bool addStartPoint);
00285
00286 void addCollinear(bool addStartPoint);
00287
00289
00293 void addOutsideTurn(int orientation, bool addStartPoint);
00294
00296
00300 void addInsideTurn(int orientation, bool addStartPoint);
00301
00303 void addLastSegment();
00304
00317 void computeOffsetSegment(const geom::LineSegment& seg,
00318 int side, double distance,
00319 geom::LineSegment& offset);
00320
00324 void addLineEndCap(const geom::Coordinate &p0,
00325 const geom::Coordinate &p1);
00326
00338 void addFillet(const geom::Coordinate &p, const geom::Coordinate &p0,
00339 const geom::Coordinate &p1,
00340 int direction, double radius);
00341
00351 void addFillet(const geom::Coordinate &p, double startAngle,
00352 double endAngle, int direction, double radius);
00353
00355 void addCircle(const geom::Coordinate &p, double distance);
00356
00358 void addSquare(const geom::Coordinate &p, double distance);
00359
00360 std::vector<OffsetCurveVertexList*> vertexLists;
00361
00362
00363 OffsetCurveBuilder(const OffsetCurveBuilder& other);
00364 OffsetCurveBuilder& operator=(const OffsetCurveBuilder& rhs);
00365 };
00366
00367 }
00368 }
00369 }
00370
00371 #endif // ndef GEOS_OP_BUFFER_OFFSETCURVEBUILDER_H
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382