Optimal localization of complex surfaces in CAD-based inspection