38const double QgsClipper::SMALL_NUM = 1e-12;
40void 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 )
42 double p0x, p0y, p0z, p1x = 0.0, p1y = 0.0, p1z = 0.0;
43 double p1x_c, p1y_c, p1z_c;
44 double lastClipX = 0.0, lastClipY = 0.0, lastClipZ = 0.0;
46 const int nPoints = xIn.size();
52 const double *sourceX = xIn.data();
53 const double *sourceY = yIn.data();
54 const double *sourceZ = zIn.data();
56 for (
int i = 0; i < nPoints; ++i )
79 if (
clipLineSegment( clipExtent, p0x, p0y, p0z, p1x_c, p1y_c, p1z_c ) )
81 bool newLine = !x.isEmpty() && ( !
qgsDoubleNear( p0x, lastClipX )
88 connectSeparatedLines( lastClipX, lastClipY, lastClipZ, p0x, p0y, p0z, clipExtent, x, y, z );
90 if ( x.isEmpty() || newLine )
117 const int nPoints = curve.size();
119 double p0x, p0y, p1x = 0.0, p1y = 0.0;
121 double lastClipX = 0.0, lastClipY = 0.0;
124 line.reserve( nPoints + 1 );
126 const QPointF *curveData = curve.data();
128 for (
int i = 0; i < nPoints; ++i )
132 p1x = curveData->x();
133 p1y = curveData->y();
140 p1x = curveData->x();
141 p1y = curveData->y();
146 p0x, p0y, p1x_c, p1y_c ) )
152 connectSeparatedLines( lastClipX, lastClipY, p0x, p0y, clipExtent, line );
154 if ( line.empty() || newLine )
157 line << QPointF( p0x, p0y );
163 line << QPointF( p1x_c, p1y_c );
171void QgsClipper::connectSeparatedLines(
double x0,
double y0,
double x1,
double y1,
269void QgsClipper::connectSeparatedLines(
double x0,
double y0,
double z0,
double x1,
double y1,
double z1,
270 const QgsBox3D &clipRect, QVector< double > &ptsX, QVector< double > &ptsY, QVector<double> &ptsZ )
273 double meanZ = ( z0 + z1 ) / 2.0;
A 3-dimensional box composed of x, y, z coordinates.
double yMaximum() const
Returns the maximum y value.
double xMinimum() const
Returns the minimum x value.
double xMaximum() const
Returns the maximum x value.
double yMinimum() const
Returns the minimum y value.
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 const double MAX_X
Maximum X-coordinate of the rectangular box used for clipping.
static const double MIN_Y
Minimum Y-coordinate of the rectangular box used for clipping.
static const double MAX_Y
Maximum Y-coordinate of the rectangular box used for clipping.
static QPolygonF clippedLine(const QgsCurve &curve, const QgsRectangle &clipExtent)
Takes a linestring and clips it to clipExtent.
static const double MIN_X
Minimum X-coordinate of the rectangular box used for clipping.
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.
Abstract base class for curved geometry type.
virtual QPolygonF asQPolygonF() const
Returns a QPolygonF representing the points.
A rectangle specified with double values.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)