Whenever we deal with triangles in 3D graphics, there is always a chance to face one terrible issue that is triangle/edge winding. It is like hell important for a lot of advanced algorithms because of normal vectors.
I started to code this algorithm 6 months ago, spent weekends, days and nights, and still couldn’t code it because of its complication (a lot of cases involved in this algorithm, such as manifold, non-manifold, 2D, or 3D mesh, unresolvable and border edges, etc.), so gave up at that time. Tried to get help from some forums (http://vtk.1045678.n5.nabble.com/How-to-correct-winding-order-of-a-triangular-mesh-using-VTK-td5721687.html) but still no answer.
So, one week ago, I started romance with this algorithm again, still it was seemed impossible. What I believe is whenever you start to do something, never give up on thinking about it. Give up just for that moment but start again some other time. I always do the same and have a good experience about it.
Actually, the issue was, I couldn’t even sleep well because of this awful algorithm since 1 week. I had to code it. Yea it happened to me a lot of time.
So, finally yesterday I got success on it. The results are pretty much impressive and the most important thing is, it is fast with no memory bug.
Today I am feeling so much relax because I have done it. Interesting thing is, I couldn’t find this algorithm in many 3D softwares and libraries. If there are some then they can not resolve all the cases. Anyway it will be very helpful for 3D reconstruction and remeshing and will be added in next version of 3DRACS.
Remember: It always seems impossible until it’s done. (N. Mandela)