Extract border from 2D mesh

Hi everyone,

I was trying to extract the border from a 2D mesh. The only function that i could find on the FreeFem Documentation is only applied for a 3D mesh (mesh3, extractborder). I hope someone could help me on this topic, i was trying to find the solution for a long time, the border that i want to extract could be from a simple square or maybe more difficult from a random shape. The reason i want to extract the border is to define the initial condition for a simulation of the traffic flow.

Thanks for your help.

Maybe with an empty mesh: see here

Thank you but what i do really need was how to extract a part of the border, to set the initial limitation. For example it could be one edge of a square, half of the circle or random edge from a random shape. Because in my project, i already have the totally border extracted now all i need is just a part of it.

Thanks a lot for your help.

I think in curvature.edp example you get the good function:

curvature.edp:real l12=extractborder(Th,ll,b12);

see FreeFem-sources/curvature.edp at master · FreeFem/FreeFem-sources · GitHub

Thank you for your reponse, i have tried your code and try to apply it into my project, but it didn’t work in my case. Because in my project, the whole border was taken from a random picture. The problem here is there is no way to identify the label of the edge that we want to extract. The function ‘extractborder’ require label of the edge to be able to extract. I was thinking about using matrix to identify the label of the edge wanted but I didn’t find any informations about this on any documents. I hope you can help me solve this problem.

Thank you for your help

I am sure they are a way to know with boudany to extract ot,hernies you problem, algorithm is not correct ,

You can sens directly tour problem and data to me, I will try.