Changeset 12127
- Timestamp:
- 04/25/12 09:36:49 (13 years ago)
- Location:
- issm/trunk-jpl/src
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/modules/ContourToMeshx/ContourToMeshx.cpp
r11695 r12127 11 11 #include "./ContourToMeshx.h" 12 12 13 int ContourToMeshx( Vector** pin_nod,Vector** pin_elem, double* index, double* x, double* y, Contour** contours,int numcontours,char* interptype,int nel,int nods, int edgevalue) {13 int ContourToMeshx( Vector** pin_nod,Vector** pin_elem, double* index, double* x, double* y,DataSet* contours,char* interptype,int nel,int nods, int edgevalue) { 14 14 15 15 int noerr=1; … … 37 37 38 38 /*initialize thread parameters: */ 39 gate.numcontours=numcontours;40 39 gate.contours=contours; 41 40 gate.nods=nods; -
issm/trunk-jpl/src/c/modules/ContourToMeshx/ContourToMeshx.h
r11695 r12127 13 13 typedef struct{ 14 14 15 int numcontours; 16 Contour** contours; 15 DataSet* contours; 17 16 int nods; 18 17 int edgevalue; … … 25 24 26 25 /* local prototypes: */ 27 int ContourToMeshx( Vector** pin_nods,Vector** pin_elem, double* index, double* x, double* y, Contour** contours,int numcontours,char* interptype,int nel,int nods, int edgevalue);26 int ContourToMeshx( Vector** pin_nods,Vector** pin_elem, double* index, double* x, double* y,DataSet* contours,char* interptype,int nel,int nods, int edgevalue); 28 27 29 28 void* ContourToMeshxt(void* vContourToMeshxThreadStruct); -
issm/trunk-jpl/src/c/modules/ContourToMeshx/ContourToMeshxt.cpp
r11695 r12127 26 26 27 27 /*Contour:*/ 28 Contour* contouri=NULL; 29 int numnodes; 30 double* xc=NULL; 31 double* yc=NULL; 32 28 DataSet* contours=NULL; 33 29 34 30 /*parameters: */ 35 int numcontours;36 Contour** contours=NULL;37 31 int nods; 38 32 int edgevalue; … … 49 43 50 44 /*recover parameters :*/ 51 numcontours=gate->numcontours;52 45 contours=gate->contours; 53 46 nods=gate->nods; … … 61 54 62 55 /*Loop through all contours: */ 63 for (i=0;i<numcontours;i++){ 64 contouri=*(contours+i); 65 numnodes=contouri->nods; 66 xc=contouri->x; 67 yc=contouri->y; 68 IsInPoly(in_nod,xc,yc,numnodes,x,y,i0,i1,edgevalue); 56 for (i=0;i<contours->Size();i++){ 57 Contour* contour=(Contour*)contours->GetObjectByOffset(i); 58 IsInPoly(in_nod,contour->x,contour->y,contour->nods,x,y,i0,i1,edgevalue); 69 59 } 70 60 -
issm/trunk-jpl/src/modules/ContourToMesh/ContourToMesh.cpp
r12060 r12127 21 21 #include "./ContourToMesh.h" 22 22 23 void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){23 WRAPPER(ContourToMesh){ 24 24 25 25 int i,j; … … 28 28 int edgevalue; 29 29 double *index = NULL; 30 int nel; 30 31 double *x = NULL; 32 int nods; 31 33 double *y = NULL; 32 34 char *interptype = NULL; 35 char* contourname = NULL; 36 DataSet* contours = NULL; 33 37 34 38 /* output: */ 35 39 Vector *in_nod = NULL; 36 int nods;37 40 Vector *in_elem = NULL; 38 int nel;39 40 //contours41 mxArray *matlabstructure = NULL;42 int numcontours;43 Contour **contours = NULL;44 Contour *contouri = NULL;45 41 46 42 /*Boot module: */ 47 43 MODULEBOOT(); 48 44 49 /*checks on arguments on the matlab side: */ 50 //CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&ContourToMeshUsage); Cant' use it here, as we have variable outputs. 51 if((nlhs!=1 && nlhs!=2) || (nrhs!=NRHS)){ 45 /*checks on output arguments on the matlab side: */ 46 #ifdef _HAVE_MATLAB_MODULES_ 47 if(nlhs!=1 && nlhs!=2){ 48 ContourToMeshUsage(); 49 _error_(" usage. See above"); 50 } 51 #endif 52 /*check on input arguments: */ 53 if(nrhs!=NRHS){ 52 54 ContourToMeshUsage(); 53 55 _error_(" usage. See above"); 54 56 } 55 57 56 /*First, call expread on filename to build a contour array in the matlab workspace: */57 mexCallMATLAB( 1, &matlabstructure, 1, (mxArray**)&FILENAME, "expread");58 58 59 59 /*Fetch inputs: */ 60 FetchData(&index,&nel,NULL,INDEXHANDLE); 61 FetchData(&x,&nods,NULL,XHANDLE); 62 FetchData(&y,NULL,NULL,YHANDLE); 63 FetchData(&edgevalue,EDGEVALUEHANDLE); 64 65 //Fetch contours 66 numcontours=mxGetNumberOfElements(matlabstructure); 67 contours=(Contour**)xmalloc(numcontours*sizeof(Contour*)); 68 for(i=0;i<numcontours;i++){ 69 //allocate 70 contouri=(Contour*)xmalloc(sizeof(Contour)); 71 //retrieve dimension of this contour. 72 contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods")); 73 //set pointers. 74 contouri->x=mxGetPr(mxGetField(matlabstructure,i,"x")); 75 contouri->y=mxGetPr(mxGetField(matlabstructure,i,"y")); 76 *(contours+i)=contouri; 77 } 60 FetchData(&index,&nel,NULL,INDEX); 61 FetchData(&x,&nods,NULL,X); 62 FetchData(&y,NULL,NULL,Y); 63 FetchData(&edgevalue,EDGEVALUE); 64 FetchData(&contourname,CONTOURNAME); 65 contours=DomainOutlineRead(contourname); 78 66 79 67 /*Fetch interptype: */ 80 FetchData(&interptype,INTERPTYPEHANDLE); 81 82 /* Debugging of contours :{{{1*/ 83 /*for(i=0;i<numcontours;i++){ 84 printf("\nContour echo: contour number %i / %i\n",i+1,numcontours); 85 contouri=*(contours+i); 86 printf(" Number of vertices %i\n",contouri->nods); 87 for (j=0;j<contouri->nods;j++){ 88 printf(" %lf %lf\n",*(contouri->x+j),*(contouri->y+j)); 89 } 90 }*/ 91 /*}}}*/ 68 FetchData(&interptype,INTERPTYPE); 92 69 93 70 /*Run interpolation routine: */ 94 ContourToMeshx( &in_nod,&in_elem,index,x,y,contours, numcontours,interptype,nel,nods,edgevalue);71 ContourToMeshx( &in_nod,&in_elem,index,x,y,contours,interptype,nel,nods,edgevalue); 95 72 96 73 /* output: */ … … 112 89 } 113 90 114 void ContourToMeshUsage(void) 91 void ContourToMeshUsage(void)//{{{1 115 92 { 116 93 printf("CONTOURTOMESH - Flag the elements or nodes inside a contour\n"); … … 134 111 printf("\n"); 135 112 } 113 //}}} -
issm/trunk-jpl/src/modules/ContourToMesh/ContourToMesh.h
r12013 r12127 8 8 #define _CONTOURTOMESH_H 9 9 10 /* local prototypes: */11 void ContourToMeshUsage(void);12 10 11 #ifdef HAVE_CONFIG_H 12 #include <config.h> 13 #else 14 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 15 #endif 16 17 /*Very important definition in case we are compiling a python module!: needs to come before header files inclusion*/ 18 #ifdef _HAVE_PYTHON_ 19 #define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol 20 #endif 21 22 /*Header files: */ 13 23 #include "../../c/include/globals.h" 24 #include "../../c/toolkits/toolkits.h" 25 #include "../../c/include/include.h" 14 26 #include "../../c/modules/modules.h" 15 27 #include "../../c/Container/Container.h" 16 28 #include "../../c/shared/shared.h" 17 29 #include "../../c/issm-binding.h" 30 #include "../../c/io/io.h" 31 #include "../../c/EnumDefinitions/EnumDefinitions.h" 32 33 #ifdef _HAVE_MATLAB_MODULES_ 34 /* serial input macros: */ 35 #define INDEX (mxArray *)prhs[0] 36 #define X (mxArray *)prhs[1] 37 #define Y (mxArray *)prhs[2] 38 #define CONTOURNAME (mxArray *)prhs[3] 39 #define INTERPTYPE (mxArray *)prhs[4] 40 #define EDGEVALUE (mxArray *)prhs[5] 41 /* serial output macros: */ 42 #define PLHS0 (mxArray**)&plhs[0] 43 #define PLHS1 (mxArray**)&plhs[1] 44 #endif 45 46 #ifdef _HAVE_PYTHON_MODULES_ 47 /* serial input macros: */ 48 #define INDEX PyTuple_GetItem(args,0) 49 #define X PyTuple_GetItem(args,1) 50 #define Y PyTuple_GetItem(args,2) 51 #define CONTOURNAME PyTuple_GetItem(args,3) 52 #define INTERPTYPE PyTuple_GetItem(args,4) 53 #define EDGEVALUE PyTuple_GetItem(args,5) 54 /* serial output macros: */ 55 #define PLHS0 output,0 56 #define PLHS1 output,1 57 #endif 18 58 19 59 #undef __FUNCT__ 20 60 #define __FUNCT__ "ContourToMesh" 21 22 23 #ifndef ALL24 #define ALL 025 #endif26 27 /* input macros: */28 #define INDEXHANDLE prhs[0]29 #define XHANDLE prhs[1]30 #define YHANDLE prhs[2]31 #define FILENAME prhs[3]32 #define INTERPTYPEHANDLE prhs[4]33 #define EDGEVALUEHANDLE prhs[5]34 35 /* serial output macros: */36 #define PLHS0 (mxArray**)&plhs[0]37 #define PLHS1 (mxArray**)&plhs[1]38 61 39 62 /* serial arg counts: */ … … 43 66 #define NRHS 6 44 67 68 /* local prototypes: */ 69 void ContourToMeshUsage(void); 45 70 46 71 #endif /* _CONTOURTOMESH_H */
Note:
See TracChangeset
for help on using the changeset viewer.