/** * BME_inset_poly * * Face Inset Tool: * * Insets a single face and returns a pointer to the face at the * center of the newly created region * * Returns - * A BME_Poly pointer. */ BME_Poly *BME_inset_poly(BME_Mesh *bm,BME_Poly *f){ BME_Vert *v, *killvert; BME_Edge *killedge; BME_Loop *l,*nextloop, *newloop, *killoop; int done,len,i; float cent[3]; //center of original face /*inset each edge in the polygon.*/ len = f->len; for(i=0,l=f->loopbase; i < len; i++){ nextloop = l->next; BME_SFME(bm,f,l->v,l->next->v,NULL); l = nextloop; } /*for each new edge, call SEMV twice on it*/ for(i=0,l=f->loopbase; i < len; i++, l=l->next){ l->tflag1 = 1; //going to store info that this loops edge still needs split l->tflag2 = l->v->tflag1 = l->v->tflag2 = 0; } /*Split each edge in the face twice*/ len = f->len; for(i=0,l=f->loopbase; i < len; i++){ if(l->tflag1){ l->tflag1 = 0; v = BME_SEMV(bm, l->next->v, l->e, NULL); l->e->tflag2 = 1; //mark for kill with JFKE v->tflag2 = 1; //mark for kill with JEKV v->tflag1 = 1; v = BME_SEMV(bm, l->next->v, l->e, NULL); v->tflag1 = 1; l= l->next->next->next;//skip over the loops we have created } } /*now link these new points of up via SFME*/ len = f->len; for(i=0,l=f->loopbase; i < len; i++){ if(l->v->tflag1){ l->v->tflag1 = l->next->next->v->tflag1 = 0; nextloop = l->next->next->next; killoop = l->next; killvert = l->v; BME_SFME(bm,f,l->v,l->next->next->v,&newloop); killedge = newloop->e; i+=2; //increment counter since we have removed some edges from the face during split. l = nextloop; /*while we are here, we can kill killoop with JFKE*/ BME_JFKE(bm,killoop->f,killoop->radial.next->data,killoop->e); /*and for good measure, get rid of */ BME_JEKV(bm,killedge,killvert); } } return NULL; }