GEOS  3.13.1
BufferBuilder.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) 2008-2010 Safe Software Inc.
8  * Copyright (C) 2006-2007 Refractions Research Inc.
9  *
10  * This is free software; you can redistribute and/or modify it under
11  * the terms of the GNU Lesser General Public Licence as published
12  * by the Free Software Foundation.
13  * See the COPYING file for more information.
14  *
15  **********************************************************************
16  *
17  * Last port: operation/buffer/BufferBuilder.java 149b38907 (JTS-1.12)
18  *
19  **********************************************************************/
20 
21 #pragma once
22 
23 #include <geos/export.h>
24 
25 #include <vector>
26 
27 #include <geos/operation/buffer/BufferOp.h> // for inlines (BufferOp enums)
28 #include <geos/operation/buffer/OffsetCurveBuilder.h> // for inline (OffsetCurveBuilder enums)
29 #include <geos/geomgraph/EdgeList.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
37 namespace geos {
38 namespace geom {
39 class PrecisionModel;
40 class Geometry;
41 class GeometryFactory;
42 }
43 namespace algorithm {
44 class LineIntersector;
45 }
46 namespace noding {
47 class Noder;
48 class SegmentString;
49 class IntersectionAdder;
50 }
51 namespace geomgraph {
52 class Edge;
53 class Label;
54 class PlanarGraph;
55 }
56 namespace operation {
57 namespace buffer {
58 class BufferSubgraph;
59 class PolygonBuilder;
60 }
61 
62 }
63 }
64 
65 namespace geos {
66 namespace operation { // geos.operation
67 namespace buffer { // geos.operation.buffer
68 
86 class GEOS_DLL BufferBuilder {
87 
88 public:
98  BufferBuilder(const BufferParameters& nBufParams)
99  :
100  bufParams(nBufParams),
101  workingPrecisionModel(nullptr),
102  li(nullptr),
103  intersectionAdder(nullptr),
104  workingNoder(nullptr),
105  geomFact(nullptr),
106  edgeList(),
107  isInvertOrientation(false)
108  {}
109 
110  ~BufferBuilder();
111 
112 
123  void
125  {
126  workingPrecisionModel = pm;
127  }
128 
136  void
138  {
139  workingNoder = newNoder;
140  }
141 
150  void
151  setInvertOrientation(bool p_isInvertOrientation)
152  {
153  isInvertOrientation = p_isInvertOrientation;
154  }
155 
156 
157  std::unique_ptr<geom::Geometry> buffer(const geom::Geometry* g, double distance);
158 
177  std::unique_ptr<geom::Geometry> bufferLineSingleSided(
178  const geom::Geometry* g,
179  double distance, bool leftSide);
180 
181 private:
182 
186  static int depthDelta(const geomgraph::Label& label);
187 
188  const BufferParameters& bufParams;
189 
190  const geom::PrecisionModel* workingPrecisionModel;
191 
193 
194  noding::IntersectionAdder* intersectionAdder;
195 
196  noding::Noder* workingNoder;
197 
198  const geom::GeometryFactory* geomFact;
199 
200  geomgraph::EdgeList edgeList;
201 
202  std::vector<geomgraph::Label*> newLabels;
203 
204  bool isInvertOrientation;
205 
206  void computeNodedEdges(std::vector<noding::SegmentString*>& bufSegStr,
207  const geom::PrecisionModel* precisionModel);
208  // throw(GEOSException);
209 
219  void insertUniqueEdge(geomgraph::Edge* e);
220 
221  void createSubgraphs(geomgraph::PlanarGraph* graph,
222  std::vector<BufferSubgraph*>& list);
223 
234  void buildSubgraphs(const std::vector<BufferSubgraph*>& subgraphList,
235  PolygonBuilder& polyBuilder);
236 
245  noding::Noder* getNoder(const geom::PrecisionModel* precisionModel);
246 
247 
255  std::unique_ptr<geom::Geometry> createEmptyResultGeometry() const;
256 
257  // Declare type as noncopyable
258  BufferBuilder(const BufferBuilder& other) = delete;
259  BufferBuilder& operator=(const BufferBuilder& rhs) = delete;
260 };
261 
262 } // namespace geos::operation::buffer
263 } // namespace geos::operation
264 } // namespace geos
265 
266 #ifdef _MSC_VER
267 #pragma warning(pop)
268 #endif
269 
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition: LineIntersector.h:53
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:70
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:197
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:88
A EdgeList is a list of Edges.
Definition: EdgeList.h:55
Definition: geomgraph/Edge.h:63
A Label indicates the topological relationship of a component of a topology graph to a given Geometry...
Definition: Label.h:57
Represents a directed graph which is embeddable in a planar surface.
Definition: geomgraph/PlanarGraph.h:72
Computes the intersections between two line segments in SegmentString and adds them to each string.
Definition: IntersectionAdder.h:54
Computes all intersections between segments in a set of SegmentString.
Definition: Noder.h:46
Builds the buffer geometry for a given input geometry and precision model.
Definition: BufferBuilder.h:86
BufferBuilder(const BufferParameters &nBufParams)
Definition: BufferBuilder.h:98
void setInvertOrientation(bool p_isInvertOrientation)
Definition: BufferBuilder.h:151
void setNoder(noding::Noder *newNoder)
Definition: BufferBuilder.h:137
std::unique_ptr< geom::Geometry > bufferLineSingleSided(const geom::Geometry *g, double distance, bool leftSide)
void setWorkingPrecisionModel(const geom::PrecisionModel *pm)
Definition: BufferBuilder.h:124
Contains the parameters which describe how a buffer should be constructed.
Definition: BufferParameters.h:56
Forms Polygon out of a graph of geomgraph::DirectedEdge.
Definition: buffer/PolygonBuilder.h:61
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25