 |
CLIP Score: 23.63
from AIDL import *
def sofa(seat_width: float = 6 * feet, seat_depth: float = 2 * feet, backrest_height: float = 2 * feet, armrest_width: float = 0.5 * feet, armrest_height: float = 1.5 * feet):
"""
Generates an aerial view of a simple sofa with a seat, backrest, and armrests.
All dimensions are parameterized with default values.
"""
sofa = Solid() # Root structure representing the sofa
seat = Solid() # Structure representing the main seating area
backrest = Solid() # Structure representing the backrest
left_armrest = Solid() # Structure representing the left armrest
right_armrest = Solid() # Structure representing the right armrest
# Attach the components to the sofa structure
sofa.seat = seat
sofa.backrest = backrest
sofa.left_armrest = left_armrest
sofa.right_armrest = right_armrest
# Define the geometry for each component
seat.rectangle = Rectangle((0, 0), seat_width, seat_depth)
backrest.rectangle = Rectangle((0, 0), seat_width, backrest_height)
left_armrest.rectangle = Rectangle((0, 0), armrest_width, armrest_height)
right_armrest.rectangle = Rectangle((0, 0), armrest_width, armrest_height)
# Positional constraints between the components
# Make the seat the main reference
sofa.AddConstraint(seat.bb.horizontal_center == sofa.bb.horizontal_center)
sofa.AddConstraint(seat.bb.vertical_center == sofa.bb.vertical_center)
# Position the backrest behind the seat
sofa.AddConstraint(backrest.bb.bottom == seat.bb.top)
sofa.AddConstraint(backrest.bb.horizontal_center == seat.bb.horizontal_center)
# Position the left armrest on the left of the seat
sofa.AddConstraint(left_armrest.bb.right == seat.bb.left)
sofa.AddConstraint(left_armrest.bb.vertical_center == seat.bb.vertical_center)
# Position the right armrest on the right of the seat
sofa.AddConstraint(right_armrest.bb.left == seat.bb.right)
sofa.AddConstraint(right_armrest.bb.vertical_center == seat.bb.vertical_center)
return sofa
# Generate, solve, and render the model
with AIDL_2D:
model = sofa()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a aerial view of sofa
Sure! Let's define an AIDL program to generate an aerial view of a sofa. When designing a sofa in an aerial view, we might consider basic components like the seat, backrest, and armrests. For simplicity, we'll model the sofa as consisting of rectangular shapes.
Here's how we'll break it down:
1. **Seat**: A rectangle representing the main seating area.
2. **Backrest**: A rectangle behind the seat to represent the backrest.
3. **Armrests**: Two rectangles on each side to represent the armrests.
We'll start by defining the basic structure as outlined and then add constraints and dimensions.
```python
from AIDL import *
def sofa(seat_width: float = 6 * feet, seat_depth: float = 2 * feet, backrest_height: float = 2 * feet, armrest_width: float = 0.5 * feet, armrest_height: float = 1.5 * feet):
"""
Generates an aerial view of a simple sofa with a seat, backrest, and armrests.
All dimensions are parameterized with default values.
"""
sofa = Solid() # Root structure representing the sofa
seat = Solid() # Structure representing the main seating area
backrest = Solid() # Structure representing the backrest
left_armrest = Solid() # Structure representing the left armrest
right_armrest = Solid() # Structure representing the right armrest
# Attach the components to the sofa structure
sofa.seat = seat
sofa.backrest = backrest
sofa.left_armrest = left_armrest
sofa.right_armrest = right_armrest
# Define the geometry for each component
seat.rectangle = Rectangle((0, 0), seat_width, seat_depth)
backrest.rectangle = Rectangle((0, 0), seat_width, backrest_height)
left_armrest.rectangle = Rectangle((0, 0), armrest_width, armrest_height)
right_armrest.rectangle = Rectangle((0, 0), armrest_width, armrest_height)
# Positional constraints between the components
# Make the seat the main reference
sofa.AddConstraint(seat.bb.horizontal_center == sofa.bb.horizontal_center)
sofa.AddConstraint(seat.bb.vertical_center == sofa.bb.vertical_center)
# Position the backrest behind the seat
sofa.AddConstraint(backrest.bb.bottom == seat.bb.top)
sofa.AddConstraint(backrest.bb.horizontal_center == seat.bb.horizontal_center)
# Position the left armrest on the left of the seat
sofa.AddConstraint(left_armrest.bb.right == seat.bb.left)
sofa.AddConstraint(left_armrest.bb.vertical_center == seat.bb.vertical_center)
# Position the right armrest on the right of the seat
sofa.AddConstraint(right_armrest.bb.left == seat.bb.right)
sofa.AddConstraint(right_armrest.bb.vertical_center == seat.bb.vertical_center)
return sofa
# Generate, solve, and render the model
with AIDL_2D:
model = sofa()
print(model.Solve())
model.Render()
```
In this model:
- The `seat_width`, `seat_depth`, `backrest_height`, `armrest_width`, and `armrest_height` are parameterized with default values.
- The `sofa` consists of four main components: `seat`, `backrest`, `left_armrest`, and `right_armrest`.
- Constraints are added to ensure the backrest is positioned correctly relative to the seat, and the armrests are properly positioned on each side of the seat.
This should generate a simple aerial view of a sofa suitable for laser cutting or any other 2D CAD application. Let me know if you need any adjustments or additional features!
|