Create cylindrical supports with solid box structures on top
supports_boxes_and_roadways =
support_spacing = length / (num_supports + 1)
for i in range(1, num_supports + 1):
support_x = i * support_spacing
support_center = rg.Point3d(support_x, width / 2, 0) # Center the circle under the bridge deck
# Create the base cylinder for the support
support_circle = rg.Circle(support_center, width / 10) # Circle with a radius relative to the bridge width
support_cylinder = rg.Cylinder(support_circle, height).ToBrep(True, True)
# Create the solid box structure on top of the support
box_base_center = rg.Point3d(support_x, width / 2, height)
box_corners = [
rg.Point3d(box_base_center.X - box_length / 2, box_base_center.Y - box_width / 2, box_base_center.Z),
rg.Point3d(box_base_center.X + box_length / 2, box_base_center.Y + box_width / 2, box_base_center.Z + box_height)
]
box_brep = rg.Brep.CreateFromBox(rg.BoundingBox(box_corners))
# Add both the cylinder and the box to the supports list
supports_boxes_and_roadways.append(support_cylinder)
supports_boxes_and_roadways.append(box_brep)
Create a single solid rectangular structure on top of all the boxes
top_base_z = height + box_height
top_corners = [
rg.Point3d(0, 0, top_base_z),
rg.Point3d(length, 0, top_base_z),
rg.Point3d(length, width, top_base_z + top_height),
rg.Point3d(0, width, top_base_z + top_height)
]
top_brep = rg.Brep.CreateFromBox(rg.BoundingBox(top_corners))
Add the top rectangular structure to the list
supports_boxes_and_roadways.append(top_brep)
Create the first trapezoid on one edge of the width
trapezoid_1_base_z = top_base_z + top_height
trapezoid_1_corners = [
rg.Point3d(0, 0, trapezoid_1_base_z),
rg.Point3d(length, 0, trapezoid_1_base_z),
rg.Point3d(length, trapezoid_top_width, trapezoid_1_base_z + trapezoid_height),
rg.Point3d(0, trapezoid_bottom_width, trapezoid_1_base_z + trapezoid_height)
]
trapezoid_1_brep = rg.Brep.CreateFromBox(rg.BoundingBox(trapezoid_1_corners))
Create the second trapezoid on the other edge of the width
trapezoid_2_base_z = top_base_z + top_height
trapezoid_2_corners = [
rg.Point3d(0, width - trapezoid_bottom_width, trapezoid_2_base_z),
rg.Point3d(length, width - trapezoid_top_width, trapezoid_2_base_z + trapezoid_height),
rg.Point3d(length, width, trapezoid_2_base_z + trapezoid_height),
rg.Point3d(0, width, trapezoid_2_base_z)
]
trapezoid_2_brep = rg.Brep.CreateFromBox(rg.BoundingBox(trapezoid_2_corners))
Add the trapezoids to the list
supports_boxes_and_roadways.append(trapezoid_1_brep)
supports_boxes_and_roadways.append(trapezoid_2_brep)
Create roadways along the sides of the bridge
roadway_1_corners = [
rg.Point3d(0, -roadway_width, 0), # Start at the side of the bridge
rg.Point3d(length, -roadway_width, 0),
rg.Point3d(length, 0, 0),
rg.Point3d(0, 0, 0),
rg.Point3d(0, -roadway_width, roadway_height),
rg.Point3d(length, -roadway_width, roadway_height),
rg.Point3d(length, 0, roadway_height),
rg.Point3d(0, 0, roadway_height)
]
roadway_1_brep = rg.Brep.CreateFromBox(rg.BoundingBox(roadway_1_corners))
roadway_2_corners = [
rg.Point3d(0, width, 0), # Start at the other side of the bridge
rg.Point3d(length, width, 0),
rg.Point3d(length, width + roadway_width, 0),
rg.Point3d(0, width + roadway_width, 0),
rg.Point3d(0, width, roadway_height),
rg.Point3d(length, width, roadway_height),
rg.Point3d(length, width + roadway_width, roadway_height),
rg.Point3d(0, width + roadway_width, roadway_height)
]
roadway_2_brep = rg.Brep.CreateFromBox(rg.BoundingBox(roadway_2_corners))
Add the roadways to the list
supports_boxes_and_roadways.append(roadway_1_brep)
supports_boxes_and_roadways.append(roadway_2_brep)
divider_1_corners = [
rg.Point3d(0, -divider_width, 0), # Place between the first roadway and the bridge
rg.Point3d(length, -divider_width, 0),
rg.Point3d(length, 0, 0),
rg.Point3d(0, 0, 0),
rg.Point3d(0, -divider_width, divider_height),
rg.Point3d(length, -divider_width, divider_height),
rg.Point3d(length, 0, divider_height),
rg.Point3d(0, 0, divider_height)
]
divider_1_brep = rg.Brep.CreateFromBox(rg.BoundingBox(divider_1_corners))
supports_boxes_and_roadways.append(divider_1_brep)
divider_2_corners = [
rg.Point3d(0, width, 0), # Place between the second roadway and the bridge
rg.Point3d(length, width, 0),
rg.Point3d(length, width + divider_width, 0),
rg.Point3d(0, width + divider_width, 0),
rg.Point3d(0, width, divider_height),
rg.Point3d(length, width, divider_height),
rg.Point3d(length, width + divider_width, divider_height),
rg.Point3d(0, width + divider_width, divider_height)
]
divider_2_brep = rg.Brep.CreateFromBox(rg.BoundingBox(divider_2_corners))
supports_boxes_and_roadways.append(divider_2_brep)
Create the road between divider_1_brep and divider_2_brep
road_corners = [
rg.Point3d(0, 0, 0), # Start at the edge of the first divider
rg.Point3d(length, 0, 0),
rg.Point3d(length, pedestrian_footpath_width, 0), # Width of the road corresponds to the footpath width
rg.Point3d(0, pedestrian_footpath_width, 0),
rg.Point3d(0, 0, pedestrian_footpath_height), # Height of the road corresponds to the footpath height
rg.Point3d(length, 0, pedestrian_footpath_height),
rg.Point3d(length, pedestrian_footpath_width, pedestrian_footpath_height),
rg.Point3d(0, pedestrian_footpath_width, pedestrian_footpath_height)
]
road_brep = rg.Brep.CreateFromBox(rg.BoundingBox(road_corners))
Add the road to the list
supports_boxes_and_roadways.append(road_brep)
return deck, supports_boxes_and_roadways
