Marching squares algorithm