Hello,
Please, take a look at this: How to extract the ids of the boundary points of a surface?
It refers to an example that is no longer avaible, though a snapshot of it is available in The Wayback Machine: https://web.archive.org/web/20200407105456/https://lorensen.github.io/VTKExamples/site/Cxx/Meshes/BoundaryEdges/ .
regards,
Paulo