Пример #1
0
 def sxy_tar(self):
     prf = self.dir + self.tar.name + "_" + "sz" + "_profile.txt"
     sx = float(getline(prf, 7).split()[1])
     sy = float(getline(prf, 8).split()[1])
     sxy = gp_Pnt(sx, sy, 0).Transformed(self.tar.trf)
     h_srf = BRep_Tool.Surface(self.tar.srf)
     self.tar.sxy = GeomAPI_ProjectPointOnSurf(sxy, h_srf).Point(1)
Пример #2
0
    def __init__(self):
        plotocc.__init__(self)
        self.shell = read_step_file(self.tmpdir + "SurfUV.stp")
        print(self.shell)
        top = TopExp_Explorer(self.shell, TopAbs_FACE)
        self.face = top.Current()
        print(top.Depth())
        print(self.face)
        self.surf = BRep_Tool.Surface(self.face)

        u0, u1, v0, v1 = shapeanalysis_GetFaceUVBounds(self.face)
        print(u0, u1, v0, v1)
        sas = ShapeAnalysis_Surface(self.surf)
        print(sas.Value(u0, v0))
        print(sas.Value(u0, v1))
        print(sas.Value(u1, v0))
        print(sas.Value(u1, v1))

        u = u0
        while u <= u1:
            v = v0
            while v <= v1:
                p = sas.Value(u, v)
                self.display.DisplayShape(p, update=False)
                v += 1 / 3
            u += 1 / 4
Пример #3
0
def setup_sxy(filename, ext="ex"):
    axs, srf, trf = set_axs_pln(filename)
    prf = filename + "_" + ext + "_profile.txt"
    sx = float(getline(prf, 7).split()[1])
    sy = float(getline(prf, 8).split()[1])
    sxy = gp_Pnt(sx, sy, 0).Transformed(trf)
    h_srf = BRep_Tool.Surface(srf)
    sxy = GeomAPI_ProjectPointOnSurf(sxy, h_srf).Point(1)
    return axs, srf, trf, sxy
Пример #4
0
 def project_to_UV(self):
     assert self.face != None
     surface = BRep_Tool.Surface(self.face)
     analysis_surface = ShapeAnalysis_Surface(surface)
     xyz = gp_Pnt(self.x, self.y, self.z)
     uv = analysis_surface.ValueOfUV(xyz, 0.0001)
     self.u = uv.X()
     self.v = uv.Y()
     if self.face.Orientation() == TopAbs_REVERSED:
         self.reverse_u()
Пример #5
0
 def Reflect(self):
     h_surf = BRep_Tool.Surface(self.tar.srf)
     g_line = gp_Lin(self.ini.beam.Location(), self.ini.beam.Direction())
     ray = Geom_Line(g_line)
     if GeomAPI_IntCS(ray, h_surf).NbPoints():
         self.tar.beam = reflect(self.ini.beam, self.tar.srf)
     else:
         pln = make_plane(self.tar.axs.Location(),
                          dir_to_vec(self.tar.axs.Direction()), 500, -500,
                          500, -500)
         self.tar.beam = reflect(self.ini.beam, pln)
Пример #6
0
def reflect(beam, face, axs=gp_Ax3()):
    p0, v0 = beam.Location(), dir_to_vec(beam.Direction())
    h_surf = BRep_Tool.Surface(face)
    ray = Geom_Line(gp_Lin(p0, vec_to_dir(v0)))
    if GeomAPI_IntCS(ray, h_surf).NbPoints() == 0:
        print("Out of Surface", axs.Location())
        pln = make_plane(axs.Location(), dir_to_vec(axs.Direction()), 500,
                         -500, 500, -500)
        h_surf = BRep_Tool.Surface(pln)
    GeomAPI_IntCS(ray, h_surf).IsDone()
    uvw = GeomAPI_IntCS(ray, h_surf).Parameters(1)
    u, v, w = uvw
    p1, vx, vy = gp_Pnt(), gp_Vec(), gp_Vec()
    GeomLProp_SurfaceTool.D1(h_surf, u, v, p1, vx, vy)
    vz = vx.Crossed(vy)
    vx.Normalize()
    vy.Normalize()
    vz.Normalize()
    v1 = v0.Mirrored(gp_Ax2(p1, vec_to_dir(vz), vec_to_dir(vx)))
    return gp_Ax3(p1, vec_to_dir(v1), beam.XDirection().Reversed())
