Changeset 15396 for issm/trunk/src/c/shared/Exp/exp.h
- Timestamp:
- 07/02/13 09:24:16 (12 years ago)
- Location:
- issm/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk
- Property svn:ignore
-
old new 1 par 2 ad 3 proj-* 1 4 projects 2 5 autom4te.cache
-
- Property svn:mergeinfo changed
/issm/trunk-jpl merged: 14311,14313,14316-14506,14508-15387,15390-15392
- Property svn:ignore
-
issm/trunk/src
- Property svn:mergeinfo changed
-
issm/trunk/src/c/shared/Exp/exp.h
r14310 r15396 7 7 8 8 #include <cstring> 9 #include "../ ../classes/objects/Contour.h"10 #include "../ ../shared/Numerics/recast.h"11 #include "../ ../Container/Container.h"9 #include "../Numerics/recast.h" 10 #include "../Exceptions/exceptions.h" 11 #include "../MemOps/MemOps.h" 12 12 13 13 int IsInPolySerial(double* in,double* xc,double* yc,int numvertices,double* x,double* y,int nods, int edgevalue); 14 14 int ExpWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,char* domainname); 15 int ExpWrite(DataSet* contours,char* domainname);16 15 int pnpoly(int npol, double *xp, double *yp, double x, double y, int edgevalue); 17 16 18 /*IsInPoly {{{*/ 19 template <class doubletype> 20 int IsInPoly(SeqVec<doubletype>* in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue){ 17 template <class doubletype> int IsInPoly(doubletype* in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue){ /*{{{*/ 21 18 22 19 int i; … … 40 37 41 38 //Get current value of value[i] -> do not change it if != 0 42 in->GetValue(&value,i);39 value=in[i]; 43 40 if (reCast<bool,doubletype>(value)){ 44 41 /*this vertex already is inside one of the contours, continue*/ … … 54 51 value=pnpoly(numvertices,xc,yc,x0,y0,edgevalue); 55 52 } 56 in ->SetValue(i,value,INS_VAL);53 in[i]=value; 57 54 } 58 55 return 1; 59 56 }/*}}}*/ 60 /*DomainOutlineRead{{{*/ 61 template <class doubletype> 62 int DomainOutlineRead(int* pnprof,int** pprofnvertices,doubletype*** ppprofx,doubletype*** ppprofy,bool** pclosed,char* domainname){ 57 template <class doubletype> int ExpRead(int* pnprof,int** pprofnvertices,doubletype*** ppprofx,doubletype*** ppprofy,bool** pclosed,char* domainname){ /*{{{*/ 63 58 64 59 /*indexing: */ … … 91 86 nprof=1; 92 87 for(;;){ 93 fscanf(fid,"%255s %255s\n",chardummy,chardummy); 94 fscanf(fid,"%255s %255s\n",chardummy,chardummy); 95 fscanf(fid,"%255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy); 96 fscanf(fid,"%20u %255s\n",&n,chardummy); 97 fscanf(fid,"%255s %255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy,chardummy); 98 for (i=0;i<n;i++) fscanf(fid,"%20lf %20lf\n",&ddummy,&ddummy); 88 //## Name:filename 89 if(fscanf(fid,"%255s %255s\n",chardummy,chardummy)!=2) _error_("Could not read " << domainname); 90 //## Icon:0 91 if(fscanf(fid,"%255s %255s\n",chardummy,chardummy)!=2) _error_("Could not read " << domainname); 92 //# Points Count Value 93 if(fscanf(fid,"%255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy)!=4) _error_("Could not read " << domainname); 94 if(fscanf(fid,"%20u %255s\n",&n,chardummy)!=2) _error_("Could not read number of points in "<<domainname); 95 //# X pos Y pos 96 if(fscanf(fid,"%255s %255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy,chardummy)!=5) _error_("Could not read " << domainname); 97 for (i=0;i<n;i++){ 98 if(fscanf(fid,"%20lf %20lf\n",&ddummy,&ddummy)!=2){ 99 _error_("Could not read coordinate of vertex "<< i <<" of "<<domainname); 100 } 101 } 99 102 /*check whether we are at the end of the file, otherwise, keep reading next profile:*/ 100 if 103 if(feof(fid)) break; 101 104 nprof++; 102 105 } … … 119 122 120 123 /*Skip header: */ 121 fscanf(fid,"%255s %255s\n",chardummy,chardummy); 122 fscanf(fid,"%255s %255s\n",chardummy,chardummy); 123 fscanf(fid,"%255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy); 124 //## Name:filename 125 if(fscanf(fid,"%255s %255s\n",chardummy,chardummy)!=2) _error_("Could not read " << domainname); 126 //## Icon:0 127 if(fscanf(fid,"%255s %255s\n",chardummy,chardummy)!=2) _error_("Could not read " << domainname); 128 //# Points Count Value 129 if(fscanf(fid,"%255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy)!=4) _error_("Could not read " << domainname); 124 130 125 131 /*Get number of profile vertices: */ 126 fscanf(fid,"%20u %255s\n",&n,chardummy);132 if(fscanf(fid,"%20u %255s\n",&n,chardummy)!=2) _error_("Could not read number of points in "<<domainname); 127 133 128 134 /*Skip next line: */ 129 fscanf(fid,"%255s %255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy,chardummy); 135 //# X pos Y pos 136 if(fscanf(fid,"%255s %255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy,chardummy)!=5) _error_("Could not read " << domainname); 130 137 131 138 /*Allocate vertices: */ … … 135 142 /*Read vertices: */ 136 143 for (i=0;i<n;i++){ 137 fscanf(fid,"%20lf %20lf\n",&x[i],&y[i]); 144 if(fscanf(fid,"%20lf %20lf\n",&x[i],&y[i])!=2){ 145 _error_("Could not read coordinate of vertex "<<i<<" of "<<domainname); 146 } 138 147 } 139 148 … … 161 170 if(pclosed) *pclosed=closed; 162 171 else xDelete<bool>(closed); 163 } /*}}}*/ 164 /*DataSet* DomainOutlineRead(char* domainname){{{*/ 165 template <class doubletype> 166 DataSet* DomainOutlineRead(char* domainname){ 172 return 1; 167 173 168 /*intermediary: */169 int nprof;170 int *profnvertices = NULL;171 doubletype **pprofx = NULL;172 doubletype **pprofy = NULL;173 174 /*output: */175 DataSet *domain = NULL;176 177 /*If domainname is an empty string, return empty dataset*/178 if (strcmp(domainname,"")==0){179 nprof=0;180 }181 else{182 DomainOutlineRead(&nprof,&profnvertices,&pprofx, &pprofy, NULL,domainname);183 }184 185 /*now create dataset of contours: */186 domain=new DataSet(0);187 188 for(int i=0;i<nprof;i++){189 domain->AddObject(new Contour<doubletype>(i,profnvertices[i],pprofx[i],pprofy[i],1));190 }191 return domain;192 174 } /*}}}*/ 193 175
Note:
See TracChangeset
for help on using the changeset viewer.