Changeset 5019


Ignore:
Timestamp:
08/06/10 11:41:13 (15 years ago)
Author:
Eric.Larour
Message:

Replaced contours structure input with filename

Location:
issm/trunk/src/mex
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/mex/ContourToMesh/ContourToMesh.cpp

    r3755 r5019  
    4444
    4545        //contours
     46        mxArray*  matlabstructure=NULL;
    4647        int numcontours;
    4748        Contour** contours=NULL;
     
    5859        }
    5960
     61        /*First, call expread on filename to build a contour array in the matlab workspace: */
     62        mexCallMATLAB( 1, &matlabstructure, 1, (mxArray**)&FILENAME, "expread");
     63
    6064        /*Fetch inputs: */
    6165        FetchData(&index,&nel,NULL,INDEXHANDLE);
     
    6468        FetchData(&edgevalue,EDGEVALUEHANDLE);
    6569
    66         /*Recover list of contours from the 'contours' structure: */
    67         //number of contours;
    68         numcontours=mxGetNumberOfElements(CONTOURSHANDLE);
    69         //allocate array:
     70        //Fetch contours
     71        numcontours=mxGetNumberOfElements(matlabstructure);
    7072        contours=(Contour**)xmalloc(numcontours*sizeof(Contour*));
    71 
    72         //go through contours, and populate xcontours and ycontours accordingly.
    7373        for(i=0;i<numcontours;i++){
    7474                //allocate
    7575                contouri=(Contour*)xmalloc(sizeof(Contour));
    7676                //retrieve dimension of this contour.
    77                 contouri->nods=(int)mxGetScalar(mxGetField(CONTOURSHANDLE,i,"nods"));
     77                contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods"));
    7878                //set pointers.
    79                 contouri->x=mxGetPr(mxGetField(CONTOURSHANDLE,i,"x"));
    80                 contouri->y=mxGetPr(mxGetField(CONTOURSHANDLE,i,"y"));
     79                contouri->x=mxGetPr(mxGetField(matlabstructure,i,"x"));
     80                contouri->y=mxGetPr(mxGetField(matlabstructure,i,"y"));
    8181                *(contours+i)=contouri;
    8282        }
    8383
    84         /*
    85         for(i=0;i<numcontours;i++){
     84        /*Fetch  interptype: */
     85        FetchData(&interptype,INTERPTYPEHANDLE);
     86
     87        /* Debugging of contours :{{{1*/
     88        /*for(i=0;i<numcontours;i++){
    8689                printf("\nContour echo: contour number  %i / %i\n",i+1,numcontours);
    8790                contouri=*(contours+i);
     
    9093                        printf("   %lf %lf\n",*(contouri->x+j),*(contouri->y+j));
    9194                }
    92         }
    93         */
    94 
    95         /*Recover  interptype: */
    96         FetchData(&interptype,INTERPTYPEHANDLE);
     95        }*/
     96        /*}}}*/
    9797
    9898        /*Run interpolation routine: */
     
    122122        printf("\n");
    123123        printf("      Usage: \n");
    124         printf("         [in_nod,in_elem]=ContourToMesh(index,x,y,contours,interptype,edgevalue)\n\n");
     124        printf("         [in_nod,in_elem]=ContourToMesh(index,x,y,contourname,interptype,edgevalue)\n\n");
    125125        printf("\n");
    126126        printf("         index,x,y: mesh triangulation.\n");
    127         printf("         contours: structure holding sets of vertices making open contours.\n");
     127        printf("         contourname: name of .exp file containing the contours.\n");
    128128        printf("         interptype: string definining type of interpolation ('element', or 'node').\n");
    129129        printf("         edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons.\n");
  • issm/trunk/src/mex/ContourToMesh/ContourToMesh.h

    r4236 r5019  
    2727#define XHANDLE prhs[1]
    2828#define YHANDLE prhs[2]
    29 #define CONTOURSHANDLE prhs[3]
     29#define FILENAME prhs[3]
    3030#define INTERPTYPEHANDLE prhs[4]
    3131#define EDGEVALUEHANDLE prhs[5]
  • issm/trunk/src/mex/ContourToNodes/ContourToNodes.cpp

    r3249 r5019  
    3939
    4040        //contours
     41        mxArray*  matlabstructure=NULL;
    4142        int numcontours;
    4243        Contour** contours=NULL;
     
    4950        CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&ContourToNodesUsage);
    5051
     52        /*First, call expread on filename to build a contour array in the matlab workspace: */
     53        mexCallMATLAB( 1, &matlabstructure, 1, (mxArray**)&FILENAME, "expread");
     54
    5155        /*Fetch inputs: */
    5256        FetchData(&x,&nods,NULL,XHANDLE);
     
    5458        FetchData(&edgevalue,EDGEVALUEHANDLE);
    5559
    56         /*Recover list of contours from the 'contours' structure: */
    57         //number of contours;
    58         numcontours=mxGetNumberOfElements(CONTOURSHANDLE);
    59         //allocate array:
     60        //Fetch contours
     61        numcontours=mxGetNumberOfElements(matlabstructure);
    6062        contours=(Contour**)xmalloc(numcontours*sizeof(Contour*));
    61 
    62         //go through contours, and populate xcontours and ycontours accordingly.
    6363        for(i=0;i<numcontours;i++){
    6464                //allocate
    6565                contouri=(Contour*)xmalloc(sizeof(Contour));
    6666                //retrieve dimension of this contour.
    67                 contouri->nods=(int)mxGetScalar(mxGetField(CONTOURSHANDLE,i,"nods"));
     67                contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods"));
    6868                //set pointers.
    69                 contouri->x=mxGetPr(mxGetField(CONTOURSHANDLE,i,"x"));
    70                 contouri->y=mxGetPr(mxGetField(CONTOURSHANDLE,i,"y"));
     69                contouri->x=mxGetPr(mxGetField(matlabstructure,i,"x"));
     70                contouri->y=mxGetPr(mxGetField(matlabstructure,i,"y"));
    7171                *(contours+i)=contouri;
    7272        }
     73
     74        /* Debugging of contours :{{{1*/
     75        /*for(i=0;i<numcontours;i++){
     76                printf("\nContour echo: contour number  %i / %i\n",i+1,numcontours);
     77                contouri=*(contours+i);
     78                printf("   Number of grids %i\n",contouri->nods);
     79                for (j=0;j<contouri->nods;j++){
     80                        printf("   %lf %lf\n",*(contouri->x+j),*(contouri->y+j));
     81                }
     82        }*/
     83        /*}}}*/
    7384
    7485        /*Run interpolation routine: */
     
    8596void ContourToNodesUsage(void){
    8697        printf("   usage:\n");
    87         printf("   [flags]=ContourToNodes(x,y,contours,edgevalue);\n\n");
     98        printf("   [flags]=ContourToNodes(x,y,contourname,edgevalue);\n\n");
    8899        printf("   where:\n");
    89100        printf("      x,y: list of nodes.\n");
    90         printf("      contours: structure holding sets of vertices making open contours.\n");
     101        printf("      contourname: name of .exp file containing the contours.\n");
    91102        printf("      interptype: string definining type of interpolation ('element', or 'node').\n");
    92103        printf("      edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons.\n");
  • issm/trunk/src/mex/ContourToNodes/ContourToNodes.h

    r4236 r5019  
    2626#define XHANDLE prhs[0]
    2727#define YHANDLE prhs[1]
    28 #define CONTOURSHANDLE prhs[2]
     28#define FILENAME prhs[2]
    2929#define EDGEVALUEHANDLE prhs[3]
    3030
  • issm/trunk/src/mex/InputToResult/InputToResult.cpp

    r4573 r5019  
    2121
    2222        /*checks on arguments on the matlab side: */
    23         //CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&ContourToMeshUsage); Cant' use it here, as we have variable inputs.
     23        //CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&InputToResultUsage); Cant' use it here, as we have variable inputs.
    2424        if((nlhs!=NLHS) || (nrhs!=7 && nrhs!=9)){
    2525                InputToResultUsage();
Note: See TracChangeset for help on using the changeset viewer.