Modeling and Programming Shape-Morphing Structured Media