def make_Thru(self, num=50): api = BRepOffsetAPI_ThruSections() print(self.poly.Location().Transformation()) for idx, phi in enumerate(np.linspace(0, 2 * np.pi, num)): ax = self.poly_axs.Rotated(self.axs.Axis(), phi) poly_i = self.poly.Located(set_loc(gp_Ax3(), ax)) # print(poly_i.Location().Transformation()) api.AddWire(poly_i) self.display.DisplayShape(poly_i) api.Build() return api.Shape()
def make_PolyWire(self, num=6, radi=1.0, shft=0.0, axs=gp_Ax3()): lxy = radi - 0.1 pnts = [] angl = 360 / num for i in range(num): thet = np.deg2rad(i * angl) + np.deg2rad(shft) x, y = radi * np.sin(thet), radi * np.cos(thet) pnts.append(gp_Pnt(x, y, 0)) pnts.append(pnts[0]) poly = make_polygon(pnts) poly.Location(set_loc(gp_Ax3(), axs)) return poly
def make_PolyPlane(self, num=6, radi=1.0, shft=0.0, axs=gp_Ax3()): lxy = radi - 0.1 pnts = [] angl = 360 / num for i in range(num): thet = np.deg2rad(i * angl) + np.deg2rad(shft) x, y = radi * np.sin(thet), radi * np.cos(thet) pnts.append(gp_Pnt(x, y, 0)) pnts.append(pnts[0]) poly = make_polygon(pnts) brep = BRepBuilderAPI_MakeFace(gp_Pln(), poly) brep.Add(poly) face = brep.Face() face.Location(set_loc(gp_Ax3(), axs)) return face
def bez_face(px, py, pz, axs=gp_Ax3()): nx, ny = px.shape pnt_2d = TColgp_Array2OfPnt(1, nx, 1, ny) for row in range(pnt_2d.LowerRow(), pnt_2d.UpperRow() + 1): for col in range(pnt_2d.LowerCol(), pnt_2d.UpperCol() + 1): i, j = row - 1, col - 1 pnt = gp_Pnt(px[i, j], py[i, j], pz[i, j]) pnt_2d.SetValue(row, col, pnt) #print (i, j, px[i, j], py[i, j], pz[i, j]) surf = Geom_BezierSurface(pnt_2d) # api.Interpolate(pnt_2d) #surface = BRepBuilderAPI_MakeFace(curve, 1e-6) # return surface.Face() face = BRepBuilderAPI_MakeFace(surf, 1e-6).Face() face.Location(set_loc(gp_Ax3(), axs)) return face
def make_PolySurf(self, num=6, radi=1.0, shft=0.0, axs=gp_Ax3()): lxy = radi - 0.1 pnts = [] angl = 360 / num for i in range(num): thet = np.deg2rad(i * angl) + np.deg2rad(shft) x, y = radi * np.sin(thet), radi * np.cos(thet) pnts.append(gp_Pnt(x, y, 0)) pnts.append(pnts[0]) poly = make_polygon(pnts) proj = BRepProj_Projection(poly, self.surf, gp_Pnt(0, 0, 10)) # print(proj.Current()) brep = BRepBuilderAPI_MakeFace(self.surf, poly) # brep.Add(poly) face = brep.Face() face.Location(set_loc(gp_Ax3(), axs)) return face
px = np.linspace(-1, 1, 25) * 150 py = np.linspace(-1, 1, 25) * 150 mesh = np.meshgrid(px, py) data2 = mesh[0]**2 / 1000 + mesh[1]**2 / 2000 pts = [] pts.append(gp_Pnt(-50, -60, 0)) pts.append(gp_Pnt(-60, +70, 0)) pts.append(gp_Pnt(+70, +80, 0)) pts.append(gp_Pnt(+80, -90, 0)) poly = make_polygon(pts, closed=True) axis1 = gp_Ax3(gp_Pnt(-150, +50.0, 0.0), gp_Dir(0, 0, 1)) surf1, face1 = spl_face(*mesh, data1, axs=axis1) poly1 = poly.Located(set_loc(gp_Ax3(), axis1)) poly1_proj = obj.proj_rim_pln(poly1, face1, axis1) print(face1) #split = BRepFeat_SplitShape(face1) #split.Add(poly1_proj, face1) # split.Build() #surf1_trim1 = split.Left() #surf1_trim2 = split.DirectLeft() # print(split.Check()) #print(surf1_trim1.Size(), surf1_trim2.Size()) face1_holl = BRepBuilderAPI_MakeFace(face1, poly1_proj).Face() print(face1_holl) api = BRepAlgo_Cut(face1, face1_holl) api.Build()
parser.add_option("--pxyz", dest="pxyz", default=[0.0, 0.0, 0.0], type="float", nargs=3) opt, argc = parser.parse_args(argvs) print(opt, argc) obj = plotocc(touch=True) dae_data = uiuc_database() axs = gp_Ax3() uic = "dae51" pnt = gp_Pnt(0, 10, 0) ax1 = gp_Ax3(pnt, axs.YDirection(), axs.XDirection().Reversed()) ui1 = make_polygon([gp_Pnt(*100 * xy, 0) for xy in uiuc_database(uic)], closed=True) ui1.Location(set_loc(gp_Ax3(), ax1)) obj.display.DisplayShape(ui1) obj.display.DisplayMessage(pnt, uic) uic = "geminism" pnt = gp_Pnt(0, 20, 0) ax1.SetLocation(pnt) ui1 = make_polygon([gp_Pnt(*100 * xy, 0) for xy in uiuc_database(uic)], closed=True) ui1.Location(set_loc(gp_Ax3(), ax1)) obj.display.DisplayShape(ui1) obj.display.DisplayMessage(pnt, uic) uic = "naca0006" pnt = gp_Pnt(0, 30, 0) ax1.SetLocation(pnt)
for xyz in dat + [pts[0]]: pts.append(gp_Pnt(*xyz)) face = plotocc.make_FaceByOrder(pts) if __name__ == '__main__': obj = plotocc() ax1 = gp_Ax3() pt1 = np.loadtxt(obj.rootname + "_pln1.txt") print(pt1) pts = [] for xyz in pt1 + [pt1[0]]: pts.append(gp_Pnt(*xyz)) br1 = make_polygon(pts, closed=True) br1.Location(set_loc(gp_Ax3(), ax1)) fc1 = obj.make_FaceByOrder(pts) fc1.Location(set_loc(gp_Ax3(), ax1)) print(fc1) obj.display.DisplayShape(br1) obj.display.DisplayShape(fc1) ax2 = gp_Ax3() ax2.SetLocation(gp_Pnt(0, 0, 25)) pt2 = np.loadtxt(obj.rootname + "_pln2.txt") print(pt2) pts = [] for xyz in pt2 + [pt2[0]]: pts.append(gp_Pnt(*xyz)) br2 = make_polygon(pts, closed=True) br2.Location(set_loc(gp_Ax3(), ax2))
argvs = sys.argv parser = OptionParser() parser.add_option("--dir", dest="dir", default="./") parser.add_option("--pxyz", dest="pxyz", default=[0.0, 0.0, 0.0], type="float", nargs=3) opt, argc = parser.parse_args(argvs) print(opt, argc) obj = plotocc(view=False) face1 = read_step_file("./stp_surf/gen_surf_001.stp") axis1 = gp_Ax3(gp_Pnt(0, 0, 1), gp_Dir(0, 0, 1)) face1.Location(set_loc(gp_Ax3(), axis1)) face2 = read_step_file("./stp_surf/gen_surf_030.stp") axis2 = gp_Ax3(gp_Pnt(0, 0, 2), gp_Dir(0, 0, 1)) face2.Location(set_loc(gp_Ax3(), axis2)) axs = gp_Ax3() ax1 = gp_Ax3(gp_Pnt(0, 0, -10), axs.Direction()) vec = gp_Vec(gp_Pnt(0, 0, -10), gp_Pnt(0, 0, 10)) face = obj.make_EllipWire(rxy=[50.0, 50.0], axs=ax1, skin=0) body = BRepPrimAPI_MakePrism(face, vec).Shape() lens = make_lens(body, face1, face2) obj.create_tempdir(flag=-1) wire1 = obj.make_PolyWire(radi=50, num=6, axs=axis1)