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!')
def last_vertex(self) -> BRepVertex: return BRepVertex(topexp_LastVertex(self.edge))
topExp = TopExp_Explorer() topExp.Init(shape, TopAbs_EDGE) def print_vertex(va): pt = BRep_Tool().Pnt(va) print("%.3f, %.3f, %.3f" % (pt.Coord(1), pt.Coord(2), pt.Coord(3))) return [pt.Coord(1), pt.Coord(2), pt.Coord(3)] fig = plt.figure() ax = fig.add_subplot(111, projection='3d') while topExp.More(): edge = topExp.Current() first, last = topexp_FirstVertex(edge), topexp_LastVertex(edge) curv = BRepAdaptor_Curve(edge).Curve().Curve() if curv.FirstParameter() == REALFIRST or curv.LastParameter() == REALFIRST: print("This is a line.") first = print_vertex(first) last = print_vertex(last) plt.plot([first[0]], [first[1]], [first[2]], 'g*') plt.plot([first[0]], [last[1]], [last[2]], 'b*') else: print() print(edge) first = print_vertex(first)