Changeset 14344
- Timestamp:
- 02/13/13 07:52:39 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/wrappers/ExpSimplify/ExpSimplify.cpp
r14342 r14344 13 13 _pprintLine_(" - expfile: name of the exp file"); 14 14 _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)"); 15 18 _pprintLine_(""); 16 19 _pprintLine_(" Example:"); 17 20 _pprintLine_(" ExpSimplify('file.exp',100);"); 21 _pprintLine_(" ExpSimplify('file.exp',100,'remove1',false);"); 18 22 }/*}}}*/ 19 23 void simplify(Contour<double>* contour,bool* flags,int ind0,int ind1,double tolerance){/*{{{*/ … … 93 97 char* expfile = NULL; 94 98 double tolerance; 99 bool remove1,remove2,save; 100 Options *options = NULL; 95 101 96 102 /*output*/ … … 102 108 103 109 /*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 } 105 114 106 115 /*Input datasets: */ 107 116 FetchData(&expfile, EXPFILE); 108 117 FetchData(&tolerance,TOLERANCE); 118 FetchData(&options,NRHS,nrhs,prhs); 109 119 110 120 /*some checks*/ … … 119 129 double* y = NULL; 120 130 double distance; 131 132 /*Process options*/ 133 options->Get(&remove1,"remove1",true); 134 options->Get(&remove2,"remove2",true); 121 135 122 136 /*Read old contours and allocate new contours*/ … … 165 179 newnods = 0; 166 180 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); 169 195 newcontour = xNew<Contour<double> >(1); 170 196 newcontour->nods = newnods; … … 184 210 newcontours->AddObject(newcontour); 185 211 } 212 else{ 213 printf(" New number of vertices in contour #%i: %i (not saved)\n",counter+1,newnods); 214 } 186 215 187 216 /*cleanup*/ … … 194 223 /*Clean-up*/ 195 224 xDelete<char>(expfile); 225 delete options; 196 226 197 227 /*end module: */
Note:
See TracChangeset
for help on using the changeset viewer.