56 # pipe[0], pipe[1], posx) |
56 # pipe[0], pipe[1], posx) |
57 return [r_1, i, r_2, pipe] |
57 return [r_1, i, r_2, pipe] |
58 print "// Abort: no suitable pipe found" |
58 print "// Abort: no suitable pipe found" |
59 sys.exit(1) |
59 sys.exit(1) |
60 |
60 |
61 def _circle(self, posx, radius, data, cylinder = ""): |
61 def _circle(self, posx, radius, data, cylinder=""): |
62 """ |
62 """ |
63 Push the circle definition for later rendering |
63 Push the circle definition for later rendering |
64 """ |
64 """ |
65 if cylinder == "": |
65 if cylinder == "": |
66 size = 0.5 |
66 size = 0.5 |
90 for i in range(0, len(self.cylinders) - 1): |
90 for i in range(0, len(self.cylinders) - 1): |
91 r_1 = CYLINDER[self.cylinders[i]][0] / 2 |
91 r_1 = CYLINDER[self.cylinders[i]][0] / 2 |
92 r_2 = CYLINDER[self.cylinders[i+1]][0] / 2 |
92 r_2 = CYLINDER[self.cylinders[i+1]][0] / 2 |
93 r_1, r_2, r_3, data = self.calc_min(r_1, r_2) |
93 r_1, r_2, r_3, data = self.calc_min(r_1, r_2) |
94 # draw cylinder |
94 # draw cylinder |
95 self._circle(posx, r_1, |
95 self._circle(posx, r_1, \ |
96 CYLINDER[self.cylinders[i]], self.cylinders[i]) |
96 CYLINDER[self.cylinders[i]], self.cylinders[i]) |
97 self.scad["cylinder"] += "tank(%f, %f, %f);\n" % ( |
97 self.scad["cylinder"] += "tank(%f, %f, %f);\n" % ( |
98 posx * SCALE3D, r_1 * SCALE3D, |
98 posx * SCALE3D, r_1 * SCALE3D, |
99 CYLINDER[self.cylinders[i]][1] * SCALE3D) |
99 CYLINDER[self.cylinders[i]][1] * SCALE3D) |
100 sx1 = posx + r_1 |
100 sx1 = posx + r_1 |
106 CYLINDER[self.cylinders[i]][1] * SCALE3D) |
106 CYLINDER[self.cylinders[i]][1] * SCALE3D) |
107 posx += offset(r_2, r_3) |
107 posx += offset(r_2, r_3) |
108 sx2 = posx - r_3 |
108 sx2 = posx - r_3 |
109 if i == (len(self.cylinders) - 2): |
109 if i == (len(self.cylinders) - 2): |
110 # draw last bottle |
110 # draw last bottle |
111 self._circle(posx, r_3, |
111 self._circle(posx, r_3, \ |
112 CYLINDER[self.cylinders[i + 1]], self.cylinders[i + 1]) |
112 CYLINDER[self.cylinders[i + 1]], self.cylinders[i + 1]) |
113 self.scad["cylinder"] += "tank(%f, %f, %f);\n" % ( |
113 self.scad["cylinder"] += "tank(%f, %f, %f);\n" % ( |
114 posx * SCALE3D, r_3 * SCALE3D, |
114 posx * SCALE3D, r_3 * SCALE3D, |
115 CYLINDER[self.cylinders[i + 1]][1] * SCALE3D) |
115 CYLINDER[self.cylinders[i + 1]][1] * SCALE3D) |
116 posx += offset(r_2, r_3) |
116 posx += offset(r_2, r_3) |
192 options.cylinders, options.space_min) |
192 options.cylinders, options.space_min) |
193 |
193 |
194 img = worker.render_image() |
194 img = worker.render_image() |
195 img.show() |
195 img.show() |
196 |
196 |
197 if (options.scad != ""): |
197 if options.scad != "": |
198 with open(options.scad, "w") as fd: |
198 with open(options.scad, "w") as fd: |
199 fd.write(worker.scad["tmpl"]) |
199 fd.write(worker.scad["tmpl"]) |
|
200 # center the object |
200 fd.write("translate([%f,0,0]) {\n" % ( |
201 fd.write("translate([%f,0,0]) {\n" % ( |
201 ((worker.width - 2 * worker.margin) / -2) * SCALE3D)) # center the object |
202 ((worker.width - 2 * worker.margin) / -2) * SCALE3D)) |
202 fd.write(worker.scad["cylinder"]) |
203 fd.write(worker.scad["cylinder"]) |
203 fd.write(worker.scad["spacer"]) |
204 fd.write(worker.scad["spacer"]) |
204 fd.write("}\n") |
205 fd.write("}\n") |
205 |
206 |
206 if __name__ == "__main__": |
207 if __name__ == "__main__": |