def getBasewireOfStirrupWithExtendedEdges( stirrup, view_plane: WorkingPlane.Plane, extension_offset: float) -> Part.Wire: """Returns stirrup base wire after adding extension_offset to stirrup extended edges, so that end edges of stirrup with 90 degree bent angle do not overlap with stirrup edges. Parameters ---------- stirrup: <ArchRebar._Rebar> The stirrup with 90 degree bent angle. view_plane: WorkingPlane.Plane The view plane from which stirrup shape is visible. extension_offset: float The distance to move extended end edges of stirrup apart. Returns ------- Part.Wire The generated stirrup base wire. """ basewire = stirrup.Base.Shape.Wires[0].copy() # This function is meant for stirrup with bent angle 90 degree if stirrup.BentAngle != 90: return basewire min_x, min_y, max_x, max_y = getVertexesMinMaxXY(basewire.Vertexes, view_plane) def getModifiedEndEdgePoints(end_edge, coincident_edge): p1 = getProjectionToSVGPlane(end_edge.firstVertex().Point, view_plane) p2 = getProjectionToSVGPlane(end_edge.lastVertex().Point, view_plane) p3 = getProjectionToSVGPlane(coincident_edge.firstVertex().Point, view_plane) p4 = getProjectionToSVGPlane(coincident_edge.lastVertex().Point, view_plane) # The extended edge is vertical and is left side of stirrup And # coincident edge is horizontal if (round(p1.x) == round(p2.x) == round(min_x)) and (round(p3.y) == round(p4.y)): mod_p1 = end_edge.firstVertex().Point.add( extension_offset * view_plane.u.negative().normalize()) mod_p2 = end_edge.lastVertex().Point.add( extension_offset * view_plane.u.negative().normalize()) # The extended edge is vertical and is right side of stirrup And # coincident edge is horizontal elif (round(p1.x) == round(p2.x) == round(max_x)) and (round(p3.y) == round(p4.y)): mod_p1 = end_edge.firstVertex().Point.add(extension_offset * view_plane.u.normalize()) mod_p2 = end_edge.lastVertex().Point.add(extension_offset * view_plane.u.normalize()) # The extended edge is horizontal and is top side of stirrup And # coincident edge is vertical elif (round(p1.y) == round(p2.y) == round(min_y)) and (round(p3.x) == round(p4.x)): mod_p1 = end_edge.firstVertex().Point.add( extension_offset * view_plane.v.negative().normalize()) mod_p2 = end_edge.lastVertex().Point.add( extension_offset * view_plane.v.negative().normalize()) # The extended edge is horizontal and is bottom side of stirrup And # coincident edge is vertical elif (round(p1.y) == round(p2.y) == round(max_y)) and (round(p3.x) == round(p4.x)): mod_p1 = end_edge.firstVertex().Point.add(extension_offset * view_plane.v.normalize()) mod_p2 = end_edge.lastVertex().Point.add(extension_offset * view_plane.v.normalize()) else: # Don't modify any point mod_p1 = end_edge.firstVertex().Point mod_p2 = end_edge.lastVertex().Point return mod_p1, mod_p2 edges = Part.__sortEdges__(basewire.Edges) # Modify one end edge point_1, point_2 = getModifiedEndEdgePoints(edges[0], edges[1]) edges[0] = DraftGeomUtils.edg(point_1, point_2) edges[1] = DraftGeomUtils.edg(point_2, edges[1].lastVertex().Point) # Modify second end edge extension_offset = -1 * extension_offset point_1, point_2 = getModifiedEndEdgePoints(edges[-1], edges[-2]) edges[-1] = DraftGeomUtils.edg(point_1, point_2) edges[-2] = DraftGeomUtils.edg(edges[-2].firstVertex().Point, point_1) return DraftGeomUtils.connect(edges)