Ejemplo n.º 1
0
Archivo: mmgs1.c Proyecto: XL64/mmg
/* attempt to collapse small edges */
static int colelt(pMesh mesh,pSol met,char typchk) {
    pTria    pt;
    pPoint   p1,p2;
    double   ll,ux,uy,uz;
    int      ier,list[LMAX+2],ilist,k,nc;
    char     i,i1,i2;

    nc = 0;
    for (k=1; k<=mesh->nt; k++) {
        pt = &mesh->tria[k];
        if ( !MS_EOK(pt) || pt->ref < 0 )   continue;

        /* check edge length */
        pt->flag = 0;
        ier = 0;
        for (i=0; i<3; i++) {
            if ( MS_SIN(pt->tag[i]) )  continue;

            i1 = inxt[i];
            i2 = iprv[i];
            p1 = &mesh->point[pt->v[i1]];
            p2 = &mesh->point[pt->v[i2]];
            if ( p1->tag & MS_NOM || p2->tag & MS_NOM )  continue;
            else if ( MS_SIN(p1->tag) )   continue;
            else if ( p1->tag > p2->tag || p1->tag > pt->tag[i] )  continue;

            /* check length */
            if ( typchk == 1 ) {
                ux = p2->c[0] - p1->c[0];
                uy = p2->c[1] - p1->c[1];
                uz = p2->c[2] - p1->c[2];
                ll = ux*ux + uy*uy + uz*uz;
                if ( ll > info.hmin*info.hmin )  continue;
            }
            else {
                ll = lenedg(mesh,met,pt->v[i1],pt->v[i2],0);
                if ( ll > LSHRT )  continue;
            }

            /* check if geometry preserved */
            ilist = chkcol(mesh,met,k,i,list,typchk);
            if ( ilist > 3 ) {
                nc += colver(mesh,list,ilist);
                break;
            }
            else if ( ilist == 3 ) {
                nc += colver3(mesh,list);
                break;
            }
            else if ( ilist == 2 ) {
                nc += colver2(mesh,list);
                break;
            }
        }
    }
    if ( nc > 0 && (abs(info.imprim) > 5 || info.ddebug) )
        fprintf(stdout,"     %8d vertices removed\n",nc);

    return(nc);
}
Ejemplo n.º 2
0
int clrcols()
{
    int i, n = 0;
    for (i=0; i<brd.height; i++) {
        if (chkcol(i)) {
            clrcol(i);
            shift(i);
            n++;
        }
    }
    return n;
}
Ejemplo n.º 3
0
Archivo: mmgs1.c Proyecto: XL64/mmg
/* analyze triangles and split or collapse to match gradation */
static int adpcol(pMesh mesh,pSol met) {
    pTria    pt;
    pPoint   p1,p2;
    double   len;
    int      k,list[LMAX+2],ilist,nc;
    char     i,i1,i2;

    nc = 0;
    for (k=1; k<=mesh->nt; k++) {
        pt = &mesh->tria[k];
        if ( !MS_EOK(pt) || pt->ref < 0 )   continue;

        /* check edge length */
        pt->flag = 0;
        for (i=0; i<3; i++) {
            if ( MS_SIN(pt->tag[i]) )  continue;

            /* check length */
            i1 = inxt[i];
            i2 = iprv[i];
            p1 = &mesh->point[pt->v[i1]];
            p2 = &mesh->point[pt->v[i2]];
            if ( p1->tag & MS_NOM || p2->tag & MS_NOM )  continue;

            len = lenedg(mesh,met,pt->v[i1],pt->v[i2],0);
            if ( len > LOPTS )  continue;

            p1 = &mesh->point[pt->v[i1]];
            p2 = &mesh->point[pt->v[i2]];
            if ( MS_SIN(p1->tag) )  continue;
            else if ( p1->tag > p2->tag || p1->tag > pt->tag[i] )  continue;

            /* check if geometry preserved */
            ilist = chkcol(mesh,met,k,i,list,2);
            if ( ilist > 3 ) {
                nc += colver(mesh,list,ilist);
                break;
            }
            else if ( ilist == 3 ) {
                nc += colver3(mesh,list);
                break;
            }
            else if ( ilist == 2 ) {
                nc += colver2(mesh,list);
                break;
            }
        }
    }
    return(nc);
}