noconstraints/aerial view of sofa/aerial view of sofa0


CLIP Score: 30.42

Image

Program

Conversation

aerial view of sofa0 image
                
from AIDL import *

def sofa(
    length: float = 6*feet,
    depth: float = 3*feet,
    armrest_thickness: float = 0.5*feet,
    backrest_height: float = 1.5*feet,
    leg_diameter: float = 0.1*feet,
    leg_offset: float = 0.2*feet,
    leg_shape: str = "circle",  # Options: "circle" or "square"
):
    """
    Generates an aerial view of a sofa with customizable parameters.
    """

    sofa = Solid()
    
    # Define the sofa structures
    seat = Solid()
    backrest = Solid()
    left_armrest = Solid()
    right_armrest = Solid()
    legs = Hole()

    sofa.seat = seat
    sofa.backrest = backrest
    sofa.left_armrest = left_armrest
    sofa.right_armrest = right_armrest
    sofa.legs = legs

    # Define seat geometry (main base)
    seat.base = Rectangle((0, 0), length, depth)

    # Define backrest geometry
    # Place backrest on top edge of seat
    backrest.base = Rectangle((0, depth/2 + backrest_height/2), length - 2 * armrest_thickness, backrest_height, axis_aligned=False)

    # Define armrest geometry
    left_armrest.base = Rectangle((-length / 2 + armrest_thickness / 2, 0), armrest_thickness, depth, axis_aligned=False)
    right_armrest.base = Rectangle((length / 2 - armrest_thickness / 2, 0), armrest_thickness, depth, axis_aligned=False)
    
    # Define leg geometry
    leg_positions = [
        (-length / 2 + leg_offset, -depth / 2 + leg_offset),
        (length / 2 - leg_offset, -depth / 2 + leg_offset),
        (-length / 2 + leg_offset, depth / 2 - leg_offset),
        (length / 2 - leg_offset, depth / 2 - leg_offset),
    ]
    
    legs.leg_holes = []
    for pos in leg_positions:
        if leg_shape == "circle":
            legs.leg_holes.append(Circle(pos, leg_diameter / 2))
        else:  # Default to square
            legs.leg_holes.append(Rectangle(pos, leg_diameter, leg_diameter, axis_aligned=True))

    return sofa

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 create an AIDL program to generate a 2D aerial view of a sofa. We'll give the sofa standard dimensions for a three-seater sofa, with optional parameters to customize size, armrest thickness, and leg positions.

### Plan:
1. **Base and Seat:**
   - We'll create the base/seat as a single rectangular solid.
  
2. **Backrest:**
   - We'll create a backrest as a solid rectangular extension attached to the back of the seat.
  
3. **Armrests:**
   - We'll add two solid rectangular armrests on either side of the seat.

4. **Legs:**
   - We'll optionally add circular or square tube legs.

Let’s proceed with the step-by-step implementation.

### Step-by-Step AIDL Program:

```python
from AIDL import *

def sofa(
    length: float = 6*feet,
    depth: float = 3*feet,
    armrest_thickness: float = 0.5*feet,
    backrest_height: float = 1.5*feet,
    leg_diameter: float = 0.1*feet,
    leg_offset: float = 0.2*feet,
    leg_shape: str = "circle",  # Options: "circle" or "square"
):
    """
    Generates an aerial view of a sofa with customizable parameters.
    """

    sofa = Solid()
    
    # Define the sofa structures
    seat = Solid()
    backrest = Solid()
    left_armrest = Solid()
    right_armrest = Solid()
    legs = Hole()

    sofa.seat = seat
    sofa.backrest = backrest
    sofa.left_armrest = left_armrest
    sofa.right_armrest = right_armrest
    sofa.legs = legs

    # Define seat geometry (main base)
    seat.base = Rectangle((0, 0), length, depth)

    # Define backrest geometry
    # Place backrest on top edge of seat
    backrest.base = Rectangle((0, depth/2 + backrest_height/2), length - 2 * armrest_thickness, backrest_height, axis_aligned=False)

    # Define armrest geometry
    left_armrest.base = Rectangle((-length / 2 + armrest_thickness / 2, 0), armrest_thickness, depth, axis_aligned=False)
    right_armrest.base = Rectangle((length / 2 - armrest_thickness / 2, 0), armrest_thickness, depth, axis_aligned=False)
    
    # Define leg geometry
    leg_positions = [
        (-length / 2 + leg_offset, -depth / 2 + leg_offset),
        (length / 2 - leg_offset, -depth / 2 + leg_offset),
        (-length / 2 + leg_offset, depth / 2 - leg_offset),
        (length / 2 - leg_offset, depth / 2 - leg_offset),
    ]
    
    legs.leg_holes = []
    for pos in leg_positions:
        if leg_shape == "circle":
            legs.leg_holes.append(Circle(pos, leg_diameter / 2))
        else:  # Default to square
            legs.leg_holes.append(Rectangle(pos, leg_diameter, leg_diameter, axis_aligned=True))

    return sofa

with AIDL_2D:
    model = sofa()
print(model.Solve())
model.Render()
```

### Explanation:
- **Seat Geometry:** Defines the main rectangle that forms the seat.
- **Backrest Geometry:** Positioned at the back edge of the seat.
- **Armrest Geometry:** Left and right armrests positioned accordingly.
- **Legs Geometry:** Four legs positioned at the corners with an offset, customizable to be round or square.

This program constructs a basic aerial view of a sofa structure with customizable dimensions using the AIDL syntax. You can run this script to generate and render the model of the sofa. Let me know if you need any modifications or additional features!