If I had a triangular mesh surface, it could be rendered according to whatever computer graphics does to render it, and done properly only the front most triangles would be visible.
What I am interested in is something similar to the rendering problem in concept, but I don't want a bitmap image. What i want is the list of 2D polygons that results when projecting a 3D triangular mesh onto a plane, and what I need are the actual vertices and edges of the resulting 2D mesh.
In addition to projecting triangles that are completely visible onto a plane which is trivial, it would also mean not including triangles that are completely covered, but also clipping triangles that are partly covered, possibly into polygons with >3 edges.
In a naive sense, I could simply project every triangle into the plane, tracking the z-value of each one, and then compare every triangle to every other polygon for overlap and then do clipping and ignoring as necessary. But then this would go as N^2 and I have to do this procedure many times and would be concerned about computational cost.
While I have found many things about operations on triangular meshes such as rendering, simplifying, performing booleans, etc. I haven't seen this exactly. If there is a library for doing this, or a reference that discusses how to do it, I would be grateful for a reference.
There are two ways of doing this.
A. Using OpenGL/GPU (Computationally faster) (This logic is also used for selection implementations)
You'll have to follow following steps (I'm assuming you are aware of rendering pipeline and aware of OpenGL/WebGL)
B. Using CPU renderers or writing custom algorithm.
In this case you can use CPU rendering libraries for the same or you can write following algorithm
I would always recommend OpenGL approach as it has an advantage of faster processing as we use GPU for rendering. And it does most of the work for you, you can control the results based on how you set the depth functions, face culling flags etc.