示例#1
0
    def combine_faces(compshape, sew_tolerance):
        """
        Method to combine faces in a shell by adding connectivity and continuity
        :param compshape: TopoDS_Shape
        :param sew_tolerance: tolerance for sewing
        :return: Topo_Shell
        """

        offsew = BRepOffsetAPI_FindContigousEdges(sew_tolerance)
        sew = BRepBuilderAPI_Sewing(sew_tolerance)

        face_explorers = TopExp_Explorer(compshape, TopAbs_FACE)
        n_faces = 0
        # cycle on Faces
        while face_explorers.More():
            tface = topods.Face(face_explorers.Current())
            sew.Add(tface)
            offsew.Add(tface)
            n_faces += 1
            face_explorers.Next()

        offsew.Perform()
        offsew.Dump()
        sew.Perform()
        shell = sew.SewedShape()
        sew.Dump()

        shell = topods.Shell(shell)
        shell_fixer = ShapeFix_Shell()
        shell_fixer.FixFaceOrientation(shell)

        if shell_fixer.Perform():
            print("{} shells fixed! ".format(shell_fixer.NbShells()))
        else:
            print "Shells not fixed! "

        new_shell = shell_fixer.Shell()

        if brepalgo_IsValid(new_shell):
            print "Shell valid! "
        else:
            print "Shell failed! "

        return new_shell
示例#2
0
def sew_shapes(shapes, tolerance=0.001, verbose=False):
    sew = BRepBuilderAPI_Sewing(tolerance)
    for shp in shapes:
        if isinstance(shp, list):
            for i in shp:
                sew.Add(i)
        else:
            sew.Add(shp)
    sew.Perform()
    # print("n degenerated shapes", sew.NbDegeneratedShapes())
    # print("n deleted faces:", sew.NbDeletedFaces())
    # print("n free edges", sew.NbFreeEdges())
    # print("n multiple edges:", sew.NbMultipleEdges())
    if verbose is True:
        sew.Dump()
    result = ShapeToTopology()(sew.SewedShape())
    # sew.Delete()

    return result