QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
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 : lituus at free dot fr
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 "qgscircle.h"
24#include "qgslinestring.h"
25#include "qgspolygon.h"
26
32class CORE_EXPORT QgsTriangle : public QgsPolygon
33{
34 public:
35 // clang-format off
40 // clang-format on
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 QgsAbstractGeometry &other ) const override SIP_HOLDGIL;
67 bool operator!=( const QgsAbstractGeometry &other ) const override 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; // cppcheck-suppress duplInheritedMember
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
105 // override QgsPolygon method to avoid unwanted overloaded-virtual warning caused by int variant of vertexAt defined below
106 QgsPoint vertexAt( QgsVertexId id ) const override;
107
113 QgsPoint vertexAt( int atVertex ) const SIP_HOLDGIL;
114
130 QVector<double> lengths() const SIP_HOLDGIL;
131
147 QVector<double> angles() const SIP_HOLDGIL;
148
170 bool isDegenerate() const SIP_HOLDGIL;
171
190 bool isIsocele( double lengthTolerance = 0.0001 ) const SIP_HOLDGIL;
191
210 bool isEquilateral( double lengthTolerance = 0.0001 ) const SIP_HOLDGIL;
211
230 bool isRight( double angleTolerance = 0.0001 ) const SIP_HOLDGIL;
231
250 bool isScalene( double lengthTolerance = 0.0001 ) const SIP_HOLDGIL;
251
267 QVector<QgsLineString> altitudes() const SIP_HOLDGIL;
268
284 QVector<QgsLineString> medians() const SIP_HOLDGIL;
285
302 QVector<QgsLineString> bisectors( double lengthTolerance = 0.0001 ) const SIP_HOLDGIL;
303
320
337 QgsPoint orthocenter( double lengthTolerance = 0.0001 ) const SIP_HOLDGIL;
338
355
371 double circumscribedRadius() const SIP_HOLDGIL;
372
389
407
423 double inscribedRadius() const SIP_HOLDGIL;
424
441
442#ifndef SIP_RUN
443
452 inline static const QgsTriangle *cast( const QgsAbstractGeometry *geom ) // cppcheck-suppress duplInheritedMember
453 {
454 if ( geom && QgsWkbTypes::flatType( geom->wkbType() ) == Qgis::WkbType::Triangle )
455 return static_cast<const QgsTriangle *>( geom );
456 return nullptr;
457 }
458
467 inline static QgsTriangle *cast( QgsAbstractGeometry *geom ) // cppcheck-suppress duplInheritedMember
468 {
469 if ( geom && QgsWkbTypes::flatType( geom->wkbType() ) == Qgis::WkbType::Triangle )
470 return static_cast<QgsTriangle *>( geom );
471 return nullptr;
472 }
473#endif
474
476
477
478};
479#endif // QGSTRIANGLE_H
@ Triangle
Triangle.
Definition qgis.h:299
Abstract base class for all geometries.
AxisOrder
Axis order for GML generation.
@ XY
X comes before Y (or lon before lat).
Qgis::WkbType wkbType() const
Returns the WKB type of the geometry.
Circle geometry type.
Definition qgscircle.h:46
A const WKB pointer.
Definition qgswkbptr.h:211
bool moveVertex(QgsVertexId position, const QgsPoint &newPos) override
Moves a vertex within the geometry.
bool operator!=(const QgsAbstractGeometry &other) const override
bool insertVertex(QgsVertexId position, const QgsPoint &vertex) override
Inserts a vertex into the geometry.
bool fromWkt(const QString &wkt) override
Sets the geometry from a WKT string.
bool deleteVertex(QgsVertexId position) override
Deletes a vertex within the geometry.
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.
bool operator==(const QgsAbstractGeometry &other) const override
Abstract base class for curved geometry type.
Definition qgscurve.h:36
Line string geometry type, with support for z-dimension and m-values.
Represents a 2D point.
Definition qgspointxy.h:62
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:53
QgsCurvePolygon * toCurveType() const override
Returns the geometry converted to the more generic curve type QgsCurvePolygon.
void setExteriorRing(QgsCurve *ring) override
Sets the exterior ring of the polygon.
void addInteriorRing(QgsCurve *ring) override
Adds an interior ring to the geometry (takes ownership).
QgsPolygon * clone() const override
Clones the geometry by performing a deep copy.
void clear() override
Clears the geometry, ie reset it to a null geometry.
QString geometryType() const override
Returns a unique string representing the geometry type.
QgsAbstractGeometry * boundary() const override
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
friend class QgsCurvePolygon
Definition qgspolygon.h:145
QgsPolygon()
Constructor for an empty polygon geometry.
QgsPolygon * createEmptyWithSameType() const override
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
bool fromWkb(QgsConstWkbPtr &wkb) override
Sets the geometry from a WKB string.
QgsPolygon * surfaceToPolygon() const override
Gets a polygon representation of this surface.
Triangle geometry type.
Definition qgstriangle.h:33
QVector< double > angles() const
Returns the three angles of the triangle.
static const QgsTriangle * cast(const QgsAbstractGeometry *geom)
Cast the geom to a QgsTriangle.
QVector< QgsLineString > altitudes() const
An altitude is a segment (defined by a QgsLineString) from a vertex to the opposite side (or,...
QgsCircle inscribedCircle() const
Inscribed circle of the triangle.
QVector< double > lengths() const
Returns the three lengths of the triangle.
QgsPoint circumscribedCenter() const
Center of the circumscribed circle of the triangle.
void setInteriorRings(const QVector< QgsCurve * > &rings)=delete
Inherited method not used.
QgsPoint orthocenter(double lengthTolerance=0.0001) const
An orthocenter is the point of intersection of the altitudes of a triangle.
QgsTriangle medial() const
Medial (or midpoint) triangle of a triangle ABC is the triangle with vertices at the midpoints of the...
bool isEquilateral(double lengthTolerance=0.0001) const
Is the triangle equilateral (three sides with the same length)?
QgsPoint inscribedCenter() const
Center of the inscribed circle of the triangle.
QgsTriangle()
Constructor for an empty triangle geometry.
bool isIsocele(double lengthTolerance=0.0001) const
Is the triangle isocele (two sides with the same length)?
bool isDegenerate() const
Convenient method checking if the geometry is degenerate (have duplicate or colinear point(s)).
bool isScalene(double lengthTolerance=0.0001) const
Is the triangle scalene (all sides have different lengths)?
double circumscribedRadius() const
Radius of the circumscribed circle of the triangle.
static QgsTriangle * cast(QgsAbstractGeometry *geom)
Cast the geom to a QgsTriangle.
QVector< QgsLineString > bisectors(double lengthTolerance=0.0001) const
The segment (defined by a QgsLineString) returned bisect the angle of a vertex to the opposite side.
bool isRight(double angleTolerance=0.0001) const
Is the triangle right-angled?
QgsCircle circumscribedCircle() const
Circumscribed circle of the triangle.
double inscribedRadius() const
Radius of the inscribed circle of the triangle.
QVector< QgsLineString > medians() const
A median is a segment (defined by a QgsLineString) from a vertex to the midpoint of the opposite side...
QgsPoint vertexAt(QgsVertexId id) const override
Returns the point corresponding to a specified vertex id.
static Qgis::WkbType flatType(Qgis::WkbType type)
Returns the flat type for a WKB type.
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_HOLDGIL
Definition qgis_sip.h:178
#define SIP_FACTORY
Definition qgis_sip.h:83
Utility class for identifying a unique vertex within a geometry.
Definition qgsvertexid.h:34