示例#1
0
文件: occ_utils.py 项目: hducg/CADGen
def normal_to_face_center(face):
    u_min, u_max, v_min, v_max = breptools_UVBounds(face)
    u_mid = (u_min + u_max) / 2.
    v_mid = (v_min + v_max) / 2.

    surf = BRep_Tool_Surface(face)
    normal = GeomLProp_SLProps(surf,u_mid, v_mid,1,0.01).Normal()  
    if face.Orientation() == TopAbs_REVERSED:
        normal.Reverse()
    
    return normal
示例#2
0
文件: occ_utils.py 项目: hducg/CADGen
def sample_point(face):
    #    randomly choose a point from F
    u_min, u_max, v_min, v_max = breptools_UVBounds(face)
    u = random.uniform(u_min, u_max)
    v = random.uniform(v_min, v_max)

    itool = IntTools_FClass2d(face, 1e-6)
    while itool.Perform(gp_Pnt2d(u,v)) != 0:
        print('outside')
        u = random.uniform(u_min, u_max)
        v = random.uniform(v_min, v_max)

    P = BRepAdaptor_Surface(face).Value(u, v)

#   the normal
    surf = BRep_Tool_Surface(face)
    D = GeomLProp_SLProps(surf,u,v,1,0.01).Normal()
    if face.Orientation() == TopAbs_REVERSED:
        D.Reverse()

    return P, D