Enhanced gauge symmetry in type II and F-theory compactifications: Dynkin diagrams from polyhedra