QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgscurvev2.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscurvev2.h
3  ------------
4  begin : September 2014
5  copyright : (C) 2014 by Marco Hugentobler
6  email : marco at sourcepole dot ch
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSCURVEV2_H
19 #define QGSCURVEV2_H
20 
21 #include "qgsabstractgeometryv2.h"
22 #include "qgspointv2.h"
23 
24 class QgsLineStringV2;
25 class QPainterPath;
26 
32 class CORE_EXPORT QgsCurveV2: public QgsAbstractGeometryV2
33 {
34  public:
35  QgsCurveV2();
36  virtual ~QgsCurveV2();
37 
38  virtual bool operator==( const QgsCurveV2& other ) const = 0;
39  virtual bool operator!=( const QgsCurveV2& other ) const = 0;
40 
41  virtual QgsCurveV2* clone() const override = 0;
42 
46  virtual QgsPointV2 startPoint() const = 0;
47 
51  virtual QgsPointV2 endPoint() const = 0;
52 
55  virtual bool isClosed() const;
56 
59  virtual bool isRing() const;
60 
65  virtual QgsLineStringV2* curveToLine( double tolerance = M_PI_2 / 90, SegmentationToleranceType toleranceType = MaximumAngle ) const = 0;
66 
69  virtual void addToPainterPath( QPainterPath& path ) const = 0;
70 
74  virtual void drawAsPolygon( QPainter& p ) const = 0;
75 
78  virtual void points( QgsPointSequenceV2 &pt ) const = 0;
79 
82  virtual int numPoints() const = 0;
83 
86  virtual void sumUpArea( double& sum ) const = 0;
87 
88  virtual QgsCoordinateSequenceV2 coordinateSequence() const override;
89  virtual bool nextVertex( QgsVertexId& id, QgsPointV2& vertex ) const override;
90 
97  virtual bool pointAt( int node, QgsPointV2& point, QgsVertexId::VertexType& type ) const = 0;
98 
102  virtual QgsCurveV2* reversed() const = 0;
103 
104  virtual QgsAbstractGeometryV2* boundary() const override;
105 
109  QgsCurveV2* segmentize( double tolerance = M_PI_2 / 90, SegmentationToleranceType toleranceType = MaximumAngle ) const override;
110 
111  virtual int vertexCount( int part = 0, int ring = 0 ) const override { Q_UNUSED( part ); Q_UNUSED( ring ); return numPoints(); }
112  virtual int ringCount( int part = 0 ) const override { Q_UNUSED( part ); return numPoints() > 0 ? 1 : 0; }
113  virtual int partCount() const override { return numPoints() > 0 ? 1 : 0; }
114  virtual QgsPointV2 vertexAt( QgsVertexId id ) const override;
115 
116  virtual QgsRectangle boundingBox() const override;
117 
118  protected:
119 
120  virtual void clearCache() const override { mBoundingBox = QgsRectangle(); mCoordinateSequence.clear(); QgsAbstractGeometryV2::clearCache(); }
121 
122  private:
123 
124  mutable QgsRectangle mBoundingBox;
125  mutable QgsCoordinateSequenceV2 mCoordinateSequence;
126 };
127 
128 #endif // QGSCURVEV2_H
A rectangle specified with double values.
Definition: qgsrectangle.h:35
virtual int partCount() const override
Returns count of parts contained in the geometry.
Definition: qgscurvev2.h:113
virtual QgsCoordinateSequenceV2 coordinateSequence() const =0
Retrieves the sequence of geometries, rings and nodes.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
static QVariant pointAt(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle...
Abstract base class for all geometries.
virtual void clearCache() const
Clears any cached parameters associated with the geometry, eg bounding boxes.
#define M_PI_2
Definition: util.cpp:45
virtual int ringCount(int part=0) const override
Definition: qgscurvev2.h:112
virtual void clearCache() const override
Clears any cached parameters associated with the geometry, eg bounding boxes.
Definition: qgscurvev2.h:120
Utility class for identifying a unique vertex within a geometry.
Line string geometry type, with support for z-dimension and m-values.
Point geometry type, with support for z-dimension and m-values.
Definition: qgspointv2.h:34
virtual QgsAbstractGeometryV2 * segmentize(double tolerance=M_PI/180., SegmentationToleranceType toleranceType=MaximumAngle) const
Returns a version of the geometry without curves.
virtual bool nextVertex(QgsVertexId &id, QgsPointV2 &vertex) const =0
Returns next vertex id and coordinates.
virtual QgsAbstractGeometryV2 * boundary() const =0
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
virtual QgsRectangle boundingBox() const =0
Returns the minimal bounding box for the geometry.
virtual QgsAbstractGeometryV2 * clone() const =0
Clones the geometry by performing a deep copy.
Abstract base class for curved geometry type.
Definition: qgscurvev2.h:32
virtual int vertexCount(int part=0, int ring=0) const override
Definition: qgscurvev2.h:111
virtual QgsPointV2 vertexAt(QgsVertexId id) const =0
Returns the point corresponding to a specified vertex id.