QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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
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 QMatrix4x4 &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
618 std::unique_ptr<QgsSfcgalGeometry> approximateMedialAxis() const SIP_THROW( QgsSfcgalException );
619
620 // ============= PRIMITIVE
621
628 SIP_SKIP QgsSfcgalGeometry( sfcgal::shared_prim sfcgalPrim, sfcgal::primitiveType type );
629
636 static std::unique_ptr<QgsSfcgalGeometry> createCube( double size ) SIP_THROW( QgsSfcgalException );
637
646 QList<std::pair<QString, QString>> primitiveParameters() const SIP_THROW( QgsSfcgalException );
647
655 QVariant primitiveParameter( const QString &name ) const SIP_THROW( QgsSfcgalException );
656
665 void primitiveSetParameter( const QString &name, const QVariant &value ) SIP_THROW( QgsSfcgalException );
666
673 std::unique_ptr<QgsSfcgalGeometry> primitiveAsPolyhedralSurface() const SIP_THROW( QgsSfcgalException );
674
681 QMatrix4x4 primitiveTransform() const SIP_THROW( QgsSfcgalException );
682
683 protected:
684
688 void clearCache() const;
689
690 private:
692 sfcgal::shared_geom workingGeom() const;
693
694 sfcgal::shared_geom mSfcgalGeom;
695 bool mIsPrimitive = false;
696
697#if SFCGAL_VERSION_NUM >= SFCGAL_MAKE_VERSION( 2, 3, 0 )
698 void setPrimitiveTranslate( const QgsVector3D &translation );
699 void setPrimitiveScale( const QgsVector3D &scaleFactor, const QgsPoint &center );
700 void setPrimitiveRotation( double angle, const QgsVector3D &axisVector, const QgsPoint &center );
701
702 sfcgal::shared_prim mSfcgalPrim;
703 sfcgal::primitiveType mPrimType;
704 QMatrix4x4 mPrimTransform;
705#endif
706};
707
708
709#endif // QGSSGCGAL_GEOMETRY_H
710#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