QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 
41 
48  QgsTriangle( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p3 ) SIP_HOLDGIL;
49 
56  explicit QgsTriangle( const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3 ) SIP_HOLDGIL;
57 
64  explicit QgsTriangle( QPointF p1, QPointF p2, QPointF p3 ) SIP_HOLDGIL;
65 
66  bool operator==( const QgsTriangle &other ) const SIP_HOLDGIL;
67  bool operator!=( const QgsTriangle &other ) const SIP_HOLDGIL;
68 
69  QString geometryType() const override SIP_HOLDGIL;
70  QgsTriangle *clone() const override SIP_FACTORY;
71  void clear() override;
72 
73  bool fromWkb( QgsConstWkbPtr &wkbPtr ) override;
74 
75  bool fromWkt( const QString &wkt ) override;
76 
77  // inherited: QString asWkt( int precision = 17 ) const;
78  // inherited (as a polygon): QDomElement asGML2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
79  QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
80 
81  QgsPolygon *surfaceToPolygon() const override SIP_FACTORY;
82 
83  QgsCurvePolygon *toCurveType() const override SIP_FACTORY;
84 
86  void addInteriorRing( QgsCurve *ring SIP_TRANSFER ) override;
87 
92  void setInteriorRings( const QVector< QgsCurve *> &rings ) = delete;
94  bool deleteVertex( QgsVertexId position ) override;
96  bool insertVertex( QgsVertexId position, const QgsPoint &vertex ) override;
97  bool moveVertex( QgsVertexId vId, const QgsPoint &newPos ) override;
98 
99  void setExteriorRing( QgsCurve *ring SIP_TRANSFER ) override;
100 
101  QgsCurve *boundary() const override SIP_FACTORY;
102 
103  // inherited: double pointDistanceToBoundary( double x, double y ) const;
104 
110  QgsPoint vertexAt( int atVertex ) const SIP_HOLDGIL;
111 
127  QVector<double> lengths() const SIP_HOLDGIL;
128 
144  QVector<double> angles() const SIP_HOLDGIL;
145 
167  bool isDegenerate() SIP_HOLDGIL;
168 
187  bool isIsocele( double lengthTolerance = 0.0001 ) const SIP_HOLDGIL;
188 
207  bool isEquilateral( double lengthTolerance = 0.0001 ) const SIP_HOLDGIL;
208 
227  bool isRight( double angleTolerance = 0.0001 ) const SIP_HOLDGIL;
228 
247  bool isScalene( double lengthTolerance = 0.0001 ) const SIP_HOLDGIL;
248 
264  QVector<QgsLineString> altitudes() const SIP_HOLDGIL;
265 
281  QVector<QgsLineString> medians() const SIP_HOLDGIL;
282 
299  QVector<QgsLineString> bisectors( double lengthTolerance = 0.0001 ) const SIP_HOLDGIL;
300 
316  QgsTriangle medial() const SIP_HOLDGIL;
317 
334  QgsPoint orthocenter( double lengthTolerance = 0.0001 ) const SIP_HOLDGIL;
335 
351  QgsPoint circumscribedCenter() const SIP_HOLDGIL;
352 
368  double circumscribedRadius() const SIP_HOLDGIL;
369 
385  QgsCircle circumscribedCircle() const SIP_HOLDGIL;
386 
403  QgsPoint inscribedCenter() const SIP_HOLDGIL;
404 
420  double inscribedRadius() const SIP_HOLDGIL;
421 
437  QgsCircle inscribedCircle() const SIP_HOLDGIL;
438 
439 #ifndef SIP_RUN
440 
448  inline const QgsTriangle *cast( const QgsAbstractGeometry *geom ) const
449  {
450  if ( geom && QgsWkbTypes::flatType( geom->wkbType() ) == QgsWkbTypes::Triangle )
451  return static_cast<const QgsTriangle *>( geom );
452  return nullptr;
453  }
454 #endif
455 
457 
458 
459 };
460 #endif // QGSTRIANGLE_H
QgsCurve
Abstract base class for curved geometry type.
Definition: qgscurve.h:36
qgspolygon.h
QgsPolygon::clear
void clear() override
Clears the geometry, ie reset it to a null geometry.
Definition: qgspolygon.cpp:59
QgsWkbTypes::Triangle
@ Triangle
Definition: qgswkbtypes.h:75
QgsCircle
Circle geometry type.
Definition: qgscircle.h:44
QgsPolygon
Polygon geometry type.
Definition: qgspolygon.h:34
qgslinestring.h
QgsPolygon::fromWkb
bool fromWkb(QgsConstWkbPtr &wkb) override
Sets the geometry from a WKB string.
Definition: qgspolygon.cpp:65
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:38
QgsPolygon::clone
QgsPolygon * clone() const override
Clones the geometry by performing a deep copy.
Definition: qgspolygon.cpp:54
QgsWkbTypes::flatType
static Type flatType(Type type) SIP_HOLDGIL
Returns the flat type for a WKB type.
Definition: qgswkbtypes.h:702
QgsCurvePolygon
Curve polygon geometry type.
Definition: qgscurvepolygon.h:35
QgsPolygon::setExteriorRing
void setExteriorRing(QgsCurve *ring) override
Sets the exterior ring of the polygon.
Definition: qgspolygon.cpp:219
QgsPolygon::toCurveType
QgsCurvePolygon * toCurveType() const override
Returns the geometry converted to the more generic curve type QgsCurvePolygon.
Definition: qgspolygon.cpp:316
QgsCurvePolygon::deleteVertex
bool deleteVertex(QgsVertexId position) override
Deletes a vertex within the geometry.
Definition: qgscurvepolygon.cpp:1077
QgsLineString
Line string geometry type, with support for z-dimension and m-values.
Definition: qgslinestring.h:44
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
precision
int precision
Definition: qgswfsgetfeature.cpp:49
QgsCurvePolygon::insertVertex
bool insertVertex(QgsVertexId position, const QgsPoint &vertex) override
Inserts a vertex into the geometry.
Definition: qgscurvepolygon.cpp:1029
SIP_HOLDGIL
#define SIP_HOLDGIL
Definition: qgis_sip.h:157
QgsAbstractGeometry::wkbType
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns the WKB type of the geometry.
Definition: qgsabstractgeometry.h:193
QgsAbstractGeometry::AxisOrder
AxisOrder
Axis order for GML generation.
Definition: qgsabstractgeometry.h:133
QgsConstWkbPtr
Definition: qgswkbptr.h:128
QgsCurvePolygon::operator!=
bool operator!=(const QgsAbstractGeometry &other) const override
Definition: qgscurvepolygon.cpp:134
qgscircle.h
qgis_sip.h
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsCurvePolygon::operator==
bool operator==(const QgsAbstractGeometry &other) const override
Definition: qgscurvepolygon.cpp:97
QgsCurvePolygon::moveVertex
bool moveVertex(QgsVertexId position, const QgsPoint &newPos) override
Moves a vertex within the geometry.
Definition: qgscurvepolygon.cpp:1055
QgsAbstractGeometry
Abstract base class for all geometries.
Definition: qgsabstractgeometry.h:74
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:44
QgsCurvePolygon::fromWkt
bool fromWkt(const QString &wkt) override
Sets the geometry from a WKT string.
Definition: qgscurvepolygon.cpp:207
QgsTriangle::cast
const QgsTriangle * cast(const QgsAbstractGeometry *geom) const
Cast the geom to a QgsTriangle.
Definition: qgstriangle.h:448
QgsCurvePolygon::asGml3
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.
Definition: qgscurvepolygon.cpp:389
QgsPolygon::surfaceToPolygon
QgsPolygon * surfaceToPolygon() const override
Gets a polygon representation of this surface.
Definition: qgspolygon.cpp:311
QgsVertexId
Utility class for identifying a unique vertex within a geometry.
Definition: qgsabstractgeometry.h:1059
QgsTriangle::setInteriorRings
void setInteriorRings(const QVector< QgsCurve * > &rings)=delete
Inherited method not used.
QgsPolygon::createEmptyWithSameType
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:47
QgsPolygon::addInteriorRing
void addInteriorRing(QgsCurve *ring) override
Adds an interior ring to the geometry (takes ownership)
Definition: qgspolygon.cpp:188
QgsPolygon::boundary
QgsAbstractGeometry * boundary() const override
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
Definition: qgspolygon.cpp:254
QgsPolygon::geometryType
QString geometryType() const override SIP_HOLDGIL
Returns a unique string representing the geometry type.
Definition: qgspolygon.cpp:42
QgsTriangle
Triangle geometry type.
Definition: qgstriangle.h:34