MetaDataDefine.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using System;
  2. using System.Collections.Generic;
  3. namespace WingAIDiagnosisService.Carotid.CarotidInterFacesData
  4. {
  5. public struct Vector3I
  6. {
  7. public int X;
  8. public int Y;
  9. public int Z;
  10. public Vector3I(int x, int y, int z)
  11. {
  12. X = x;
  13. Y = y;
  14. Z = z;
  15. }
  16. }
  17. public struct Vector3F
  18. {
  19. public float X;
  20. public float Y;
  21. public float Z;
  22. }
  23. public struct Vector3D : IEquatable<Vector3D>
  24. {
  25. private const float Precision = 0.000001f;
  26. public double X;
  27. public double Y;
  28. public double Z;
  29. public Vector3D(double x, double y, double z)
  30. {
  31. X = x;
  32. Y = y;
  33. Z = z;
  34. }
  35. public bool Equals(Vector3D other)
  36. {
  37. if (Math.Abs(X - other.X) < Precision && Math.Abs(Y - other.Y) < Precision &&
  38. Math.Abs(Z - other.Z) < Precision)
  39. {
  40. return true;
  41. }
  42. return false;
  43. }
  44. public override bool Equals(object obj)
  45. {
  46. if (ReferenceEquals(null, obj)) return false;
  47. return obj is Vector3D && Equals((Vector3D) obj);
  48. }
  49. public override int GetHashCode()
  50. {
  51. unchecked
  52. {
  53. var hashCode = X.GetHashCode();
  54. hashCode = (hashCode * 397) ^ Y.GetHashCode();
  55. hashCode = (hashCode * 397) ^ Z.GetHashCode();
  56. return hashCode;
  57. }
  58. }
  59. /// <summary>
  60. /// Judge two vector is parallel.
  61. /// </summary>
  62. /// <param name="v2">other vector</param>
  63. /// <returns>True indicate parallel, otherwise false.</returns>
  64. public bool IsParallel(Vector3D v2)
  65. {
  66. //判断是否平行(x,y,z)与(a,b,c)平行的条件。 xb - ya=0,xc - za = 0, yc - zb = 0
  67. var a1 = X * v2.Y - Y * v2.X;
  68. var a2 = X * v2.Z - Z * v2.X;
  69. var a3 = Y * v2.Z - Z * v2.Y;
  70. return Math.Abs(a1) < Precision && Math.Abs(a2) < Precision && Math.Abs(a3) < Precision;
  71. }
  72. /// <summary>
  73. /// Subtracts v2 from this vector.
  74. /// </summary>
  75. /// <param name="v2">vector v2.</param>
  76. public void Sub(Vector3D v2)
  77. {
  78. X -= v2.X;
  79. Y -= v2.Y;
  80. Z -= v2.Z;
  81. }
  82. /// <summary>
  83. /// Get a new vector (a - b);
  84. /// </summary>
  85. public static Vector3D SubVectors(Vector3D a, Vector3D b)
  86. {
  87. return new Vector3D(a.X - b.X, a.Y - b.Y, a.Z - b.Z);
  88. }
  89. }
  90. public struct Vector2
  91. {
  92. public double X;
  93. public double Y;
  94. public Vector2(double x, double y)
  95. {
  96. X = x;
  97. Y = y;
  98. }
  99. }
  100. public struct Vector2I
  101. {
  102. public int X;
  103. public int Y;
  104. public Vector2I(int x, int y)
  105. {
  106. X = x;
  107. Y = y;
  108. }
  109. }
  110. public class ClipPlaneData
  111. {
  112. //Error code.
  113. public int ErrorCode { get; }
  114. /// <summary>
  115. /// Get Vector3 points.
  116. /// </summary>
  117. public IEnumerable<Vector3D> WorldPoints { get; }
  118. /// <summary>
  119. /// Get Vector2 points.
  120. /// </summary>
  121. public IEnumerable<Vector2> ImagePoints { get; }
  122. /// <summary>
  123. /// Get Image data.
  124. /// </summary>
  125. public string ImageData { get; }
  126. public ClipPlaneData(IEnumerable<Vector3D> worldPoints, IEnumerable<Vector2> imagePoints, string imageData, int errorCode)
  127. {
  128. WorldPoints = worldPoints;
  129. ImagePoints = imagePoints;
  130. ImageData = imageData;
  131. ErrorCode = errorCode;
  132. }
  133. }
  134. public class ClipPlanePoints
  135. {
  136. //Error code.
  137. public int ErrorCode { get; }
  138. /// <summary>
  139. /// Get Vector3 points.
  140. /// </summary>
  141. public IEnumerable<Vector3D> WorldPoints { get; }
  142. public ClipPlanePoints(IEnumerable<Vector3D> worldPoints, int errorCode)
  143. {
  144. WorldPoints = worldPoints;
  145. ErrorCode = errorCode;
  146. }
  147. }
  148. }