Solution (source code)

= Solution

The supplied <subdivision mask> describes the regular, valence-six triangular grid. Its coefficients split into four parity classes after binary refinement: one class for old vertices and three classes for the three edge directions. For an old vertex $V$ with cyclic neighbors $V_1,\ldots,V_6$, the even stencil is
$$
\boxed{V'=\frac{10V+V_1+\cdots+V_6}{16}=\frac58V+\frac1{16}\sum_{r=1}^6V_r.}
$$
For an edge with endpoints $A,B$ and opposite vertices $C,D$ in its two incident <triangles>, the new odd vertex is
$$
\boxed{M'=\frac{6A+6B+2C+2D}{16}=\frac38(A+B)+\frac18(C+D).}
$$
Rotating this edge stencil supplies the other two odd parity classes. All stencil weights sum to one, giving affine invariance; their first moments place an affine regular grid at the old positions and edge midpoints. Apply the same weights separately to $x,y,z$. Boundary edges and extraordinary vertices need additional rules, which are not specified by this uniform mask. The subsequent arguments concern the regular interior grid and compatible extruded boundary treatment.