A polynomial-time algorithm for the topological type of a real algebraic curve