/// <summary> /// Returns first element of list (O(1)) /// </summary> public T front() { return(_head.elem()); }
/** Used in polygon composition to composit polygons into scan lines * Combining polya and polyb into one super-polygon stored in polya. **/ private static void combLeft(ref GeomPoly polya, ref GeomPoly polyb) { var ap = polya.points; var bp = polyb.points; var ai = ap.begin(); var bi = bp.begin(); var b = bi.elem(); CxFastListNode <Vector2> prea = null; while (ai != ap.end()) { var a = ai.elem(); if (vec_dsq(a, b) < float.Epsilon) { //ignore shared vertex if parallel if (prea != null) { var a0 = prea.elem(); b = bi.next().elem(); Vector2 u = a - a0; //vec_new(u); vec_sub(a.p.p, a0.p.p, u); Vector2 v = b - a; //vec_new(v); vec_sub(b.p.p, a.p.p, v); var dot = vec_cross(u, v); if (dot * dot < float.Epsilon) { ap.erase(prea, ai); polya.length--; ai = prea; } } //insert polyb into polya var fst = true; CxFastListNode <Vector2> preb = null; while (!bp.empty()) { var bb = bp.front(); bp.pop(); if (!fst && !bp.empty()) { ai = ap.insert(ai, bb); polya.length++; preb = ai; } fst = false; } //ignore shared vertex if parallel ai = ai.next(); var a1 = ai.elem(); ai = ai.next(); if (ai == ap.end()) { ai = ap.begin(); } var a2 = ai.elem(); var a00 = preb.elem(); Vector2 uu = a1 - a00; //vec_new(u); vec_sub(a1.p, a0.p, u); Vector2 vv = a2 - a1; //vec_new(v); vec_sub(a2.p, a1.p, v); var dot1 = vec_cross(uu, vv); if (dot1 * dot1 < float.Epsilon) { ap.erase(preb, preb.next()); polya.length--; } return; } prea = ai; ai = ai.next(); } }