GEOS  3.9.1dev
OffsetSegmentGenerator.h
Go to the documentation of this file.
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 #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
38 namespace geos {
39 namespace geom {
40 class CoordinateSequence;
41 class PrecisionModel;
42 }
43 }
44 
45 namespace geos {
46 namespace operation { // geos.operation
47 namespace buffer { // geos.operation.buffer
48 
62 
63 public:
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 
87  bool
89  {
90  return _hasNarrowConcaveAngle;
91  }
92 
93  void initSideSegments(const geom::Coordinate& nS1,
94  const geom::Coordinate& nS2, int nSide);
95 
104  void
105  getCoordinates(std::vector<geom::CoordinateSequence*>& to)
106  {
107  to.push_back(segList.getCoordinates());
108  }
109 
110  void
112  {
113  segList.closeRing();
114  }
115 
117  void createCircle(const geom::Coordinate& p, double distance);
118 
120  void createSquare(const geom::Coordinate& p, double distance);
121 
123  void
125  {
126  segList.addPt(offset1.p0);
127  }
128 
130  void
132  {
133  segList.addPt(offset1.p1);
134  }
135 
136  void addNextSegment(const geom::Coordinate& p, bool addStartPoint);
137 
141  void addLineEndCap(const geom::Coordinate& p0,
142  const geom::Coordinate& p1);
143 
144  void
145  addSegments(const geom::CoordinateSequence& pts, bool isForward)
146  {
147  segList.addPts(pts, isForward);
148  }
149 
150 private:
151 
156  static const double OFFSET_SEGMENT_SEPARATION_FACTOR; // 1.0E-3;
157 
162  static const double INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR; // 1.0E-3;
163 
167  static const double CURVE_VERTEX_SNAP_DISTANCE_FACTOR; // 1.0E-6;
168 
172  static const int MAX_CLOSING_SEG_LEN_FACTOR = 80;
173 
178  double maxCurveSegmentError; // 0.0
179 
185 
204 
214 
215  double distance;
216 
218 
220 
222 
224 
226 
228 
230 
232 
233  int side;
234 
235  bool _hasNarrowConcaveAngle; // =false
236 
237  void addCollinear(bool addStartPoint);
238 
245  void addMitreJoin(const geom::Coordinate& p,
246  const geom::LineSegment& offset0,
247  const geom::LineSegment& offset1,
248  double distance);
249 
260  void addLimitedMitreJoin(
261  const geom::LineSegment& offset0,
262  const geom::LineSegment& offset1,
263  double distance, double mitreLimit);
264 
272  void addBevelJoin(const geom::LineSegment& offset0,
273  const geom::LineSegment& offset1);
274 
275  static const double PI; // 3.14159265358979
276 
277  // Not in JTS, used for single-sided buffers
279 
280  void init(double newDistance);
281 
289  static const double SIMPLIFY_FACTOR; // 100.0;
290 
296  void addOutsideTurn(int orientation, bool addStartPoint);
297 
303  void addInsideTurn(int orientation, bool addStartPoint);
304 
317  void computeOffsetSegment(const geom::LineSegment& seg,
318  int side, double distance,
319  geom::LineSegment& offset);
320 
332  void addDirectedFillet(const geom::Coordinate& p, const geom::Coordinate& p0,
333  const geom::Coordinate& p1,
334  int direction, double radius);
335 
345  void addDirectedFillet(const geom::Coordinate& p, double startAngle,
346  double endAngle, int direction, double radius);
347 private:
348  // An OffsetSegmentGenerator cannot be copied because of member "const BufferParameters& bufParams"
349  // Not declaring these functions triggers MSVC warning C4512: "assignment operator could not be generated"
351  void operator=(const OffsetSegmentGenerator&);
352 
353 };
354 
355 } // namespace geos::operation::buffer
356 } // namespace geos::operation
357 } // namespace geos
358 
359 #ifdef _MSC_VER
360 #pragma warning(pop)
361 #endif
362 
363 #endif // ndef GEOS_OP_BUFFER_OFFSETSEGMENTGENERATOR_H
364 
#define GEOS_DLL
Definition: export.h:28
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
double maxCurveSegmentError
the max error of approximation (distance) between a quad segment and the true fillet curve ...
Specifies the precision model of the Coordinate in a Geometry.
void getCoordinates(std::vector< geom::CoordinateSequence * > &to)
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
double filletAngleQuantum
The angle quantum with which to approximate a fillet curve (based on the input # of quadrant segments...
void addSegments(const geom::CoordinateSequence &pts, bool isForward)
Basic namespace for all GEOS functionalities.
Contains the parameters which describe how a buffer should be constructed.
The internal representation of a list of coordinates inside a Geometry.