void QwtRect::clipEdge(Edge edge, const QwtPointArray &pa, QwtPointArray &cpa) const { if ( pa.count() == 0 ) { cpa.resize(0); return; } unsigned int count = 0; QPoint p1 = pa.point(0); if ( insideEdge(p1, edge) ) addPoint(cpa, count++, p1); const uint nPoints = pa.size(); for ( uint i = 1; i < nPoints; i++ ) { const QPoint p2 = pa.point(i); if ( insideEdge(p2, edge) ) { if ( insideEdge(p1, edge) ) addPoint(cpa, count++, p2); else { addPoint(cpa, count++, intersectEdge(p1, p2, edge)); addPoint(cpa, count++, p2); } } else { if ( insideEdge(p1, edge) ) addPoint(cpa, count++, intersectEdge(p1, p2, edge)); } p1 = p2; } cpa.resize(count); }
void QwtPolygonClipperF::clipEdge(Edge edge, const QwtPolygonF &pa, QwtPolygonF &cpa) const { if ( pa.count() == 0 ) { cpa.resize(0); return; } unsigned int count = 0; QwtDoublePoint p1 = pa[0]; if ( insideEdge(p1, edge) ) addPoint(cpa, count++, p1); const uint nPoints = pa.size(); for ( uint i = 1; i < nPoints; i++ ) { const QwtDoublePoint p2 = pa[(int)i]; if ( insideEdge(p2, edge) ) { if ( insideEdge(p1, edge) ) addPoint(cpa, count++, p2); else { addPoint(cpa, count++, intersectEdge(p1, p2, edge)); addPoint(cpa, count++, p2); } } else { if ( insideEdge(p1, edge) ) addPoint(cpa, count++, intersectEdge(p1, p2, edge)); } p1 = p2; } cpa.resize(count); }