GEOS 3.14.0dev
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 std::unique_ptr<geom::CoordinateSequence>
110 getCoordinates()
111 {
112 return std::unique_ptr<geom::CoordinateSequence>(segList.getCoordinates());
113 }
114
115 void
116 closeRing()
117 {
118 segList.closeRing();
119 }
120
122 void createCircle(const geom::Coordinate& p, double distance);
123
125 void createSquare(const geom::Coordinate& p, double distance);
126
128 void
130 {
131 segList.addPt(offset1.p0);
132 }
133
135 void
137 {
138 segList.addPt(offset1.p1);
139 }
140
141 void addNextSegment(const geom::Coordinate& p, bool addStartPoint);
142
147 const geom::Coordinate& p1);
148
149 void
150 addSegments(const geom::CoordinateSequence& pts, bool isForward)
151 {
152 segList.addPts(pts, isForward);
153 }
154
168 int side, double distance,
169 geom::LineSegment& offset);
170
171private:
172
177 static const double OFFSET_SEGMENT_SEPARATION_FACTOR; // 1.0E-3;
178
183 static const double INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR; // 1.0E-3;
184
188 static const double CURVE_VERTEX_SNAP_DISTANCE_FACTOR; // 1.0E-6;
189
193 static const int MAX_CLOSING_SEG_LEN_FACTOR = 80;
194
199 double maxCurveSegmentError; // 0.0
200
205 double filletAngleQuantum;
206
224 int closingSegLengthFactor; // 1;
225
234 OffsetSegmentString segList;
235
236 double distance;
237
238 const geom::PrecisionModel* precisionModel;
239
240 const BufferParameters& bufParams;
241
243
244 geom::Coordinate s0, s1, s2;
245
247
249
250 geom::LineSegment offset0;
251
252 geom::LineSegment offset1;
253
254 int side;
255
256 bool _hasNarrowConcaveAngle; // =false
257
258 void addCollinear(bool addStartPoint);
259
266 void addMitreJoin(const geom::Coordinate& cornerPt,
267 const geom::LineSegment& offset0,
268 const geom::LineSegment& offset1,
269 double distance);
270
271
282 void addLimitedMitreJoin(
283 const geom::LineSegment& offset0,
284 const geom::LineSegment& offset1,
285 double distance,
286 double mitreLimitDistance);
287
295 static geom::LineSegment extend(const geom::LineSegment& seg, double dist);
296
307 static geom::Coordinate project(const geom::Coordinate& pt, double d, double dir);
308
316 void addBevelJoin(const geom::LineSegment& offset0,
317 const geom::LineSegment& offset1);
318
319 static const double PI; // 3.14159265358979
320
321 // Not in JTS, used for single-sided buffers
322 int endCapIndex;
323
324 void init(double newDistance);
325
333 static const double SIMPLIFY_FACTOR; // 100.0;
334
340 void addOutsideTurn(int orientation, bool addStartPoint);
341
347 void addInsideTurn(int orientation, bool addStartPoint);
348
360 void addDirectedFillet(const geom::Coordinate& p, const geom::Coordinate& p0,
361 const geom::Coordinate& p1,
362 int direction, double radius);
363
373 void addDirectedFillet(const geom::Coordinate& p, double startAngle,
374 double endAngle, int direction, double radius);
375private:
376 // An OffsetSegmentGenerator cannot be copied because of member "const BufferParameters& bufParams"
377 // Not declaring these functions triggers MSVC warning C4512: "assignment operator could not be generated"
379 void operator=(const OffsetSegmentGenerator&);
380
381};
382
383} // namespace geos::operation::buffer
384} // namespace geos::operation
385} // namespace geos
386
387#ifdef _MSC_VER
388#pragma warning(pop)
389#endif
390
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition LineIntersector.h:53
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
Definition LineSegment.h:61
Specifies the precision model of the Coordinate in a Geometry.
Definition PrecisionModel.h:88
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:129
bool hasNarrowConcaveAngle() const
Definition OffsetSegmentGenerator.h:87
void addLastSegment()
Add last offset point.
Definition OffsetSegmentGenerator.h:136
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:41
Basic namespace for all GEOS functionalities.
Definition geos.h:39