Shape reconstruction from medical images and quality mesh generation via implicit surfaces