Padding

This example demonstrates the qtcad.builder.Builder.pad_volume operation.

Initialization

from qtcad.builder import Builder
from qtcad.builder import Mask, Polygon
from pathlib import Path
from util import is_interactive

Setting up the shapes

Here we define the device substrateprint shape (a simple box)…

substrateprint = Polygon.box(10, 10, name="substrate").centered()

… and the two “gates”

gate_1 = Polygon.box(10, 1, name="gate_1").centered().translated(0, -2)
gate_2 = gate_1.translated(0, 4).named("gate_2")

Finally we assemble them into masks

box_mask = Mask("substrateprint")
box_mask.add_shape(substrateprint)
gate_mask = Mask("gates")
gate_mask.add_shape(gate_1)
gate_mask.add_shape(gate_2)
Polygon(name='gate_2', id=1, hull=[(-5, 1.5), (-5, 2.5), (5, 2.5), (5, 1.5)], holes=[])

Generating the geometry

builder = Builder(name="padding demo")

(
    builder.set_mesh_size(10)
    .add_mask(box_mask)
    .add_mask(gate_mask)
    .group_from_shape()
    .use_mask("substrateprint")
    .use_shape("substrate")
    .extrude(3)
    .use_mask("gates")
    .extrude(0.4)
)
<qtcad.builder.builder.Builder object at 0x7fe14a2d51d0>

At this point we have two “gates” on top of a “substrate”

builder.view(
    surfaces=False,
    volume_labels=True,
    angles=(-45, 0, 45),
    save="figs/before_padding.svg",
)
padding
<qtcad.builder.builder.Builder object at 0x7fe14a2d51d0>

Now we add padding around those gates. The first padding will not be clipped, whereas the padding around the second gate will be clipped by the substrateprint shape we selected beforehand. We also set polygonize=False for the first gate to create a curved padding volume.

(
    builder.use_mask("substrateprint")
    .use_shape("substrate")
    .pad_volume("gate_1", 0.6, noclip=False, polygonize=False)
    .pad_volume("gate_2", 0.6, noclip=True)
)
<qtcad.builder.builder.Builder object at 0x7fe14a2d51d0>

Viewing the result

builder.view(
    surfaces=False, angles=(-45, 0, 45), save="figs/final.svg", show=is_interactive
)
padding
<qtcad.builder.builder.Builder object at 0x7fe14a2d51d0>

Hiding the padding volume

builder.view(
    True,
    groups=["gate_1", "gate_2", "substrate"],
    surfaces=True,
    volume_labels=True,
    angles=(-90, 0, 90),
    orthographic=True,
    save="figs/padding_removed.svg",
    show=is_interactive,
)
padding
<qtcad.builder.builder.Builder object at 0x7fe14a2d51d0>

Total running time of the script: (0 minutes 10.567 seconds)

Gallery generated by Sphinx-Gallery