Beispiel #1
0
def cut_solid_parts(array):
    from OCC.Core.BRepAlgoAPI import BRepAlgoAPI_Section
    from OCC.Core.BRepFeat import BRepFeat_SplitShape
    from OCC.TopTools import TopTools_ListIteratorOfListOfShape
    from OCC.Extend.TopologyUtils import TopologyExplorer
    from OCC.Core.TopoDS import TopoDS_Face
    #array contains several parts
    for i, si in enumerate(array):
        #for ki in si.dico:
        shpi = si.solid
        split = BRepFeat_SplitShape(shpi)
        for j, sj in enumerate(array):
            if i != j:
                shpj = sj.solid
                sect = BRepAlgoAPI_Section(shpi, shpj, False)
                sect.ComputePCurveOn1(True)
                sect.Approximation(True)
                sect.SetFuzzyValue(1.e-12)
                sect.Build()
                shpsect = sect.Shape()
                for edg in TopologyExplorer(shpsect).edges():
                    face = TopoDS_Face()
                    if sect.HasAncestorFaceOn1(edg, face):
                        split.Add(edg, face)
        split.Build()
        lst = TopTools_ListIteratorOfListOfShape(split.Modified(shpi))
        while lst.More():
            for face in TopologyExplorer(lst.Value()).faces():
                array[i].splitsolid.append(face)
            lst.Next()
Beispiel #2
0
def split_shape(event=None):
    S = BRepPrimAPI_MakeBox(gp_Pnt(-100, -60, -80), 150, 200, 170).Shape()
    asect = BRepAlgoAPI_Section(S, gp_Pln(1, 2, 1, -15), False)
    asect.ComputePCurveOn1(True)
    asect.Approximation(True)
    asect.Build()
    R = asect.Shape()

    asplit = BRepFeat_SplitShape(S)

    for edg in TopologyExplorer(R).edges():
        face = TopoDS_Face()
        if asect.HasAncestorFaceOn1(edg, face):
            asplit.Add(edg, face)

    asplit.Build()
    display.EraseAll()
    display.DisplayShape(asplit.Shape())
    display.FitAll()
Beispiel #3
0
def split_shells_by_solid(array, solid, display):
    from OCC.Core.BRepAlgoAPI import BRepAlgoAPI_Section
    from OCC.Core.BRepFeat import BRepFeat_SplitShape
    from OCC.TopTools import TopTools_ListIteratorOfListOfShape
    from OCC.Extend.TopologyUtils import TopologyExplorer
    from OCC.Core.TopoDS import TopoDS_Face
    for i, si in enumerate(array):
        for ki in si.dico:
            print ki
            sfi = si.dico[ki]
            split = BRepFeat_SplitShape(sfi.Shape())
            sect = BRepAlgoAPI_Section(solid, sfi.Shape(), False)
            sect.ComputePCurveOn1(True)
            sect.Approximation(True)
            sect.SetFuzzyValue(1.e-12)
            sect.Build()
            shpsect = sect.Shape()
            for edg in TopologyExplorer(shpsect).edges():
                face = TopoDS_Face()
                if sect.HasAncestorFaceOn1(edg, face):
                    split.Add(edg, face)
            split.Build()
            ais_shape = display.DisplayColoredShape(split.Shape(), color='RED')
            display.Context.SetTransparency(ais_shape, 0.5)
Beispiel #4
0
    for edg in all_edges:
        face_explorer = TopExp_Explorer(faces1[f].Shape(), TopAbs_FACE)
        while False:  #face_explorer.More():
            try:
                TopOpeBRepTool_CurveTool_MakePCurveOnFace(
                    edg, topods_Face(face_explorer.Current()))
                print 'done'
            except:
                print 'rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr'
            face_explorer.Next()
    print 'out'
    ss = BRepFeat_SplitShape(faces1[f].Shape())
    ss.SetCheckInterior(True)
    for edg in all_edges:
        face = TopoDS_Face()
        if section.HasAncestorFaceOn1(edg, face):
            ss.Add(edg, face)
            display.DisplayColoredShape(face, 'RED')
    ss.Build()
    dl = ss.DirectLeft()
    test = TopTools_ListIteratorOfListOfShape(dl)
    #display.DisplayColoredShape(ss.Shape(),'GREEN')
    display.DisplayColoredShape(faces1[f].Shape(), 'RED')
#surfaces = [med_ax]
#for k in fore_cad:
#    surfaces.append(fore_cad[k])
#    display.DisplayShape(fore_cad[k])
#for k in aft_cad:
#    surfaces.append(fore_cad[k])
#    display.DisplayShape(aft_cad[k])