 |
CLIP Score: 33.78
from AIDL import *
def lighthouse():
lighthouse = Solid()
# Define main components as sub-structures
base = Solid()
tower = Solid()
balcony = Solid()
light_chamber = Solid()
door = Hole()
windows = Hole()
# Attach them to the main lighthouse structure
lighthouse.base = base
lighthouse.tower = tower
lighthouse.balcony = balcony
lighthouse.light_chamber = light_chamber
tower.door = door
tower.windows = windows
# Add constraints to position the components
lighthouse.AddConstraint(base.bb.top == tower.bb.bottom)
lighthouse.AddConstraint(tower.bb.top == balcony.bb.bottom)
lighthouse.AddConstraint(balcony.bb.top == light_chamber.bb.bottom)
lighthouse.AddConstraint(lighthouse.bb.vertical_center == tower.bb.vertical_center)
# Define geometric shapes and sizes
base.body = Rectangle((0,0), 10*inches, 2*inches) # Wide rectangular base
tower.body = Rectangle((0,0), 7*inches, 20*inches) # Narrow tower
balcony.body = RoundedRectangle((0,0), 9*inches, 1*inch, 0.5*inches) # Wider balcony with rounded corners
light_chamber.body = Rectangle((0,0), 5*inches, 3*inches) # Light chamber at the top
door.shape = Rectangle((0, -18*inch), 2*inches, 4*inches) # Door at the bottom of the tower (shifted vertically downward)
windows.shapes = [Rectangle((i * 3*inches - 6*inches, (j - 2)*4*inches + 8*inches), 1*inch, 2*inches) for i in range(3) for j in range(2)] # Windows position
# Add local constraints to ensure proper fitting
lighthouse.AddConstraint(base.body.width == 10*inches)
lighthouse.AddConstraint(tower.body.width == 7*inches)
lighthouse.AddConstraint(balcony.body.width == 9*inches)
lighthouse.AddConstraint(light_chamber.body.width == 5*inches)
tower.AddConstraint(HorizontallySymmetric(door.shape.bottom_left, door.shape.bottom_right)) # Center the door
return lighthouse
with AIDL_2D:
model = lighthouse()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a lighthouse
Sure, let's get started with creating a model for a lighthouse. A basic lighthouse can be divided into several main components: the base, the body (tower), the balcony, and the light chamber at the top. Additionally, we could add details like windows and doors.
We'll break this down into steps as you mentioned:
### Step 1: Define the Structures and Their Hierarchical Relationships
We'll start by defining the hierarchical structure of the lighthouse.
```python
from AIDL import *
def lighthouse():
lighthouse = Solid()
# Define main components as sub-structures
base = Solid()
tower = Solid()
balcony = Solid()
light_chamber = Solid()
# Attach them to the main lighthouse structure
lighthouse.base = base
lighthouse.tower = tower
lighthouse.balcony = balcony
lighthouse.light_chamber = light_chamber
return lighthouse
with AIDL_2D:
model = lighthouse()
print(model.Solve())
model.Render()
```
### Step 2: Add Constraints Between Structures
Next, we will add some basic constraints to position the components relative to each other.
```python
from AIDL import *
def lighthouse():
lighthouse = Solid()
# Define main components as sub-structures
base = Solid()
tower = Solid()
balcony = Solid()
light_chamber = Solid()
# Attach them to the main lighthouse structure
lighthouse.base = base
lighthouse.tower = tower
lighthouse.balcony = balcony
lighthouse.light_chamber = light_chamber
# Add constraints to position the components
lighthouse.AddConstraint(base.bb.top == tower.bb.bottom)
lighthouse.AddConstraint(tower.bb.top == balcony.bb.bottom)
lighthouse.AddConstraint(balcony.bb.top == light_chamber.bb.bottom)
lighthouse.AddConstraint(lighthouse.bb.vertical_center == tower.bb.vertical_center)
return lighthouse
with AIDL_2D:
model = lighthouse()
print(model.Solve())
model.Render()
```
### Step 3: Define Geometry for Each Structure
Let's define the geometric shapes for each part of the lighthouse.
```python
from AIDL import *
def lighthouse():
lighthouse = Solid()
# Define main components as sub-structures
base = Solid()
tower = Solid()
balcony = Solid()
light_chamber = Solid()
# Attach them to the main lighthouse structure
lighthouse.base = base
lighthouse.tower = tower
lighthouse.balcony = balcony
lighthouse.light_chamber = light_chamber
# Add constraints to position the components
lighthouse.AddConstraint(base.bb.top == tower.bb.bottom)
lighthouse.AddConstraint(tower.bb.top == balcony.bb.bottom)
lighthouse.AddConstraint(balcony.bb.top == light_chamber.bb.bottom)
lighthouse.AddConstraint(lighthouse.bb.vertical_center == tower.bb.vertical_center)
# Define geometric shapes and sizes
base.body = Rectangle((0,0), 10*inches, 2*inches) # Wide rectangular base
tower.body = Rectangle((0,0), 7*inches, 20*inches) # Narrow tower
balcony.body = Rectangle((0,0), 9*inches, 1*inch) # Wider balcony
light_chamber.body = Rectangle((0,0), 5*inches, 3*inches) # Light chamber at the top
# Add local constraints to ensure proper fitting
lighthouse.AddConstraint(base.body.width == 10*inches)
lighthouse.AddConstraint(tower.body.width == 7*inches)
lighthouse.AddConstraint(balcony.body.width == 9*inches)
lighthouse.AddConstraint(light_chamber.body.width == 5*inches)
return lighthouse
with AIDL_2D:
model = lighthouse()
print(model.Solve())
model.Render()
```
### Step 4: Add Details (Windows, Door, etc.)
Finally, we can add more details like windows and doors to the lighthouse.
```python
from AIDL import *
def lighthouse():
lighthouse = Solid()
# Define main components as sub-structures
base = Solid()
tower = Solid()
balcony = Solid()
light_chamber = Solid()
door = Hole()
windows = Hole()
# Attach them to the main lighthouse structure
lighthouse.base = base
lighthouse.tower = tower
lighthouse.balcony = balcony
lighthouse.light_chamber = light_chamber
tower.door = door
tower.windows = windows
# Add constraints to position the components
lighthouse.AddConstraint(base.bb.top == tower.bb.bottom)
lighthouse.AddConstraint(tower.bb.top == balcony.bb.bottom)
lighthouse.AddConstraint(balcony.bb.top == light_chamber.bb.bottom)
lighthouse.AddConstraint(lighthouse.bb.vertical_center == tower.bb.vertical_center)
# Define geometric shapes and sizes
base.body = Rectangle((0,0), 10*inches, 2*inches) # Wide rectangular base
tower.body = Rectangle((0,0), 7*inches, 20*inches) # Narrow tower
balcony.body = RoundedRectangle((0,0), 9*inches, 1*inch, 0.5*inches) # Wider balcony with rounded corners
light_chamber.body = Rectangle((0,0), 5*inches, 3*inches) # Light chamber at the top
door.shape = Rectangle((0, -18*inch), 2*inches, 4*inches) # Door at the bottom of the tower (shifted vertically downward)
windows.shapes = [Rectangle((i * 3*inches - 6*inches, (j - 2)*4*inches + 8*inches), 1*inch, 2*inches) for i in range(3) for j in range(2)] # Windows position
# Add local constraints to ensure proper fitting
lighthouse.AddConstraint(base.body.width == 10*inches)
lighthouse.AddConstraint(tower.body.width == 7*inches)
lighthouse.AddConstraint(balcony.body.width == 9*inches)
lighthouse.AddConstraint(light_chamber.body.width == 5*inches)
tower.AddConstraint(HorizontallySymmetric(door.shape.bottom_left, door.shape.bottom_right)) # Center the door
return lighthouse
with AIDL_2D:
model = lighthouse()
print(model.Solve())
model.Render()
```
This program constructs a basic lighthouse model with a base, tower, balcony, and light chamber, including some added details like a door and windows.
I hope this helps! Let me know if there are any more details or adjustments you would like to add.
|