示例#1
0
 def setup_phas(self):
     p_prof = getline(self.cfg_txt, 11).split()[0]
     p_txy = [float(v) for v in getline(self.cfg_txt, 12).split()]
     p_sxy = [float(v) for v in getline(self.cfg_txt, 13).split()]
     if p_prof == "curvature":
         phas_x = curvature(self.mesh[0], p_txy[0], p_sxy[0])
         phas_y = curvature(self.mesh[1], p_txy[1], p_sxy[1])
     elif p_prof == "tilt":
         phas_x = self.mesh[0] * np.tan(np.deg2rad(p_txy[0]))
         phas_y = self.mesh[1] * np.tan(np.deg2rad(p_txy[1]))
     else:
         phas_x = np.zeros_like(self.mesh[0])
         phas_y = np.zeros_like(self.mesh[0])
     phas = phas_x + phas_y
     return phas
示例#2
0
def wavefront(rxy=[1000, 1000], axs=gp_Ax3()):
    px = np.linspace(-1, 1, 100) * 10
    py = np.linspace(-1, 1, 100) * 10
    mesh = np.meshgrid(px, py)

    rx_0 = curvature(mesh[0], rxy[0], 0)
    ry_0 = curvature(mesh[1], rxy[1], 0)
    ph_0 = rx_0 + ry_0
    phas = surf_spl(*mesh, ph_0)

    trf = gp_Trsf()
    trf.SetTransformation(axs, gp_Ax3())
    loc_face = TopLoc_Location(trf)
    phas.Location(loc_face)
    return phas
示例#3
0
 def SurfCurvature(self,
                   nxy=[200, 200],
                   lxy=[450, 450],
                   rxy=[700, 0],
                   sxy=[0, 0]):
     px = np.linspace(-1, 1, int(nxy[0])) * lxy[0] / 2
     py = np.linspace(-1, 1, int(nxy[1])) * lxy[1] / 2
     mesh = np.meshgrid(px, py)
     surf_x = curvature(mesh[0], r=rxy[0], s=sxy[0])
     surf_y = curvature(mesh[1], r=rxy[1], s=sxy[1])
     data = surf_x + surf_y
     self.surf, self.surf_pts = surf_spl_pcd(*mesh, data)
     trf = gp_Trsf()
     trf.SetTransformation(self.axs, gp_Ax3())
     self.surf.Location(TopLoc_Location(trf))
示例#4
0
                                obj.ini.axs)

    obj.MultiReflect()
    print(obj.tar.beam.Location())
    print(obj.tar.beam_rght.Location())
    print(obj.tar.beam_left.Location())
    print(obj.tar.beam_uppr.Location())
    print(obj.tar.beam_bott.Location())

    rxy = [-10, -100]

    px = np.linspace(-1, 1, 100) * 25
    py = np.linspace(-1, 1, 100) * 25
    mesh = np.meshgrid(px, py)

    rx_0 = curvature(mesh[0], rxy[0], 0)
    ry_0 = curvature(mesh[1], rxy[1], 0)
    ph_0 = wavefront_xyz(*mesh, rx_0 + ry_0, obj.ini.beam)

    dist = obj.ini.beam.Location().Distance(obj.tar.beam.Location())

    rx_1 = curvature(mesh[0], rxy[0] + dist / 2, 0)
    ry_1 = curvature(mesh[1], rxy[1] + dist / 2, 0)
    ph_1 = wavefront_xyz(*mesh, rx_1 + ry_1 + dist / 2, obj.ini.beam)

    rx_r = curvature(mesh[0], rxy[0] + dist, 0)
    ry_r = curvature(mesh[1], rxy[1] + dist, 0)
    ph_r = wavefront_xyz(*mesh, rx_r + ry_r + dist, obj.ini.beam)

    obj.Display_Shape(["BLUE", "GREEN"])
    obj.display.DisplayShape(ph_0, color="RED")
示例#5
0
文件: surf.py 项目: 1127378627/OCCGO
from src.pyocc.surface import surf_spl
from src.pyocc.export import export_STEPFile_single

from OCC.Core.gp import gp_Pnt, gp_Vec, gp_Dir
from OCC.Core.gp import gp_Ax1, gp_Ax2, gp_Ax3

if __name__ == "__main__":
    argvs = sys.argv
    parser = OptionParser()
    parser.add_option("--dir", dest="dir", default="./")
    parser.add_option("--surf", dest="surf", default="surf1")
    parser.add_option("--lxy", dest="lxy",
                      default=(500, 500), type="float", nargs=2)
    parser.add_option("--nxy", dest="nxy",
                      default=(100.0, 100.0), type="int", nargs=2)
    parser.add_option("--sxy", dest="sxy", default=(0, 0),
                      type="float", nargs=2)
    parser.add_option("--rxy", dest="rxy",
                      default=(100, 200), type="float", nargs=2)
    opt, argc = parser.parse_args(argvs)
    print(argc, opt)

    px = np.linspace(-1, 1, opt.nxy[0]) * opt.lxy[0] / 2
    py = np.linspace(-1, 1, opt.nxy[1]) * opt.lxy[1] / 2
    mesh = np.meshgrid(px, py)
    curx = curvature(mesh[0], opt.rxy[0], opt.sxy[0])
    cury = curvature(mesh[1], opt.rxy[1], opt.sxy[1])
    surf = curx + cury

    grasp_sfc(mesh, surf, opt.dir + opt.surf + "_mat.sfc")
示例#6
0
if __name__ == "__main__":
    from src.plot import plot_contour_sub
    from src.geomtory import curvature

    argvs = sys.argv
    parser = OptionParser()
    parser.add_option("--dir", dest="dir", default="./")
    parser.add_option("--radi",
                      dest="radi",
                      default=(-1000, -500),
                      type="float",
                      nargs=2)
    parser.add_option("--dist", dest="dist", default=500.0, type="float")
    opt, argc = parser.parse_args(argvs)
    print(argc, opt)

    px = np.linspace(-1, 1, 100) * 100
    py = np.linspace(-1, 1, 100) * 100
    mesh = np.meshgrid(px, py)

    rx_0 = curvature(mesh[0], opt.radi[0], 0)
    ry_0 = curvature(mesh[1], opt.radi[1], 0)
    ph_0 = rx_0 + ry_0

    rx_r = curvature(mesh[0], opt.radi[0] + opt.dist, 0)
    ry_r = curvature(mesh[1], opt.radi[1] + opt.dist, 0)
    ph_r = ph_0 + rx_r + ry_r

    plot_contour_sub(mesh, ph_0, dirname="phas_r0")
    plot_contour_sub(mesh, ph_r, dirname="phas_r")