77 static void trimFeature( QVector<double>& x,
81 static void trimPolygon( QPolygonF& pts,
const QgsRectangle& clipRect );
87 static const unsigned char* clippedLineWKB(
const unsigned char* wkb,
const QgsRectangle& clipExtent, QPolygonF& line );
96 static void trimFeatureToBoundary(
const QVector<double>& inX,
97 const QVector<double>& inY,
98 QVector<double>& outX,
99 QVector<double>& outY,
103 static void trimPolygonToBoundary(
const QPolygonF& inPts, QPolygonF& outPts,
const QgsRectangle& rect,
Boundary b,
double boundaryValue );
106 static bool inside(
const double x,
const double y,
Boundary b );
108 static bool inside(
const QPointF& pt,
Boundary b,
double val );
112 static QgsPoint intersect(
const double x1,
const double y1,
113 const double x2,
const double y2,
116 static QPointF intersectRect(
const QPointF& pt1,
121 static bool clipLineSegment(
double xLeft,
double xRight,
double yBottom,
double yTop,
double& x0,
double& y0,
double& x1,
double& y1 );
131 static void connectSeparatedLines(
double x0,
double y0,
double x1,
double y1,
135 static void clipStartTop(
double& x0,
double& y0,
const double& x1,
const double& y1,
double yMax );
136 static void clipStartBottom(
double& x0,
double& y0,
const double& x1,
const double& y1,
double yMin );
137 static void clipStartRight(
double& x0,
double& y0,
const double& x1,
const double& y1,
double xMax );
138 static void clipStartLeft(
double& x0,
double& y0,
const double& x1,
const double& y1,
double xMin );
139 static void clipEndTop(
const double& x0,
const double& y0,
double& x1,
double& y1,
double yMax );
140 static void clipEndBottom(
const double& x0,
const double& y0,
double& x1,
double& y1,
double yMin );
141 static void clipEndRight(
const double& x0,
const double& y0,
double& x1,
double& y1,
double xMax );
142 static void clipEndLeft(
const double& x0,
const double& y0,
double& x1,
double& y1,
double xMin );
161 QVector<double> tmpX;
162 QVector<double> tmpY;
181 tmpPts.reserve( pts.size() );
198 const QVector<double>& inX,
199 const QVector<double>& inY,
200 QVector<double>& outX,
201 QVector<double>& outY,
208 int i1 = inX.size() - 1;
211 for (
int i2 = 0; i2 < inX.size() ; ++i2 )
216 if ( qIsNaN( inX[i2] ) || qIsNaN( inY[i2] ) || qIsInf( inX[i2] ) || qIsInf( inY[i2] )
217 || qIsNaN( inX[i1] ) || qIsNaN( inY[i1] ) || qIsInf( inX[i1] ) || qIsInf( inY[i1] ) )
224 if (
inside( inX[i2], inY[i2], b ) )
226 if (
inside( inX[i1], inY[i1], b ) )
228 outX.push_back( inX[i2] );
229 outY.push_back( inY[i2] );
235 if ( !( i2 == 0 && shapeOpen ) )
238 outX.push_back( p.
x() );
239 outY.push_back( p.
y() );
242 outX.push_back( inX[i2] );
243 outY.push_back( inY[i2] );
249 if (
inside( inX[i1], inY[i1], b ) )
251 if ( !( i2 == 0 && shapeOpen ) )
254 outX.push_back( p.
x() );
255 outY.push_back( p.
y() );
265 int i1 = inPts.size() - 1;
268 for (
int i2 = 0; i2 < inPts.size() ; ++i2 )
270 if (
inside( inPts[i2], b, boundaryValue ) )
272 if (
inside( inPts[i1], b, boundaryValue ) )
274 outPts.append( inPts[i2] );
280 outPts.append(
intersectRect( inPts[i1], inPts[i2], b, rect ) );
281 outPts.append( inPts[i2] );
287 if (
inside( inPts[i1], b, boundaryValue ) )
289 outPts.append(
intersectRect( inPts[i1], inPts[i2], b, rect ) );
328 return ( pt.x() < val );
330 return ( pt.x() > val );
332 return ( pt.y() < val );
334 return ( pt.y() > val );
345 const double x2,
const double y2,
378 double r = r_n / r_d;
379 p.
set( x1 + r*( x2 - x1 ), y1 + r*( y2 - y1 ) );
400 const double x1 = pt1.x(), x2 = pt2.x();
401 const double y1 = pt1.y(), y2 = pt2.y();
428 return QPointF( x1 + r*( x2 - x1 ), y1 + r*( y2 - y1 ) );
433 x0 += ( x1 - x0 ) * ( yMax - y0 ) / ( y1 - y0 );
439 x0 += ( x1 - x0 ) * ( yMin - y0 ) / ( y1 - y0 );
445 y0 += ( y1 - y0 ) * ( xMax - x0 ) / ( x1 - x0 );
451 y0 += ( y1 - y0 ) * ( xMin - x0 ) / ( x1 - x0 );
457 x1 += ( x1 - x0 ) * ( yMax - y1 ) / ( y1 - y0 );
463 x1 += ( x1 - x0 ) * ( yMin - y1 ) / ( y1 - y0 );
469 y1 += ( y1 - y0 ) * ( xMax - x1 ) / ( x1 - x0 );
475 y1 += ( y1 - y0 ) * ( xMin - x1 ) / ( x1 - x0 );
480 inline bool QgsClipper::clipLineSegment(
double xLeft,
double xRight,
double yBottom,
double yTop,
double& x0,
double& y0,
double& x1,
double& y1 )
486 else if ( y1 > yTop )
491 else if ( x1 < xLeft )
496 else if ( y0 > yTop )
501 else if ( x0 < xLeft )
static const double MAX_Y
A rectangle specified with double values.
static const double SMALL_NUM
static void trimFeature(QVector< double > &x, QVector< double > &y, bool shapeOpen)
static QgsPoint intersect(const double x1, const double y1, const double x2, const double y2, Boundary b)
double yMaximum() const
Get the y maximum value (top side of rectangle)
static void trimPolygonToBoundary(const QPolygonF &inPts, QPolygonF &outPts, const QgsRectangle &rect, Boundary b, double boundaryValue)
static void clipEndTop(const double &x0, const double &y0, double &x1, double &y1, double yMax)
static bool clipLineSegment(double xLeft, double xRight, double yBottom, double yTop, double &x0, double &y0, double &x1, double &y1)
static void clipEndLeft(const double &x0, const double &y0, double &x1, double &y1, double xMin)
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
static void clipStartRight(double &x0, double &y0, const double &x1, const double &y1, double xMax)
static const double MIN_X
static void trimFeatureToBoundary(const QVector< double > &inX, const QVector< double > &inY, QVector< double > &outX, QVector< double > &outY, Boundary b, bool shapeOpen)
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
A class to trim lines and polygons to within a rectangular region.
double xMaximum() const
Get the x maximum value (right side of rectangle)
static QPointF intersectRect(const QPointF &pt1, const QPointF &pt2, Boundary b, const QgsRectangle &rect)
void set(double x, double y)
A class to represent a point geometry.
static void clipStartTop(double &x0, double &y0, const double &x1, const double &y1, double yMax)
static void clipStartLeft(double &x0, double &y0, const double &x1, const double &y1, double xMin)
static bool inside(const double x, const double y, Boundary b)
static const double MIN_Y
static void clipEndRight(const double &x0, const double &y0, double &x1, double &y1, double xMax)
static void trimPolygon(QPolygonF &pts, const QgsRectangle &clipRect)
static const double MAX_X
static void clipStartBottom(double &x0, double &y0, const double &x1, const double &y1, double yMin)
double xMinimum() const
Get the x minimum value (left side of rectangle)
static void clipEndBottom(const double &x0, const double &y0, double &x1, double &y1, double yMin)