GEOS 3.11.1
OffsetSegmentGenerator.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
7 *
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
12 *
13 **********************************************************************
14 *
15 * Last port: operation/buffer/OffsetSegmentGenerator.java r378 (JTS-1.12)
16 *
17 **********************************************************************/
18
19#pragma once
20
21#include <geos/export.h>
22
23#include <vector>
24
25#include <geos/algorithm/LineIntersector.h> // for composition
26#include <geos/geom/Coordinate.h> // for composition
27#include <geos/geom/LineSegment.h> // for composition
28#include <geos/operation/buffer/BufferParameters.h> // for composition
29#include <geos/operation/buffer/OffsetSegmentString.h> // for composition
30
31#ifdef _MSC_VER
32#pragma warning(push)
33#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
34#endif
35
36// Forward declarations
37namespace geos {
38namespace geom {
39class CoordinateSequence;
40class PrecisionModel;
41}
42}
43
44namespace geos {
45namespace operation { // geos.operation
46namespace buffer { // geos.operation.buffer
47
60class GEOS_DLL OffsetSegmentGenerator {
61
62public:
63
64 /*
65 * @param nBufParams buffer parameters, this object will
66 * keep a reference to the passed parameters
67 * so caller must make sure the object is
68 * kept alive for the whole lifetime of
69 * the buffer builder.
70 */
71 OffsetSegmentGenerator(const geom::PrecisionModel* newPrecisionModel,
72 const BufferParameters& bufParams, double distance);
73
86 bool
88 {
89 return _hasNarrowConcaveAngle;
90 }
91
92 void initSideSegments(const geom::Coordinate& nS1,
93 const geom::Coordinate& nS2, int nSide);
94
103 void
104 getCoordinates(std::vector<geom::CoordinateSequence*>& to)
105 {
106 to.push_back(segList.getCoordinates());
107 }
108
109 void
110 closeRing()
111 {
112 segList.closeRing();
113 }
114
116 void createCircle(const geom::Coordinate& p, double distance);
117
119 void createSquare(const geom::Coordinate& p, double distance);
120
122 void
124 {
125 segList.addPt(offset1.p0);
126 }
127
129 void
131 {
132 segList.addPt(offset1.p1);
133 }
134
135 void addNextSegment(const geom::Coordinate& p, bool addStartPoint);
136
141 const geom::Coordinate& p1);
142
143 void
144 addSegments(const geom::CoordinateSequence& pts, bool isForward)
145 {
146 segList.addPts(pts, isForward);
147 }
148
162 int side, double distance,
163 geom::LineSegment& offset);
164
165private:
166
171 static const double OFFSET_SEGMENT_SEPARATION_FACTOR; // 1.0E-3;
172
177 static const double INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR; // 1.0E-3;
178
182 static const double CURVE_VERTEX_SNAP_DISTANCE_FACTOR; // 1.0E-6;
183
187 static const int MAX_CLOSING_SEG_LEN_FACTOR = 80;
188
193 double maxCurveSegmentError; // 0.0
194
199 double filletAngleQuantum;
200
218 int closingSegLengthFactor; // 1;
219
228 OffsetSegmentString segList;
229
230 double distance;
231
232 const geom::PrecisionModel* precisionModel;
233
234 const BufferParameters& bufParams;
235
237
238 geom::Coordinate s0, s1, s2;
239
241
243
244 geom::LineSegment offset0;
245
246 geom::LineSegment offset1;
247
248 int side;
249
250 bool _hasNarrowConcaveAngle; // =false
251
252 void addCollinear(bool addStartPoint);
253
260 void addMitreJoin(const geom::Coordinate& cornerPt,
261 const geom::LineSegment& offset0,
262 const geom::LineSegment& offset1,
263 double distance);
264
265
276 void addLimitedMitreJoin(
277 const geom::LineSegment& offset0,
278 const geom::LineSegment& offset1,
279 double distance,
280 double mitreLimitDistance);
281
289 static geom::LineSegment extend(const geom::LineSegment& seg, double dist);
290
301 static geom::Coordinate project(const geom::Coordinate& pt, double d, double dir);
302
310 void addBevelJoin(const geom::LineSegment& offset0,
311 const geom::LineSegment& offset1);
312
313 static const double PI; // 3.14159265358979
314
315 // Not in JTS, used for single-sided buffers
316 int endCapIndex;
317
318 void init(double newDistance);
319
327 static const double SIMPLIFY_FACTOR; // 100.0;
328
334 void addOutsideTurn(int orientation, bool addStartPoint);
335
341 void addInsideTurn(int orientation, bool addStartPoint);
342
354 void addDirectedFillet(const geom::Coordinate& p, const geom::Coordinate& p0,
355 const geom::Coordinate& p1,
356 int direction, double radius);
357
367 void addDirectedFillet(const geom::Coordinate& p, double startAngle,
368 double endAngle, int direction, double radius);
369private:
370 // An OffsetSegmentGenerator cannot be copied because of member "const BufferParameters& bufParams"
371 // Not declaring these functions triggers MSVC warning C4512: "assignment operator could not be generated"
373 void operator=(const OffsetSegmentGenerator&);
374
375};
376
377} // namespace geos::operation::buffer
378} // namespace geos::operation
379} // namespace geos
380
381#ifdef _MSC_VER
382#pragma warning(pop)
383#endif
384
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition: LineIntersector.h:50
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:44
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:58
Definition: LineSegment.h:60
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:90
Contains the parameters which describe how a buffer should be constructed.
Definition: BufferParameters.h:56
Definition: OffsetSegmentGenerator.h:60
void addFirstSegment()
Add first offset point.
Definition: OffsetSegmentGenerator.h:123
bool hasNarrowConcaveAngle() const
Definition: OffsetSegmentGenerator.h:87
void addLastSegment()
Add last offset point.
Definition: OffsetSegmentGenerator.h:130
static void computeOffsetSegment(const geom::LineSegment &seg, int side, double distance, geom::LineSegment &offset)
Compute an offset segment for an input segment on a given side and at a given distance.
void addLineEndCap(const geom::Coordinate &p0, const geom::Coordinate &p1)
Add an end cap around point p1, terminating a line segment coming from p0.
void createSquare(const geom::Coordinate &p, double distance)
Adds a CW square around a point.
void createCircle(const geom::Coordinate &p, double distance)
Adds a CW circle around a point.
void getCoordinates(std::vector< geom::CoordinateSequence * > &to)
Definition: OffsetSegmentGenerator.h:104
Definition: OffsetSegmentString.h:42
Basic namespace for all GEOS functionalities.
Definition: geos.h:39