Пример #7
0
def getPntsEdgesFacesIntersect(edgesShape, facesShape):
    pnts = []
    faces = getShapeItems(facesShape, TopAbs_FACE)
    edges = getShapeItems(edgesShape, TopAbs_EDGE)
    for edge in edges:
        for face in faces:
            curve3 = BRep_Tool.Curve(edge)
            curve = Geom_TrimmedCurve(curve3[0],curve3[1],curve3[2])
            surface = BRep_Tool.Surface(face)
            pntsToAdd = getPntsCurveSurfaceIntersect(curve, surface)
            pnts += pntsToAdd
    return pnts
Пример #8
0
def reflect(p0, v0, face):
    h_surf = BRep_Tool.Surface(face)
    ray = Geom_Line(gp_Lin(p0, vec_to_dir(v0)))
    uvw = GeomAPI_IntCS(ray.GetHandle(), h_surf).Parameters(1)
    u, v, w = uvw
    p1, vx, vy = gp_Pnt(), gp_Vec(), gp_Vec()
    GeomLProp_SurfaceTool.D1(h_surf, u, v, p1, vx, vy)
    vz = vx.Crossed(vy)
    vx.Normalize()
    vy.Normalize()
    vz.Normalize()
    v1 = v0.Mirrored(gp_Ax2(p1, vec_to_dir(vz)))
    return p1, v1
Пример #9
0
def xyz_from_uv_face_unnormlized(uv, face):
    """
    Given a face and a uv coordinate, return the xyz coordinate
    """
    #    print(uv)
    result = BRep_Tool.Surface(
        face
    )  ###result[0] is the handle of curve;result[1] is the umin; result[2] is umax
    aPnt = result.GetObject().Value(
        uv[0],
        uv[1])  ###handle_Geom_Curve.GetObject() will give the Geom_Curve

    return aPnt
Пример #10
0
    def Reflect(self):
        h_surf = BRep_Tool.Surface(self.tar.srf)
        g_line = gp_Lin(self.ini.beam.Location(), self.ini.beam.Direction())
        ray = Geom_Line(g_line)
        if GeomAPI_IntCS(ray, h_surf).NbPoints():
            self.tar.beam = reflect(self.ini.beam, self.tar.srf)
        else:
            pln = make_plane(self.tar.axs.Location(),
                             dir_to_vec(self.tar.axs.Direction()), 500, -500,
                             500, -500)
            h_surf = BRep_Tool.Surface(pln)
            self.tar.beam = reflect(self.ini.beam, pln)

        print(self.ini.beam.Location())
        print(self.tar.beam.Location())

        GeomAPI_IntCS(ray, h_surf).IsDone()
        uvw = GeomAPI_IntCS(ray, h_surf).Parameters(1)
        u, v, w = uvw
        print(u, v, w)
        vz, v1, v2, r1, r2 = axs_curvature(h_surf, u, v)

        tar_surf_axs = gp_Ax3(self.tar.beam.Location(), vec_to_dir(vz),
                              vec_to_dir(v1))
        tar_surf = wavefront([r1, r2], tar_surf_axs)
        self.display.DisplayShape(tar_surf, color="BLUE")
        self.display.DisplayShape(axs_pln(tar_surf_axs))

        self.GO_Prop(w)

        h_tar_wave = BRep_Tool.Surface(self.ini_wave)
        vz, v1, v2, r1, r2 = axs_curvature(h_tar_wave, u, v)
        tar_wave_axs = self.tar.beam.Translated(gp_Vec(0, 0, 0))
        tar_wave_axs.SetXDirection(vec_to_dir(v1))
        self.tar.wave = wavefront([r1, r2], tar_wave_axs)
        self.display.DisplayShape(self.tar.wave, color="RED")
        self.display.DisplayShape(axs_pln(tar_wave_axs))
