The Poincaré-Hopf theorem for relative braid classes