QGIS API Documentation 3.99.0-Master (357b655ed83)
Loading...
Searching...
No Matches
qgssfcgalgeometry.h
Go to the documentation of this file.
1/***************************************************************************
2 qgssfcgalGeometry.h
3 -------------------
4 begin : May 2025
5 copyright : (C) 2025 by Oslandia
6 email : benoit dot de dot mezzo at oslandia dot com
7 email : jean dot felder at oslandia dot com
8 email : loic dot bartoletti at oslandia dot com
9 ***************************************************************************/
10
11/***************************************************************************
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 * *
18 ***************************************************************************/
19
20#ifdef WITH_SFCGAL
21#ifndef QGSSGCGAL_GEOMETRY_H
22#define QGSSGCGAL_GEOMETRY_H
23
24#include "qgis_core.h"
25#include "qgis_sip.h"
26
27SIP_IF_MODULE( HAVE_SFCGAL_SIP )
28
29#include "qgsabstractgeometry.h"
30#include "qgslinestring.h"
31#include "qgspoint.h"
32#include "qgssfcgalengine.h"
33
34#include <QtGui/qmatrix4x4.h>
35
44class CORE_EXPORT QgsSfcgalGeometry
45{
46 public:
48 QgsSfcgalGeometry();
49
55 SIP_SKIP QgsSfcgalGeometry( sfcgal::shared_geom sfcgalGeom );
56
64 QgsSfcgalGeometry( const QgsAbstractGeometry *qgsGeom ) SIP_THROW( QgsSfcgalException );
65
71 QgsSfcgalGeometry( const QgsAbstractGeometry &qgsGeom ) SIP_THROW( QgsSfcgalException );
72
78 QgsSfcgalGeometry( const QgsGeometry &qgsGeom ) SIP_THROW( QgsSfcgalException );
79
85 QgsSfcgalGeometry( const QString &wkt ) SIP_THROW( QgsSfcgalException );
86
92 QgsSfcgalGeometry( const QgsSfcgalGeometry &otherGeom ) SIP_THROW( QgsSfcgalException );
93
97 QgsSfcgalGeometry &operator=( const QgsSfcgalGeometry &other ) = default;
98
103 SIP_SKIP sfcgal::shared_geom sfcgalGeometry() const { return mSfcgalGeom; }
104
111 std::unique_ptr<QgsAbstractGeometry> asQgisGeometry() const SIP_THROW( QgsSfcgalException );
112
121 Qgis::WkbType wkbType() const SIP_THROW( QgsSfcgalException );
122
132 QString geometryType() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException ) SIP_HOLDGIL;
133
137 std::unique_ptr<QgsSfcgalGeometry> clone() const;
138
146 static std::unique_ptr<QgsSfcgalGeometry> fromWkb( const QgsConstWkbPtr &wkbPtr ) SIP_THROW( QgsSfcgalException );
147
156 QByteArray asWkb( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const SIP_THROW( QgsSfcgalException );
157
165 static std::unique_ptr<QgsSfcgalGeometry> fromWkt( const QString &wkt ) SIP_THROW( QgsSfcgalException );
166
175 QString asWkt( int precision = -1 ) const SIP_THROW( QgsSfcgalException );
176
187 std::unique_ptr<QgsSfcgalGeometry> boundary() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
188
198 bool operator==( const QgsSfcgalGeometry &other ) const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
199
209 bool operator!=( const QgsSfcgalGeometry &other ) const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
210
222 bool fuzzyEqual( const QgsSfcgalGeometry &other, double epsilon ) const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
223
234 int dimension() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
235
247 int partCount() const SIP_THROW( QgsSfcgalException );
248
259 bool addZValue( double zValue = 0 ) SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
260
271 bool addMValue( double mValue = 0 ) SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
272
282 bool dropZValue() SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
283
293 bool dropMValue() SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
294
303 void swapXy() SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
304
311 bool isValid() const SIP_THROW( QgsSfcgalException );
312
319 bool isEmpty() const SIP_THROW( QgsSfcgalException );
320
330 double area( bool withDiscretization = false ) const SIP_THROW( QgsSfcgalException );
331
343 double volume( bool withDiscretization = false ) const SIP_THROW( QgsSfcgalException );
344
356 double length() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
357
370 bool isSimple() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
371
382 QgsPoint centroid() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
383
395 std::unique_ptr<QgsSfcgalGeometry> translate( const QgsVector3D &translation ) const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
396
406 std::unique_ptr<QgsSfcgalGeometry> scale( const QgsVector3D &scaleFactor, const QgsPoint &center = QgsPoint() ) const SIP_THROW( QgsSfcgalException );
407
417 std::unique_ptr<QgsSfcgalGeometry> rotate2D( double angle, const QgsPoint &center ) const SIP_THROW( QgsSfcgalException );
418
429 std::unique_ptr<QgsSfcgalGeometry> rotate3D( double angle, const QgsVector3D &axisVector, const QgsPoint &center = QgsPoint() ) const SIP_THROW( QgsSfcgalException );
430
441 std::unique_ptr<QgsSfcgalGeometry> transform( const QMatrix4x4 &mat ) const SIP_THROW( QgsSfcgalException );
442
451 bool intersects( const QgsAbstractGeometry *otherGeom ) const SIP_THROW( QgsSfcgalException );
452
461 bool intersects( const QgsSfcgalGeometry &otherGeom ) const SIP_THROW( QgsSfcgalException );
462
471 std::unique_ptr<QgsSfcgalGeometry> intersection( const QgsAbstractGeometry *otherGeom ) const SIP_THROW( QgsSfcgalException );
472
481 std::unique_ptr<QgsSfcgalGeometry> intersection( const QgsSfcgalGeometry &otherGeom ) const SIP_THROW( QgsSfcgalException );
482
491 std::unique_ptr<QgsSfcgalGeometry> combine( const QVector<QgsAbstractGeometry *> &geomList ) const SIP_THROW( QgsSfcgalException );
492
501 std::unique_ptr<QgsSfcgalGeometry> difference( const QgsAbstractGeometry *otherGeom ) const SIP_THROW( QgsSfcgalException );
502
511 std::unique_ptr<QgsSfcgalGeometry> difference( const QgsSfcgalGeometry &otherGeom ) const SIP_THROW( QgsSfcgalException );
512
519 std::unique_ptr<QgsSfcgalGeometry> triangulate() const SIP_THROW( QgsSfcgalException );
520
527 std::unique_ptr<QgsSfcgalGeometry> convexHull() const SIP_THROW( QgsSfcgalException );
528
538 std::unique_ptr<QgsSfcgalGeometry> envelope() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
539
550 bool covers( const QgsSfcgalGeometry &otherGeom ) const SIP_THROW( QgsSfcgalException );
551
565 std::unique_ptr<QgsSfcgalGeometry> buffer3D( double radius, int segments, Qgis::JoinStyle3D joinStyle3D ) const SIP_THROW( QgsSfcgalException );
566
579 std::unique_ptr<QgsSfcgalGeometry> buffer2D( double radius, int segments, Qgis::JoinStyle joinStyle ) const SIP_THROW( QgsSfcgalException );
580
593 std::unique_ptr<QgsSfcgalGeometry> simplify( double tolerance, bool preserveTopology ) const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
594
604 std::unique_ptr<QgsSfcgalGeometry> extrude( const QgsVector3D &extrusion ) const SIP_THROW( QgsSfcgalException );
605
616 std::unique_ptr<QgsSfcgalGeometry> approximateMedialAxis() const SIP_THROW( QgsSfcgalException );
617
618 // ============= PRIMITIVE
619
626 SIP_SKIP QgsSfcgalGeometry( sfcgal::shared_prim sfcgalPrim, sfcgal::primitiveType type );
627
634 static std::unique_ptr<QgsSfcgalGeometry> createCube( double size ) SIP_THROW( QgsSfcgalException );
635
644 QList<std::pair<QString, QString>> primitiveParameters() const SIP_THROW( QgsSfcgalException );
645
653 QVariant primitiveParameter( const QString &name ) const SIP_THROW( QgsSfcgalException );
654
663 void primitiveSetParameter( const QString &name, const QVariant &value ) SIP_THROW( QgsSfcgalException );
664
671 std::unique_ptr<QgsSfcgalGeometry> primitiveAsPolyhedralSurface() const SIP_THROW( QgsSfcgalException );
672
679 QMatrix4x4 primitiveTransform() const SIP_THROW( QgsSfcgalException );
680
681 protected:
682
686 void clearCache() const;
687
688 private:
690 sfcgal::shared_geom workingGeom() const;
691
692 sfcgal::shared_geom mSfcgalGeom;
693 bool mIsPrimitive = false;
694
695#if SFCGAL_VERSION_NUM >= SFCGAL_MAKE_VERSION( 2, 3, 0 )
696 void setPrimitiveTranslate( const QgsVector3D &translation );
697 void setPrimitiveScale( const QgsVector3D &scaleFactor, const QgsPoint &center );
698 void setPrimitiveRotation( double angle, const QgsVector3D &axisVector, const QgsPoint &center );
699
700 sfcgal::shared_prim mSfcgalPrim;
701 sfcgal::primitiveType mPrimType;
702 QMatrix4x4 mPrimTransform;
703#endif
704};
705
706
707#endif // QGSSGCGAL_GEOMETRY_H
708#endif
#define SIP_IF_MODULE(condition)
Definition qgis_sip.h:28
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_HOLDGIL
Definition qgis_sip.h:179
#define SIP_THROW(name,...)
Definition qgis_sip.h:211