QGIS API Documentation 4.1.0-Master (376402f9aeb)
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 "qgsmatrix4x4.h"
32#include "qgspoint.h"
33#include "qgssfcgalengine.h"
34
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
123 // clang-format off
133 QString geometryType() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException ) SIP_HOLDGIL;
134 // clang-format on
135
139 std::unique_ptr<QgsSfcgalGeometry> clone() const;
140
148 static std::unique_ptr<QgsSfcgalGeometry> fromWkb( const QgsConstWkbPtr &wkbPtr ) SIP_THROW( QgsSfcgalException );
149
158 QByteArray asWkb( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const SIP_THROW( QgsSfcgalException );
159
167 static std::unique_ptr<QgsSfcgalGeometry> fromWkt( const QString &wkt ) SIP_THROW( QgsSfcgalException );
168
177 QString asWkt( int precision = -1 ) const SIP_THROW( QgsSfcgalException );
178
189 std::unique_ptr<QgsSfcgalGeometry> boundary() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
190
200 bool operator==( const QgsSfcgalGeometry &other ) const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
201
211 bool operator!=( const QgsSfcgalGeometry &other ) const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
212
224 bool fuzzyEqual( const QgsSfcgalGeometry &other, double epsilon ) const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
225
236 int dimension() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
237
249 int partCount() const SIP_THROW( QgsSfcgalException );
250
261 bool addZValue( double zValue = 0 ) SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
262
273 bool addMValue( double mValue = 0 ) SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
274
284 bool dropZValue() SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
285
295 bool dropMValue() SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
296
305 void swapXy() SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
306
313 bool isValid() const SIP_THROW( QgsSfcgalException );
314
321 bool isEmpty() const SIP_THROW( QgsSfcgalException );
322
332 double area( bool withDiscretization = false ) const SIP_THROW( QgsSfcgalException );
333
345 double volume( bool withDiscretization = false ) const SIP_THROW( QgsSfcgalException );
346
358 double length() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
359
372 bool isSimple() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
373
384 QgsPoint centroid() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
385
397 std::unique_ptr<QgsSfcgalGeometry> translate( const QgsVector3D &translation ) const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
398
408 std::unique_ptr<QgsSfcgalGeometry> scale( const QgsVector3D &scaleFactor, const QgsPoint &center = QgsPoint() ) const SIP_THROW( QgsSfcgalException );
409
419 std::unique_ptr<QgsSfcgalGeometry> rotate2D( double angle, const QgsPoint &center ) const SIP_THROW( QgsSfcgalException );
420
431 std::unique_ptr<QgsSfcgalGeometry> rotate3D( double angle, const QgsVector3D &axisVector, const QgsPoint &center = QgsPoint() ) const SIP_THROW( QgsSfcgalException );
432
443 std::unique_ptr<QgsSfcgalGeometry> transform( const QgsMatrix4x4 &mat ) const SIP_THROW( QgsSfcgalException );
444
453 bool intersects( const QgsAbstractGeometry *otherGeom ) const SIP_THROW( QgsSfcgalException );
454
463 bool intersects( const QgsSfcgalGeometry &otherGeom ) const SIP_THROW( QgsSfcgalException );
464
473 std::unique_ptr<QgsSfcgalGeometry> intersection( const QgsAbstractGeometry *otherGeom ) const SIP_THROW( QgsSfcgalException );
474
483 std::unique_ptr<QgsSfcgalGeometry> intersection( const QgsSfcgalGeometry &otherGeom ) const SIP_THROW( QgsSfcgalException );
484
493 std::unique_ptr<QgsSfcgalGeometry> combine( const QVector<QgsAbstractGeometry *> &geomList ) const SIP_THROW( QgsSfcgalException );
494
503 std::unique_ptr<QgsSfcgalGeometry> difference( const QgsAbstractGeometry *otherGeom ) const SIP_THROW( QgsSfcgalException );
504
513 std::unique_ptr<QgsSfcgalGeometry> difference( const QgsSfcgalGeometry &otherGeom ) const SIP_THROW( QgsSfcgalException );
514
521 std::unique_ptr<QgsSfcgalGeometry> triangulate() const SIP_THROW( QgsSfcgalException );
522
529 std::unique_ptr<QgsSfcgalGeometry> convexHull() const SIP_THROW( QgsSfcgalException );
530
540 std::unique_ptr<QgsSfcgalGeometry> envelope() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
541
552 bool covers( const QgsSfcgalGeometry &otherGeom ) const SIP_THROW( QgsSfcgalException );
553
567 std::unique_ptr<QgsSfcgalGeometry> buffer3D( double radius, int segments, Qgis::JoinStyle3D joinStyle3D ) const SIP_THROW( QgsSfcgalException );
568
581 std::unique_ptr<QgsSfcgalGeometry> buffer2D( double radius, int segments, Qgis::JoinStyle joinStyle ) const SIP_THROW( QgsSfcgalException );
582
595 std::unique_ptr<QgsSfcgalGeometry> simplify( double tolerance, bool preserveTopology ) const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
596
606 std::unique_ptr<QgsSfcgalGeometry> extrude( const QgsVector3D &extrusion ) const SIP_THROW( QgsSfcgalException );
607
620 std::unique_ptr<QgsSfcgalGeometry> approximateMedialAxis( bool extendToEdges = false ) const SIP_THROW( QgsSfcgalException );
621
632 std::unique_ptr<QgsSfcgalGeometry> toSolid() const SIP_THROW( QgsSfcgalException );
633
644 std::unique_ptr<QgsSfcgalGeometry> toPolyhedralSurface() const SIP_THROW( QgsSfcgalException );
645
646 // ============= PRIMITIVE
647
654 SIP_SKIP QgsSfcgalGeometry( sfcgal::shared_prim sfcgalPrim, sfcgal::primitiveType type );
655
662 static std::unique_ptr<QgsSfcgalGeometry> createCube( double size ) SIP_THROW( QgsSfcgalException );
663
672 QList<std::pair<QString, QString>> primitiveParameters() const SIP_THROW( QgsSfcgalException );
673
681 QVariant primitiveParameter( const QString &name ) const SIP_THROW( QgsSfcgalException );
682
691 void primitiveSetParameter( const QString &name, const QVariant &value ) SIP_THROW( QgsSfcgalException );
692
699 std::unique_ptr<QgsSfcgalGeometry> primitiveAsPolyhedralSurface() const SIP_THROW( QgsSfcgalException );
700
707 QgsMatrix4x4 primitiveTransform() const SIP_THROW( QgsSfcgalException );
708
709 protected:
710
714 void clearCache() const;
715
716 private:
718 sfcgal::shared_geom workingGeom() const;
719
720 sfcgal::shared_geom mSfcgalGeom;
721 bool mIsPrimitive = false;
722
723#if SFCGAL_VERSION_NUM >= SFCGAL_MAKE_VERSION( 2, 3, 0 )
724 void setPrimitiveTranslate( const QgsVector3D &translation );
725 void setPrimitiveScale( const QgsVector3D &scaleFactor, const QgsPoint &center );
727 void setPrimitiveRotation( double angle, const QgsVector3D &axisVector, const QgsPoint &center );
728
729 sfcgal::shared_prim mSfcgalPrim;
730 sfcgal::primitiveType mPrimType;
731 QgsMatrix4x4 mPrimTransform;
732#endif
733};
734
735
736#endif // QGSSGCGAL_GEOMETRY_H
737#endif
#define SIP_IF_MODULE(condition)
Definition qgis_sip.h:27
#define SIP_SKIP
Definition qgis_sip.h:133
#define SIP_HOLDGIL
Definition qgis_sip.h:178
#define SIP_THROW(name,...)
Definition qgis_sip.h:210