GEOS 3.6.2
OffsetSegmentGenerator.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
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#ifndef GEOS_OP_BUFFER_OFFSETSEGMENTGENERATOR_H
20#define GEOS_OP_BUFFER_OFFSETSEGMENTGENERATOR_H
21
22#include <geos/export.h>
23
24#include <vector>
25
26#include <geos/algorithm/LineIntersector.h> // for composition
27#include <geos/geom/Coordinate.h> // for composition
28#include <geos/geom/LineSegment.h> // for composition
29#include <geos/operation/buffer/BufferParameters.h> // for composition
30#include <geos/operation/buffer/OffsetSegmentString.h> // for composition
31
32#ifdef _MSC_VER
33#pragma warning(push)
34#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
35#endif
36
37// Forward declarations
38namespace geos {
39 namespace geom {
41 class PrecisionModel;
42 }
43}
44
45namespace geos {
46namespace operation { // geos.operation
47namespace buffer { // geos.operation.buffer
48
61class GEOS_DLL OffsetSegmentGenerator {
62
63public:
64
65 /*
66 * @param nBufParams buffer parameters, this object will
67 * keep a reference to the passed parameters
68 * so caller must make sure the object is
69 * kept alive for the whole lifetime of
70 * the buffer builder.
71 */
72 OffsetSegmentGenerator(const geom::PrecisionModel *newPrecisionModel,
73 const BufferParameters& bufParams, double distance);
74
88 {
89 return _hasNarrowConcaveAngle;
90 }
91
92 void initSideSegments(const geom::Coordinate &nS1,
93 const geom::Coordinate &nS2, int nSide);
94
96 //
103 void getCoordinates(std::vector<geom::CoordinateSequence*>& to) {
104 to.push_back(segList.getCoordinates());
105 }
106
107 void closeRing() {
108 segList.closeRing();
109 }
110
112 void createCircle(const geom::Coordinate &p, double distance);
113
115 void createSquare(const geom::Coordinate &p, double distance);
116
119 {
120 segList.addPt(offset1.p0);
121 }
122
125 {
126 segList.addPt(offset1.p1);
127 }
128
129 void addNextSegment(const geom::Coordinate &p, bool addStartPoint);
130
135 const geom::Coordinate &p1);
136
137 void addSegments(const geom::CoordinateSequence& pts, bool isForward)
138 {
139 segList.addPts(pts, isForward);
140 }
141
142private:
143
148 static const double OFFSET_SEGMENT_SEPARATION_FACTOR; // 1.0E-3;
149
154 static const double INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR; // 1.0E-3;
155
159 static const double CURVE_VERTEX_SNAP_DISTANCE_FACTOR; // 1.0E-6;
160
164 static const int MAX_CLOSING_SEG_LEN_FACTOR = 80;
165
170 double maxCurveSegmentError; // 0.0
171
176 double filletAngleQuantum;
177
195 int closingSegLengthFactor; // 1;
196
198 //
205 OffsetSegmentString segList;
206
207 double distance;
208
209 const geom::PrecisionModel* precisionModel;
210
211 const BufferParameters& bufParams;
212
214
215 geom::Coordinate s0, s1, s2;
216
218
220
221 geom::LineSegment offset0;
222
223 geom::LineSegment offset1;
224
225 int side;
226
227 bool _hasNarrowConcaveAngle; // =false
228
229 void addCollinear(bool addStartPoint);
230
232 //
237 void addMitreJoin(const geom::Coordinate& p,
238 const geom::LineSegment& offset0,
239 const geom::LineSegment& offset1,
240 double distance);
241
243 //
252 void addLimitedMitreJoin(
253 const geom::LineSegment& offset0,
254 const geom::LineSegment& offset1,
255 double distance, double mitreLimit);
256
260 //
264 void addBevelJoin(const geom::LineSegment& offset0,
265 const geom::LineSegment& offset1);
266
267 static const double PI; // 3.14159265358979
268
269 // Not in JTS, used for single-sided buffers
270 int endCapIndex;
271
272 void init(double newDistance);
273
281 static const double SIMPLIFY_FACTOR; // 100.0;
282
284 //
288 void addOutsideTurn(int orientation, bool addStartPoint);
289
291 //
295 void addInsideTurn(int orientation, bool addStartPoint);
296
309 void computeOffsetSegment(const geom::LineSegment& seg,
310 int side, double distance,
311 geom::LineSegment& offset);
312
324 void addFillet(const geom::Coordinate &p, const geom::Coordinate &p0,
325 const geom::Coordinate &p1,
326 int direction, double radius);
327
337 void addFillet(const geom::Coordinate &p, double startAngle,
338 double endAngle, int direction, double radius);
339private:
340 // An OffsetSegmentGenerator cannot be copied because of member "const BufferParameters& bufParams"
341 // Not declaring these functions triggers MSVC warning C4512: "assignment operator could not be generated"
343 void operator=(const OffsetSegmentGenerator&);
344
345};
346
347} // namespace geos::operation::buffer
348} // namespace geos::operation
349} // namespace geos
350
351#ifdef _MSC_VER
352#pragma warning(pop)
353#endif
354
355#endif // ndef GEOS_OP_BUFFER_OFFSETSEGMENTGENERATOR_H
356
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition LineIntersector.h:49
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:59
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:60
Definition LineSegment.h:57
Specifies the precision model of the Coordinate in a Geometry.
Definition PrecisionModel.h:87
Contains the parameters which describe how a buffer should be constructed.
Definition BufferParameters.h:58
Definition OffsetSegmentGenerator.h:61
void addFirstSegment()
Add first offset point.
Definition OffsetSegmentGenerator.h:118
bool hasNarrowConcaveAngle() const
Definition OffsetSegmentGenerator.h:87
void addLastSegment()
Add last offset point.
Definition OffsetSegmentGenerator.h:124
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)
Get coordinates by taking ownership of them.
Definition OffsetSegmentGenerator.h:103
A dynamic list of the vertices in a constructed offset curve.
Definition OffsetSegmentString.h:44
Contains the Geometry interface hierarchy and supporting classes.
Definition IndexedNestedRingTester.h:26
Provides classes for computing buffers of geometries.
Definition opBuffer.h:23
Provides classes for computing the distance between geometries.
Definition opDistance.h:23
Provides classes for implementing operations on geometries.
Definition IndexedNestedRingTester.h:40
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:25