Skip to main content

Lattices, frames and foam

A Voronoi diagram has edges, faces and cells, and each can carry material. Put a strut on every edge and you have a lattice. Keep every face but cut a window in it and you have frames, the open cage most people picture when they hear "Voronoi". Keep every cell but hollow it and you have closed-cell foam; open the hollows into each other and it is open-cell foam. All three are built by bitbybit.occt.patterns.voronoi straight from the cells, with no boolean, and each takes values per seed so a field can grade it.

Beams on the edges of cells​

bitbybit.occt.patterns.voronoi.beams2d puts a beam on every edge of the cells in a planar face, each edge two cells share once, and a sphere at each node where beams meet:

  • radius is every beam's radius, at least a ten-millionth of a unit.
  • sides is 0 for round beams, cylinders, or from 3 to 12 for prisms with that many flat sides. In a face, each prism is turned to lie on one of its flat sides; in space, each is turned the same way every time from the axis least along it.
  • nodeRadius is the radius of the sphere at each node. Left out, each node takes the radius of its widest beam, so the spheres round off every joint; 0 leaves them out.
  • walls says whether the edges along the face's own boundary carry beams too. A curved piece of the boundary, such as the arc of a hole, carries none, since a straight beam cannot follow it; the report counts them as skippedCurves.
  • build set to graph builds the beams' centre lines as edges instead of solids, for a quick look or a drawing.
Beams on the cells of a faceBeams on the cells of a face, top view
Bitbybit Platform

Beams on the cells of a face in Rete

Rete

bitbybit.occt.patterns.voronoi.beams3d does the same in a box or a convex solid of planar faces: a beam on every edge of the cells in space, each once, which is a strut lattice. sizes gives each seed its own radius, and each beam takes the mean of the cells round its edge, so a field read at the seeds grades the struts smoothly from thick to thin. The lattice mount thickens its struts toward its load this way.

A strut lattice in a cubeA strut lattice in a cube, back view
Bitbybit Platform

A strut lattice in a cube in Rete

Rete

The beams and spheres come as one compound of separate solids, a beam a strut and a sphere a node, and nothing is fused: a beam's end overlaps the sphere at its node and the beams beside it. Export the compound and a slicer merges the overlaps as it prints. Keeping them apart keeps every beam its own shape with its own radius, and the build linear in the number of beams.

The beam graph​

bitbybit.occt.patterns.voronoi.beams2dWithReport and bitbybit.occt.patterns.voronoi.beams3dWithReport build the same beams and report them, and their report carries the whole lattice as plain data:

  • nodes, every end of a beam once, ends that meet joined into one node;
  • struts, one pair of node positions a beam, from its edge's start to its end;
  • radii, one radius a beam, in the order of struts;
  • nodeRadii, one radius a node: its sphere's, or its widest beam's.

The graph is enough to rebuild the lattice in another program, to count and measure struts, or to export it as JSON. With build set to graph, only the edges are built and no solids at all. The TypeScript tab of the lattice above prints how many nodes and struts it has.

Frames​

bitbybit.occt.patterns.voronoi.frames3d builds every face between two cells in a box or a convex solid once, and each face on the solid's boundary when walls is on, and cuts a window in each: the face made smaller in its own plane by the same shrink rule perforated faces use, scale about its centroid or inset from every edge, its corners rounded by radius. The frames are flat faces.

sizes gives each seed its own scale or inset, and a frame between two cells takes the mean of their two values, a frame on the boundary its one cell's. A face too small for its window, or closed by its size, stays whole. bitbybit.occt.patterns.voronoi.frames3dWithReport reports each frame: the cells or wall it lies between, the scale or inset its window took, and whether it has one.

Hollow walls​

wall gives the frames substance: each cell becomes one hollow solid inside itself, its faces with their windows outside, the cell made smaller inside, and a tunnel of planar faces from each window through the wall to the inside. Neighbouring cells hold their shared face at the same points, so they touch face to face and never overlap:

  • wall set to scale makes the inside the cell scaled toward its centroid by 1 less thickness, the wall's share of the cell, from 0.001 to 0.999: larger cells get thicker walls, and each window's tunnel narrows toward the centroid.
  • wall set to inset moves every face of the cell inward by wallInset for the inside, so every wall is that thick, and each tunnel runs from the window to the inside's face made smaller by the window's own shrink.

