예제 #1
0
def point_in_solid(occ_solid, pypt):
    gp_pnt = gp_Pnt(pypt[0], pypt[1], pypt[2])
    if Common.point_in_solid(occ_solid, gp_pnt)[0]:
        return True
    elif Common.point_in_solid(occ_solid, gp_pnt)[0] == None:
        return None  #means its on the solid
    else:
        return False
예제 #2
0
def get_bounding_box(occtopology):
    """
    This function calculates the bounding box of the OCCtopology.
 
    Parameters
    ----------
    occtopology : OCCtopology
        The OCCtopology to be analysed.
        OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex 
        
    Returns
    -------
    xmin : float
        Minimum X-coordinate
        
    ymin : float
        Minimum Y-coordinate
        
    zmin : float
        Minimum Z-coordinate
        
    xmax : float
        Maximum X-coordinate
        
    ymax : float
        Maximum Y-coordinate
        
    zmax : float
        Maximum Z-coordinate
    """
    return Common.get_boundingbox(occtopology)
예제 #3
0
def get_bounding_box(occtopology):
    """
    This function calculates the bounding box of the OCCtopology.
 
    Parameters
    ----------
    occtopology : OCCtopology
        The OCCtopology to be analysed.
        OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex 
        
    Returns
    -------
    xmin : float
        Minimum X-coordinate
        
    ymin : float
        Minimum Y-coordinate
        
    zmin : float
        Minimum Z-coordinate
        
    xmax : float
        Maximum X-coordinate
        
    ymax : float
        Maximum Y-coordinate
        
    zmax : float
        Maximum Z-coordinate
    """
    return Common.get_boundingbox(occtopology)
예제 #4
0
def rmv_duplicated_pts_by_distance(pyptlist, distance=1e-06):
    """
    This function fuses all the points within a certain distance.
 
    Parameters
    ----------
    pyptlist : a list of tuples
        List of points to be fused. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), 
        thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), ...]
        
    distance : float, optional
        The minimal distance between two points, default = 1e-06. Any points closer than this distance will be fused.
        
    Returns
    -------
    list of fused points : pyptlist
        The list of fused points.
    """
    vert_list = construct.make_occvertex_list(pyptlist)
    occpt_list = occvertex_list_2_occpt_list(vert_list)

    filtered_pt_list = Common.filter_points_by_distance(occpt_list,
                                                        distance=distance)
    f_pyptlist = occpt_list_2_pyptlist(filtered_pt_list)

    return f_pyptlist
예제 #5
0
파일: modify.py 프로젝트: chenkianwee/envuo
def rmv_duplicated_pts_by_distance(pyptlist, distance = 1e-06):
    """
    This function fuses all the points within a certain distance.
 
    Parameters
    ----------
    pyptlist : a list of tuples
        List of points to be fused. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), 
        thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), ...]
        
    distance : float, optional
        The minimal distance between two points, default = 1e-06. Any points closer than this distance will be fused.
        
    Returns
    -------
    list of fused points : pyptlist
        The list of fused points.
    """
    vert_list = construct.make_occvertex_list(pyptlist)
    occpt_list = occvertex_list_2_occpt_list(vert_list)
    
    filtered_pt_list = Common.filter_points_by_distance(occpt_list, distance = distance)
    f_pyptlist = occpt_list_2_pyptlist(filtered_pt_list)

    return f_pyptlist
예제 #6
0
def make_bspline_edge_interpolate(pyptlist, is_closed):
    '''
    pyptlist: list of pypt
    type: list(tuple)
    
    is_closed: is the curve open or close
    type: bool, True or False
    '''
    gpptlist = make_gppntlist(pyptlist)
    bcurve = Common.interpolate_points_to_spline_no_tangency(gpptlist,
                                                             closed=is_closed)
    curve_edge = BRepBuilderAPI_MakeEdge(bcurve)
    return curve_edge.Edge()
예제 #7
0
def calc_center(product, ifcfile):
    productIfc = ifcfile.by_id(product.pid)
    try:
        productShape = get_shape(productIfc)
        center = Common.center_boundingbox(productShape)
        pnt = Pnt(X=center.Coord()[0],
                  Y=center.Coord()[1],
                  Z=center.Coord()[2])
        pnt.save()
        product.center.add(pnt)
        product.save()

    except:
        pass
예제 #8
0
def point_in_solid(pypt, occsolid):
    """
    This function checks if a point is inside an OCCsolid.
 
    Parameters
    ----------
    pypt : tuple of floats
        Check if this point is inside the OCCsolid. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)
        
    occsolid : OCCsolid
        Check if the point is inside this OCCsolid.

    Returns
    -------
    True, False, None : True, False, None
        If True means the point is in the solid, if False the point is not in the solid, if None means the point is on the solid.
    """
    gp_pnt = gp_Pnt(pypt[0], pypt[1], pypt[2] )
    if Common.point_in_solid(occsolid, gp_pnt)[0]:
        return True 
    elif Common.point_in_solid(occsolid, gp_pnt)[0] == None:
        return None #means its on the solid
    else: 
        return False
예제 #9
0
def point_in_solid(pypt, occsolid):
    """
    This function checks if a point is inside an OCCsolid.
 
    Parameters
    ----------
    pypt : tuple of floats
        Check if this point is inside the OCCsolid. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)
        
    occsolid : OCCsolid
        Check if the point is inside this OCCsolid.

    Returns
    -------
    True, False, None : True, False, None
        If True means the point is in the solid, if False the point is not in the solid, if None means the point is on the solid.
    """
    gp_pnt = gp_Pnt(pypt[0], pypt[1], pypt[2])
    if Common.point_in_solid(occsolid, gp_pnt)[0]:
        return True
    elif Common.point_in_solid(occsolid, gp_pnt)[0] == None:
        return None  #means its on the solid
    else:
        return False
