コード例 #1
0
ファイル: calculate.py プロジェクト: Linwal/pyliburo
def face_midpt(occface):
    fc = face.Face(occface)
    centre_uv, gpcentre_pt = fc.mid_point()
    centre_pt = (gpcentre_pt.X(), gpcentre_pt.Y(), gpcentre_pt.Z())
    #is_pt_in_face = point_in_face(centre_pt, occface)
    #if not is_pt_in_face:

    return centre_pt
コード例 #2
0
ファイル: calculate.py プロジェクト: Linwal/pyliburo
def face_normal(occface):
    fc = face.Face(occface)
    centre_uv, centre_pt = fc.mid_point()
    normal_dir = fc.DiffGeom.normal(centre_uv[0], centre_uv[1])
    if occface.Orientation() == TopAbs_REVERSED:
        normal_dir = normal_dir.Reversed()

    normal = (normal_dir.X(), normal_dir.Y(), normal_dir.Z())
    return normal
コード例 #3
0
ファイル: calculate.py プロジェクト: CES-MDE/py4design
def face_midpt(occface):
    """
    This function calculates the mid point of the OCCface.
 
    Parameters
    ----------
    occface : OCCface
        The OCCface to be analysed.
        
    Returns
    -------
    face mid point : pypt
        The mid point of the face.
    """
    fc = face.Face(occface)
    centre_uv, gpcentre_pt = fc.mid_point()
    centre_pt = (gpcentre_pt.X(), gpcentre_pt.Y(), gpcentre_pt.Z())
    return centre_pt
コード例 #4
0
ファイル: calculate.py プロジェクト: CES-MDE/py4design
def is_face_planar(occface, tolerance=1e-06):
    """
    This function calculates if the OCCface is planar.
 
    Parameters
    ----------
    occface : OCCface
        The OCCface to be analysed.
        
    tolerance : float, optional
        The precision for checking the planarity, Default = 1e-06.
        
    Returns
    -------
    True or False : bool
        If True face is planar, if False face is not planar.
    """
    fc = face.Face(occface)
    return fc.is_planar(tol=tolerance)
コード例 #5
0
ファイル: calculate.py プロジェクト: CES-MDE/py4design
def face_normal(occface):
    """
    This function calculates the normal of the OCCface.
 
    Parameters
    ----------
    occface : OCCface
        The OCCface to be analysed.
        
    Returns
    -------
    face normal : pydirection
        The normal of the face. A pydir is a tuple that documents the xyz vector of a dir e.g. (x,y,z)
    """
    fc = face.Face(occface)
    centre_uv, centre_pt = fc.mid_point()
    normal_dir = fc.DiffGeom.normal(centre_uv[0], centre_uv[1])
    if occface.Orientation() == TopAbs_REVERSED:
        normal_dir = normal_dir.Reversed()

    normal = (normal_dir.X(), normal_dir.Y(), normal_dir.Z())
    return normal
コード例 #6
0
ファイル: calculate.py プロジェクト: CES-MDE/py4design
def project_edge_on_face(occedge, occface):
    """
    This function projects an OCCedge towards the OCCface. #TODO: figure out if it is a faceplane or just the face. 
 
    Parameters
    ----------
    occedge : OCCedge
        The edge to be projected.
        
    occface : OCCface
        The face to be projected on.

    Returns
    -------
    Projected edge : OCCedge
        The projected edge on the face.
    """

    fc = face.Face(occface)
    projected_curve = fc.project_curve(occedge)
    curve_edge = BRepBuilderAPI_MakeEdge(projected_curve)
    return curve_edge.Edge()
コード例 #7
0
ファイル: calculate.py プロジェクト: CES-MDE/py4design
def project_point_on_faceplane(pypt, occface):
    """
    This function projects a point towards the OCCface. The face is treated as a plane and it stretched through infinity.  
 
    Parameters
    ----------
    pypt : tuple of floats
        The point to be projected. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)
        
    occface : OCCface
        The face to be projected on.

    Returns
    -------
    Projected point : pypt
        The projected point on the face.
    """
    gp_pt = gp_Pnt(pypt[0], pypt[1], pypt[2])
    fc = face.Face(occface)
    uv, projected_pt = fc.project_vertex(gp_pt)
    proj_pypt = modify.occpt_2_pypt(projected_pt)
    return proj_pypt
コード例 #8
0
ファイル: construct.py プロジェクト: Linwal/pyliburo
def grid_face(occ_face, udim, vdim):
    #returns a series of polygons
    pt_list = []
    face_list = []
    fc = face.Face(occ_face)
    umin, umax, vmin, vmax = fc.domain()
    u_div = int(math.ceil((umax - umin) / udim))
    v_div = int(math.ceil((vmax - vmin) / vdim))
    for ucnt in range(u_div + 1):
        for vcnt in range(v_div + 1):
            u = umin + (ucnt * udim)
            v = vmin + (vcnt * vdim)
            occpt = fc.parameter_to_point(u, v)
            pt = [occpt.X(), occpt.Y(), occpt.Z()]
            pt_list.append(pt)

    for pucnt in range(u_div):
        for pvcnt in range(v_div):
            pcnt = pucnt * (v_div + 1) + pvcnt
            #print pcnt
            pt1 = pt_list[pcnt]
            pt2 = pt_list[pcnt + v_div + 1]
            pt3 = pt_list[pcnt + v_div + 2]
            pt4 = pt_list[pcnt + 1]
            occface = make_polygon([pt1, pt2, pt3, pt4])
            face_list.append(occface)

    #intersect the grids and the face so that those grids that are not in the face will be erase
    intersection_list = []
    for f in face_list:
        intersection = BRepAlgoAPI_Common(f, occ_face).Shape()
        compound = fetch.shape2shapetype(intersection)
        inter_face_list = fetch.topos_frm_compound(compound)["face"]
        if inter_face_list:
            for inter_face in inter_face_list:
                intersection_list.append(inter_face)
    return intersection_list
コード例 #9
0
ファイル: calculate.py プロジェクト: Linwal/pyliburo
def is_face_planar(occface, tolerance):
    fc = face.Face(occface)
    return fc.is_planar(tol=tolerance)
コード例 #10
0
ファイル: calculate.py プロジェクト: Linwal/pyliburo
def project_point_on_faceplane(occface, pypt):
    gp_pt = gp_Pnt(pypt[0], pypt[1], pypt[2])
    fc = face.Face(occface)
    uv, projected_pt = fc.project_vertex(gp_pt)
    return projected_pt
コード例 #11
0
ファイル: calculate.py プロジェクト: Linwal/pyliburo
def project_edge_on_face(occface, occ_edge):
    #TODO: figure out if it is a faceplane or just the face
    fc = face.Face(occface)
    projected_curve = fc.project_curve(occ_edge)
    return projected_curve