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 )