snowflake.tcl 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. # Creation of 2d drawing
  2. #Category: Modeling
  3. #Title: Snowflake - creation of 2d drawing
  4. pload MODELING VISUALIZATION
  5. puts "Generating sample drawing of snowflake..."
  6. # make circular elements
  7. circle c11 5 5 0 5
  8. circle c12 5 5 0 3
  9. circle c21 18 7 0 7
  10. circle c22 18 7 0 5
  11. circle c31 28.5 5 0 5
  12. circle c32 28.5 5 0 3
  13. trim c21 c21 pi/4 -pi/4
  14. trim c22 c22 pi/4 -pi/4
  15. trim c31 c31 pi/4 -pi/4
  16. trim c32 c32 pi/4 -pi/4
  17. line l21 18 7 0 1 1 0
  18. line l22 18 7 0 1 -1 0
  19. line l31 28.5 5 0 1 1 0
  20. line l32 28.5 5 0 1 -1 0
  21. trim l21 l21 5 7
  22. trim l22 l22 5 7
  23. trim l31 l31 3 5
  24. trim l32 l32 3 5
  25. line l1 -6 0 0 0.86602540378443864 0.5 0
  26. line l2 -6 1 0 1 0 0
  27. trim l1 l1 0 30
  28. trim l2 l2 0 45
  29. mkedge c11 c11
  30. mkedge c12 c12
  31. mkedge c21 c21
  32. mkedge c22 c22
  33. mkedge c31 c31
  34. mkedge c32 c32
  35. mkedge l21 l21
  36. mkedge l22 l22
  37. mkedge l31 l31
  38. mkedge l32 l32
  39. mkedge l1 l1
  40. mkedge l2 l2
  41. wire b11 c11
  42. wire b12 c12
  43. orientation b12 R
  44. # build one ray
  45. plane p -6 0 0 0 0 1
  46. mkface f1 p b11
  47. add b12 f1
  48. wire b2 c21 l21 c22 l22
  49. mkface f2 p b2
  50. wire b3 c31 l31 c32 l32
  51. mkface f3 p b3
  52. prism f5 l1 -5 8.6602540378443864 0
  53. prism f4 l2 0 -1 0
  54. compound f1 f2 f3 bc
  55. bfuse r bc f4
  56. bcut r r f5
  57. tcopy r r1
  58. tmirror r1 -6 0 0 0 1 0
  59. bfuse w r r1
  60. unifysamedom w w
  61. donly w
  62. # construct complete snowflake
  63. tcopy w w1
  64. tcopy w w2
  65. tcopy w w3
  66. tcopy w w4
  67. tcopy w w5
  68. trotate w1 -6 0 0 0 0 1 60
  69. trotate w2 -6 0 0 0 0 1 120
  70. trotate w3 -6 0 0 0 0 1 180
  71. trotate w4 -6 0 0 0 0 1 240
  72. trotate w5 -6 0 0 0 0 1 300
  73. bfuse w w w1
  74. bfuse w w w2
  75. bfuse w w w3
  76. bfuse w w w4
  77. bfuse w w w5
  78. shape wsh Sh
  79. foreach f [explode w f] {add $f wsh}
  80. renamevar wsh w
  81. unifysamedom r w
  82. # keep only wires in compound
  83. eval compound [explode r w] snowflake
  84. tscale snowflake -6 0 0 1.5
  85. # draw frame loosely following GOST 2.104-68
  86. polyline frame -100 -100 0 172 -100 0 172 100 0 -100 100 0 -100 -100 0
  87. polyline t1 52 -100 0 52 -45 0 172 -45 0
  88. polyline t2 52 -60 0 172 -60 0
  89. polyline t3 52 -85 0 172 -85 0
  90. polyline t4 122 -100 0 122 -60 0
  91. polyline t5 122 -80 0 172 -80 0
  92. polyline t6 122 -65 0 172 -65 0
  93. polyline t7 142 -80 0 142 -85 0
  94. polyline t8 137 -80 0 137 -60 0
  95. polyline t9 154 -80 0 154 -60 0
  96. compound frame t1 t2 t3 t4 t5 t6 t7 t8 t9 lines
  97. # add text
  98. text2brep sample "SAMPLE" -font Arial -height 10 -pos 90 -55 0 -aspect bolditalic
  99. text2brep occ "Open CASCADE" -font Times -height 6 -pos 125 -95 0
  100. text2brep name "Snowflake" -font Courier -height 7 -pos 65 -75 0 -aspect italic
  101. text2brep material "Ice" -font Courier -height 7 -pos 75 -95 0 -aspect italic
  102. text2brep sheets "Sheets 1" -font Courier -height 3.5 -pos 145 -83 0 -aspect italic
  103. text2brep scale "Scale\n\n1:100" -font Courier -height 3.5 -pos 157 -63 0 -aspect italic -valign topfirstline
  104. text2brep mass "Mass\n\n1 mg" -font Courier -height 3.5 -pos 140 -63 0 -aspect italic -valign topfirstline
  105. eval compound [explode sample w] sample
  106. eval compound [explode occ w] occ
  107. eval compound [explode name w] name
  108. eval compound [explode material w] material
  109. eval compound [explode sheets w] sheets
  110. eval compound [explode scale w] scale
  111. eval compound [explode mass w] mass
  112. compound sample occ name material sheets scale mass text
  113. compound snowflake lines text drawing
  114. bounding snowflake -save x1 y1 z1 x2 y2 z2
  115. # display in 3d view
  116. vinit Driver1/Viewer1/View1 w=1024 h=768
  117. vdisplay snowflake lines text
  118. vrenderparams -msaa 8
  119. vsetcolor snowflake BLACK
  120. vsetcolor lines BLACK
  121. vsetcolor text BLACK
  122. vbackground -color WHITE
  123. vtop
  124. vfit
  125. # add dimension:
  126. # detect vertices extremal in X direction
  127. plane f1 x1 0 0 1 0 0
  128. plane f2 x2 0 0 1 0 0
  129. mkface f1 f1
  130. mkface f2 f2
  131. bsection s1 snowflake f1
  132. bsection s2 snowflake f2
  133. # select only upper vertices (nearer to the upper bound)
  134. explode s1 v
  135. explode s2 v
  136. plane fup 0 y2 0 0 1 0
  137. mkface fup fup
  138. for {set i 1} {$i <= 2} {incr i} {
  139. set dmin 1e10
  140. for {set j 1} {$j <= 2} {incr j} {
  141. distmini d s${i}_$j fup
  142. set dist [dval d_val]
  143. if {$dmin > $dist} {
  144. set dmin $dist
  145. eval set v$i s${i}_$j
  146. }
  147. }
  148. }
  149. vdimension length -length -shapes $v1 $v2 -plane xoy -value 0.001 -dispunits mm -showunits -flyout 70 -label above -color black -text 5 3d sh