def test_point_from_projections(self):
     """Test: point from projections"""
     P = gp_Pnt(7.0, 8.0, 9.0)
     radius = 5
     SP = Geom_SphericalSurface(gp_Ax3(gp_XOY()), radius)
     PPS = GeomAPI_ProjectPointOnSurf(P, SP)
     N = PPS.NearestPoint()
     self.assertTrue(isinstance(N, gp_Pnt))
     NbResults = PPS.NbPoints()
     if NbResults > 0:
         for i in range(1, NbResults + 1):
             Q = PPS.Point(i)
             self.assertTrue(isinstance(Q, gp_Pnt))
             distance = PPS.Distance(i)
             # in any case, it should be > 1
             self.assertGreater(distance, 1.0)
     lower_d = PPS.LowerDistance()
     self.assertGreater(lower_d, 1.0)
     if NbResults > 0:
         for i in range(1, NbResults + 1):
             Q = PPS.Point(i)
             distance = PPS.Distance(i)
             pstring = "Q" + repr(i) + ": at Distance :" + repr(
                 PPS.Distance(i))
             print(pstring)
 def test_point_from_projections(self):
     '''Test: point from projections'''
     P = gp_Pnt(7., 8., 9.)
     radius = 5
     SP = Geom_SphericalSurface(gp_Ax3(gp_XOY()), radius)
     PPS = GeomAPI_ProjectPointOnSurf(P, SP)
     N = PPS.NearestPoint()
     NbResults = PPS.NbPoints()
     if NbResults > 0:
         for i in range(1, NbResults + 1):
             Q = PPS.Point(i)
             distance = PPS.Distance(i)
     pstring = "N  : at Distance : " + repr(PPS.LowerDistance())
     if NbResults > 0:
         for i in range(1, NbResults + 1):
             Q = PPS.Point(i)
             distance = PPS.Distance(i)
             pstring = "Q" + repr(i) + ": at Distance :" + repr(
                 PPS.Distance(i))
예제 #3
0
    mesh = np.meshgrid(px, py)
    data = mesh[0]**2 / 1000 + mesh[1]**2 / 2000
    face = spl_face(*mesh, data, ax0)
    surf = BRep_Tool.Surface(face)
    surf.Rotate(gp_Ax1(ax0.Location(), ax0.Direction()), np.deg2rad(15))

    ax1 = gp_Ax3(gp_Pnt(150, 150, -20),
                 gp_Dir(0.5, 0.1, 1.0),
                 gp_Dir(0.0, 0.1, 1.0))
    pnt = ax1.Location()
    api = GeomAPI_ProjectPointOnSurf(pnt, surf)
    print(api.NbPoints(), api.NearestPoint())
    for i in range(api.NbPoints()):
        idx = i + 1
        u, v = api.Parameters(idx)
        obj.display.DisplayShape(api.Point(idx))
        print(idx, u, v)

    print(GeomAPI_IntCS(Geom_Line(ax1.Axis()), surf).NbPoints())
    u, v, w = GeomAPI_IntCS(Geom_Line(ax1.Axis()), surf).Parameters(1)
    p, vx, vy = gp_Pnt(), gp_Vec(), gp_Vec()
    api = GeomLProp_SLProps(surf, u, v, 1, 0.1E-03)
    pnt = api.Value()
    dst = pnt.Distance(ax1.Location())
    ax2 = obj.prop_axs(ax1, dst)
    rim_u = surf.UIso(u)
    rim_v = surf.VIso(v)
    print(v, rim_u.FirstParameter(), rim_u.LastParameter())
    print(u, rim_v.FirstParameter(), rim_v.LastParameter())
    obj.display.DisplayShape(rim_u, color="BLUE")
    obj.display.DisplayShape(rim_v, color="BLUE")