Non-axisymmetric equilibrium reconstruction for stellarators, reversed field pinches and tokamaks