Пример #11
0
    def export_sfc1_axs(self, sfcfile="pln1_mat.sfc", name="pln1 Mat"):
        surf = BRep_Tool.Surface(self.surf)

        trf = set_trf(self.axs, gp_Ax3())
        xy0 = dispocc.proj_pnt_pln(self, surf.Value(0, 0), self.pln, self.axs)
        xy1 = dispocc.proj_pnt_pln(self, surf.Value(1, 1), self.pln, self.axs)
        xy0.Transform(trf)
        xy1.Transform(trf)

        m2_trf = set_trf(gp_Ax3(), self.axs)
        m2_pln = BRep_Tool.Surface(self.pln)
        for px in np.linspace(-100, 100, 10):
            for py in np.linspace(-100, 100, 10):
                p0 = gp_Pnt(px, py, 0).Transformed(m2_trf)
                p1 = obj.proj_pnt_pln(p0, self.surf, self.axs)

        #ix0, ix1 = m2.surf_pts.LowerRow(), m2.surf_pts.UpperRow()
        #iy0, iy1 = m2.surf_pts.LowerCol(), m2.surf_pts.UpperCol()
        #xy0 = m2.surf_pts.Value(ix0, iy0).Transformed(trf)
        #xy1 = m2.surf_pts.Value(ix1, iy1).Transformed(trf)
        nx, ny = 200, 200
        xs, xe = xy0.X(), xy1.X()
        ys, ye = xy0.Y(), xy1.Y()
        fp = open(sfcfile, "w")
        fp.write(" {} \n".format(name))
        fp.write(" {:.2e} {:.2e} {:.2e} {:.2e}\n".format(xs, ys, xe, ye))
        fp.write(" {:d} {:d}\n".format(nx, ny))
        for ix in np.linspace(0, 1, nx):
            for iy in np.linspace(0, 1, ny):
                p0 = surf.Value(ix, iy)
                p1 = dispocc.proj_pnt_pln(self, p0, self.pln, self.axs)
                pz = p1.Transformed(trf)
                z = p0.Distance(p1)
                fp.write(" {:.5e} ".format(z))
            fp.write("\n")
        fp.close()
        print(xy0)
Пример #12
0
def xyz_from_uv_face(uv, face):
    """
    Given a face and a uv coordinate, return the xyz coordinate
    """
    #    print(uv)
    [umin, umax, vmin, vmax] = face_extreme(face)
    u = umin + (umax - umin) * uv[0]
    v = vmin + (vmax - vmin) * uv[1]
    result = BRep_Tool.Surface(
        face
    )  ###result[0] is the handle of curve;result[1] is the umin; result[2] is umax
    aPnt = result.GetObject().Value(
        u, v)  ###handle_Geom_Curve.GetObject() will give the Geom_Curve

    return aPnt
Пример #13
0
def get_ellips(axs, wxy, face=None):
    wx, wy = wxy
    if wx >= wy:
        ax2 = axs
        r0, r1 = wx, wy
    else:
        ax2 = axs.Rotated(axs.Axis(), np.deg2rad(90))
        r0, r1 = wy, wx
    el = Geom_Ellipse(ax2, r0, r1)

    if face == None:
        return el
    else:
        curv = geomprojlib_Project(el.GetHandle(), BRep_Tool.Surface(face))
        return curv
Пример #14
0
 def proj_pln_show(self,
                   face,
                   nxy=[10, 10],
                   ux=[0, 1],
                   uy=[0, 1],
                   axs=gp_Ax3()):
     trf = set_trf(gp_Ax3(), axs)
     pln = self.make_plane_axs(axs, [-1000, 1000], [-1000, 1000])
     surf = BRep_Tool.Surface(face)
     for px in np.linspace(ux[0], ux[1], nxy[0]):
         for py in np.linspace(uy[0], uy[1], nxy[1]):
             p0 = surf.Value(px, py)
             p1 = self.proj_pnt_pln(p0, pln, axs)
             self.display.DisplayShape(p0)
             self.display.DisplayShape(p1)
