An algorithm for 3-dimensional free-surface problems in Hydrodynamics