示例#1
0
def sortWiresByBuildOrder(wireList, plane, result=[]):
    """Tries to determine how wires should be combined into faces.

    Assume:
        The wires make up one or more faces, which could have 'holes'
        Outer wires are listed ahead of inner wires
        there are no wires inside wires inside wires
        ( IE, islands -- we can deal with that later on )
        none of the wires are construction wires

    Compute:
        one or more sets of wires, with the outer wire listed first, and inner
        ones

    Returns, list of lists.
    """

    # check if we have something to sort at all
    if len(wireList) < 2:
        return [
            wireList,
        ]

    # make a Face
    face = Face.makeFromWires(wireList[0], wireList[1:])

    # use FixOrientation
    outer_inner_map = TopTools_DataMapOfShapeListOfShape()
    sf = ShapeFix_Face(face.wrapped)  # fix wire orientation
    sf.FixOrientation(outer_inner_map)

    # Iterate through the Inner:Outer Mapping
    all_wires = face.Wires()
    result = {
        w: outer_inner_map.Find(w.wrapped)
        for w in all_wires if outer_inner_map.IsBound(w.wrapped)
    }

    # construct the result
    rv = []
    for k, v in result.items():
        tmp = [
            k,
        ]

        iterator = TopTools_ListIteratorOfListOfShape(v)
        while iterator.More():
            tmp.append(Wire(iterator.Value()))
            iterator.Next()

        rv.append(tmp)

    return rv
示例#2
0
    def makeFromWires(cls, outerWire, innerWires=[]):
        '''
        Makes a planar face from one or more wires
        '''
        face_builder = BRepBuilderAPI_MakeFace(outerWire.wrapped,
                                               True)  # True is for planar only

        for w in innerWires:
            face_builder.Add(w.wrapped)
        face_builder.Build()
        f = face_builder.Face()

        sf = ShapeFix_Face(f)  # fix wire orientation
        sf.FixOrientation()

        return cls(sf.Face())
示例#3
0
def fix_face(occ_face):
    """
    This function fixes an OCCface.
 
    Parameters
    ----------        
    occface : OCCface
        The OCCface to be fixed.

    Returns
    -------
    fixed face : OCCface
        The fixed OCCface.
    """
    fix = ShapeFix_Face(occ_face)
    #fix.FixMissingSeam()
    fix.FixOrientation()
    fix.Perform()
    return fix.Face()
示例#4
0
def fix_face(shp, tolerance=1e-3):
    fix = ShapeFix_Face(shp)
    fix.SetMaxTolerance(tolerance)
    fix.Perform()
    return fix.Face()