Note. The description has become a little longer than expected. Do you know a readable implementation of this algorithm using this grid? Please let me know!
I am trying to implement the Catmull-Clark division using Matlab, because later the results should be compared with some other materials implemented in Matlab. The first attempt was with the Vertex-Face grid, the algorithm works, but it is not very efficient, since you need neighboring information for edges and faces. Therefore, I now use a semi-cross mesh . See also Designing a data structure for polyhedral surfaces, Lutz Kettner (PDF link on this page).
My problem is finding Twin HalfEdges , I just don't know how to do this. Below I describe my thoughts on implementation, trying to keep it concise.
Half-screen grid (using indexes to vertices / half-elements / faces):
Vertex (x,y,z,Outgoing_HalfEdge) HalfEdge (HeadVertex (or TailVertex, which one should I use), Next, Face, Twin). Face (HalfEdge)
To keep it simple, suppose each face is quadrilateral. The actual grid is a list of Vertices, HalfEdges and Faces. The new grid will consist of NewVertices, NewHalfEdges and NewFaces, like this (note: The number _... is the number ... ):
NumberNewVertices: Number_Faces + Number_HalfEdges/2 + Number_Vertices NumberNewHalfEdges: 4 * 4 * NumberFaces NumberNewfaces: 4 * NumberFaces
Catmull-Clark:
Find the FacePoint (centroid) of each Face:
So, now all new vertices are calculated (however, their Outgoing_HalfEdge is still unknown). The next step is to save the new HalfEdges and Faces. This is the part that causes me problems!
Loop through each old Face, there are 4 new Faces to be created (because of the quadrilateral assumption) First create the 4 new HalfEdges per New Face, starting at the FacePoint to the Edgepoint Next a new HalfEdge from the EdgePoint to an Updated Vertex Another new one from the Updated Vertex to the next EdgePoint Finally the fourth new HalfEdge from the EdgePoint back to the FacePoint.
HeadVertex of each new HalfEdge, Next HalfEdge is known . The face is also known (because it is the new face that you create!). Only Twin HalfEdge is unknown, how can I find out?
By the way, when going through the vertices of a new face, assign Outgoing_HalfEdge vertices. This is probably the place to find out which HalfEdge is Twin.
Finally, after creating 4 new HalfEdges, save the Face with the HalfVertex index of the last recently created HalfVertex.
Hope this is clear, if necessary, I can publish my (obviously not yet finished) Matlab code.
Change Thank you for moving my thread. I posted a link to the source code in a comment, note that this implementation considers common polygonal meshes, so not only quadrangular meshes.
In addition, the twins of the new HalfEdges 1 and 4 (red numbers in each new face) are pretty easy to find if you think the old quadrangular face is divided into 4 new faces (green numbers):

So, how to find Gemini 2- and 3 HalfEdges?