Hatch.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. using FastReport.Export.Dxf.Utils;
  2. using System.Drawing;
  3. namespace FastReport.Export.Dxf.Sections.Entities
  4. {
  5. public class Hatch : EntityBase
  6. {
  7. #region Private Fields
  8. private Color color;
  9. private PointF[] points;
  10. private byte[] pointTypes;
  11. private float x;
  12. private float y;
  13. #endregion Private Fields
  14. #region Public Constructors
  15. public Hatch(float x, float y, PointF[] points, byte[] pointTypes, Color color)
  16. {
  17. this.x = x;
  18. this.y = y;
  19. this.points = points;
  20. this.pointTypes = pointTypes;
  21. this.color = color;
  22. InitGroups();
  23. }
  24. #endregion Public Constructors
  25. #region Private Methods
  26. private void AddInsert()
  27. {
  28. // 0
  29. // INSERT
  30. // 8
  31. // 0
  32. // 6
  33. // BYLAYER
  34. AddTypeName("INSERT");
  35. AddGroup(8, "Layer_1");
  36. }
  37. private void AddVertex(PointF point)
  38. {
  39. AddPrimary2DPoint(x + point.X, y + point.Y);
  40. }
  41. private void InitGroups()
  42. {
  43. // 0
  44. // HATCH
  45. // 62
  46. // 1
  47. // 10
  48. // 0
  49. // 20
  50. // 0
  51. // 210
  52. //0
  53. //220
  54. // 0
  55. // 30
  56. // 0
  57. // 210
  58. // 0
  59. // 220
  60. // 0
  61. // 230
  62. // 1
  63. // 2
  64. // SOLID
  65. // 70
  66. // 1
  67. // 91
  68. // 1
  69. // 92
  70. // 2
  71. // 72
  72. // 0
  73. // 73
  74. // 1
  75. // 93
  76. // 6
  77. // 10
  78. // 20.1140162880412
  79. // 20
  80. // -2.24903557651093
  81. // 10
  82. // 22.320617231033
  83. // 20
  84. // 9.42048864123446
  85. // 10
  86. // 34.5417916845264
  87. // 20
  88. // 9.42048864123446
  89. // 10
  90. // 37.6583987659518
  91. // 20
  92. // -2.21084733387416
  93. // 10
  94. // 30.8499785683669
  95. // 20
  96. // -11.8816973853408
  97. // 10
  98. // 26.5214379415101
  99. // 20
  100. // -11.8816973853408
  101. // 75
  102. // 0
  103. // 76
  104. // 1
  105. // 47
  106. // 1E-6
  107. // 98
  108. // 0
  109. AddTypeName("HATCH");
  110. AddGroup(8, "Layer_1");
  111. byte aciColor = ACIDictionary.GetAciColor(color);
  112. AddColor(aciColor);
  113. AddPrimary2DPoint(0, 0);
  114. // Extrusion direction
  115. AddGroup(210, 0);
  116. AddGroup(220, 0);
  117. AddName("SOLID");
  118. // Solid fill flag (solid fill = 1; pattern fill = 0)
  119. AddGroup(70, 1);
  120. // Number of boundary paths (loops)
  121. AddGroup(91, 1);
  122. // Boundary path type flag (bit coded):
  123. // 0 = Default; 1 = External; 2 = Polyline;
  124. // 4 = Derived; 8 = Textbox; 16 = Outermost
  125. AddGroup(92, 7);//why 7? - becouse Inkscape
  126. // Edge type (only if boundary is not a polyline):
  127. // 1 = Line; 2 = Circular arc; 3 = Elliptic arc; 4 = Spline
  128. AddGroup(72, 0);
  129. // Is counterclockwise flag
  130. AddGroup(73, 1);
  131. // Number of polyline vertices
  132. AddGroup(93, points.Length);
  133. // Hatch style:
  134. // 0 = Hatch "odd parity" area(Normal style)
  135. // 1 = Hatch outermost area only(Outer style)
  136. // 2 = Hatch through entire area(Ignore style)
  137. //AddGroup(75, 0);
  138. //// Hatch pattern type:
  139. //// 0 = User - defined; 1 = Predefined; 2 = Custom
  140. //AddGroup(76, 1);
  141. // add vertices
  142. for (int i = 0; i < points.Length; i++)
  143. {
  144. PointF point = points[i];
  145. AddVertex(point);
  146. }
  147. // 0 = User - defined; 1 = Predefined; 2 = Custom
  148. AddGroup(47, "1E-6");
  149. // 0 = User - defined; 1 = Predefined; 2 = Custom
  150. AddGroup(98, 0);
  151. AddInsert();
  152. }
  153. #endregion Private Methods
  154. }
  155. }