Optimal design of flat patterns for 3D folded structures by unfolding with topological validation