QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | Static Public Attributes | List of all members
QgsClipper Class Reference

A class to trim lines and polygons to within a rectangular region. More...

#include <qgsclipper.h>

Public Types

enum  Boundary {
  XMax , XMin , YMax , YMin ,
  ZMax , ZMin
}
 A handy way to refer to the four boundaries. More...
 

Static Public Member Functions

static bool clipLineSegment (double left, double right, double bottom, double top, double &x0, double &y0, double &x1, double &y1)
 Clips a line segment to a rectangle.
 
static void clipped3dLine (const QVector< double > &xIn, const QVector< double > &yIn, const QVector< double > &zIn, QVector< double > &x, QVector< double > &y, QVector< double > &z, const QgsBox3D &clipExtent)
 Takes a line with 3D coordinates and clips it to clipExtent.
 
static QPolygonF clippedLine (const QgsCurve &curve, const QgsRectangle &clipExtent)
 Takes a linestring and clips it to clipExtent.
 
static QPolygonF clippedLine (const QPolygonF &curve, const QgsRectangle &clipExtent)
 Takes a 2D curve and clips it to clipExtent.
 
static void trimFeature (QVector< double > &x, QVector< double > &y, bool shapeOpen)
 Trims the given feature to a rectangular box.
 
static void trimPolygon (QPolygonF &pts, const QgsRectangle &clipRect)
 Trims the given polygon to a rectangular box, by modifying the given polygon in place.
 
static void trimPolygon (QVector< double > &x, QVector< double > &y, QVector< double > &z, const QgsBox3D &clipRect)
 Trims a polygon consisting of the specified x, y and z values to a pseudo 3D box, by modifying the arrays in place.
 

Static Public Attributes

static const double MAX_X = 16000
 Maximum X-coordinate of the rectangular box used for clipping.
 
static const double MAX_Y = 16000
 Maximum Y-coordinate of the rectangular box used for clipping.
 
static const double MIN_X = -16000
 Minimum X-coordinate of the rectangular box used for clipping.
 
static const double MIN_Y = -16000
 Minimum Y-coordinate of the rectangular box used for clipping.
 

Detailed Description

A class to trim lines and polygons to within a rectangular region.

The functions in this class are likely to be called from within a render loop and hence need to as CPU efficient as possible. The main purpose of the functions in this class are to trim lines and polygons to lie within a rectangular region. This is necessary for drawing items to an X11 display which have a limit on the magnitude of the screen coordinates (+/- 32768, i.e. 16 bit integer).

Definition at line 50 of file qgsclipper.h.

Member Enumeration Documentation

◆ Boundary

A handy way to refer to the four boundaries.

Enumerator
XMax 
XMin 
YMax 
YMin 
ZMax 

Maximum Z (since QGIS 3.26)

ZMin 

Minimum Z (since QGIS 3.26)

Definition at line 82 of file qgsclipper.h.

Member Function Documentation

◆ clipLineSegment()

bool QgsClipper::clipLineSegment ( double  left,
double  right,
double  bottom,
double  top,
double &  x0,
double &  y0,
double &  x1,
double &  y1 
)
inlinestatic

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).

Parameters
leftx-coordinate of left side of rectangle
rightx-coordinate of right side of rectangle
bottomy-coordinate of bottom side of rectangle
topy-coordinate of top side of rectangle
x0x-coordinate of start of line
y0y-coordinate of start of line
x1x-coordinate of end of line
y1y-coordinate of end of line
Returns
true if line was clipped.
Since
QGIS 3.26

Definition at line 780 of file qgsclipper.h.

◆ clipped3dLine()

void QgsClipper::clipped3dLine ( const QVector< double > &  xIn,
const QVector< double > &  yIn,
const QVector< double > &  zIn,
QVector< double > &  x,
QVector< double > &  y,
QVector< double > &  z,
const QgsBox3D clipExtent 
)
static

Takes a line with 3D coordinates and clips it to clipExtent.

Note
Not available in Python bindings
Since
QGIS 3.26

Definition at line 40 of file qgsclipper.cpp.

◆ clippedLine() [1/2]

QPolygonF QgsClipper::clippedLine ( const QgsCurve curve,
const QgsRectangle clipExtent 
)
static

Takes a linestring and clips it to clipExtent.

Parameters
curvethe linestring
clipExtentclipping bounds
Returns
clipped line coordinates

Definition at line 110 of file qgsclipper.cpp.

◆ clippedLine() [2/2]

QPolygonF QgsClipper::clippedLine ( const QPolygonF &  curve,
const QgsRectangle clipExtent 
)
static

Takes a 2D curve and clips it to clipExtent.

Parameters
curvethe linestring
clipExtentclipping bounds
Returns
clipped line coordinates
Since
QGIS 3.16

Definition at line 115 of file qgsclipper.cpp.

◆ trimFeature()

void QgsClipper::trimFeature ( QVector< double > &  x,
QVector< double > &  y,
bool  shapeOpen 
)
inlinestatic

Trims the given feature to a rectangular box.

Returns the trimmed feature in x and y. The shapeOpen parameter determines whether the function treats the points as a closed shape (polygon), or as an open shape (linestring).

Note
not available in Python bindings on android

Definition at line 264 of file qgsclipper.h.

◆ trimPolygon() [1/2]

void QgsClipper::trimPolygon ( QPolygonF &  pts,
const QgsRectangle clipRect 
)
inlinestatic

Trims the given polygon to a rectangular box, by modifying the given polygon in place.

Parameters
ptspolygon as 2D coordinates
clipRectclipping rectangle

Definition at line 285 of file qgsclipper.h.

◆ trimPolygon() [2/2]

void QgsClipper::trimPolygon ( QVector< double > &  x,
QVector< double > &  y,
QVector< double > &  z,
const QgsBox3D clipRect 
)
inlinestatic

Trims a polygon consisting of the specified x, y and z values to a pseudo 3D box, by modifying the arrays in place.

Note
Not available in Python bindings
Since
QGIS 3.26

Definition at line 299 of file qgsclipper.h.

Member Data Documentation

◆ MAX_X

const double QgsClipper::MAX_X = 16000
static

Maximum X-coordinate of the rectangular box used for clipping.

Definition at line 72 of file qgsclipper.h.

◆ MAX_Y

const double QgsClipper::MAX_Y = 16000
static

Maximum Y-coordinate of the rectangular box used for clipping.

Definition at line 76 of file qgsclipper.h.

◆ MIN_X

const double QgsClipper::MIN_X = -16000
static

Minimum X-coordinate of the rectangular box used for clipping.

Definition at line 74 of file qgsclipper.h.

◆ MIN_Y

const double QgsClipper::MIN_Y = -16000
static

Minimum Y-coordinate of the rectangular box used for clipping.

Definition at line 78 of file qgsclipper.h.


The documentation for this class was generated from the following files: