 |
CLIP Score: 25.91
from AIDL import *
def wine_glass(
bowl_diameter: float = 3*inches,
bowl_height: float = 4*inches,
stem_height: float = 6*inches,
base_diameter: float = 3.5*inches,
stem_width: float = 0.5*inch
):
wine_glass = Solid()
bowl = Solid()
stem = Solid()
base = Solid()
wine_glass.bowl = bowl
wine_glass.stem = stem
wine_glass.base = base
# Step 2: Add Constraints
# Constraints for positioning and dimensions.
# Align the stem's bottom with the base's top
wine_glass.AddConstraint(stem.bb.bottom == base.bb.top)
# Align the bowl's bottom with the stem's top
wine_glass.AddConstraint(bowl.bb.bottom == stem.bb.top)
# Center the bowl, stem, and base horizontally
wine_glass.AddConstraint(bowl.bb.horizontal_center == wine_glass.bb.horizontal_center)
wine_glass.AddConstraint(stem.bb.horizontal_center == wine_glass.bb.horizontal_center)
wine_glass.AddConstraint(base.bb.horizontal_center == wine_glass.bb.horizontal_center)
# Step 3: Define the Geometry for Each Part
# Bowl Geometry
bowl.curve1 = Arc((0, 0), (0, bowl_height), (bowl_diameter / 2, bowl_height / 2))
bowl.curve2 = Arc((0, 0), (0, bowl_height), (-bowl_diameter / 2, bowl_height / 2))
bowl.rim = Line(bowl.curve1.end, bowl.curve2.end)
bowl.AddConstraint(HorizontallySymmetric(bowl.curve1.start, bowl.curve2.start))
bowl.AddConstraint(HorizontallySymmetric(bowl.curve1.end, bowl.curve2.end))
bowl.AddConstraint(bowl.curve1.radius == bowl.curve2.radius)
# Stem Geometry
stem.shape = Rectangle((0, 0), stem_width, stem_height)
stem.AddConstraint(stem.shape.width == stem_width)
stem.AddConstraint(stem.shape.height == stem_height)
# Base Geometry
base.shape = Circle((0, 0), base_diameter / 2)
base.AddConstraint(base.shape.radius == base_diameter / 2)
return wine_glass
with AIDL_2D:
model = wine_glass()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a fancy wine glass
Sure! Let's start by breaking down the wine glass into its main components. A typical wine glass consists of the following parts:
1. The Bowl: The part of the glass that holds the wine.
2. The Stem: The narrow part that you hold.
3. The Base: The flat part that the glass stands on.
We need to design these three parts as separate structures and then assemble them together. Here's a step-by-step outline:
1. Define the general dimensions and shapes of the Bowl, Stem, and Base.
2. Create individual structures for each part.
3. Apply constraints to define the relationships between different parts.
4. Define the geometry for each part.
5. Assemble the parts into one coherent model.
Let's write the program step by step. I'll start with defining the overall structures.
### Step 1: Define Structures
```python
from AIDL import *
def wine_glass(
bowl_diameter: float = 3*inches,
bowl_height: float = 4*inches,
stem_height: float = 6*inches,
base_diameter: float = 3.5*inches,
stem_width: float = 0.5*inch
):
wine_glass = Solid()
bowl = Solid()
stem = Solid()
base = Solid()
wine_glass.bowl = bowl
wine_glass.stem = stem
wine_glass.base = base
# Step 2: Add Constraints
# Constraints for positioning and dimensions.
# Align the stem's bottom with the base's top
wine_glass.AddConstraint(stem.bb.bottom == base.bb.top)
# Align the bowl's bottom with the stem's top
wine_glass.AddConstraint(bowl.bb.bottom == stem.bb.top)
# Center the bowl, stem, and base horizontally
wine_glass.AddConstraint(bowl.bb.horizontal_center == wine_glass.bb.horizontal_center)
wine_glass.AddConstraint(stem.bb.horizontal_center == wine_glass.bb.horizontal_center)
wine_glass.AddConstraint(base.bb.horizontal_center == wine_glass.bb.horizontal_center)
return wine_glass
with AIDL_2D:
model = wine_glass()
print(model.Solve())
model.Render()
```
Now, we need to add geometry to each of these parts, starting with the bowl.
### Step 3: Define the Geometry for Each Part
This is an iterative process. Let's define the bowl's geometry:
```python
from AIDL import *
def wine_glass(
bowl_diameter: float = 3*inches,
bowl_height: float = 4*inches,
stem_height: float = 6*inches,
base_diameter: float = 3.5*inches,
stem_width: float = 0.5*inch
):
wine_glass = Solid()
bowl = Solid()
stem = Solid()
base = Solid()
wine_glass.bowl = bowl
wine_glass.stem = stem
wine_glass.base = base
# Step 2: Add Constraints
# Constraints for positioning and dimensions.
# Align the stem's bottom with the base's top
wine_glass.AddConstraint(stem.bb.bottom == base.bb.top)
# Align the bowl's bottom with the stem's top
wine_glass.AddConstraint(bowl.bb.bottom == stem.bb.top)
# Center the bowl, stem, and base horizontally
wine_glass.AddConstraint(bowl.bb.horizontal_center == wine_glass.bb.horizontal_center)
wine_glass.AddConstraint(stem.bb.horizontal_center == wine_glass.bb.horizontal_center)
wine_glass.AddConstraint(base.bb.horizontal_center == wine_glass.bb.horizontal_center)
# Step 3: Define the Geometry for Each Part
# Bowl Geometry
bowl.curve1 = Arc((0, 0), (0, bowl_height), (bowl_diameter / 2, bowl_height / 2))
bowl.curve2 = Arc((0, 0), (0, bowl_height), (-bowl_diameter / 2, bowl_height / 2))
bowl.rim = Line(bowl.curve1.end, bowl.curve2.end)
bowl.AddConstraint(HorizontallySymmetric(bowl.curve1.start, bowl.curve2.start))
bowl.AddConstraint(HorizontallySymmetric(bowl.curve1.end, bowl.curve2.end))
bowl.AddConstraint(bowl.curve1.radius == bowl.curve2.radius)
return wine_glass
with AIDL_2D:
model = wine_glass()
print(model.Solve())
model.Render()
```
Once the bowl is defined, we can move on to defining the stem:
```python
from AIDL import *
def wine_glass(
bowl_diameter: float = 3*inches,
bowl_height: float = 4*inches,
stem_height: float = 6*inches,
base_diameter: float = 3.5*inches,
stem_width: float = 0.5*inch
):
wine_glass = Solid()
bowl = Solid()
stem = Solid()
base = Solid()
wine_glass.bowl = bowl
wine_glass.stem = stem
wine_glass.base = base
# Step 2: Add Constraints
# Constraints for positioning and dimensions.
# Align the stem's bottom with the base's top
wine_glass.AddConstraint(stem.bb.bottom == base.bb.top)
# Align the bowl's bottom with the stem's top
wine_glass.AddConstraint(bowl.bb.bottom == stem.bb.top)
# Center the bowl, stem, and base horizontally
wine_glass.AddConstraint(bowl.bb.horizontal_center == wine_glass.bb.horizontal_center)
wine_glass.AddConstraint(stem.bb.horizontal_center == wine_glass.bb.horizontal_center)
wine_glass.AddConstraint(base.bb.horizontal_center == wine_glass.bb.horizontal_center)
# Step 3: Define the Geometry for Each Part
# Bowl Geometry
bowl.curve1 = Arc((0, 0), (0, bowl_height), (bowl_diameter / 2, bowl_height / 2))
bowl.curve2 = Arc((0, 0), (0, bowl_height), (-bowl_diameter / 2, bowl_height / 2))
bowl.rim = Line(bowl.curve1.end, bowl.curve2.end)
bowl.AddConstraint(HorizontallySymmetric(bowl.curve1.start, bowl.curve2.start))
bowl.AddConstraint(HorizontallySymmetric(bowl.curve1.end, bowl.curve2.end))
bowl.AddConstraint(bowl.curve1.radius == bowl.curve2.radius)
# Stem Geometry
stem.shape = Rectangle((0, 0), stem_width, stem_height)
stem.AddConstraint(stem.shape.width == stem_width)
stem.AddConstraint(stem.shape.height == stem_height)
return wine_glass
with AIDL_2D:
model = wine_glass()
print(model.Solve())
model.Render()
```
Finally, let's define the base:
```python
from AIDL import *
def wine_glass(
bowl_diameter: float = 3*inches,
bowl_height: float = 4*inches,
stem_height: float = 6*inches,
base_diameter: float = 3.5*inches,
stem_width: float = 0.5*inch
):
wine_glass = Solid()
bowl = Solid()
stem = Solid()
base = Solid()
wine_glass.bowl = bowl
wine_glass.stem = stem
wine_glass.base = base
# Step 2: Add Constraints
# Constraints for positioning and dimensions.
# Align the stem's bottom with the base's top
wine_glass.AddConstraint(stem.bb.bottom == base.bb.top)
# Align the bowl's bottom with the stem's top
wine_glass.AddConstraint(bowl.bb.bottom == stem.bb.top)
# Center the bowl, stem, and base horizontally
wine_glass.AddConstraint(bowl.bb.horizontal_center == wine_glass.bb.horizontal_center)
wine_glass.AddConstraint(stem.bb.horizontal_center == wine_glass.bb.horizontal_center)
wine_glass.AddConstraint(base.bb.horizontal_center == wine_glass.bb.horizontal_center)
# Step 3: Define the Geometry for Each Part
# Bowl Geometry
bowl.curve1 = Arc((0, 0), (0, bowl_height), (bowl_diameter / 2, bowl_height / 2))
bowl.curve2 = Arc((0, 0), (0, bowl_height), (-bowl_diameter / 2, bowl_height / 2))
bowl.rim = Line(bowl.curve1.end, bowl.curve2.end)
bowl.AddConstraint(HorizontallySymmetric(bowl.curve1.start, bowl.curve2.start))
bowl.AddConstraint(HorizontallySymmetric(bowl.curve1.end, bowl.curve2.end))
bowl.AddConstraint(bowl.curve1.radius == bowl.curve2.radius)
# Stem Geometry
stem.shape = Rectangle((0, 0), stem_width, stem_height)
stem.AddConstraint(stem.shape.width == stem_width)
stem.AddConstraint(stem.shape.height == stem_height)
# Base Geometry
base.shape = Circle((0, 0), base_diameter / 2)
base.AddConstraint(base.shape.radius == base_diameter / 2)
return wine_glass
with AIDL_2D:
model = wine_glass()
print(model.Solve())
model.Render()
```
This should give us a nicely defined wine glass with a bowl, stem, and base. Feel free to customize the parameters or add more details according to your needs. If you require any adjustments or additional features, let me know!
|