示例#1
0
def vertex_fillet(cube_shp, vert):
    # apply a fillet on incident edges on a vertex
    afillet = BRepFilletAPI_MakeFillet(cube_shp)
    cnt = 0
    # find edges from vertex
    _map = TopTools_IndexedDataMapOfShapeListOfShape()
    topexp_MapShapesAndAncestors(cube_shp, TopAbs_VERTEX, TopAbs_EDGE, _map)
    results = _map.FindFromKey(vert)
    topology_iterator = TopTools_ListIteratorOfListOfShape(results)
    while topology_iterator.More():
        edge = topods_Edge(topology_iterator.Value())
        topology_iterator.Next()
        first, last = topexp_FirstVertex(edge), topexp_LastVertex(edge)
        vertex, first_vert, last_vert = BRep_Tool().Pnt(vert), BRep_Tool().Pnt(first), BRep_Tool().Pnt(last)
        if edge.Orientation():
            if not vertex.IsEqual(first_vert, 0.001):
                afillet.Add(0, 20., edge)
            else:
                afillet.Add(20, 0, edge)
        cnt += 1
    afillet.Build()
    if afillet.IsDone():
        return afillet.Shape()
    else:
        raise AssertionError('you failed on me you fool!')
示例#2
0
def variable_filleting(event=None):
    a_pnt = gp_Pnt(350, 0, 0)
    box_2 = BRepPrimAPI_MakeBox(a_pnt, 200, 200, 200).Shape()
    a_fillet = BRepFilletAPI_MakeFillet(box_2)

    tab_point = TColgp_Array1OfPnt2d(1, 6)
    p_1 = gp_Pnt2d(0., 8.)
    p_2 = gp_Pnt2d(0.2, 16.)
    p_3 = gp_Pnt2d(0.4, 25.)
    p_4 = gp_Pnt2d(0.6, 55.)
    p_5 = gp_Pnt2d(0.8, 28.)
    p_6 = gp_Pnt2d(1., 20.)
    tab_point.SetValue(1, p_1)
    tab_point.SetValue(2, p_2)
    tab_point.SetValue(3, p_3)
    tab_point.SetValue(4, p_4)
    tab_point.SetValue(5, p_5)
    tab_point.SetValue(6, p_6)

    expl3 = list(TopologyExplorer(box_2).edges())

    a_fillet.Add(tab_point, expl3[9])
    a_fillet.Build()
    if a_fillet.IsDone():
        law_evolved_box = a_fillet.Shape()
        display.DisplayShape(law_evolved_box)
    else:
        print("aFillet not done.")
    display.FitAll()
示例#3
0
def rake(event=None):
    display.EraseAll()
    # Create Box
    box = BRepPrimAPI_MakeBox(200, 200, 200).Shape()
    # Fillet
    rake = BRepFilletAPI_MakeFillet(box)
    expl = list(TopologyExplorer(box).edges())

    rake.Add(8, 50, expl[3])
    rake.Build()
    if rake.IsDone():
        evolved_box = rake.Shape()
        display.DisplayShape(evolved_box, update=True)
    else:
        print("Rake not done.")
示例#4
0
def fillet_cylinder(event=None):
    display.EraseAll()
    # Create Cylinder
    cylinder = BRepPrimAPI_MakeCylinder(
        gp_Ax2(gp_Pnt(-300, 0, 0), gp_Dir(0, 0, 1)), 100, 200).Shape()
    fillet = BRepFilletAPI_MakeFillet(cylinder)
    display.DisplayShape(cylinder, update=True)
    tab_point_2 = TColgp_Array1OfPnt2d(0, 20)
    for i in range(0, 20):
        point_2d = gp_Pnt2d(i * 2 * pi / 19,
                            60 * cos(i * pi / 19 - pi / 2) + 10)
        tab_point_2.SetValue(i, point_2d)
        display.DisplayShape(point_2d)

    expl2 = TopologyExplorer(cylinder).edges()
    fillet.Add(tab_point_2, next(expl2))
    fillet.Build()
    if fillet.IsDone():
        law_evolved_cylinder = fillet.Shape()
        display.DisplayShape(law_evolved_cylinder, update=True)
    else:
        print("fillet not done.")
def variable_filleting(event=None):
    display.EraseAll()
    # Create Box
    Box = BRepPrimAPI_MakeBox(200, 200, 200).Shape()
    # Fillet
    Rake = BRepFilletAPI_MakeFillet(Box)
    ex = TopologyExplorer(Box).edges()
    next(ex)
    next(ex)
    next(ex)

    Rake.Add(8, 50, next(ex))
    Rake.Build()
    if Rake.IsDone():
        evolvedBox = Rake.Shape()
        display.DisplayShape(evolvedBox)
    else:
        print("Rake not done.")
    # Create Cylinder
    Cylinder = BRepPrimAPI_MakeCylinder(
        gp_Ax2(gp_Pnt(-300, 0, 0), gp_Dir(0, 0, 1)), 100, 200).Shape()
    fillet_ = BRepFilletAPI_MakeFillet(Cylinder)

    TabPoint2 = TColgp_Array1OfPnt2d(0, 20)
    for i in range(0, 20):
        Point2d = gp_Pnt2d(i * 2 * pi / 19,
                           60 * cos(i * pi / 19 - pi / 2) + 10)
        TabPoint2.SetValue(i, Point2d)

    exp2 = TopologyExplorer(Cylinder).edges()
    fillet_.Add(TabPoint2, next(exp2))
    fillet_.Build()
    if fillet_.IsDone():
        LawEvolvedCylinder = fillet_.Shape()
        display.DisplayShape(LawEvolvedCylinder)
    else:
        print("fillet not done.")  ## TODO : fillet not done
    P = gp_Pnt(350, 0, 0)
    Box2 = BRepPrimAPI_MakeBox(P, 200, 200, 200).Shape()
    afillet = BRepFilletAPI_MakeFillet(Box2)

    TabPoint = TColgp_Array1OfPnt2d(1, 6)
    P1 = gp_Pnt2d(0., 8.)
    P2 = gp_Pnt2d(0.2, 16.)
    P3 = gp_Pnt2d(0.4, 25.)
    P4 = gp_Pnt2d(0.6, 55.)
    P5 = gp_Pnt2d(0.8, 28.)
    P6 = gp_Pnt2d(1., 20.)
    TabPoint.SetValue(1, P1)
    TabPoint.SetValue(2, P2)
    TabPoint.SetValue(3, P3)
    TabPoint.SetValue(4, P4)
    TabPoint.SetValue(5, P5)
    TabPoint.SetValue(6, P6)

    exp = TopologyExplorer(Box2).edges()
    next(exp)
    next(exp)
    next(exp)

    afillet.Add(TabPoint, next(exp))
    afillet.Build()
    if afillet.IsDone():
        LawEvolvedBox = afillet.Shape()
        display.DisplayShape(LawEvolvedBox)
    else:
        print("aFillet not done.")
    display.FitAll()