Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string curvesXPath = fullName("edges") + "/" + fullName("Edge") + "[@cubics!='']";
- foreach (XmlElement edgeNode in element.SelectNodes(curvesXPath, _nsmgr))
- {
- string curvesString = edgeNode.Attributes["cubics"].InnerText;
- if (!string.IsNullOrEmpty(curvesString))
- {
- var trimmedString = curvesString.Trim('!');
- var s = trimmedString.Split('(');
- var points = s[1].Split(';')[1].Split(')')[0].Split('q');
- var curvePoints = points[0].Split(' ');
- var start = convertStringToPoint(s[0]);
- var end = convertStringToPoint(curvePoints[2]);
- // now let's find all quadratic curve stubs we read and replace them with cubic curves
- bool removedAny = false;
- foreach (var point in points.Skip(1).Select(p => convertStringToPoint(p.Split('Q')[0])))
- {
- removedAny = true;
- // hack to make closure capture by value
- PointF point1 = point;
- _edges.RemoveAll(e => e.start == point1 && e.a.IsEmpty);
- }
- if (removedAny)
- {
- _edges.Add(new FlaEdge
- {
- start = start,
- a = convertStringToPoint(curvePoints[0]),
- b = convertStringToPoint(curvePoints[1]),
- end = end
- });
- }
- }
- }
Add Comment
Please, Sign In to add comment