How thick is that foam? One thing to keep in mind is that the laser beam has an hour glass shape as is goes through the focal point.
So for straighter cut profiles you would want a longer focus point lens. Most of these 40W machines come with a 2" focal length lens but you could go with a longer focal length. The spot size does go up with longer focal length so they are not as good for engraving.
Also if the beam isn’t perpendicular to the work surface you can get some wonky angle cuts.

