bottle.tcl 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. # Script reproducing creation of bottle model as described in OCCT Tutorial
  2. #Category: Modeling
  3. #Title: OCCT Tutorial bottle shape
  4. pload MODELING VISUALIZATION
  5. puts "Constructing bottle body..."
  6. # set basic dimensions
  7. dset height 70
  8. dset width 50
  9. dset thickness 30
  10. # construct base profile (half)
  11. vertex v1 -width/2 0 0
  12. vertex v2 -width/2 -thickness/4 0
  13. edge e1 v1 v2
  14. point p2 -width/2 -thickness/4 0
  15. point p3 0 -thickness/2 0
  16. point p4 width/2 -thickness/4 0
  17. catch {gcarc arc cir p2 p3 p4}
  18. mkedge e2 arc
  19. vertex v4 width/2 -thickness/4 0
  20. vertex v5 width/2 0 0
  21. edge e3 v4 v5
  22. wire w1 e1 e2 e3
  23. # complete profile by mirror and make a prism
  24. copy w1 w2
  25. tmirror w2 0 0 0 0 1 0
  26. wire w3 w1 w2
  27. mkplane f w3
  28. prism p f 0 0 height
  29. # fillet all edges
  30. explode p e
  31. blend b p thickness/12 p_1 thickness/12 p_2 thickness/12 p_3 thickness/12 p_4 thickness/12 p_5 thickness/12 p_6 thickness/12 p_7 thickness/12 p_8 thickness/12 p_9 thickness/12 p_10 thickness/12 p_11 thickness/12 p_12 thickness/12 p_13 thickness/12 p_14 thickness/12 p_15 thickness/12 p_16 thickness/12 p_17 thickness/12 p_18
  32. # neck dimensions
  33. dset neckradius thickness/4
  34. dset neckheight height/10
  35. # add neck
  36. pcylinder c neckradius neckheight
  37. ttranslate c 0 0 height
  38. bfuse f b c
  39. # make body hollow
  40. explode c f
  41. offsetshape body f -thickness/50 1.e-3 c_2
  42. puts "Constructing threading..."
  43. # make two cylinders
  44. cylinder c1 0 0 height 0 0 1 neckradius*0.99
  45. cylinder c2 0 0 height 0 0 1 neckradius*1.05
  46. # define threading dimensions in parametric space
  47. dset major 2*pi
  48. dset minor neckheight/10
  49. # make parametric curves for threading
  50. ellipse el1 2*pi neckheight/2 2*pi neckheight/4 major minor
  51. ellipse el2 2*pi neckheight/2 2*pi neckheight/4 major minor/4
  52. trim arc1 el1 0 pi
  53. trim arc2 el2 0 pi
  54. 2dcvalue el1 0 x1 y1
  55. 2dcvalue el1 pi x2 y2
  56. line l x1 y1 x2-x1 y2-y1
  57. parameters l x2 y2 1.e-9 U
  58. trim s l 0 U
  59. # construct 3d edges and wires
  60. mkedge E1OnS1 arc1 c1 0 pi
  61. mkedge E2OnS1 s c1 0 U
  62. mkedge E1OnS2 arc2 c2 0 pi
  63. mkedge E2OnS2 s c2 0 U
  64. wire tw1 E1OnS1 E2OnS1
  65. wire tw2 E1OnS2 E2OnS2
  66. mkedgecurve tw1 1.e-5
  67. mkedgecurve tw2 1.e-5
  68. # build threading as solid
  69. thrusections -N thread 1 0 tw1 tw2
  70. puts "Putting together and writing \"Open CASCADE\"..."
  71. # define text
  72. text2brep text2d OpenCASCADE -font Times-Roman -height 8 -aspect bold -composite off
  73. prism text text2d 0 0 2
  74. trotate text 0 0 0 0 1 0 90
  75. ttranslate text 24.75 -2 65
  76. # cut operation
  77. bcut bodytext body text
  78. bop bodytext thread
  79. bopfuse bottle
  80. puts "Showing result..."
  81. # display result
  82. vdisplay bottle
  83. vfit
  84. vsetdispmode 1
  85. vaspects -isoontriangulation 1