00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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>
00026 #include <geos/geom/Coordinate.h>
00027 #include <geos/geom/LineSegment.h>
00028
00029
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 {
00044 namespace 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;
00105
00106 static const double PI;
00107
00108 static const double MAX_CLOSING_SEG_LEN;
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
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
00155
00156 void init(double newDistance);
00157
00158
00159
00160 void computeLineBufferCurve(const geom::CoordinateSequence& inputPts);
00161
00162 void computeRingBufferCurve(const geom::CoordinateSequence& inputPts, int side);
00163
00164
00165
00166
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
00219 inline void OffsetCurveBuilder::setEndCapStyle(int newEndCapStyle) {
00220 endCapStyle=newEndCapStyle;
00221 }
00222
00223
00224 }
00225 }
00226 }
00227
00228 #endif // ndef GEOS_OP_BUFFER_OFFSETCURVEBUILDER_H
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239