예제 #1
0
def face_normal(face):
    from OCC.Core.BRepTools import breptools_UVBounds
    umin, umax, vmin, vmax = breptools_UVBounds(face)
    surf = BRep_Tool().Surface(face)
    props = GeomLProp_SLProps(surf, (umin+umax)/2., (vmin+vmax)/2., 1, TOLERANCE)
    norm = props.Normal()
    if face.Orientation() == TopAbs_REVERSED:
        norm.Reverse()
    return norm
예제 #2
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
예제 #3
0
 def is_trimmed(self):
     """
     :return: True if the Wire delimiting the Face lies on the bounds
     of the surface
     if this is not the case, the wire represents a contour that delimits
     the face [ think cookie cutter ]
     and implies that the surface is trimmed
     """
     _round = lambda x: round(x, 3)
     a = map(_round, breptools_UVBounds(self))
     b = map(_round, self.adaptor.Surface().Surface().GetObject().Bounds())
     if a != b:
         print('a,b', a, b)
         return True
     return False
예제 #4
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
예제 #5
0
 def domain(self):
     '''the u,v domain of the curve
     :return: UMin, UMax, VMin, VMax
     '''
     return breptools_UVBounds(self)