예제 #10
0
def resample_wire(occwire):
    """
    This function resamples an OCCwire uniformly.
 
    Parameters
    ----------        
    occwire : OCCwire
        The OCCwire to be resampled.

    Returns
    -------
    resampled wire : OCCwire
        The resampled OCCwire.
    """
    resample_curve = Common.resample_curve_with_uniform_deflection(occwire)
    return resample_curve
예제 #11
0
def face_area(occface):
    """
    This function calculates the area of the OCCface.
 
    Parameters
    ----------
    occface : OCCface
        The OCCface to be analysed.
        
    Returns
    -------
    face area : float
        The area of the face.
    """
    surface_area = Common.GpropsFromShape(occface).surface()
    return surface_area.Mass()
예제 #12
0
파일: modify.py 프로젝트: chenkianwee/envuo
def resample_wire(occwire):
    """
    This function resamples an OCCwire uniformly.
 
    Parameters
    ----------        
    occwire : OCCwire
        The OCCwire to be resampled.

    Returns
    -------
    resampled wire : OCCwire
        The resampled OCCwire.
    """
    resample_curve = Common.resample_curve_with_uniform_deflection(occwire)
    return resample_curve
예제 #13
0
def get_centre_bbox(occtopology):
    """
    This function calculates the centre of the bounding box of the OCCtopology.
 
    Parameters
    ----------
    occtopology : OCCtopology
        The OCCtopology to be analysed.
        OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex 
        
    Returns
    -------
    centre point : pypt
        The centre point of the OCCtopology's bounding box.
    """
    occ_midpt = Common.center_boundingbox(occtopology)
    return (occ_midpt.X(), occ_midpt.Y(), occ_midpt.Z())
예제 #14
0
def get_centre_bbox(occtopology):
    """
    This function calculates the centre of the bounding box of the OCCtopology.
 
    Parameters
    ----------
    occtopology : OCCtopology
        The OCCtopology to be analysed.
        OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex 
        
    Returns
    -------
    centre point : pypt
        The centre point of the OCCtopology's bounding box.
    """
    occ_midpt = Common.center_boundingbox(occtopology)
    return (occ_midpt.X(), occ_midpt.Y(), occ_midpt.Z())
예제 #15
0
def minimum_distance(occtopology1, occtopology2):
    """
    This function calculates the minimum distance between the two OCCtopologies.
 
    Parameters
    ----------
    occtopology1 : OCCtopology
        The OCCtopology to be analysed.
        OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex 
        
    occtopology2 : OCCtopology
        The OCCtopology to be analysed.
        OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex 
        
    Returns
    -------
    minimum distance : float
        The minimum distance between the two topologies.
    """
    min_dist, min_dist_shp1, min_dist_shp2 = Common.minimum_distance(occtopology1, occtopology2)
    return min_dist
예제 #16
0
def minimum_distance(occtopology1, occtopology2):
    """
    This function calculates the minimum distance between the two OCCtopologies.
 
    Parameters
    ----------
    occtopology1 : OCCtopology
        The OCCtopology to be analysed.
        OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex 
        
    occtopology2 : OCCtopology
        The OCCtopology to be analysed.
        OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex 
        
    Returns
    -------
    minimum distance : float
        The minimum distance between the two topologies.
    """
    min_dist, min_dist_shp1, min_dist_shp2 = Common.minimum_distance(
        occtopology1, occtopology2)
    return min_dist
예제 #17
0
def get_bbox(shape, length):

    vertices = []
    shape = Common.get_boundingbox(shape)
    vertices.append([
        correctLengt(shape[0], length, None),
        correctLengt(shape[1], length, None),
        correctLengt(shape[2], length, None)
    ])
    vertices.append([
        correctLengt(shape[3], length, None),
        correctLengt(shape[1], length, None),
        correctLengt(shape[2], length, None)
    ])
    vertices.append([
        correctLengt(shape[0], length, None),
        correctLengt(shape[4], length, None),
        correctLengt(shape[2], length, None)
    ])
    vertices.append([
        correctLengt(shape[0], length, None),
        correctLengt(shape[1], length, None),
        correctLengt(shape[5], length, None)
    ])
    vertices.append([
        correctLengt(shape[3], length, None),
        correctLengt(shape[1], length, None),
        correctLengt(shape[5], length, None)
    ])
    vertices.append([
        correctLengt(shape[0], length, None),
        correctLengt(shape[4], length, None),
        correctLengt(shape[5], length, None)
    ])

    return vertices
예제 #18
0
def get_bounding_box(occ_shape):
    """return xmin,ymin,zmin,xmax,ymax,zmax"""
    return Common.get_boundingbox(occ_shape)
예제 #19
0
def get_centre_bbox(occ_shape):
    occ_midpt = Common.center_boundingbox(occ_shape)
    return (occ_midpt.X(), occ_midpt.Y(), occ_midpt.Z())
예제 #20
0
def face_area(occ_face):
    surface_area = Common.GpropsFromShape(occ_face).surface()
    return surface_area.Mass()
예제 #21
0
def minimum_distance(occ_shape1, occ_shape2):
    min_dist, min_dist_shp1, min_dist_shp2 = Common.minimum_distance(
        occ_shape1, occ_shape2)
    return min_dist