GEOS  3.8.0dev
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 r378 (JTS-1.12)
18  *
19  **********************************************************************/
20 
21 #ifndef GEOS_OP_BUFFER_BUFFERBUILDER_H
22 #define GEOS_OP_BUFFER_BUFFERBUILDER_H
23 
24 #include <geos/export.h>
25 
26 #include <vector>
27 
28 #include <geos/operation/buffer/BufferOp.h> // for inlines (BufferOp enums)
29 #include <geos/operation/buffer/OffsetCurveBuilder.h> // for inline (OffsetCurveBuilder enums)
30 #include <geos/geomgraph/EdgeList.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 PrecisionModel;
41 class Geometry;
42 class GeometryFactory;
43 }
44 namespace algorithm {
45 class LineIntersector;
46 }
47 namespace noding {
48 class Noder;
49 class SegmentString;
50 class IntersectionAdder;
51 }
52 namespace geomgraph {
53 class Edge;
54 class Label;
55 class PlanarGraph;
56 }
57 namespace operation {
58 namespace buffer {
59 class BufferSubgraph;
60 }
61 namespace overlay {
62 class PolygonBuilder;
63 }
64 }
65 }
66 
67 namespace geos {
68 namespace operation { // geos.operation
69 namespace buffer { // geos.operation.buffer
70 
88 class GEOS_DLL BufferBuilder {
89 
90 public:
100  BufferBuilder(const BufferParameters& nBufParams)
101  :
102  bufParams(nBufParams),
103  workingPrecisionModel(nullptr),
104  li(nullptr),
105  intersectionAdder(nullptr),
106  workingNoder(nullptr),
107  geomFact(nullptr),
108  edgeList()
109  {}
110 
111  ~BufferBuilder();
112 
113 
124  void
126  {
127  workingPrecisionModel = pm;
128  }
129 
137  void
139  {
140  workingNoder = newNoder;
141  }
142 
143  geom::Geometry* buffer(const geom::Geometry* g, double distance);
144  // throw (GEOSException);
145 
164  geom::Geometry* bufferLineSingleSided(const geom::Geometry* g,
165  double distance, bool leftSide) ;
166  // throw (GEOSException);
167 
168 private:
169 
173  static int depthDelta(const geomgraph::Label& label);
174 
175  const BufferParameters& bufParams;
176 
177  const geom::PrecisionModel* workingPrecisionModel;
178 
180 
181  noding::IntersectionAdder* intersectionAdder;
182 
183  noding::Noder* workingNoder;
184 
185  const geom::GeometryFactory* geomFact;
186 
187  geomgraph::EdgeList edgeList;
188 
189  std::vector<geomgraph::Label*> newLabels;
190 
191  void computeNodedEdges(std::vector<noding::SegmentString*>& bufSegStr,
192  const geom::PrecisionModel* precisionModel);
193  // throw(GEOSException);
194 
204  void insertUniqueEdge(geomgraph::Edge* e);
205 
206  void createSubgraphs(geomgraph::PlanarGraph* graph,
207  std::vector<BufferSubgraph*>& list);
208 
219  void buildSubgraphs(const std::vector<BufferSubgraph*>& subgraphList,
220  overlay::PolygonBuilder& polyBuilder);
221 
225  //
230  noding::Noder* getNoder(const geom::PrecisionModel* precisionModel);
231 
232 
240  geom::Geometry* createEmptyResultGeometry() const;
241 
242  // Declare type as noncopyable
243  BufferBuilder(const BufferBuilder& other) = delete;
244  BufferBuilder& operator=(const BufferBuilder& rhs) = delete;
245 };
246 
247 } // namespace geos::operation::buffer
248 } // namespace geos::operation
249 } // namespace geos
250 
251 #ifdef _MSC_VER
252 #pragma warning(pop)
253 #endif
254 
255 #endif // ndef GEOS_OP_BUFFER_BUFFERBUILDER_H
Forms Polygon out of a graph of geomgraph::DirectedEdge.
Definition: PolygonBuilder.h:62
BufferBuilder(const BufferParameters &nBufParams)
Definition: BufferBuilder.h:100
Represents a directed graph which is embeddable in a planar surface.
Definition: geomgraph/PlanarGraph.h:75
Definition: EdgeList.h:58
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:87
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition: LineIntersector.h:49
Computes the intersections between two line segments in SegmentString and adds them to each string...
Definition: IntersectionAdder.h:60
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:66
A Label indicates the topological relationship of a component of a topology graph to a given Geometry...
Definition: Label.h:58
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Computes all intersections between segments in a set of SegmentString.
Definition: Noder.h:49
Contains the parameters which describe how a buffer should be constructed.
Definition: BufferParameters.h:57
void setWorkingPrecisionModel(const geom::PrecisionModel *pm)
Definition: BufferBuilder.h:125
Builds the buffer geometry for a given input geometry and precision model.
Definition: BufferBuilder.h:88
void setNoder(noding::Noder *newNoder)
Definition: BufferBuilder.h:138
Definition: geomgraph/Edge.h:66