18#ifndef QGSNURBSCURVE_H
19#define QGSNURBSCURVE_H
80 if ( a0 < 0.0 || a0 > 1.0 )
82 PyErr_SetString( PyExc_ValueError,
"Parameter t must be in range [0, 1]" );
87 sipRes = sipConvertFromType(
new QgsPoint( sipCpp->evaluate( a0 ) ), sipType_QgsPoint, Py_None );
120 void draw( QPainter &p )
const override;
130 void scroll(
int firstVertexIndex )
override;
135 double xAt(
int index )
const override;
136 double yAt(
int index )
const override;
137 double zAt(
int index )
const override;
138 double mAt(
int index )
const override;
149 bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<double>::epsilon(),
bool useZValues =
false )
override;
156 void transform(
const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
double mTranslate = 0.0,
double mScale = 1.0 )
override;
163 QString
asWkt(
int precision = 17 )
const override;
167 QString
asKml(
int precision = 17 )
const override;
170 void clear()
override;
176 bool addZValue(
double zValue = 0 )
override;
177 bool addMValue(
double mValue = 0 )
override;
185 bool fromWkt(
const QString &wkt )
override;
272 bool setWeight(
int index,
double weight );
283 const int count = sipCpp->controlPoints().size();
284 if ( a0 < 0 || a0 >= count )
286 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
291 sipRes = sipCpp->weight( a0 );
303 void setWeight(
int index,
double weight );
305 const int count = sipCpp->controlPoints().size();
306 if ( a0 < 0 || a0 >= count )
308 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
313 PyErr_SetString( PyExc_ValueError,
"Weight must be positive (> 0)" );
318 sipCpp->setWeight( a0, a1 );
330 if ( geom && geom->geometryType() ==
"NurbsCurve"_L1 )
342 if ( geom && geom->geometryType() ==
"NurbsCurve"_L1 )
361 void generateUniformKnots();
363 QVector<QgsPoint> mControlPoints;
364 QVector<double> mKnots;
365 QVector<double> mWeights;
367 mutable bool mValidityComputed =
false;
368 mutable bool mIsValid =
false;
QFlags< GeometryValidityFlag > GeometryValidityFlags
Geometry validity flags.
VertexType
Types of vertex.
TransformDirection
Indicates the direction (forward or inverse) of a transform.
@ Forward
Forward transform (from source to destination).
Abstract base class for all geometries.
virtual QgsAbstractGeometry * snappedToGrid(double hSpacing, double vSpacing, double dSpacing=0, double mSpacing=0, bool removeRedundantPoints=false) const =0
Makes a new geometry with all the points or vertices snapped to the closest point of the grid.
virtual bool addZValue(double zValue=0)=0
Adds a z-dimension to the geometry, initialized to a preset value.
virtual bool fromWkb(QgsConstWkbPtr &wkb)=0
Sets the geometry from a WKB string.
virtual bool moveVertex(QgsVertexId position, const QgsPoint &newPos)=0
Moves a vertex within the geometry.
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle.
@ MaximumAngle
Maximum angle between generating radii (lines from arc center to output vertices).
virtual double vertexAngle(QgsVertexId vertex) const =0
Returns approximate angle at a vertex.
virtual bool dropMValue()=0
Drops any measure values which exist in the geometry.
virtual QgsBox3D calculateBoundingBox3D() const
Calculates the minimal 3D bounding box for the geometry.
virtual void draw(QPainter &p) const =0
Draws the geometry using the specified QPainter.
QFlags< WkbFlag > WkbFlags
virtual QgsAbstractGeometry * simplifyByDistance(double tolerance) const =0
Simplifies the geometry by applying the Douglas Peucker simplification by distance algorithm.
virtual QgsRectangle boundingBox() const
Returns the minimal bounding box for the geometry.
AxisOrder
Axis order for GML generation.
@ XY
X comes before Y (or lon before lat).
virtual QString geometryType() const =0
Returns a unique string representing the geometry type.
virtual QgsAbstractGeometry * createEmptyWithSameType() const =0
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
virtual QByteArray asWkb(WkbFlags flags=QgsAbstractGeometry::WkbFlags()) const =0
Returns a WKB representation of the geometry.
virtual QDomElement asGml2(QDomDocument &doc, int precision=17, const QString &ns="gml", AxisOrder axisOrder=QgsAbstractGeometry::AxisOrder::XY) const =0
Returns a GML2 representation of the geometry.
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
virtual bool insertVertex(QgsVertexId position, const QgsPoint &vertex)=0
Inserts a vertex into the geometry.
virtual void swapXy()=0
Swaps the x and y coordinates from the geometry.
virtual double length() const
Returns the planar, 2-dimensional length of the geometry.
virtual QString asWkt(int precision=17) const =0
Returns a WKT representation of the geometry.
virtual bool fuzzyEqual(const QgsAbstractGeometry &other, double epsilon=1e-8) const =0
Performs fuzzy comparison between this geometry and other using an epsilon.
virtual bool isEmpty() const
Returns true if the geometry is empty.
virtual bool fuzzyDistanceEqual(const QgsAbstractGeometry &other, double epsilon=1e-8) const =0
Performs fuzzy distance comparison between this geometry and other using an epsilon.
virtual json asJsonObject(int precision=17) const
Returns a json object representation of the geometry.
virtual QDomElement asGml3(QDomDocument &doc, int precision=17, const QString &ns="gml", AxisOrder axisOrder=QgsAbstractGeometry::AxisOrder::XY) const =0
Returns a GML3 representation of the geometry.
virtual bool fromWkt(const QString &wkt)=0
Sets the geometry from a WKT string.
virtual void transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection d=Qgis::TransformDirection::Forward, bool transformZ=false)=0
Transforms the geometry using a coordinate transform.
virtual bool boundingBoxIntersects(const QgsRectangle &rectangle) const
Returns true if the bounding box of this geometry intersects with a rectangle.
virtual bool deleteVertex(QgsVertexId position)=0
Deletes a vertex within the geometry.
virtual bool hasCurvedSegments() const
Returns true if the geometry contains curved segments.
virtual void clear()=0
Clears the geometry, ie reset it to a null geometry.
virtual void filterVertices(const std::function< bool(const QgsPoint &) > &filter)
Filters the vertices from the geometry in place, removing any which do not return true for the filter...
virtual bool dropZValue()=0
Drops any z-dimensions which exist in the geometry.
virtual QgsPoint centroid() const
Returns the centroid of the geometry.
virtual int dimension() const =0
Returns the inherent dimension of the geometry.
virtual double segmentLength(QgsVertexId startVertex) const =0
Returns the length of the segment of the geometry which begins at startVertex.
virtual bool removeDuplicateNodes(double epsilon=4 *std::numeric_limits< double >::epsilon(), bool useZValues=false)=0
Removes duplicate nodes from the geometry, wherever removing the nodes does not result in a degenerat...
virtual int wkbSize(QgsAbstractGeometry::WkbFlags flags=QgsAbstractGeometry::WkbFlags()) const =0
Returns the length of the QByteArray returned by asWkb().
QgsAbstractGeometry()=default
virtual int compareToSameClass(const QgsAbstractGeometry *other) const =0
Compares to an other geometry of the same class, and returns a integer for sorting of the two geometr...
virtual double closestSegment(const QgsPoint &pt, QgsPoint &segmentPt, QgsVertexId &vertexAfter, int *leftOf=nullptr, double epsilon=4 *std::numeric_limits< double >::epsilon()) const =0
Searches for the closest segment of the geometry to a given point.
A 3-dimensional box composed of x, y, z coordinates.
Custom exception class for Coordinate Reference System related exceptions.
virtual bool equals(const QgsCurve &other) const =0
Checks whether this curve exactly equals another curve.
virtual int numPoints() const =0
Returns the number of points in the curve.
void clearCache() const override
Clears any cached parameters associated with the geometry, e.g., bounding boxes.
int vertexNumberFromVertexId(QgsVertexId id) const override
Returns the vertex number corresponding to a vertex id.
virtual void scroll(int firstVertexIndex)=0
Scrolls the curve vertices so that they start with the vertex at the given index.
int partCount() const override
Returns count of parts contained in the geometry.
virtual bool pointAt(int node, QgsPoint &point, Qgis::VertexType &type) const =0
Returns the point and vertex id of a point within the curve.
QgsBox3D boundingBox3D() const override
Returns the 3D bounding box for the geometry.
virtual QgsCurve * curveSubstring(double startDistance, double endDistance) const =0
Returns a new curve representing a substring of this curve.
virtual bool isClosed() const
Returns true if the curve is closed.
bool isValid(QString &error, Qgis::GeometryValidityFlags flags=Qgis::GeometryValidityFlags()) const override
Checks validity of the geometry, and returns true if the geometry is valid.
virtual bool isClosed2D() const
Returns true if the curve is closed.
int vertexCount(int part=0, int ring=0) const override
Returns the number of vertices of which this geometry is built.
QgsPoint vertexAt(QgsVertexId id) const override
Returns the point corresponding to a specified vertex id.
virtual QPolygonF asQPolygonF() const
Returns a QPolygonF representing the points.
virtual void addToPainterPath(QPainterPath &path) const =0
Adds a curve to a painter path.
virtual int indexOf(const QgsPoint &point) const =0
Returns the index of the first vertex matching the given point, or -1 if a matching vertex is not fou...
QgsCurve * toCurveType() const override
Returns the geometry converted to the more generic curve type.
virtual void sumUpArea(double &sum) const =0
Sums up the area of the curve by iterating over the vertices (shoelace formula).
QString asKml(int precision=17) const override
Returns a KML representation of the geometry.
virtual QgsPoint * interpolatePoint(double distance) const =0
Returns an interpolated point on the curve at the specified distance.
QgsCurve * clone() const override=0
Clones the geometry by performing a deep copy.
virtual double distanceBetweenVertices(QgsVertexId fromVertex, QgsVertexId toVertex) const =0
Returns the distance along the curve between two vertices.
virtual double xAt(int index) const =0
Returns the x-coordinate of the specified node in the line string.
virtual QgsPoint startPoint() const =0
Returns the starting point of the curve.
virtual std::tuple< std::unique_ptr< QgsCurve >, std::unique_ptr< QgsCurve > > splitCurveAtVertex(int index) const =0
Splits the curve at the specified vertex index, returning two curves which represent the portion of t...
virtual double zAt(int index) const =0
Returns the z-coordinate of the specified node in the line string.
virtual QgsCurve * reversed() const =0
Returns a reversed copy of the curve, where the direction of the curve has been flipped.
virtual void drawAsPolygon(QPainter &p) const =0
Draws the curve as a polygon on the specified QPainter.
virtual double mAt(int index) const =0
Returns the m-coordinate of the specified node in the line string.
virtual QgsPoint endPoint() const =0
Returns the end point of the curve.
virtual double yAt(int index) const =0
Returns the y-coordinate of the specified node in the line string.
virtual void points(QgsPointSequence &pt) const =0
Returns a list of points within the curve.
virtual QgsLineString * curveToLine(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const =0
Returns a new line string geometry corresponding to a segmentized approximation of the curve.
virtual void sumUpArea3D(double &sum) const =0
Sums up the 3d area of the curve by iterating over the vertices (shoelace formula).
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Line string geometry type, with support for z-dimension and m-values.
bool isRational() const
Returns true if this curve is rational (has non-uniform weights).
QgsNurbsCurve()
Constructor for an empty NURBS curve geometry.
QVector< double > knots() const
Returns the knot vector of the NURBS curve.
static QgsNurbsCurve * cast(QgsAbstractGeometry *geom)
Cast the geom to a QgsNurbsCurve.
static const QgsNurbsCurve * cast(const QgsAbstractGeometry *geom)
Cast the geom to a QgsNurbsCurve.
bool isPolyBezier() const
Returns true if this curve represents a poly-Bézier curve.
bool isBSpline() const
Returns true if this curve represents a B-spline (non-rational NURBS).
void setWeights(const QVector< double > &weights)
Sets the weight vector of the NURBS curve.
void points(QgsPointSequence &pts) const override
Returns a list of points within the curve.
int degree() const
Returns the degree of the NURBS curve.
QVector< QgsPoint > controlPoints() const
Returns the control points of the NURBS curve.
void setKnots(const QVector< double > &knots)
Sets the knot vector of the NURBS curve.
bool isBezier() const
Returns true if this curve represents a Bézier curve.
void setDegree(int degree)
Sets the degree of the NURBS curve.
QgsPoint evaluate(double t) const
Evaluates the NURBS curve at parameter t ∈ [0,1].
void setControlPoints(const QVector< QgsPoint > &points)
Sets the control points of the NURBS curve.
QVector< double > weights() const
Returns the weight vector of the NURBS curve.
Point geometry type, with support for z-dimension and m-values.
A rectangle specified with double values.
#define SIP_TYPEHINT(type)
#define SIP_THROW(name,...)
QVector< QgsPoint > QgsPointSequence
Utility class for identifying a unique vertex within a geometry.