Пример #15
0
 def __init__(self):
     super().__init__()
     self.axs = gp_Ax3()
     self.radi = [500, 200]
     self.rxyz = [1.5, 1.2, 1.5]
     mat = gp_Mat(self.rxyz[0], 0, 0, 0, self.rxyz[1], 0, 0, 0,
                  self.rxyz[2])
     gtrf = gp_GTrsf(mat, gp_XYZ(0, 0, 0))
     #self.t = Geom_ToroidalSurface(self.axs, *self.radi)
     self.t = Geom_SphericalSurface(self.axs, 100.0)
     self.face = BRepBuilderAPI_MakeFace(self.t, 1e-6).Face()
     self.face = BRepBuilderAPI_GTransform(self.face, gtrf).Shape()
     self.surf = BRep_Tool.Surface(self.face)
     self.prop = GeomLProp_SLProps(self.surf, 0.0, 0.0, 1, 1.0)
     self.export_stp(self.face)
     print(self.t.UPeriod())
 def _bspline_surface_from_face(self, face):
     """
     Private method that takes a TopoDS_Face and transforms it into a
     Bspline_Surface.
     
 	:param TopoDS_Face face: the TopoDS_Face to be converted
     :rtype: Geom_BSplineSurface
     """
     if not isinstance(face, TopoDS_Face):
         raise TypeError("face must be a TopoDS_Face")
     # TopoDS_Face converted to Nurbs
     nurbs_face = topods_Face(BRepBuilderAPI_NurbsConvert(face).Shape())
     # GeomSurface obtained from Nurbs face
     surface = BRep_Tool.Surface(nurbs_face)
     # surface is now further converted to a bspline surface
     bspline_surface = geomconvert_SurfaceToBSplineSurface(surface)
     return bspline_surface
Пример #17
0
def _unify_faces_array(input):
    ret = []
    fset = {}

    for i in input:
        surface = BRep_Tool.Surface(i.Face())

        adaptor_surface = BRepAdaptor_Surface(i.Face())
        surface_type = adaptor_surface.GetType()

        if surface_type == GeomAbs_Plane:
            pln = Geom_Plane.DownCast(surface)
            pln0 = pln.Pln()

            found = False

            for key, arr in fset.items():
                pnt = gp_Pnt()
                key.D0(0, 0, pnt)
                pln1 = key.Pln()

                dir0 = pln0.Axis().Direction()
                dir1 = pln1.Axis().Direction()

                if (dir0.IsEqual(dir1, 0.00001) and
                        abs(pln0.Distance(pln1.Axis().Location())) < 0.0000001
                        and abs(pln1.Distance(
                            pln0.Axis().Location())) < 0.0000001):

                    found = True
                    arr.append(i)
                    break

            if found == False:
                fset[pln] = [i]

        else:
            ret.append(i)
            continue

    for key, arr in fset.items():
        farr = _union(arr)
        ret.append(_unify_face(farr))

    return ret
Пример #18
0
    def __init__(self):
        plotocc.__init__(self)
        self.b1 = self.get_face(gen_ellipsoid(rxyz=[100, 100, 105]))
        self.b2 = self.get_face(gen_ellipsoid(rxyz=[210, 210, 210]))
        self.beam = gp_Ax3(gp_Pnt(0, 150, 0), gp_Dir(1, 1.5, 0))
        print(self.b1)

        h_surf = BRep_Tool.Surface(self.b2)
        ray = Geom_Line(self.beam.Axis())
        self.RayTrace = GeomAPI_IntCS(ray, h_surf)
        print(self.RayTrace.NbPoints())
        self.num = 0
        self.pts = [self.beam.Location()]
        for i in range(5):
            self.beam = self.reflect_b1(num=1)
            self.beam = self.reflect_b1(num=2)
            self.beam = self.reflect_b2(num=1)
            self.beam = self.reflect_b2(num=2)
Пример #19
0
    def GO_Prop(self, s=0):
        h_ini_wave = BRep_Tool.Surface(self.ini.wave)
        vz, v1, v2, r1, r2 = axs_curvature(h_ini_wave, 0.5, 0.5)

        r1_z = r1 + s / 2
        r2_z = r2 + s / 2
        ini_wave_axs = self.ini.beam.Translated(
            dir_to_vec(self.ini.beam.Direction()).Scaled(s / 2))
        ini_wave_axs.SetXDirection(vec_to_dir(v1))
        ini_wave = wavefront([r1_z, r2_z], ini_wave_axs)
        self.display.DisplayShape(ini_wave)

        r1_z = r1 + s
        r2_z = r2 + s
        self.ini_wave_axs = self.ini.beam.Translated(
            dir_to_vec(self.ini.beam.Direction()).Scaled(s))
        self.ini_wave_axs.SetXDirection(vec_to_dir(v1))
        self.ini_wave = wavefront([r1_z, r2_z], self.ini_wave_axs)
        self.display.DisplayShape(self.ini_wave)
