def sections(src_dim, tgt_dim):
"""Generate all boundary sections from a source dimension to a target
dimension. For example, `sections(3,1)` generates all edges on a volume.
The return values are lists of length `src_dim` with each element either 0,
--1 or `None`, which are suitable for passing to
:func:`splipy.SplineObject.section`.
"""
# Enumerate all combinations of fixed directions
nfixed = src_dim - tgt_dim
for fixed in combinations(range(src_dim), r=nfixed):
# Enumerate all {0,-1}^n over the fixed directions
for indices in product([0, -1], repeat=nfixed):
args = [None] * src_dim
for f, i in zip(fixed, indices[::-1]):
args[f] = i
yield args
评论列表
文章目录