Additive manufacturing (AM) technology has achieved universal application in a great number of fields, such as aerospace, medicine, and military industry. As a significant factor causing weak mechanical properties and part flaws, underfill is inevitable in AM based on the conventional equidistant toolpaths with a limited extra cost. To eliminate underfill caused by sharp corners and voids, this paper develops an optimization-based non-equidistant toolpath, i.e., isoperimetric-quotient-optimal toolpath (IQOP). Firstly, an optimization problem minimizing the isoperimetric quotient of toolpaths is designed to generate smooth toolpaths and is convexified. Then, a unilateral rolling circle method is proposed to guarantee the well-defined condition of the optimization-based toolpath planning process. Finally, the application of the depth tree makes the IQOP method adopt slices with complex boundaries and topological structures. The experimental results show that the proposed IQOP achieves an average 88.5% lower underfill rate than the contour-parallel toolpath (CP). IQOP significantly outperforms the dense CP (DCP) on toolpath smoothness and printing efficiency, with better performance on underfill. With obvious advantages on toolpath smoothness and underfill rate, IQOP achieves higher printing quality than CP in the real world. The proposed approach also provides a general framework of non-equidistant toolpath planning for complex slices in AM and computer numerical control (CNC) milling.