Пример #20
0
    def __init__(self, pnt=gp_Pnt(-10, 0, -10), vec=gp_Vec(10, 20, 100)):
        plotocc.__init__(self)
        self.solver = ode(self.newton).set_integrator('dopri5')
        self.initial_conditions = self.gen_condition(pnt, vec)
        self.m = 10.0
        self.k = 0.0
        ray = spl_2pnt()

        px = np.linspace(-1, 1, 50) * 750
        py = np.linspace(-1, 1, 50) * 750
        mesh = np.meshgrid(px, py)
        surf = mesh[0]**2 / 500 + mesh[1]**2 / 750

        self.grd_axs = gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(-0.25, 0, 1))
        #self.grd = pln_for_axs(self.grd_axs, [500, 500])
        self.grd = spl_face(*mesh, surf)
        self.h_surf = BRep_Tool.Surface(self.grd)
        self.p_trce = GeomAPI_IntCS(ray, self.h_surf)

        self.pts, self.vel = [], []
Пример #21
0
def reflect_axs2(beam, surf, axs=gp_Ax3(), indx=1):
    p0, v0 = beam.Location(), dir_to_vec(beam.Direction())
    h_surf = BRep_Tool.Surface(surf)
    ray = Geom_Line(gp_Lin(p0, vec_to_dir(v0)))
    if GeomAPI_IntCS(ray, h_surf).NbPoints() == 0:
        return beam, beam, None
    elif GeomAPI_IntCS(ray, h_surf).NbPoints() == 1:
        return beam, beam, None
    GeomAPI_IntCS(ray, h_surf).IsDone()
    u, v, w = GeomAPI_IntCS(ray, h_surf).Parameters(indx)
    p1, vx, vy = gp_Pnt(), gp_Vec(), gp_Vec()
    GeomLProp_SurfaceTool.D1(h_surf, u, v, p1, vx, vy)
    vz = vx.Crossed(vy)
    vx.Normalize()
    vy.Normalize()
    vz.Normalize()
    v1 = v0.Mirrored(gp_Ax2(p1, vec_to_dir(vz), vec_to_dir(vx)))
    norm_ax = gp_Ax3(p1, vec_to_dir(vz), vec_to_dir(vx))
    beam_ax = gp_Ax3(p1, vec_to_dir(v1), beam.XDirection().Reversed())
    return beam_ax, norm_ax, 1
Пример #22
0
 def Reflect(self, beam=gp_Ax3(), surf=make_plane()):
     h_surf = BRep_Tool.Surface(surf)
     ray = Geom_Line(beam.Location(), beam.Direction())
     if GeomAPI_IntCS(ray, h_surf).NbPoints() == 0:
         beam_v1 = beam
     else:
         GeomAPI_IntCS(ray, h_surf).IsDone()
         uvw = GeomAPI_IntCS(ray, h_surf).Parameters(1)
         u, v, w = uvw
         p1, vx, vy = gp_Pnt(), gp_Vec(), gp_Vec()
         GeomLProp_SurfaceTool.D1(h_surf, u, v, p1, vx, vy)
         vz = vx.Crossed(vy)
         vx.Normalize()
         vy.Normalize()
         vz.Normalize()
         norm = gp_Ax3(p1, vec_to_dir(vz), vec_to_dir(vx))
         beam_v0 = beam
         beam_v0.SetLocation(p1)
         beam_v1 = beam_v0.Mirrored(norm.Ax2())
         beam_v1.XReverse()
     return beam_v1
