This paper presents a surface reconstruction algorithm that can recover correct shape geometry as well as its unknown topology from both volumetric images and unorganized point clouds. The algorithm starts from a simple seed model (of genus zero) that can be arbitrarily initiated within any datasets. The deformable behavior of the model is governed by a locally defined objective function associated with each vertex of the model. Through the numerical computation of function optimization, the algorithm can adaptively subdivide the model geometry, automatically detect self-collision of the model, properly modify its topology (because of the occurrence of self-collision), continuously evolve the model towards the object boundary, and reduce fitting error and improve fitting quality via global refinement. Commonly used mesh optimization techniques are employed throughout the geometric deformation and topological variation to ensure the model both locally smooth and globally well defined. ...