75 static void trimFeature( QVector<double>& x,
79 static void trimPolygon( QPolygonF& pts,
const QgsRectangle& clipRect );
85 static const unsigned char* clippedLineWKB(
const unsigned char* wkb,
const QgsRectangle& clipExtent, QPolygonF& line );
94 static void trimFeatureToBoundary(
const QVector<double>& inX,
95 const QVector<double>& inY,
96 QVector<double>& outX,
97 QVector<double>& outY,
101 static void trimPolygonToBoundary(
const QPolygonF& inPts, QPolygonF& outPts,
const QgsRectangle& rect,
Boundary b,
double boundaryValue );
104 static bool inside(
const double x,
const double y,
Boundary b );
106 static bool inside(
const QPointF& pt,
Boundary b,
double val );
110 static QgsPoint intersect(
const double x1,
const double y1,
111 const double x2,
const double y2,
114 static QPointF intersectRect(
const QPointF& pt1,
119 static bool clipLineSegment(
double xLeft,
double xRight,
double yBottom,
double yTop,
double& x0,
double& y0,
double& x1,
double& y1 );
129 static void connectSeparatedLines(
double x0,
double y0,
double x1,
double y1,
133 static void clipStartTop(
double& x0,
double& y0,
const double& x1,
const double& y1,
double yMax );
134 static void clipStartBottom(
double& x0,
double& y0,
const double& x1,
const double& y1,
double yMin );
135 static void clipStartRight(
double& x0,
double& y0,
const double& x1,
const double& y1,
double xMax );
136 static void clipStartLeft(
double& x0,
double& y0,
const double& x1,
const double& y1,
double xMin );
137 static void clipEndTop(
const double& x0,
const double& y0,
double& x1,
double& y1,
double yMax );
138 static void clipEndBottom(
const double& x0,
const double& y0,
double& x1,
double& y1,
double yMin );
139 static void clipEndRight(
const double& x0,
const double& y0,
double& x1,
double& y1,
double xMax );
140 static void clipEndLeft(
const double& x0,
const double& y0,
double& x1,
double& y1,
double xMin );
159 QVector<double> tmpX;
160 QVector<double> tmpY;
179 tmpPts.reserve( pts.size() );
196 const QVector<double>& inX,
197 const QVector<double>& inY,
198 QVector<double>& outX,
199 QVector<double>& outY,
206 int i1 = inX.size() - 1;
209 for (
int i2 = 0; i2 < inX.size() ; ++i2 )
214 if ( qIsNaN( inX[i2] ) || qIsNaN( inY[i2] ) || qIsInf( inX[i2] ) || qIsInf( inY[i2] )
215 || qIsNaN( inX[i1] ) || qIsNaN( inY[i1] ) || qIsInf( inX[i1] ) || qIsInf( inY[i1] ) )
222 if (
inside( inX[i2], inY[i2], b ) )
224 if (
inside( inX[i1], inY[i1], b ) )
226 outX.push_back( inX[i2] );
227 outY.push_back( inY[i2] );
233 if ( !( i2 == 0 && shapeOpen ) )
236 outX.push_back( p.
x() );
237 outY.push_back( p.
y() );
240 outX.push_back( inX[i2] );
241 outY.push_back( inY[i2] );
247 if (
inside( inX[i1], inY[i1], b ) )
249 if ( !( i2 == 0 && shapeOpen ) )
252 outX.push_back( p.
x() );
253 outY.push_back( p.
y() );
263 int i1 = inPts.size() - 1;
266 for (
int i2 = 0; i2 < inPts.size() ; ++i2 )
268 if (
inside( inPts[i2], b, boundaryValue ) )
270 if (
inside( inPts[i1], b, boundaryValue ) )
272 outPts.append( inPts[i2] );
278 outPts.append(
intersectRect( inPts[i1], inPts[i2], b, rect ) );
279 outPts.append( inPts[i2] );
285 if (
inside( inPts[i1], b, boundaryValue ) )
287 outPts.append(
intersectRect( inPts[i1], inPts[i2], b, rect ) );
326 return ( pt.x() < val );
328 return ( pt.x() > val );
330 return ( pt.y() < val );
332 return ( pt.y() > val );
343 const double x2,
const double y2,
376 double r = r_n / r_d;
377 p.
set( x1 + r*( x2 - x1 ), y1 + r*( y2 - y1 ) );
398 const double x1 = pt1.x(), x2 = pt2.x();
399 const double y1 = pt1.y(), y2 = pt2.y();
426 return QPointF( x1 + r*( x2 - x1 ), y1 + r*( y2 - y1 ) );
431 x0 += ( x1 - x0 ) * ( yMax - y0 ) / ( y1 - y0 );
437 x0 += ( x1 - x0 ) * ( yMin - y0 ) / ( y1 - y0 );
443 y0 += ( y1 - y0 ) * ( xMax - x0 ) / ( x1 - x0 );
449 y0 += ( y1 - y0 ) * ( xMin - x0 ) / ( x1 - x0 );
455 x1 += ( x1 - x0 ) * ( yMax - y1 ) / ( y1 - y0 );
461 x1 += ( x1 - x0 ) * ( yMin - y1 ) / ( y1 - y0 );
467 y1 += ( y1 - y0 ) * ( xMax - x1 ) / ( x1 - x0 );
473 y1 += ( y1 - y0 ) * ( xMin - x1 ) / ( x1 - x0 );
478 inline bool QgsClipper::clipLineSegment(
double xLeft,
double xRight,
double yBottom,
double yTop,
double& x0,
double& y0,
double& x1,
double& y1 )
484 else if ( y1 > yTop )
489 else if ( x1 < xLeft )
494 else if ( y0 > yTop )
499 else if ( x0 < xLeft )