Changeset 14341


Ignore:
Timestamp:
02/12/13 09:31:32 (12 years ago)
Author:
Mathieu Morlighem
Message:

BUG: fixed some crashes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/wrappers/ExpSimplify/ExpSimplify.cpp

    r14340 r14341  
    3737
    3838                /*calculate the shortest distance of all vertices between ind0 and ind1*/
    39                 for(int i=ind0;i<ind1;i++){
    40                         distance = sqrt((x[i]-x[i+1])*(x[i]-x[i+1]) + (y[i]-y[i+1])*(y[i]-y[i+1]));
     39                for(int i=ind0;i<ind1-1;i++){
     40                        distance = sqrt((x[ind0]-x[i+1])*(x[ind0]-x[i+1]) + (y[ind0]-y[i+1])*(y[ind0]-y[i+1]));
    4141                        if(i==ind0 || distance>maxdistance){
    4242                                maxdistance=distance;
    43                                 index = i;
     43                                index = i + 1;
    4444                        }
    4545                }
     
    5454                 *
    5555                 * So: beta = <x-x0,xend-x0>/<xend-x0,xend-x0>  */
    56                  
    57                 for(int i=ind0+1;i<ind1;i++){
     56
     57                for(int i=ind0+1;i<=ind1;i++){
    5858                        beta = ((x[i]-x[ind0])*(x[ind1]-x[ind0]) + (y[i]-y[ind0])*(y[ind1]-y[ind0]))/((x[ind1]-x[ind0])*(x[ind1]-x[ind0])+(y[ind1]-y[ind0])*(y[ind1]-y[ind0]));
    5959                        dx   = x[i]-beta*x[ind1]+(beta-1.)*x[ind0];
     
    7878                 * (index and ind1)*/
    7979                _assert_(index!=-1);
     80                _assert_(index!=ind1);
     81                _assert_(index!=ind0);
    8082                simplify(contour,flags,ind0 ,index,tolerance);
    8183                simplify(contour,flags,index,ind1, tolerance);
     
    157159                        /*Start recursive call to simplify*/
    158160                        for(int i=0;i<nods;i++) flags[i]=true;
     161                        printf("-------------- file: ExpSimplify.cpp line: %i\n",__LINE__);
    159162                        simplify(contour,flags,0,nods-1,tolerance);
    160163                }
Note: See TracChangeset for help on using the changeset viewer.