def split_face_and_edge(event=None):
    display.EraseAll()
    p0 = gp_Pnt()
    vnorm = gp_Dir(1, 0, 0)
    pln = gp_Pln(p0, vnorm)
    face = BRepBuilderAPI_MakeFace(pln, -10, 10, -10, 10).Face()
    p1 = gp_Pnt(0, 0, 15)
    p2 = gp_Pnt(0, 0, -15)
    edge = BRepBuilderAPI_MakeEdge(p1, p2).Edge()
    # Initialize splitter
    splitter = GEOMAlgo_Splitter()
    # Add both the face and edge as arguments. This will split both of the
    # shapes.
    splitter.AddArgument(face)
    splitter.AddArgument(edge)
    splitter.Perform()
    display.DisplayShape(splitter.Shape())
    display.FitAll()
def split_edge_with_face(event=None):
    display.EraseAll()
    p0 = gp_Pnt()
    vnorm = gp_Dir(1, 0, 0)
    pln = gp_Pln(p0, vnorm)
    face = BRepBuilderAPI_MakeFace(pln, -10, 10, -10, 10).Face()
    p1 = gp_Pnt(0, 0, 15)
    p2 = gp_Pnt(0, 0, -15)
    edge = BRepBuilderAPI_MakeEdge(p1, p2).Edge()
    # Initialize splitter
    splitter = GEOMAlgo_Splitter()
    # Add the edge as an argument and the face as a tool. This will split
    # the edge with the face.
    splitter.AddArgument(edge)
    splitter.AddTool(face)
    splitter.Perform()

    edges = []
    exp = TopExp_Explorer(splitter.Shape(), TopAbs_EDGE)
    while exp.More():
        edges.append(exp.Current())
        exp.Next()
    print('Number of edges in split shape: ', len(edges))
    display.DisplayShape(edges[0], color='red')
    display.DisplayShape(edges[1], color='green')
    display.DisplayShape(edges[2], color='yellow')
    display.FitAll()
Esempio n. 3
0
def splitter(shape, profile):
    '''split a *shape* using a *profile*
    :returns the splitted shape
    '''
    splitter = GEOMAlgo_Splitter()
    splitter.AddShape(shape)
    splitter.AddTool(profile)
    splitter.Perform()
    splitter_shape = splitter.Shape()
    return splitter_shape
Esempio n. 4
0
def splitter(shape, profile):
    '''split a *shape* using a *profile*
    :returns the splitted shape
    '''
    try:
        from OCC.GEOMAlgo import GEOMAlgo_Splitter
    except ImportError:
        msg = "GEOM wrapper is necesary to access advanced constructs"
        warnings.warn(msg)
        return None
    splitter = GEOMAlgo_Splitter()
    splitter.AddShape(shape)
    splitter.AddTool(profile)
    splitter.Perform()
    splitter_shape = splitter.Shape()
    return splitter_shape
Esempio n. 5
0
def splitter(shape, profile):
    r"""split a shape using a profile

    Parameters
    ----------
    shape
    profile

    Returns
    -------
    the splitted shape

    """
    split = GEOMAlgo_Splitter()
    split.AddShape(shape)
    split.AddTool(profile)
    split.Perform()
    splitter_shape = split.Shape()
    return splitter_shape