QGIS API Documentation 4.1.0-Master (d6fb7a379fb)
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
337 std::unique_ptr<QgsSfcgalGeometry> geometryN( unsigned int index ) const SIP_THROW( QgsSfcgalException );
338
348 double area( bool withDiscretization = false ) const SIP_THROW( QgsSfcgalException );
349
361 double volume( bool withDiscretization = false ) const SIP_THROW( QgsSfcgalException );
362
374 double length() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
375
388 bool isSimple() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
389
400 QgsPoint centroid() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
401
413 std::unique_ptr<QgsSfcgalGeometry> translate( const QgsVector3D &translation ) const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
414
424 std::unique_ptr<QgsSfcgalGeometry> scale( const QgsVector3D &scaleFactor, const QgsPoint &center = QgsPoint() ) const SIP_THROW( QgsSfcgalException );
425
435 std::unique_ptr<QgsSfcgalGeometry> rotate2D( double angle, const QgsPoint &center ) const SIP_THROW( QgsSfcgalException );
436
447 std::unique_ptr<QgsSfcgalGeometry> rotate3D( double angle, const QgsVector3D &axisVector, const QgsPoint &center = QgsPoint() ) const SIP_THROW( QgsSfcgalException );
448
459 std::unique_ptr<QgsSfcgalGeometry> transform( const QgsMatrix4x4 &mat ) const SIP_THROW( QgsSfcgalException );
460
478 std::unique_ptr<QgsSfcgalGeometry> split3D( const QgsPoint &planePoint, const QgsVector3D &planeNormal, bool closeGeometries ) const SIP_THROW( QgsSfcgalException );
479
488 bool intersects( const QgsAbstractGeometry *otherGeom ) const SIP_THROW( QgsSfcgalException );
489
498 bool intersects( const QgsSfcgalGeometry &otherGeom ) const SIP_THROW( QgsSfcgalException );
499
508 std::unique_ptr<QgsSfcgalGeometry> intersection( const QgsAbstractGeometry *otherGeom ) const SIP_THROW( QgsSfcgalException );
509
518 std::unique_ptr<QgsSfcgalGeometry> intersection( const QgsSfcgalGeometry &otherGeom ) const SIP_THROW( QgsSfcgalException );
519
528 std::unique_ptr<QgsSfcgalGeometry> combine( const QVector<QgsAbstractGeometry *> &geomList ) const SIP_THROW( QgsSfcgalException );
529
538 std::unique_ptr<QgsSfcgalGeometry> difference( const QgsAbstractGeometry *otherGeom ) const SIP_THROW( QgsSfcgalException );
539
548 std::unique_ptr<QgsSfcgalGeometry> difference( const QgsSfcgalGeometry &otherGeom ) const SIP_THROW( QgsSfcgalException );
549
556 std::unique_ptr<QgsSfcgalGeometry> triangulate() const SIP_THROW( QgsSfcgalException );
557
564 std::unique_ptr<QgsSfcgalGeometry> convexHull() const SIP_THROW( QgsSfcgalException );
565
575 std::unique_ptr<QgsSfcgalGeometry> envelope() const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
576
587 bool covers( const QgsSfcgalGeometry &otherGeom ) const SIP_THROW( QgsSfcgalException );
588
602 std::unique_ptr<QgsSfcgalGeometry> buffer3D( double radius, int segments, Qgis::JoinStyle3D joinStyle3D ) const SIP_THROW( QgsSfcgalException );
603
616 std::unique_ptr<QgsSfcgalGeometry> buffer2D( double radius, int segments, Qgis::JoinStyle joinStyle ) const SIP_THROW( QgsSfcgalException );
617
630 std::unique_ptr<QgsSfcgalGeometry> simplify( double tolerance, bool preserveTopology ) const SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
631
641 std::unique_ptr<QgsSfcgalGeometry> extrude( const QgsVector3D &extrusion ) const SIP_THROW( QgsSfcgalException );
642
655 std::unique_ptr<QgsSfcgalGeometry> approximateMedialAxis( bool extendToEdges = false ) const SIP_THROW( QgsSfcgalException );
656
667 std::unique_ptr<QgsSfcgalGeometry> toSolid() const SIP_THROW( QgsSfcgalException );
668
679 std::unique_ptr<QgsSfcgalGeometry> toPolyhedralSurface() const SIP_THROW( QgsSfcgalException );
680
681 // ============= PRIMITIVE
682
689 SIP_SKIP QgsSfcgalGeometry( sfcgal::shared_prim sfcgalPrim, sfcgal::primitiveType type );
690
703 static std::unique_ptr<QgsSfcgalGeometry> createBox( double sizeX, double sizeY, double sizeZ ) SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
704
718 static std::unique_ptr<QgsSfcgalGeometry> createCone( double bottomRadius, double height, double topRadius, unsigned int radial ) SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
719
726 static std::unique_ptr<QgsSfcgalGeometry> createCube( double size ) SIP_THROW( QgsSfcgalException );
727
740 static std::unique_ptr<QgsSfcgalGeometry> createCylinder( double radius, double height, unsigned int radial ) SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
741
753 static std::unique_ptr<QgsSfcgalGeometry> createSphere( double radius, unsigned int subdivisions ) SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
754
768 static std::unique_ptr<QgsSfcgalGeometry> createTorus( double mainRadius, double tubeRadius, unsigned int mainRadial, unsigned int tubeRadial ) SIP_THROW( QgsNotSupportedException, QgsSfcgalException );
769
778 QList<std::pair<QString, QString>> primitiveParameters() const SIP_THROW( QgsSfcgalException );
779
787 QVariant primitiveParameter( const QString &name ) const SIP_THROW( QgsSfcgalException );
788
797 void primitiveSetParameter( const QString &name, const QVariant &value ) SIP_THROW( QgsSfcgalException );
798
805 std::unique_ptr<QgsSfcgalGeometry> primitiveAsPolyhedralSurface() const SIP_THROW( QgsSfcgalException );
806
813 QgsMatrix4x4 primitiveTransform() const SIP_THROW( QgsSfcgalException );
814
815 protected:
816
820 void clearCache() const;
821
822 private:
824 sfcgal::shared_geom workingGeom() const;
825
826 sfcgal::shared_geom mSfcgalGeom;
827 bool mIsPrimitive = false;
828
829#if SFCGAL_VERSION_NUM >= SFCGAL_MAKE_VERSION( 2, 3, 0 )
830 void setPrimitiveTranslate( const QgsVector3D &translation );
831 void setPrimitiveScale( const QgsVector3D &scaleFactor, const QgsPoint &center );
833 void setPrimitiveRotation( double angle, const QgsVector3D &axisVector, const QgsPoint &center );
834
835 sfcgal::shared_prim mSfcgalPrim;
836 sfcgal::primitiveType mPrimType;
837 QgsMatrix4x4 mPrimTransform;
838#endif
839};
840
841
842#endif // QGSSGCGAL_GEOMETRY_H
843#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