selecting edges and vertices with mouse


I’m developing an OpenGL application for solid modeling using boundary representation. What is the most reliable strategy to implement vertices, edges and faces selection using the mouse?
Is there a standard to develop these kind of routines? My intuition tells me to develop routines to check the intersections between point and ray, segment and ray and polygon and ray. The ray would be constructed using gluUnProject.
Any help, links, references are welcome.


There are several ways for implementing these ideas and some lead to different results. For example, if you limit yourself to ray-face intersections, you get a very simple fast algorithm that gives you the closest face and you can see after this which vertex or edge is closest to the mouse (instead of doing every vertex and edge). You can see Wings3D does it this way by moving your mouse over a face in vertex mode and it highlights even inches away, while if you go real close to it but don’t have your mouse above the mesh, it won’t highlight anything.