An adaptive method to identify the plasma magnetic contour from magnetic and polarimetric measurements