Freeform surfaces exist widely in the stock cutting process of clinical prosthesis preparation, aviation, ship, and other manufacturing industries. The free-form contours of surfaces need to be packed before they are machined from raw materials. The existing methods search a contour position by rotating the contour and translating it to connect other contours for packing. The relative position between two contours will be changed after the rotation as the contour description is lack of geometric invariance. These methods easily miss the best layout position resulting in interspaces in the raw material. Moreover, this result seriously reduces the performance and efficiency of an automatic packing system. Therefore, a new packing algorithm is proposed in this paper by combining the geometric invariant description and coding matching for contours to solve the contour rotating and position connecting problems. The optimal position of a contour can be found directly and then connected by the extracted similar complement features of the contour. The experimental results show that the proposed method can greatly improve quality and efficiency of the layout, especially in the material utilization. INDEX TERMS Computer graphics, code matching, shape, free-form contour packing, freeman chain code, geometric invariant description, layout.