Пример #23
0
def makeEdgesFacesIntersectPoints(edgesShape, facesShape):
    def findIntersectPoints(curve, surface):
        ps = []
        tool = GeomAPI_IntCS(curve, surface)
        pCount = tool.NbPoints()
        for i in range(1, pCount + 1):
            ps += [tool.Point(i)]
        return ps

    intersectPoints = []
    aEdges = getShapeItems(edgesShape, TopAbs_EDGE)
    aFaces = getShapeItems(facesShape, TopAbs_FACE)
    for aEdge in aEdges:
        for aFace in aFaces:
            # noinspection PyTypeChecker
            edgeCurves = BRep_Tool.Curve(aEdge)
            edgeTrimmedCurve = Geom_TrimmedCurve(edgeCurves[0], edgeCurves[1], edgeCurves[2])
            # noinspection PyTypeChecker
            faceSurface = BRep_Tool.Surface(aFace)
            foundIntersectPoints = findIntersectPoints(edgeTrimmedCurve, faceSurface)
            intersectPoints += foundIntersectPoints
    return intersectPoints
Пример #24
0
 def reflect_b2(self, num=1):
     h_surf = BRep_Tool.Surface(self.b2)
     ray = Geom_Line(self.beam.Axis())
     self.RayTrace.Perform(ray, h_surf)
     if self.RayTrace.NbPoints() == 0:
         beam = self.beam
     else:
         self.num += 1
         uvw = self.RayTrace.Parameters(num)
         u, v, w = uvw
         p1, vx, vy = gp_Pnt(), gp_Vec(), gp_Vec()
         GeomLProp_SurfaceTool.D1(h_surf, u, v, p1, vx, vy)
         vz = vx.Crossed(vy).Reversed()
         norm = gp_Ax3(p1, vec_to_dir(vz), vec_to_dir(vx))
         self.show_axs_pln(norm, scale=10)
         beam = self.beam
         beam.SetLocation(p1)
         beam.SetDirection(beam.Direction().Reversed())
         beam.Mirror(norm.Axis())
         print(self.num, self.b2, p1)
         self.pts.append(p1)
         # self.beam.XReverse()
         # self.beam.Mirror(norm.Ax2())
     return beam
Пример #25
0
 def reflect_beam(self, beam0=gp_Ax3(), tr=0):
     v0 = dir_to_vec(beam0.Direction())
     v1 = dir_to_vec(beam0.XDirection())
     surf = BRep_Tool.Surface(self.surf)
     ray = Geom_Line(beam0.Axis())
     uvw = GeomAPI_IntCS(ray, surf).Parameters(1)
     u, v, w = uvw
     p1, vx, vy = gp_Pnt(), gp_Vec(), gp_Vec()
     GeomLProp_SurfaceTool.D1(surf, u, v, p1, vx, vy)
     vz = vx.Crossed(vy)
     if vz.Dot(v0) > 0:
         vz.Reverse()
     vx.Normalize()
     vy.Normalize()
     vz.Normalize()
     self.beam = gp_Ax3(p1, vec_to_dir(v0.Reversed()),
                        vec_to_dir(v1.Reversed()))
     self.norm = gp_Ax3(p1, vec_to_dir(vz), vec_to_dir(vx))
     if tr == 0:
         self.beam.Mirror(self.norm.Ax2())
         if self.beam.Direction().Dot(self.norm.Direction()) < 0:
             self.beam.ZReverse()
     elif tr == 1:
         self.beam.ZReverse()
