How to get in order the coordinates of all corners from any mesh?

Basically, it doesn’t matter where to start; the main thing is to outline the mesh with a spline so that it looks like in the photo