QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
qgstriangle.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgstriangle.h
3  -------------------
4  begin : January 2017
5  copyright : (C) 2017 by Loïc Bartoletti
6  email : lbartoletti at tuxfamily dot org
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 QGSTRIANGLE_H
19 #define QGSTRIANGLE_H
20 
21 #include "qgis_core.h"
22 #include "qgis_sip.h"
23 #include "qgspolygon.h"
24 #include "qgscircle.h"
25 #include "qgslinestring.h"
26 
33 class CORE_EXPORT QgsTriangle : public QgsPolygon
34 {
35  public:
36  QgsTriangle();
37 
44  QgsTriangle( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p3 );
45 
52  explicit QgsTriangle( const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3 );
53 
60  explicit QgsTriangle( QPointF p1, QPointF p2, QPointF p3 );
61 
62  bool operator==( const QgsTriangle &other ) const;
63  bool operator!=( const QgsTriangle &other ) const;
64 
65  QString geometryType() const override;
66  QgsTriangle *clone() const override SIP_FACTORY;
67  void clear() override;
68 
69  bool fromWkb( QgsConstWkbPtr &wkbPtr ) override;
70 
71  bool fromWkt( const QString &wkt ) override;
72 
73  // inherited: QString asWkt( int precision = 17 ) const;
74  // inherited (as a polygon): QDomElement asGML2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
75  QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
76 
77  QgsPolygon *surfaceToPolygon() const override SIP_FACTORY;
78 
79  QgsCurvePolygon *toCurveType() const override SIP_FACTORY;
80 
82  void addInteriorRing( QgsCurve *ring SIP_TRANSFER ) override;
83 
88  void setInteriorRings( const QVector< QgsCurve *> &rings ) = delete;
90  bool deleteVertex( QgsVertexId position ) override;
92  bool insertVertex( QgsVertexId position, const QgsPoint &vertex ) override;
93  bool moveVertex( QgsVertexId vId, const QgsPoint &newPos ) override;
94 
95  void setExteriorRing( QgsCurve *ring SIP_TRANSFER ) override;
96 
97  QgsCurve *boundary() const override SIP_FACTORY;
98 
99  // inherited: double pointDistanceToBoundary( double x, double y ) const;
100 
106  QgsPoint vertexAt( int atVertex ) const;
107 
121  QVector<double> lengths() const;
122 
136  QVector<double> angles() const;
137 
157  bool isDegenerate();
158 
175  bool isIsocele( double lengthTolerance = 0.0001 ) const;
176 
193  bool isEquilateral( double lengthTolerance = 0.0001 ) const;
194 
211  bool isRight( double angleTolerance = 0.0001 ) const;
212 
229  bool isScalene( double lengthTolerance = 0.0001 ) const;
230 
244  QVector<QgsLineString> altitudes() const;
245 
259  QVector<QgsLineString> medians() const;
260 
275  QVector<QgsLineString> bisectors( double lengthTolerance = 0.0001 ) const;
276 
290  QgsTriangle medial() const;
291 
306  QgsPoint orthocenter( double lengthTolerance = 0.0001 ) const;
307 
321  QgsPoint circumscribedCenter() const;
322 
336  double circumscribedRadius() const;
337 
351  QgsCircle circumscribedCircle() const;
352 
367  QgsPoint inscribedCenter() const;
368 
382  double inscribedRadius() const;
383 
397  QgsCircle inscribedCircle() const;
398 
399 #ifndef SIP_RUN
400 
408  inline const QgsTriangle *cast( const QgsAbstractGeometry *geom ) const
409  {
410  if ( geom && QgsWkbTypes::flatType( geom->wkbType() ) == QgsWkbTypes::Triangle )
411  return static_cast<const QgsTriangle *>( geom );
412  return nullptr;
413  }
414 #endif
415 
417 
418 
419 };
420 #endif // QGSTRIANGLE_H
Circle geometry type.
Definition: qgscircle.h:43
int precision
bool operator==(const QgsAbstractGeometry &other) const override
QgsPolygon * surfaceToPolygon() const override
Gets a polygon representation of this surface.
Definition: qgspolygon.cpp:271
A class to represent a 2D point.
Definition: qgspointxy.h:43
Curve polygon geometry type.
Triangle geometry type.
Definition: qgstriangle.h:33
QgsAbstractGeometry * boundary() const override
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
Definition: qgspolygon.cpp:214
void addInteriorRing(QgsCurve *ring) override
Adds an interior ring to the geometry (takes ownership)
Definition: qgspolygon.cpp:148
void clear() override
Clears the geometry, ie reset it to a null geometry.
Definition: qgspolygon.cpp:47
Utility class for identifying a unique vertex within a geometry.
bool insertVertex(QgsVertexId position, const QgsPoint &vertex) override
Inserts a vertex into the geometry.
QgsPoint vertexAt(QgsVertexId id) const override
Returns the point corresponding to a specified vertex id.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
bool fromWkb(QgsConstWkbPtr &wkb) override
Sets the geometry from a WKB string.
Definition: qgspolygon.cpp:53
QgsCurvePolygon * toCurveType() const override
Returns the geometry converted to the more generic curve type QgsCurvePolygon.
Definition: qgspolygon.cpp:276
bool fromWkt(const QString &wkt) override
Sets the geometry from a WKT string.
Abstract base class for curved geometry type.
Definition: qgscurve.h:35
#define SIP_FACTORY
Definition: qgis_sip.h:76
QString geometryType() const override
Returns a unique string representing the geometry type.
Definition: qgspolygon.cpp:30
Abstract base class for all geometries.
QgsPolygon * createEmptyWithSameType() const override
Creates a new geometry with the same class and same WKB type as the original and transfers ownership...
Definition: qgspolygon.cpp:35
QgsWkbTypes::Type wkbType() const
Returns the WKB type of the geometry.
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:37
AxisOrder
Axis order for GML generation.
bool operator!=(const QgsAbstractGeometry &other) const override
const QgsTriangle * cast(const QgsAbstractGeometry *geom) const
Cast the geom to a QgsTriangle.
Definition: qgstriangle.h:408
void setExteriorRing(QgsCurve *ring) override
Sets the exterior ring of the polygon.
Definition: qgspolygon.cpp:179
bool moveVertex(QgsVertexId position, const QgsPoint &newPos) override
Moves a vertex within the geometry.
bool deleteVertex(QgsVertexId position) override
Deletes a vertex within the geometry.
QgsPolygon * clone() const override
Clones the geometry by performing a deep copy.
Definition: qgspolygon.cpp:42
QDomElement asGml3(QDomDocument &doc, int precision=17, const QString &ns="gml", QgsAbstractGeometry::AxisOrder axisOrder=QgsAbstractGeometry::AxisOrder::XY) const override
Returns a GML3 representation of the geometry.
Polygon geometry type.
Definition: qgspolygon.h:31
void setInteriorRings(const QVector< QgsCurve *> &rings)
Sets all interior rings (takes ownership)
static Type flatType(Type type)
Returns the flat type for a WKB type.
Definition: qgswkbtypes.h:576