Skip to content

Commit

Permalink
Showing 2 changed files with 39 additions and 3 deletions.
20 changes: 20 additions & 0 deletions python/core/auto_generated/qgsclipper.sip.in
Original file line number Diff line number Diff line change
@@ -83,6 +83,26 @@ Takes a linestring and clips it to clipExtent
Takes a ``curve`` and clips it to clipExtent.

.. versionadded:: 3.16
%End

static bool clipLineSegment( double left, double right, double bottom, double top, double &x0 /In,Out/, double &y0 /In,Out/, double &x1 /In,Out/, double &y1 /In,Out/ );
%Docstring
Clips a line segment to a rectangle.

An implementation of the 'Fast clipping' algorithm (Sobkow et al. 1987, Computers & Graphics Vol.11, 4, p.459-467).

:param left: x-coordinate of left side of rectangle
:param right: x-coordinate of right side of rectangle
:param bottom: y-coordinate of bottom side of rectangle
:param top: y-coordinate of top side of rectangle
:param x0: x-coordinate of start of line
:param y0: y-coordinate of start of line
:param x1: x-coordinate of end of line
:param y1: y-coordinate of end of line

:return: ``True`` if line was clipped.

.. versionadded:: 3.26
%End

};
22 changes: 19 additions & 3 deletions src/core/qgsclipper.h
Original file line number Diff line number Diff line change
@@ -116,6 +116,25 @@ class CORE_EXPORT QgsClipper
*/
static QPolygonF clippedLine( const QPolygonF &curve, const QgsRectangle &clipExtent );

/**
* Clips a line segment to a rectangle.
*
* An implementation of the 'Fast clipping' algorithm (Sobkow et al. 1987, Computers & Graphics Vol.11, 4, p.459-467).
*
* \param left x-coordinate of left side of rectangle
* \param right x-coordinate of right side of rectangle
* \param bottom y-coordinate of bottom side of rectangle
* \param top y-coordinate of top side of rectangle
* \param x0 x-coordinate of start of line
* \param y0 y-coordinate of start of line
* \param x1 x-coordinate of end of line
* \param y1 y-coordinate of end of line
* \returns TRUE if line was clipped.
*
* \since QGIS 3.26
*/
static bool clipLineSegment( double left, double right, double bottom, double top, double &x0 SIP_INOUT, double &y0 SIP_INOUT, double &x1 SIP_INOUT, double &y1 SIP_INOUT );

private:

// Used when testing for equivalence to 0.0
@@ -147,9 +166,6 @@ class CORE_EXPORT QgsClipper
QPointF pt2,
Boundary b, const QgsRectangle &rect );

//Implementation of 'Fast clipping' algorithm (Sobkow et al. 1987, Computers & Graphics Vol.11, 4, p.459-467)
static bool clipLineSegment( double xLeft, double xRight, double yBottom, double yTop, double &x0, double &y0, double &x1, double &y1 );

/**
* Connects two lines split by the clip (by inserting points on the clip border)
* \param x0 x-coordinate of the first line end

0 comments on commit f0946aa

Please sign in to comment.