void LKSurface::Polyline(const POINT *apt, int cpt, const RECT& ClipRect) { if(cpt >= 2) { POINT Line[2]; const POINT * Start = NULL; size_t n=0; LKGeom::clipper<POINT> Clipper((POINT) {ClipRect.left, ClipRect.top}, (POINT) {ClipRect.right, ClipRect.bottom}); const POINT * const ItFirst = std::next(apt); const POINT * const ItLast = std::next(apt, cpt); Line[0] = *(apt); for(const POINT * It = ItFirst; It != ItLast; ++It) { Line[1] = *(It); const unsigned j = Clipper.ClipLine(Line[0], Line[1]); if(j&LKGeom::clipper<POINT>::_SEGM) { if(j&LKGeom::clipper<POINT>::_CLIP) { if(Start && n > 1) { Polyline(Start, n); Start = NULL; n=0; } Polyline(Line, 2); } else { if(!Start) { Start = std::prev(It); n = 2; } else { ++n; } } } Line[0] = *(It); } if(Start) { Polyline(Start, n); } } }
void LKSurface::Polyline(const POINT *apt, int cpt, const RECT& ClipRect) { if(cpt >= 2) { POINT Line[2]; const POINT * It = apt; const POINT * Start = NULL; size_t n=0; LKGeom::clipper<POINT> Clipper((POINT) {ClipRect.left, ClipRect.top}, (POINT) {ClipRect.right, ClipRect.bottom}); Line[0] = *(It++); while ( It < apt+cpt) { Line[1] = *(It); unsigned j = Clipper.ClipLine(Line[0], Line[1]); if(j&LKGeom::clipper<POINT>::_SEGM) { if(j&LKGeom::clipper<POINT>::_CLIP) { if(Start && n > 1) { Polyline(Start, n); Start = NULL; n=0; } Polyline(Line, 2); } else { if(!Start) { Start = It-1; n = 2; } else { ++n; } } } Line[0] = *(It++); } if(Start) { Polyline(Start, n); } } }