Heterogeneous conformal lattices#
A single CellMap can lay out several kinds of lattice in one part. The map is the shared grid: it tells every cell where to sit in the finished shape. You can then use a smooth TPMS sheet in one area and a beam-based graph lattice in another without losing that shared layout.
This guide shows three ways to join those areas: make a clean cut, blend two similar TPMS patterns, or let two unlike patterns overlap. It then applies them to a curved mesh part and shows how to check that the result is one connected piece. It assumes you have worked through the metamaterial concepts and functionally graded geometry guides.
Build sharp topology regions#
Goal: put one topology on each side of a chosen boundary. Build each lattice across the full shared map, keep the required portion with Intersection, then combine the portions with Union:
import pyvcad as pv
import pyvcad_metamaterials as mm
cell_map = mm.rectangular_cell_map(
(pv.Vec3(-24.0, -12.0, -8.0), pv.Vec3(24.0, 12.0, 8.0)),
cells=(6, 3, 2),
)
gyroid = mm.gyroid(cell_map, wall_thickness=1.2)
schwarz_d = mm.schwarz_d(cell_map, wall_thickness=1.2)
left_region = pv.RectPrism.FromMinAndMax(
pv.Vec3(-30.0, -18.0, -12.0), pv.Vec3(0.0, 18.0, 12.0)
)
right_region = pv.RectPrism.FromMinAndMax(
pv.Vec3(0.0, -18.0, -12.0), pv.Vec3(30.0, 18.0, 12.0)
)
root = pv.Union(
pv.Intersection(gyroid, left_region),
pv.Intersection(schwarz_d, right_region),
)
left_region and right_region are simple box-shaped cutters. They meet at x = 0, so the two lattices meet there with no transition zone. A region can also be an imported CAD body or any other OpenVCAD shape. The shared CellMap still controls cell placement; the region merely decides which lattice is visible at each point.
The first render below has a gyroid on one side and Schwarz-D on the other. The second uses straight cubic beams and body-centred-cubic (BCC) beams. In both, the visible change is an immediate cut at the boundary.
Mix compatible topology fields smoothly#
Goal: change gradually from one compatible pattern to another. Use mm.mix when a clean cut would look or behave too abrupt. Instead of keeping only one shape at each point, it blends the two underlying shape values across a band. The same region box can define that band:
root = mm.mix(
gyroid,
schwarz_d,
region=left_region,
half_width=4.0,
)
The region surface is the middle of the transition. gyroid remains unchanged for one half_width inside left_region; schwarz_d remains unchanged for the same distance outside it. Between those limits, OpenVCAD changes smoothly from one to the other. The total blend width is twice half_width, so half_width=4.0 makes an 8 mm-wide transition band.
For coordinate-driven transitions, pass a weight field instead:
weight = mm.ramp(-8.0, 8.0, axis="x", smooth=True)
root = mm.mix(gyroid, schwarz_d, weight)
For a transition that follows cell positions rather than millimetres, pass the map itself as the coordinates. The ramp then reads the map’s logical position, counted in cells:
weight = mm.ramp(2.0, 4.0, axis="u", coordinates=cell_map)
root = mm.mix(gyroid, schwarz_d, weight)
Logical coordinates exist only inside the map. A mix still asks for its weight everywhere in its bounding box, including the empty corners around a curved map. There the ramp returns its outside value, 0 by default, which selects the first body. That is harmless because both mapped lattices are empty outside the map. Choose another value with outside=1.0, or pass outside=None to raise an error instead. Hand-built fields get the same protection from field.with_fallback(0.0, cell_map).
mm.idw_weight can create a weight from the distance to chosen seed points, and mm.mix_many can combine more than two bodies. Keep the bodies on the same CellMap. They may have different outer boundaries, but expect an abrupt change where only one body exists.
Number, vector, and material volume-fraction attributes blend with the same weight by default. Material fractions are combined and normalized, which gives a continuous material transition. If an attribute is a discrete label rather than a value that should blend, choose an appropriate pv.Mix attribute policy or conflict resolver.
For two TPMS patterns, ImplicitUnitCell.mixed is the preferred approach. It blends the repeating unit-cell patterns before OpenVCAD turns them into walls and maps them into the part. 01_tpms_to_tpms.py uses that approach:
cell_weight = mm.ramp(
2.5,
3.5,
axis="u",
coordinates=cell_map.logical_position,
)
mixed_cell = pv.ImplicitUnitCell.mixed(
pv.ImplicitUnitCell.standard("gyroid"),
pv.ImplicitUnitCell.standard("schwarz_d"),
cell_weight,
)
root = mm.tpms(cell_map, mixed_cell, wall_thickness=1.2)
Even a smooth blend needs inspection. Its geometry can pinch apart, create small isolated pieces, or close a passage when the two source patterns do not line up. This is most likely when blending unlike families, such as a TPMS sheet and a beam lattice. Treat a general mm.mix result as a design to inspect for connected material, thin features, and enclosed voids—not as a mechanically validated connector.
Connect incompatible topologies with overlap#
Goal: join unlike patterns, such as a TPMS sheet and a beam lattice. Rather than blending shapes that mean different things, keep both structures in a shared overlap band. Their physical intersections make the connection. 03_tpms_to_graph_overlap.py uses a one-cell-wide, 8 mm overlap:
OVERLAP_HALF_WIDTH = 4.0
tpms_region = pv.RectPrism.FromMinAndMax(
pv.Vec3(-30.0, -18.0, -12.0),
pv.Vec3(OVERLAP_HALF_WIDTH, 18.0, 12.0),
)
graph_region = pv.RectPrism.FromMinAndMax(
pv.Vec3(-OVERLAP_HALF_WIDTH, -18.0, -12.0),
pv.Vec3(30.0, 18.0, 12.0),
)
root = pv.Union(
pv.Intersection(schwarz_p, tpms_region),
pv.Intersection(octet, graph_region),
)
Overlap uses more material than a blend and still needs mechanical validation. It avoids inventing an in-between shape, though: each source remains recognizable and can intersect the other across the whole band. Adjust the beam radius, wall thickness, and band width until those intersections have enough area to print and carry load.
Drag the divider in this close-up. The left image shows a hard cut between the gyroid and Schwarz-D sheets; the right image shows the same two sheets changing through a blend band. The matching camera makes the difference easy to see.
Sharp CSG clipping
Field mixing
Divide a curved mesh part into zones#
The same tools work on a conformal map built from a triangle-mesh patch, such
as the dome in the conformal meshes guide.
mm.zones assigns one structure per region and joins neighbours in the same
way throughout. 06_dome_mesh_zones.py
puts a gyroid on the crown of a dome, an octet band below it, and Kelvin cells
at the rim:
cell_map = mm.cell_map_from_surface(surface, cells=(12, 12, 2), height=8.0)
crown = mm.gyroid(cell_map, wall_thickness=0.7)
middle = mm.octet(cell_map, beam_radius=0.45)
rim = mm.kelvin(cell_map, beam_radius=0.5)
above_crown = pv.RectPrism.FromMinAndMax(pv.Vec3(-50, -50, 21), pv.Vec3(50, 50, 60))
above_rim = pv.RectPrism.FromMinAndMax(pv.Vec3(-50, -50, 13), pv.Vec3(50, 50, 60))
root = mm.zones(
[crown, middle, rim],
[above_crown, above_rim],
mode="overlap",
half_width=2.0,
)
There is always one more structure than regions. The first region wins where
regions overlap, and the last structure fills everything outside them. mode
chooses how neighbours meet: "sharp" cuts at each region surface, "mix"
blends distance fields across a 2 * half_width band (compatible families
only), and "overlap" keeps both structures through that band, as in the
earlier TPMS-to-beam example. mm.overlap(inside, outside, region, half_width)
makes a single overlap join.
Ramp along u, v, or w#
On any map, logical u and v run across the patch and w runs from the
patch to the outer surface. A ramp along w therefore changes a structure
through the thickness, whatever the shape of the part.
07_dome_mesh_uvw_ramps.py
changes the TPMS family through the thickness and the wall thickness across
the patch:
through_thickness = mm.ramp(0.5, 2.5, axis="w", coordinates=cell_map)
mixed_cell = pv.ImplicitUnitCell.mixed(
pv.ImplicitUnitCell.standard("gyroid"),
pv.ImplicitUnitCell.standard("schwarz_d"),
through_thickness,
)
across = mm.ramp(2.0, 10.0, axis="u", coordinates=cell_map, smooth=False)
root = mm.tpms(cell_map, mixed_cell, wall_thickness=across.map_range(0.0, 1.0, 0.45, 1.0))
mm.ramp is 0 at start, 1 at end and clamped beyond them, so the ends
may be given in either order. smooth=True (the default) eases in and out of
the band; smooth=False is linear. Equal ends raise an error: use a sharp
region instead of a zero-width band.
Check that a transition is one piece#
Any join can separate: a field blend can pinch apart, and clipping can leave
loose pieces at a region or host boundary. mm.check_connectivity samples the
finished design and counts its separate solid pieces:
report = mm.check_connectivity(root, voxel_size=0.2)
print(report)
assert report.connected
Choose a voxel size of at most about half the thinnest wall or beam radius. The report lists the volume and location of every extra piece, so you can see which band to widen or which members to thicken. The section Keep clipped foams in one piece of the stochastic lattices guide explains the options in more detail.
Transitions with stochastic foams#
Random Voronoi foams can join this kind of design too. The stochastic lattices guide shows how a foam becomes a regular Kelvin, cubic, or rhombic-dodecahedron lattice by moving its seeds, how to attach a foam to a mapped strut lattice, and how to join a foam to a TPMS through an overlap band.
Choose sharp clipping, field mixing, or overlap#
Use sharp clipping when the boundary location matters most and you want both patterns unchanged right up to it. It can leave beams or sheets abruptly cut off, so align the boundary with cell vertices where possible, enlarge important beam joints, or add a deliberate connector where the load must cross.
Use smooth mixing for compatible patterns with matching features, especially two TPMS patterns. ImplicitUnitCell.mixed is the best choice for that case. A continuous change in the underlying shape values does not promise one connected, printable solid, so inspect the result for islands, thin necks, and trapped voids.
Use overlap as the safer starting point for unlike families such as TPMS-to-graph. It keeps both source structures through a finite band, which costs material but gives their connections a clear physical form. Check connected components with mm.check_connectivity, then load paths and manufacturability, before relying on any transition. For a random foam, prefer moving its seeds (see the stochastic lattices guide) over any of these joins.
The complete interactive examples are 01_tpms_to_tpms.py, 02_tpms_to_tpms_surface_conformal.py, 03_tpms_to_graph_overlap.py, 04_tpms_to_graph_between_surfaces.py, 05_graph_to_graph.py, 06_dome_mesh_zones.py, and 07_dome_mesh_uvw_ramps.py.






