void Append(SmoothCurveElement cTo, SmoothCurveElement cAppend) { ParametricCurveSequence2 use = null; if (cTo.source is ParametricCurveSequence2) { use = cTo.source as ParametricCurveSequence2; } else { use = new ParametricCurveSequence2(); use.Append(cTo.source); } if (cAppend.source is ParametricCurveSequence2) { var cseq = cAppend.source as ParametricCurveSequence2; foreach (var c in cseq.Curves) { use.Append(c); } } else { use.Append(cAppend.source); } cTo.source = use; UpdateSampling(cTo); }
public static IParametricCurve2d Convert(Polygon2d poly) { ParametricCurveSequence2 seq = new ParametricCurveSequence2(); int N = poly.VertexCount; for (int i = 0; i < N; ++i) { seq.Append(new Segment2d(poly[i], poly[(i + 1) % N])); } seq.IsClosed = true; return(seq); }
public IParametricCurve2d Clone() { ParametricCurveSequence2 s2 = new ParametricCurveSequence2(); s2.closed = this.closed; s2.curves = new List <IParametricCurve2d>(); foreach (var c in this.curves) { s2.curves.Add(c.Clone()); } return(s2); }
public static VectorArray2d AutoSample(ParametricCurveSequence2 curves, double fSpacingLength, double fSpacingT) { int N = curves.Count; bool bClosed = curves.IsClosed; VectorArray2d[] vecs = new VectorArray2d[N]; int i = 0; int nTotal = 0; foreach (IParametricCurve2d c in curves.Curves) { vecs[i] = AutoSample(c, fSpacingLength, fSpacingT); nTotal += vecs[i].Count; i++; } int nDuplicates = (bClosed) ? N : N - 1; // handle closed here... nTotal -= nDuplicates; VectorArray2d final = new VectorArray2d(nTotal); int k = 0; for (int vi = 0; vi < N; ++vi) { VectorArray2d vv = vecs[vi]; // skip final vertex unless we are on last curve (because it is // the same as first vertex of next curve) int nStop = (bClosed || vi < N - 1) ? vv.Count - 1 : vv.Count; final.Set(k, nStop, vv); k += nStop; } return(final); }