How does the winged-edge structure for meshes work?
I'm implementing an开发者_Go百科 algorithm in which I need manipulate a mesh, adding and deleting edges quickly and iterating quickly over the edges adjacent to a vertex in CCW or CW order.
The winged-edge structure is used in the description of the algorithm I'm working from, but I can't find any concise descriptions of how to perform those operations on this data structure.
I've learned about it in University but that was a while ago.
In response to this question i've searched the web too for any good documentation, found none that is good, but we can go through a quick example for CCW and CW order and insertion/deletion here. Have a look at this table and graphic:
from this page:http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/model/winged-e.html
The table gives only the entry for one edge a
, in a real table you have this row for every edge. You can see you get the:
- left predecessor,
- left successor,
- right predecessor,
- right successor
but here comes the critical point: it gives them relative to the direction of the edge which is X->Y
in this case, and when it is right-traversed (e->a->c)
.
So for the CW-order of going through the graph this is very easy to read: edge a
left has right-successor c
and then you look into the row for edge c
.
Ok, this table is easy to read for CW-order traversal; for CCW you have to think "from which edge did i come from when i walked this edge backwards". Effectively you get the next edge in CCW-order by taking the left-traverse-predecessor in this case b
and continue with the row-entry for edge b
in the same manner.
Now insertion and deletion: It is clear that you cant just remove the edge and think that the graph would still consist of only triangles; during deletion you have to join two vertices, for example X
and Y
in the graphic. To do this you first have to make sure that everywhere the edge a
is referred-to we have to fix that reference.
So where can a
be referred-to? only in the edges b,c,d and e
(all other edges are too far away to know a
) plus in the vertex->edge-table if you have that (but let's only consider the edges-table in this example).
As an example of how we have to fix edges lets take a look at c
. Like a
, c
has a left and right pre- and successor (so 4 edges), which one of those is a
? We cannot know that without checking because the table-entry for c
can have the node Y
in either its Start- or End-Node. So we have to check which one it is, let's assume we find that c
has Y in its Start-Node, we then have to check whether a
is c's
right predecessor (which it is and which we find out by looking at c's
entry and comparing it to a
) OR whether it is c's
right successor. "Successor??" you might ask? Yes because remember the two "left-traverse"-columns are relative to going the edge backward. So, now we have found that a
is c's
right predecessor and we can fix that reference by inserting a's
right predecessor. Continue with the other 3 edges and you are done with the edges-table. Fixing an additional Node->Vertices
is trivial of course, just look into the entries for X and Y and delete a
there.
Adding edges is basically the reverse of this fix-up of 4 other edges BUT with a little twist. Lets call the node which we want to split Z
(it will be split into X
and Y
). You have to take care that you split it in the right direction because you can have either d
and e
combined in a node or e
and c
(like if the new edge is horizontal instead of the vertical a
in the graphic)! You first have to find out between which 2 edges of the soon-to-be X
and between which 2 edges of Y
the new edge is added: You just choose which edges shall be on one node and which on the other node: In this example graphic: choose that you want b
, c
and the 2 edges to the north in between them on one node, and it follows that the other edges are on the other node which will become X
. You then find by vector-subtraction that the new edge a
has to be between b and c, not between say c and one of the 2 edges in the north. The vector-subtraction is the desired position of the new X
minus the desired position of Y
.
精彩评论