| | |
| | | ts_bool bond_assign_triangles(ts_bond *bond){ |
| | | ts_vertex *vtx1=bond->vtx1, *vtx2=bond->vtx2; |
| | | ts_uint i,j,k; |
| | | |
| | | ts_uint i1=0,i2=0,i3=0,im=0; |
| | | ts_triangle *ttria; |
| | | for(i=0,k=0;i<vtx1->tristar_no;i++){ |
| | | for(j=0;j<3;j++){ |
| | | if(vtx1->tristar[i]->vertex[j]==vtx2){ |
| | |
| | | } |
| | | } |
| | | if(k<2) return TS_FAIL; |
| | | else return TS_SUCCESS; |
| | | |
| | | //We will sort the triangles so, they are oriented as km and kp for bondflip |
| | | for(i=0;i<3;i++){ |
| | | if(bond->tria[0]->vertex[i]==vtx1){ |
| | | i1=i; |
| | | } |
| | | else if(bond->tria[0]->vertex[i]==vtx2){ |
| | | i2=i; |
| | | } |
| | | else i3=i; |
| | | } |
| | | |
| | | if(i1>i2 || (i1==0 && i2==2)){ |
| | | //pozitivna orientacija! |
| | | ttria=bond->tria[0]; |
| | | bond->tria[0]=bond->tria[1]; |
| | | bond->tria[1]=ttria; |
| | | bond->adjvtx[1]=bond->tria[0]->vertex[i3]; |
| | | im=0; |
| | | } |
| | | else{ |
| | | bond->adjvtx[0]=bond->tria[0]->vertex[i3]; |
| | | im=1; |
| | | } |
| | | |
| | | for(i=0;i<3;i++){ |
| | | if(bond->tria[1]->vertex[i]==vtx1){ |
| | | i1=i; |
| | | } |
| | | else if(bond->tria[1]->vertex[i]==vtx2){ |
| | | i2=i; |
| | | } |
| | | else i3=i; |
| | | } |
| | | bond->adjvtx[im]=bond->tria[1]->vertex[i3]; |
| | | |
| | | |
| | | return TS_SUCCESS; |
| | | } |
| | | |
| | | ts_bool bond_list_free(ts_bond_list *blist){ |