script/save_basis.py: fix mesh mode, make permutations directly from mesh