Microscopic growth mechanisms for carbon and boron-nitride nanotubes