The windows are made by the same scale or inset and sizes as flat frames, but with sharp corners: a wall refuses a radius above 0. walls says whether the cells' faces on the solid's boundary get windows or stay closed. A window opens only where both cells round it are hollow and its far end fits on the inside; with an inset wall, a face whose inset takes a different shape, as a short edge of a cell disappears, keeps its window closed. A cell its wall would leave nothing of stays solid. With a wall, frames3dWithReport reports each cell instead of each frame: whether it is hollow, how many windows it opened and how many stayed closed.

Voronoi frames, flat and walledVoronoi frames, flat and walled, back view
Bitbybit Platform

Voronoi frames, flat and walled in Rete

Rete

Flat frames are open surfaces, seen from both sides, so the example draws them with both sides white. Like the beams, each frame is its own piece in an unfused compound; frames that meet along an edge overlap there, and merge when printed. The walled cells are solids and draw like any part, one solid a cell, each touching its neighbours face to face: the scaled walls open a window in every face, while the inset walls keep some closed where a cell's inset face takes another shape than the face outside it. The TypeScript tab prints how many of the inset walls' windows opened and how many stayed closed.

Closed-cell foam​

bitbybit.occt.patterns.voronoi.foam makes a solid into closed-cell foam: one solid whose outer shell is the solid's own boundary and which holds a sealed void in each seed's cell. Each void is its cell made smaller, by the same shrink rule:

  • with scale, each void is its cell scaled about its centroid, so it lies strictly inside its cell and no two voids ever touch, however close their cells. The walls between voids are thicker where the cells are larger.
  • with inset, every face of the cell moves inward by inset, so two neighbouring voids are their two insets apart: walls of one thickness throughout.

skin is the least distance any void keeps from the solid's outside: 0 for scaled voids and the inset for inset ones, unless set. In a box or a convex solid of planar faces, a void near the outside is cut back by the skin, so the cells along the outside keep their voids too. In any other solid, a void is made only for a cell wholly inside the solid, and only when it lies at least the skin from the solid's faces, so the outermost cells along a curved or concave surface stay solid. sizes gives each cell its own scale or inset, closing a cell entirely at a scale of 0.001 or less.

Like a perforated face, the foam is made without a boolean: the voids are built from their cells' planar faces and added to the solid as inner shells. bitbybit.occt.patterns.voronoi.foamWithReport reports each cell's void: made, with its exact volume; closed, by its size or a shrink that left nothing; notInside, a cell not wholly inside a solid that is not convex; tooClose, nearer the outside than the skin; or noCell. A shape of more than one solid is refused: "the foam needs a shape of one solid".

Closed-cell foam, cut openClosed-cell foam, cut open, side view
Bitbybit Platform

Closed-cell foam, cut open in Rete

Rete

From the outside the foam looks like the block it was made from; the voids are sealed inside it. The example cuts away its front half to show them, with a boolean, which is the one step here that is not part of the foam itself. The foam-core arm grades the cells from fine under the skin to coarse in the core.

Open-cell foam​

windows opens the voids into each other. Each face two voided cells share gets a window, the face made smaller by windowScale about its centroid or by windowInset from every edge, and each void gets a tunnel of planar faces from its own face out to the window, so the voids join and the foam is open-cell. It is still one solid, with no boolean: the voids that join make one inner shell a group. wallWindows opens the voids through the solid's own faces too, in a box or a convex solid of planar faces, so they reach the outside and the inside and the outside become one surface, as in a sponge.

The windows take one value for every cell, the voids keep their sizes, and a window opens only where both cells round it have a void. A window is a piece two cells share, so, as for frames, seeds closer than a hundred-thousandth of the solid's box diagonal are refused, or merged when coincidentSeeds is merge. bitbybit.occt.patterns.voronoi.foamWithReport counts each cell's windows, and windows and wallWindows for the whole foam.

Open-cell foamOpen-cell foam, back view
Bitbybit Platform

Open-cell foam in Rete

Rete

The same block and seeds as the closed-cell foam above, with the voids scaled instead of inset: through the windows in its faces the voids show behind each other, every one joined to its neighbours. The TypeScript tab prints how many windows join two voids and how many open through the block's faces.