def vertex_fillet(cube, vert): # apply a fillet on incident edges on a vertex afillet = BRepFilletAPI_MakeFillet(cube) cnt = 0 # find edges from vertex _map = TopTools_IndexedDataMapOfShapeListOfShape() topexp_MapShapesAndAncestors(cube, 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!')
#!/usr/bin/env python