added CGAL for polygon handling, everything works fine, but the code got even worse