Changeset 14344


Ignore:
Timestamp:
02/13/13 07:52:39 (12 years ago)
Author:
Mathieu Morlighem
Message:

New: added remove1 and remove2 options

File:
1 edited

Legend:

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

    r14342 r14344  
    1313        _pprintLine_("      - expfile: name of the exp file");
    1414        _pprintLine_("      - tol:  tolerance (maximal euclidean distance allowed between the new line and a vertex)");
     15        _pprintLine_("      Additional options:");
     16        _pprintLine_("      - 'remove1': remove singleton from exp file (default is true)");
     17        _pprintLine_("      - 'remove2': remove pairs from exp file (default is true)");
    1518        _pprintLine_("");
    1619        _pprintLine_("   Example:");
    1720        _pprintLine_("      ExpSimplify('file.exp',100);");
     21        _pprintLine_("      ExpSimplify('file.exp',100,'remove1',false);");
    1822}/*}}}*/
    1923void simplify(Contour<double>* contour,bool* flags,int ind0,int ind1,double tolerance){/*{{{*/
     
    9397        char*    expfile  = NULL;
    9498        double   tolerance;
     99        bool     remove1,remove2,save;
     100        Options *options      = NULL;
    95101
    96102        /*output*/
     
    102108
    103109        /*checks on arguments: */
    104         CHECKARGUMENTS(NLHS,NRHS,&ExpSimplifyUsage);
     110        /*checks on arguments on the matlab side: */
     111        if (nrhs<NRHS || nlhs>NLHS){
     112                ExpSimplifyUsage(); _error_("ExpSimplify usage error");
     113        }
    105114
    106115        /*Input datasets: */
    107116        FetchData(&expfile,  EXPFILE);
    108117        FetchData(&tolerance,TOLERANCE);
     118        FetchData(&options,NRHS,nrhs,prhs);
    109119
    110120        /*some checks*/
     
    119129        double* y = NULL;
    120130        double distance;
     131
     132        /*Process options*/
     133        options->Get(&remove1,"remove1",true);
     134        options->Get(&remove2,"remove2",true);
    121135
    122136        /*Read old contours and allocate new contours*/
     
    165179                newnods = 0;
    166180                for(int i=0;i<nods;i++) if(flags[i]) newnods++;
    167                 printf("   New     number of vertices in contour #%i: %i\n",counter+1,newnods);
    168                 if(newnods){
     181
     182                /*Do we save new profile?*/
     183                save = true;
     184                if(newnods==0){
     185                        save = false;
     186                }
     187                else if(remove1 && newnods==1){
     188                        save = false;
     189                }
     190                else if(remove2 && newnods==2){
     191                        save = false;
     192                }
     193                if(save){
     194                        printf("   New     number of vertices in contour #%i: %i\n",counter+1,newnods);
    169195                        newcontour       = xNew<Contour<double> >(1);
    170196                        newcontour->nods = newnods;
     
    184210                        newcontours->AddObject(newcontour);
    185211                }
     212                else{
     213                        printf("   New     number of vertices in contour #%i: %i (not saved)\n",counter+1,newnods);
     214                }
    186215
    187216                /*cleanup*/
     
    194223        /*Clean-up*/
    195224        xDelete<char>(expfile);
     225        delete options;
    196226
    197227        /*end module: */
Note: See TracChangeset for help on using the changeset viewer.