GEOS 3.15.0dev
OffsetCurveBuilder.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2009-2011 Sandro Santilli <strk@kbt.io>
7 * Copyright (C) 2006-2007 Refractions Research Inc.
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 **********************************************************************
15 *
16 * Last port: operation/buffer/OffsetCurveBuilder.java r378 (JTS-1.12)
17 *
18 **********************************************************************/
19
20#pragma once
21
22#include <geos/export.h>
23
24#include <geos/operation/buffer/BufferParameters.h> // for composition
25#include <geos/operation/buffer/OffsetSegmentGenerator.h>
26
27#include <vector>
28#include <memory> // for unique_ptr
29
30#ifdef _MSC_VER
31#pragma warning(push)
32#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
33#endif
34
35// Forward declarations
36namespace geos {
37namespace geom {
38class CoordinateSequence;
39class PrecisionModel;
40}
41}
42
43namespace geos {
44namespace operation { // geos.operation
45namespace buffer { // geos.operation.buffer
46
65class GEOS_DLL OffsetCurveBuilder {
68
69public:
70
71 /*
72 * @param nBufParams buffer parameters, this object will
73 * keep a reference to the passed parameters
74 * so caller must make sure the object is
75 * kept alive for the whole lifetime of
76 * the buffer builder.
77 */
79 const PrecisionModel* newPrecisionModel,
80 const BufferParameters& nBufParams)
81 : distance(0.0)
82 , precisionModel(newPrecisionModel)
83 , bufParams(nBufParams)
84 {}
85
91 const BufferParameters&
93 {
94 return bufParams;
95 }
96
108 bool isLineOffsetEmpty(double distance);
109
121 void getLineCurve(const CoordinateSequence* inputPts,
122 double distance,
123 std::vector<std::unique_ptr<CoordinateSequence>>& lineList);
124
136 std::unique_ptr<CoordinateSequence> getLineCurve(
137 const CoordinateSequence* inputPts, double pDistance);
138
158 double distance, std::vector<std::unique_ptr<CoordinateSequence>>& lineList,
159 bool leftSide, bool rightSide) ;
160
171 void getRingCurve(const CoordinateSequence* inputPts, int side,
172 double distance,
173 std::vector<std::unique_ptr<CoordinateSequence>>& lineList);
174
185 std::unique_ptr<CoordinateSequence> getRingCurve(
186 const CoordinateSequence* inputPts,
187 int side, double pDistance);
188
189 void getOffsetCurve(const CoordinateSequence* inputPts,
190 double p_distance,
191 std::vector<std::unique_ptr<CoordinateSequence>>& lineList);
192
193 std::unique_ptr<CoordinateSequence> getOffsetCurve(
194 const CoordinateSequence* inputPts,
195 double pDistance);
196
197
198private:
199
200 double distance;
201
202 const PrecisionModel* precisionModel;
203
204 const BufferParameters& bufParams;
205
213 static const double SIMPLIFY_FACTOR; // 100.0;
214
222 double simplifyTolerance(double bufDistance);
223
224 void computeLineBufferCurve(const CoordinateSequence& inputPts,
225 OffsetSegmentGenerator& segGen);
226
227 void computeSingleSidedBufferCurve(const CoordinateSequence& inputPts,
228 bool isRightSide,
229 OffsetSegmentGenerator& segGen);
230
231 void computeRingBufferCurve(const CoordinateSequence& inputPts,
232 int side, OffsetSegmentGenerator& segGen);
233
234 void computePointCurve(const geom::Coordinate& pt,
235 OffsetSegmentGenerator& segGen);
236
237 void computeOffsetCurve(
238 const CoordinateSequence* inputPts,
239 bool isRightSide,
240 OffsetSegmentGenerator& segGen);
241
242
243
244 // Declare type as noncopyable
245 OffsetCurveBuilder(const OffsetCurveBuilder& other) = delete;
246 OffsetCurveBuilder& operator=(const OffsetCurveBuilder& rhs) = delete;
247};
248
249} // namespace geos::operation::buffer
250} // namespace geos::operation
251} // namespace geos
252
253#ifdef _MSC_VER
254#pragma warning(pop)
255#endif
256
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
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:56
Computes the raw offset curve for a single Geometry component (ring, line or point).
Definition OffsetCurveBuilder.h:65
void getLineCurve(const CoordinateSequence *inputPts, double distance, std::vector< std::unique_ptr< CoordinateSequence > > &lineList)
This method handles single points as well as lines.
std::unique_ptr< CoordinateSequence > getRingCurve(const CoordinateSequence *inputPts, int side, double pDistance)
const BufferParameters & getBufferParameters() const
Gets the buffer parameters being used to generate the curve.
Definition OffsetCurveBuilder.h:92
void getSingleSidedLineCurve(const CoordinateSequence *inputPts, double distance, std::vector< std::unique_ptr< CoordinateSequence > > &lineList, bool leftSide, bool rightSide)
This method handles single points as well as lines.
void getRingCurve(const CoordinateSequence *inputPts, int side, double distance, std::vector< std::unique_ptr< CoordinateSequence > > &lineList)
This method handles the degenerate cases of single points and lines, as well as rings.
std::unique_ptr< CoordinateSequence > getLineCurve(const CoordinateSequence *inputPts, double pDistance)
Definition OffsetSegmentGenerator.h:60
Basic namespace for all GEOS functionalities.
Definition geos.h:38