def make_conic_part(self, start_x, part_h, vn_arg, cur_r_f, part_name, all_in_one = False): if not all_in_one: mu.reset_scene() self.make_conic_part_low(start_x, part_h, vn_arg, cur_r_f, part_name) if not all_in_one: self.save_part(part_name)
def make_prismic_part(self, start_x, part_h, vn_arg, cur_poly_f, part_name, all_in_one = False): if not all_in_one: mu.reset_scene() n_poly = None x = start_x dx = part_h / float(vn_arg) verts = [] faces = [] for v_ind in range(0, vn_arg + 1): cur_poly = cur_poly_f(x) verts += cur_poly x += dx if n_poly == None: n_poly = len(cur_poly) assert(n_poly == len(cur_poly)) if v_ind > 0: base_low = (v_ind - 1) * n_poly for i in range(0, n_poly): next_i = base_low + (i + 1) % n_poly faces.append([ base_low + i, next_i, next_i + n_poly, base_low + i + n_poly ]) #print("bottom_face:" + str(verts[0:n_poly])) bottom_face = range(0, n_poly) faces.append(bottom_face) faces.append(range((vn_arg) * n_poly, (vn_arg + 1) * n_poly)) mu.create_mesh_from_data(self.get_piece_name() + ' ' + part_name, o_v, verts, faces, True) if not all_in_one: self.save_part(part_name)
def make(self): for all_in_one in [False, True]: mu.reset_scene() for p in ["base", "middle", "top"]: if self.part != "all" and self.part != p: continue getattr(self, "make_" + p)(all_in_one) bpy.ops.export_mesh.stl(filepath=self.get_fname(), ascii=False)
def make_top(self, all_in_one): if not all_in_one: mu.reset_scene() self.make_prismic_part(self.middle_h + self.base_h, self.top_h - self.ear_h, self.vn_top, self.top_cur_poly, "top", True) for f in [self.ear_poly_left, self.ear_poly_right]: self.make_prismic_part(self.middle_h + self.base_h + self.top_h - self.ear_h, self.ear_h, self.vn_top, f, "top", True) if not all_in_one: self.save_part("top")
def make_ring_part(self, start_x, part_h, vn_arg, cur_outer_r_f, cur_inner_r_f, part_name, all_in_one = False): if not all_in_one: mu.reset_scene() x = start_x dx = part_h / float(vn_arg) verts = [] faces = [] print("start_x="+str(x) + " dx=" + str(dx)) for v_ind in range(0, vn_arg + 1): cur_inner_r = cur_inner_r_f(x) cur_outer_r = cur_outer_r_f(x) #print("x=" + str(x) + ", cur_inner_r = " + str(cur_inner_r) + # ", cur_outer_r = " + str(cur_outer_r)) cur_inner_verts = mu.get_circle_verts((0,0,x), cur_inner_r, n) cur_outer_verts = mu.get_circle_verts((0,0,x), cur_outer_r, n) #cur_n_verts = len(verts) verts += cur_outer_verts + cur_inner_verts x += dx if v_ind > 0: outer_base_low = (v_ind - 1) * 2 * n inner_base_low = outer_base_low + n for i in range(0, n): outer_next_i = outer_base_low + (i + 1) % n inner_next_i = inner_base_low + (i + 1) % n #print(base_low) outer_face = [ outer_base_low + i, outer_next_i, outer_next_i + 2 * n, outer_base_low + i + 2 * n ] faces.append(outer_face) faces.append([ inner_base_low + i + 2 * n, inner_next_i + 2 * n, inner_next_i, inner_base_low + i]) print("final x="+str(x) + " final r = " + str(cur_outer_r)) print("n_verts="+str(len(verts))) #print(faces) if cur_outer_r: outer_base = vn_arg * 2 * n inner_base = outer_base + n for i in range(0, n): i_next = (i + 1) % n faces.append([outer_base + i, outer_base + i_next, inner_base + i_next, inner_base + i ]) mu.create_mesh_from_data(self.get_piece_name() + ' ' + part_name, o_v, verts, faces, True) if not all_in_one: self.save_part(part_name)