A new approach to the solution of the vacuum magnetic problem in fusion machines