void DPolyline::normalize(DPoint src, DPoint tgt) { if (empty()) return; unify(); ListIterator<DPoint> iter, next, onext; DPoint pCur = src; DPoint pNext; DPoint pNextNext; for (iter = begin(); iter.valid(); ++iter) { for( ; ; ) { if (!iter.valid()) break; next = iter; pNext = *next; next++; if (!next.valid()) { pNextNext = tgt; } else pNextNext = *next; DSegment s1(pCur, pNext); DSegment s2(pNext, pNextNext); DRect r (pCur, pNextNext); // is *next on the way from *iter to *onext? if (s1.slope() == s2.slope() && r.contains(pNext)) { del(iter); iter = next; } else break; /* while */ } if (iter.valid()) pCur = *iter; else break; } }
// deletes all points, which are not facets void DPolygon::normalize() { unify(); ListIterator<DPoint> iter, next; for (iter = begin(); iter.valid(); ++iter) { for( ; ; ) { next = cyclicSucc(iter); DSegment s1 = segment(iter); DSegment s2 = segment(next); DRect r (*iter, *cyclicSucc(next)); if (s1.slope() == s2.slope() && r.contains(*next)) del(next); else break; // while } } }
// deletes all points, which are not facets void DPolyline::normalize() { unify(); ListIterator<DPoint> iter, next, onext; for (iter = begin(); iter.valid(); ++iter) { for( ; ; ) { next = iter; next++; if (!next.valid()) break; onext = next, onext++; if (!onext.valid()) break; DSegment s1((*iter), (*next)); DSegment s2((*next), (*onext)); DRect r ((*iter), (*onext)); // is *next on the way from *iter to *onext? if (s1.slope() == s2.slope() && r.contains(*next)) del(next); else break; /* while */ } } }