Пример #26
0
                                   1e-6).Face()

    display.DisplayShape(surf)
    display.DisplayShape(obj)
    #display.DisplayShape(axs_pln(axs))

    display.FitAll()
    start_display()

    init = "surf1"
    surf = ["surf2", "surf3", "surf4"]

    surf1 = SurfSystem("../input/", "surf1")
    surf2 = SurfSystem("../input/", "surf2")

    h_surf = BRep_Tool.Surface(surf1.srf)
    second_derivative(h_surf, 0.5, 0.5)
    second_derivative(h_surf, 0.5, 0.0)
    second_derivative(h_surf, 0.0, 0.5)
    """h_surf = BRep_Tool.Surface(surf2.srf)
    second_derivative(h_surf, 0.5, 0.5)
    second_derivative(h_surf, 0.5, 0.0)
    second_derivative(h_surf, 0.0, 0.5)
    second_derivative(h_surf, 0.0, 0.0)"""
    """print(surf1.name, surf1.axs.Location())
    print(surf2.name, surf2.axs.Location())
    print(surf2.srf)
    loc_surf = surf2.srf
    loc_trsf = gp_Trsf()
    loc_trsf.SetTransformation(gp_Ax3(), surf2.axs)
    loc_face = TopLoc_Location(loc_trsf)
Пример #27
0

# https://www.opencascade.com/doc/occt-7.4.0/refman/html/class_b_rep_builder_a_p_i___make_face.html
if __name__ == '__main__':
    obj = plotocc()
    obj.show_axs_pln(obj.base_axs, scale=1)

    px = np.linspace(-1, 1, 10) * 5
    py = np.linspace(-1, 1, 10) * 5
    mesh = np.meshgrid(px, py)
    data = mesh[0]**2 / 10 + mesh[1]**2 / 20
    axis = gp_Ax3(gp_Pnt(0.5, 0.0, 0.0), gp_Dir(0, 0, 1))
    face = spl_face(*mesh, data, axs=axis)
    #face = bez_face(*mesh, data, axs=axis)
    trsf = face.Location().Transformation()
    surf = BRep_Tool.Surface(face)

    axis_0 = axis.Transformed(trsf)
    axis_0.Translate(gp_Pnt(0, 0, 0), gp_Pnt(2, 0, 0))
    poly_0 = obj.make_EllipWire(rxy=[1.1, 1.0], axs=axis_0)
    proj = BRepProj_Projection(poly_0, face, axis.Direction())
    bound_poly_0 = proj.Current()

    axis_1 = axis.Transformed(trsf)
    axis_1.Translate(gp_Pnt(0, 0, 0), gp_Pnt(-2, 0, 0))
    poly_1 = obj.make_PolyWire(num=6, axs=axis_1)
    proj = BRepProj_Projection(poly_1, face, axis.Direction())
    bound_poly_1 = proj.Current()

    axis_2 = axis.Transformed(trsf)
    axis_2.Translate(gp_Pnt(0, 0, 0), gp_Pnt(0, 2, 0))
Пример #28
0
 def proj_pnt_pln(self, pnt, surf, axs=gp_Ax3()):
     lin = gp_Lin(pnt, axs.Direction())
     sxy = GeomAPI_IntCS(Geom_Line(lin), BRep_Tool.Surface(surf)).Point(1)
     return sxy
Пример #29
0
def Prj_pnt_to_face(axs, pnt, face):
    lin = gp_Lin(pnt, axs.Direction())
    sxy = GeomAPI_IntCS(Geom_Line(lin).GetHandle(),
                        BRep_Tool.Surface(face)).Point(1)
    return sxy
Пример #30
0
    obj = dispocc(touch=True)
    axs = gp_Ax3(gp_Pnt(100, -100, 200), gp_Dir(0, 0.5, 1.0),
                 gp_Dir(0.5, 1.0, 0))
    qp = gp_Quaternion()
    qp.SetRotation(gp_Vec(0, 0, 100), gp_Vec(50, 0, 0))
    print(qp)
    obj.show_axs_pln(axs, scale=50, name="axs0")

    trf = gp_Trsf()
    trf.SetTransformation(qp, gp_Vec(0, 0, 1))
    ax1 = axs.Transformed(trf)
    obj.show_axs_pln(ax1, scale=50, name="axs1")

    ax2 = obj.prop_axs(ax1, scale=50)
    obj.show_axs_pln(ax2, scale=50, name="axs2")

    ax3 = obj.rot_axis(ax2, xyz="z", deg=45)
    obj.show_axs_pln(ax3, scale=50)
    pln1 = obj.show_plane(ax3, scale=25, trs=0.9, color="RED")
    srf1 = BRep_Tool.Surface(pln1)
    ax3 = obj.rot_axis(ax3, xyz="x", deg=5)
    obj.show_axs_pln(ax3, scale=50)
    pln2 = obj.show_plane(ax3, scale=25, trs=0.9, color="BLUE")
    srf2 = BRep_Tool.Surface(pln2)

    api = GeomAPI_IntSS(srf1, srf2, 0.1E-3)
    obj.display.DisplayShape(api.Line(1))

    obj.show_axs_pln(scale=25)
    obj.show()