QGIS API Documentation 3.99.0-Master (26c88405ac0)
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
24SIP_IF_MODULE( HAVE_SFCGAL_SIP )
25
26#include "qgis_core.h"
27#include "qgis_sip.h"
28#include "qgsabstractgeometry.h"
29#include "qgslinestring.h"
30#include "qgspoint.h"
31#include "qgssfcgalengine.h"
32
33#include <QtGui/qmatrix4x4.h>
34
43class CORE_EXPORT QgsSfcgalGeometry
44{
45 public:
47 QgsSfcgalGeometry();
48
54 SIP_SKIP QgsSfcgalGeometry( sfcgal::shared_geom sfcgalGeom );
55
63 QgsSfcgalGeometry( const QgsAbstractGeometry *qgsGeom ) SIP_THROW( QgsSfcgalException );
64
70 QgsSfcgalGeometry( const QgsAbstractGeometry &qgsGeom ) SIP_THROW( QgsSfcgalException );
71
77 QgsSfcgalGeometry( const QgsGeometry &qgsGeom ) SIP_THROW( QgsSfcgalException );
78
84 QgsSfcgalGeometry( const QString &wkt ) SIP_THROW( QgsSfcgalException );
85
91 QgsSfcgalGeometry( const QgsSfcgalGeometry &otherGeom ) SIP_THROW( QgsSfcgalException );
92
96 QgsSfcgalGeometry &operator=( const QgsSfcgalGeometry &other ) = default;
97
102 SIP_SKIP sfcgal::shared_geom sfcgalGeometry() const { return mSfcgalGeom; }
103
110 std::unique_ptr<QgsAbstractGeometry> asQgisGeometry() const SIP_THROW( QgsSfcgalException );
111
120 Qgis::WkbType wkbType() const SIP_THROW( QgsSfcgalException );
121
131 QString geometryType() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException ) SIP_HOLDGIL;
132
136 std::unique_ptr<QgsSfcgalGeometry> clone() const;
137
145 static std::unique_ptr<QgsSfcgalGeometry> fromWkb( const QgsConstWkbPtr &wkbPtr ) SIP_THROW( QgsSfcgalException );
146
155 QByteArray asWkb( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const SIP_THROW( QgsSfcgalException );
156
164 static std::unique_ptr<QgsSfcgalGeometry> fromWkt( const QString &wkt ) SIP_THROW( QgsSfcgalException );
165
174 QString asWkt( int precision = -1 ) const SIP_THROW( QgsSfcgalException );
175
186 std::unique_ptr<QgsSfcgalGeometry> boundary() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
187
197 bool operator==( const QgsSfcgalGeometry &other ) const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
198
208 bool operator!=( const QgsSfcgalGeometry &other ) const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
209
221 bool fuzzyEqual( const QgsSfcgalGeometry &other, double epsilon ) const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
222
233 int dimension() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
234
246 int partCount() const SIP_THROW( QgsSfcgalException );
247
258 bool addZValue( double zValue = 0 ) SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
259
270 bool addMValue( double mValue = 0 ) SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
271
281 bool dropZValue() SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
282
292 bool dropMValue() SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
293
302 void swapXy() SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
303
310 bool isValid() const SIP_THROW( QgsSfcgalException );
311
318 bool isEmpty() const SIP_THROW( QgsSfcgalException );
319
329 double area( bool withDiscretization = false ) const SIP_THROW( QgsSfcgalException );
330
342 double volume( bool withDiscretization = false ) const SIP_THROW( QgsSfcgalException );
343
355 double length() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
356
369 bool isSimple() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
370
381 QgsPoint centroid() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
382
394 std::unique_ptr<QgsSfcgalGeometry> translate( const QgsVector3D &translation ) const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
395
405 std::unique_ptr<QgsSfcgalGeometry> scale( const QgsVector3D &scaleFactor, const QgsPoint &center = QgsPoint() ) const SIP_THROW( QgsSfcgalException );
406
416 std::unique_ptr<QgsSfcgalGeometry> rotate2D( double angle, const QgsPoint &center ) const SIP_THROW( QgsSfcgalException );
417
428 std::unique_ptr<QgsSfcgalGeometry> rotate3D( double angle, const QgsVector3D &axisVector, const QgsPoint &center = QgsPoint() ) const SIP_THROW( QgsSfcgalException );
429
440 std::unique_ptr<QgsSfcgalGeometry> transform( const QMatrix4x4 &mat ) const SIP_THROW( QgsSfcgalException );
441
450 bool intersects( const QgsAbstractGeometry *otherGeom ) const SIP_THROW( QgsSfcgalException );
451
460 bool intersects( const QgsSfcgalGeometry &otherGeom ) const SIP_THROW( QgsSfcgalException );
461
470 std::unique_ptr<QgsSfcgalGeometry> intersection( const QgsAbstractGeometry *otherGeom ) const SIP_THROW( QgsSfcgalException );
471
480 std::unique_ptr<QgsSfcgalGeometry> intersection( const QgsSfcgalGeometry &otherGeom ) const SIP_THROW( QgsSfcgalException );
481
490 std::unique_ptr<QgsSfcgalGeometry> combine( const QVector<QgsAbstractGeometry *> &geomList ) const SIP_THROW( QgsSfcgalException );
491
500 std::unique_ptr<QgsSfcgalGeometry> difference( const QgsAbstractGeometry *otherGeom ) const SIP_THROW( QgsSfcgalException );
501
510 std::unique_ptr<QgsSfcgalGeometry> difference( const QgsSfcgalGeometry &otherGeom ) const SIP_THROW( QgsSfcgalException );
511
518 std::unique_ptr<QgsSfcgalGeometry> triangulate() const SIP_THROW( QgsSfcgalException );
519
526 std::unique_ptr<QgsSfcgalGeometry> convexHull() const SIP_THROW( QgsSfcgalException );
527
537 std::unique_ptr<QgsSfcgalGeometry> envelope() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
538
549 bool covers( const QgsSfcgalGeometry &otherGeom ) const SIP_THROW( QgsSfcgalException );
550
564 std::unique_ptr<QgsSfcgalGeometry> buffer3D( double radius, int segments, Qgis::JoinStyle3D joinStyle3D ) const SIP_THROW( QgsSfcgalException );
565
578 std::unique_ptr<QgsSfcgalGeometry> buffer2D( double radius, int segments, Qgis::JoinStyle joinStyle ) const SIP_THROW( QgsSfcgalException );
579
592 std::unique_ptr<QgsSfcgalGeometry> simplify( double tolerance, bool preserveTopology ) const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
593
603 std::unique_ptr<QgsSfcgalGeometry> extrude( const QgsVector3D &extrusion ) const SIP_THROW( QgsSfcgalException );
604
615 std::unique_ptr<QgsSfcgalGeometry> approximateMedialAxis() const SIP_THROW( QgsSfcgalException );
616
617 // ============= PRIMITIVE
618
625 SIP_SKIP QgsSfcgalGeometry( sfcgal::shared_prim sfcgalPrim, sfcgal::primitiveType type );
626
633 static std::unique_ptr<QgsSfcgalGeometry> createCube( double size ) SIP_THROW( QgsSfcgalException );
634
643 QList<std::pair<QString, QString>> primitiveParameters() const SIP_THROW( QgsSfcgalException );
644
652 QVariant primitiveParameter( const QString &name ) const SIP_THROW( QgsSfcgalException );
653
662 void primitiveSetParameter( const QString &name, const QVariant &value ) SIP_THROW( QgsSfcgalException );
663
670 std::unique_ptr<QgsSfcgalGeometry> primitiveAsPolyhedralSurface() const SIP_THROW( QgsSfcgalException );
671
678 QMatrix4x4 primitiveTransform() const SIP_THROW( QgsSfcgalException );
679
680 protected:
681
685 void clearCache() const;
686
687 private:
689 sfcgal::shared_geom workingGeom() const;
690
691 sfcgal::shared_geom mSfcgalGeom;
692 bool mIsPrimitive = false;
693
694#if SFCGAL_VERSION >= SFCGAL_MAKE_VERSION( 2, 3, 0 )
695 void setPrimitiveTranslate( const QgsVector3D &translation );
696 void setPrimitiveScale( const QgsVector3D &scaleFactor, const QgsPoint &center );
697 void setPrimitiveRotation( double angle, const QgsVector3D &axisVector, const QgsPoint &center );
698
699 sfcgal::shared_prim mSfcgalPrim;
700 sfcgal::primitiveType mPrimType;
701 QMatrix4x4 mPrimTransform;
702#endif
703};
704
705
706#endif // QGSSGCGAL_GEOMETRY_H
707#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