def make_EllipWire(self, rxy=[1.0, 1.0], shft=0.0, skin=None, axs=gp_Ax3()): rx, ry = rxy if rx > ry: major_radi = rx minor_radi = ry axis = gp_Ax2() axis.SetXDirection(axis.XDirection()) else: major_radi = ry minor_radi = rx axis = gp_Ax2() axis.SetXDirection(axis.YDirection()) axis.Rotate(axis.Axis(), np.deg2rad(shft)) elip = make_edge(gp_Elips(axis, major_radi, minor_radi)) poly = make_wire(elip) poly.Location(set_loc(gp_Ax3(), axs)) if skin == None: return poly else: n_sided = BRepFill_Filling() for e in Topo(poly).edges(): n_sided.Add(e, GeomAbs_C0) n_sided.Build() face = n_sided.Face() if skin == 0: return face else: solid = BRepOffset_MakeOffset(face, skin, 1.0E-5, BRepOffset_Skin, False, True, GeomAbs_Arc, True, True) return solid.Shape()
def make_StarWire(self, num=5, radi=[2.0, 1.0], shft=0.0, axs=gp_Ax3(), skin=None): lxy = radi pnts = [] angl = 360 / num for i in range(num): a_thet = np.deg2rad(i * angl) + np.deg2rad(shft) ax, ay = radi[0] * np.sin(a_thet), radi[0] * np.cos(a_thet) pnts.append(gp_Pnt(ax, ay, 0)) b_thet = a_thet + np.deg2rad(angl) / 2 bx, by = radi[1] * np.sin(b_thet), radi[1] * np.cos(b_thet) pnts.append(gp_Pnt(bx, by, 0)) pnts.append(pnts[0]) poly = make_polygon(pnts) poly.Location(set_loc(gp_Ax3(), axs)) n_sided = BRepFill_Filling() for e in Topo(poly).edges(): n_sided.Add(e, GeomAbs_C0) n_sided.Build() face = n_sided.Face() if skin == None: return poly elif skin == 0: return face else: solid = BRepOffset_MakeOffset(face, skin, 1.0E-5, BRepOffset_Skin, False, True, GeomAbs_Arc, True, True) return solid.Shape()
def __init__(self): plotocc.__init__(self) print(gxyz.shape) for i, xyz in enumerate(gxyz): print(i, *xyz) self.display.DisplayShape(gp_Pnt(*xyz)) e_array = [] for e in xyz_max: x, y, z = e e = gp_Pnt(float(x), float(y), float(z)) e_array.append(e) e_array.append(e_array[0]) poly = make_polygon(e_array) n_sided = BRepFill_Filling() for e in Topo(poly).edges(): n_sided.Add(e, GeomAbs_C0) for pt in gxyz: x, y, z = pt if (x < xmax) and (x > xmin) and (y < ymax) and (y > ymin) and ( z < zmax) and (z > zmin): n_sided.Add(gp_Pnt(x, y, z)) n_sided.Build() face = n_sided.Face() #face = make_n_sided(edges, p_array) # THICKEN SURFACE thickness = 0.15 solid = BRepOffset_MakeOffset(face, thickness, 1.0E-5, BRepOffset_Skin, False, False, GeomAbs_Intersection, True) # The last True is important to make solid # solid.MakeOffsetShape() # solid.MakeThickSolid() #aShape = solid.Shape() self.display.DisplayShape(poly) self.display.DisplayShape(face) #display.DisplayShape(aShape, update=True) #write_step_file(aShape, "./tmp/gyroid.stp") self.export_stp(solid.Shape())