A self-folding structure fabricated by additive manufacturing (AM) can be automatically folded into a demanding three-dimensional (3D) shape by actuation mechanisms such as heating. However, 3D surfaces can only be fabricated by self-folding structures when they are flattenable. Most generally, designed parts are not flattenable. To address the problem, we develop a shape optimization method to modify a nonflattenable surface into flattenable. The shape optimization framework is equipped with topological operators for adding interior/boundary cuts to further improve the flattenability. When inserting cuts, self-intersection is locally prevented on the flattened two-dimensional (2D) pieces. The total length of inserted cuts is also minimized to reduce artifacts on the finally folded 3D shape.