Twin edges - Half edge data structure

Posted by Pradeep Kumar on Stack Overflow See other posts from Stack Overflow or by Pradeep Kumar
Published on 2012-11-07T04:58:39Z Indexed on 2012/11/07 4:59 UTC
Read the original article Hit count: 131

Filed under:
|
|

I have implemented a Half-edge data structure for loading 3d objects. I find that the part of assigning twin/pair edges takes the longest computation time (especially for objects which have hundreds of thousands half edges). The reason is that I use nested loops to accomplish this. Is there a simpler and efficient way of doing this? Below is the code which I've written. HE is the half-edge data structure. hearr is a vector containing all the half edges. vert is the starting vertex and end is the ending vertex. Thanks!!

HE *e1,*e2;

for(size_t i=0;i<hearr.size();i++){
    e1=hearr[i];
    for(size_t j=1;j<hearr.size();j++){
        e2=hearr[j];
        if((e1->vert==e2->end)&&(e2->vert==e1->end)){
            e1->twin=e2;
            e2->twin=e1;
        }
    }
}

© Stack Overflow or respective owner

Related posts about c++

Related posts about opengl