Guest User

Untitled

a guest
Oct 21st, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. string curvesXPath = fullName("edges") + "/" + fullName("Edge") + "[@cubics!='']";
  2. foreach (XmlElement edgeNode in element.SelectNodes(curvesXPath, _nsmgr))
  3. {
  4. string curvesString = edgeNode.Attributes["cubics"].InnerText;
  5. if (!string.IsNullOrEmpty(curvesString))
  6. {
  7. var trimmedString = curvesString.Trim('!');
  8. var s = trimmedString.Split('(');
  9. var points = s[1].Split(';')[1].Split(')')[0].Split('q');
  10. var curvePoints = points[0].Split(' ');
  11. var start = convertStringToPoint(s[0]);
  12. var end = convertStringToPoint(curvePoints[2]);
  13. // now let's find all quadratic curve stubs we read and replace them with cubic curves
  14. bool removedAny = false;
  15. foreach (var point in points.Skip(1).Select(p => convertStringToPoint(p.Split('Q')[0])))
  16. {
  17. removedAny = true;
  18. // hack to make closure capture by value
  19. PointF point1 = point;
  20. _edges.RemoveAll(e => e.start == point1 && e.a.IsEmpty);
  21. }
  22. if (removedAny)
  23. {
  24. _edges.Add(new FlaEdge
  25. {
  26. start = start,
  27. a = convertStringToPoint(curvePoints[0]),
  28. b = convertStringToPoint(curvePoints[1]),
  29. end = end
  30. });
  31. }
  32. }
  33. }
Add Comment
Please, Sign In to add comment