Exemplo n.º 1
0
def project_shape_on_shape(occtopo_proj, occtopo_projon, tolerance=1e-06):
    """
    This function project the occtopoproj (OCCtopology) onto the occtopoprojon (OCCtopology), and returns the list of projected points.
 
    Parameters
    ----------
    occtopo_proj : OCCtopology
        The OCCtopology to to project.
        OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex 
        
    occtopo_projon : OCCtopology
        The OCCtopology to be projected on.
        OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex 
        
    tolerance : float, optional
        The precision of the projection, Default = 1e-06.
        
    Returns
    -------
    list of projected points : pyptlist
        The list of projected points.
    """

    interpyptlist = []
    dss = BRepExtrema_DistShapeShape(occtopo_proj, occtopo_projon)
    dss.SetDeflection(tolerance)
    dss.Perform()
    min_dist = dss.Value()
    npts = dss.NbSolution()
    for i in range(npts):
        gppt = dss.PointOnShape2(i + 1)
        pypt = (gppt.X(), gppt.Y(), gppt.Z())
        interpyptlist.append(pypt)

    return interpyptlist
Exemplo n.º 2
0
    def __init__(self, shape_1, shape_2):
        dist_shape_shape = BRepExtrema_DistShapeShape(shape_1, shape_2)
        dist_shape_shape.Perform()

        with AssertIsDone(dist_shape_shape,
                          'Failed computing minimum distances'):
            self._min_dist = dist_shape_shape.Value()
            self._points_pairs = list()
            self._nb_solutions = dist_shape_shape.NbSolution()
            for i in range(1, dist_shape_shape.NbSolution() + 1):
                self._points_pairs.append((dist_shape_shape.PointOnShape1(i),
                                           dist_shape_shape.PointOnShape2(i)))
def compute_minimal_distance_between_cubes():
    """ compute the minimal distance between 2 cubes

    the line between the 2 points is rendered in cyan

    """
    b1 = BRepPrimAPI_MakeBox(gp_Pnt(100, 0, 0), 10., 10., 10.).Shape()
    b2 = BRepPrimAPI_MakeBox(gp_Pnt(45, 45, 45), 10., 10., 10.).Shape()
    display.DisplayShape([b1, b2])

    dss = BRepExtrema_DistShapeShape()
    dss.LoadS1(b1)
    dss.LoadS2(b2)
    dss.Perform()

    assert dss.IsDone()

    edg = make_edge(dss.PointOnShape1(1), dss.PointOnShape2(1))
    display.DisplayColoredShape([edg], color="CYAN")
Exemplo n.º 4
0
def minimum_distance(shp1, shp2):
    """
    compute minimum distance between 2 BREP's
    @param shp1:    any TopoDS_*
    @param shp2:    any TopoDS_*

    @return: minimum distance,
             minimum distance points on shp1
             minimum distance points on shp2
    """
    bdss = BRepExtrema_DistShapeShape(shp1, shp2)
    bdss.Perform()
    with assert_isdone(bdss, 'failed computing minimum distances'):
        min_dist = bdss.Value()
        min_dist_shp1, min_dist_shp2 = [], []
        for i in range(1, bdss.NbSolution() + 1):
            min_dist_shp1.append(bdss.PointOnShape1(i))
            min_dist_shp2.append(bdss.PointOnShape2(i))
    return min_dist, min_dist_shp1, min_dist_shp2
Exemplo n.º 5
0
def project_shape_on_shape(occshape1, occshape2, tolerance=1e-06):
    '''
    occshape1: shape to project
    type: occshape
    
    occshape2: shape to be projected on
    type: occshape
    
    tolerance: precision of the projection
    type: float
    '''
    interpyptlist = []
    dss = BRepExtrema_DistShapeShape(occshape1, occshape2)
    dss.SetDeflection(tolerance)
    dss.Perform()
    min_dist = dss.Value()
    npts = dss.NbSolution()
    for i in range(npts):
        gppt = dss.PointOnShape2(i + 1)
        pypt = (gppt.X(), gppt.Y(), gppt.Z())
        interpyptlist.append(pypt)

    return interpyptlist