QGIS API Documentation  3.2.0-Bonn (bc43194)
qgsinternalgeometryengine.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsinternalgeometryengine.h - QgsInternalGeometryEngine
3 
4  ---------------------
5  begin : 13.1.2016
6  copyright : (C) 2016 by Matthias Kuhn
7  email : matthias@opengis.ch
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 #ifndef QGSINTERNALGEOMETRYENGINE_H
17 #define QGSINTERNALGEOMETRYENGINE_H
18 
19 #define SIP_NO_FILE
20 
21 #include "qgspointxy.h"
22 
23 class QgsGeometry;
25 class QgsLineString;
26 class QgsLineSegment2D;
27 
39 {
40  public:
41 
47  explicit QgsInternalGeometryEngine( const QgsGeometry &geometry );
48 
57  QgsGeometry extrude( double x, double y ) const;
58 
68  QgsGeometry poleOfInaccessibility( double precision, double *distanceFromBoundary = nullptr ) const;
69 
78  QgsGeometry orthogonalize( double tolerance = 1.0E-8, int maxIterations = 1000, double angleThreshold = 15.0 ) const;
79 
88  QgsGeometry densifyByCount( int extraNodesPerSegment ) const;
89 
103  QgsGeometry densifyByDistance( double distance ) const;
104 
119  QgsGeometry variableWidthBuffer( int segments, const std::function< std::unique_ptr< double[] >( const QgsLineString *line ) > &widthFunction ) const;
120 
135  QgsGeometry taperedBuffer( double startWidth, double endWidth, int segments ) const;
136 
147  QgsGeometry variableWidthBufferByM( int segments ) const;
148 
149  private:
150  const QgsAbstractGeometry *mGeometry = nullptr;
151 };
152 
159 class CORE_EXPORT QgsRay2D
160 {
161  public:
162 
167  QgsRay2D( const QgsPointXY &origin, QgsVector direction )
168  : origin( origin )
169  , direction( direction )
170  {}
171 
179  bool intersects( const QgsLineSegment2D &segment, QgsPointXY &intersectPoint ) const;
180 
181  private:
182 
183  QgsPointXY origin;
184  QgsVector direction;
185 };
186 
188 
189 // adapted for QGIS geometry classes from original work at https://github.com/trylock/visibility by trylock
190 
199 class CORE_EXPORT QgsLineSegmentDistanceComparer
200 {
201  public:
202 
207  explicit QgsLineSegmentDistanceComparer( const QgsPointXY &origin )
208  : mOrigin( origin )
209  {}
210 
218  bool operator()( QgsLineSegment2D ab, QgsLineSegment2D cd ) const;
219 
220  private:
221 
222  QgsPointXY mOrigin;
223 
224 };
225 
226 
227 // adapted for QGIS geometry classes from original work at https://github.com/trylock/visibility by trylock
228 
234 class CORE_EXPORT QgsClockwiseAngleComparer
235 {
236  public:
237  explicit QgsClockwiseAngleComparer( const QgsPointXY &origin )
238  : mVertex( origin )
239  {}
240 
241  bool operator()( const QgsPointXY &a, const QgsPointXY &b ) const;
242 
243  private:
244 
245  QgsPointXY mVertex;
246 
247 };
248 
250 
251 #endif // QGSINTERNALGEOMETRYENGINE_H
QgsGeometry taperedBuffer(double startWidth, double endWidth, int segments) const
Calculates a tapered width buffer for a (multi)curve geometry.
QgsInternalGeometryEngine(const QgsGeometry &geometry)
The caller is responsible that the geometry is available and unchanged for the whole lifetime of this...
QgsGeometry variableWidthBufferByM(int segments) const
Calculates a variable width buffer using the m-values from a (multi)line geometry.
QgsGeometry variableWidthBuffer(int segments, const std::function< std::unique_ptr< double[] >(const QgsLineString *line) > &widthFunction) const
Calculates a variable width buffer for a (multi)curve geometry.
QgsGeometry poleOfInaccessibility(double precision, double *distanceFromBoundary=nullptr) const
Calculates the approximate pole of inaccessibility for a surface, which is the most distant internal ...
A class to represent a 2D point.
Definition: qgspointxy.h:43
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:104
A 2D ray which extends from an origin point to an infinite distance in a given direction.
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:79
QgsGeometry densifyByDistance(double distance) const
Densifies the geometry by adding regularly placed extra nodes inside each segment so that the maximum...
Abstract base class for all geometries.
This class offers geometry processing methods.
Represents a single 2D line segment, consisting of a 2D start and end vertex only.
A class to represent a vector.
Definition: qgsvector.h:28
QgsRay2D(const QgsPointXY &origin, QgsVector direction)
Constructor for a ray starting at the given origin and extending an infinite distance in the specifie...
Line string geometry type, with support for z-dimension and m-values.
Definition: qgslinestring.h:43
QgsGeometry orthogonalize(double tolerance=1.0E-8, int maxIterations=1000, double angleThreshold=15.0) const
Attempts to orthogonalize a line or polygon geometry by shifting vertices to make the geometries angl...
QgsGeometry densifyByCount(int extraNodesPerSegment) const
Densifies the geometry by adding the specified number of extra nodes within each segment of the geome...
QgsGeometry extrude(double x, double y) const
Will extrude a line or (segmentized) curve by a given offset and return a polygon representation of i...