ExportUtils.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* ==============================================================================
  2. * 功能描述:ExportUtils
  3. * 创 建 者:Garrett
  4. * 创建日期:2019/12/17 17:20:14
  5. * ==============================================================================*/
  6. using System;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using SAGA.DotNetUtils;
  13. using SAGA.DotNetUtils.Extend;
  14. using TestCad.Model;
  15. namespace TestCad
  16. {
  17. /// <summary>
  18. /// ExportUtils
  19. /// </summary>
  20. public class ExportUtils
  21. {
  22. public static TestCad.Model.XYZ Point2XYZ(object point)
  23. {
  24. string str = "";
  25. XYZ xyz = null;
  26. if (point is double[] array)
  27. {
  28. if (array.Length == 3)
  29. {
  30. xyz=new XYZ(){X = array[0],Y= array[1], Z= array[2] };
  31. }
  32. }
  33. return xyz;
  34. }
  35. public static TestCad.Model.PolyLine Coordinates2PloyLine(object points)
  36. {
  37. string str = "";
  38. List<XYZ> list=new List<XYZ>();
  39. if (points is IEnumerable iEnumerable)
  40. {
  41. for (int i = 0; i < iEnumerable.GetCount()-1; i=i+2)
  42. {
  43. double[] array = {iEnumerable.GetByIndexT<double>(i), iEnumerable.GetByIndexT<double>(i + 1), 0};
  44. XYZ xyz = Point2XYZ(array);
  45. list.Add(xyz);
  46. }
  47. }
  48. return new PolyLine(list);
  49. }
  50. }
  51. }