Changeset 13330


Ignore:
Timestamp:
09/11/12 15:01:24 (13 years ago)
Author:
Mathieu Morlighem
Message:

NEW: added python support for ContourToMesh (had to remove structs as arguments

Location:
issm/trunk-jpl/src/modules
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/modules/ContourToMesh/ContourToMesh.cpp

    r13236 r13330  
    2929WRAPPER(ContourToMesh){
    3030
    31         int i,j;
    32 
    3331        /* required input: */
    34         int     edgevalue;
    35         double *index      = NULL;
    36         int     nel;
    37         double *x          = NULL;
    38         int     nods;
    39         double *y          = NULL;
    40         char   *interptype = NULL;
    41         char* contourname = NULL;
    42         DataSet* contours  = NULL;
     32        int      edgevalue;
     33        double  *index       = NULL;
     34        int      nel;
     35        double  *x           = NULL;
     36        int      nods;
     37        double  *y           = NULL;
     38        char    *interptype = NULL;
     39        char    *contourname = NULL;
     40        DataSet *contours    = NULL;
    4341
    4442        /* output: */
     
    9189        /*end module: */
    9290        MODULEEND();
    93        
    9491}
  • issm/trunk-jpl/src/modules/ContourToNodes/ContourToNodes.cpp

    r13236 r13330  
    1111        _printLine_("      x,y: list of nodes.");
    1212        _printLine_("      contourname: name of .exp file containing the contours, or resulting structure from call to expread.");
    13         _printLine_("      interptype: string definining type of interpolation ('element', or 'node').");
    1413        _printLine_("      edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons.");
    1514        _printLine_("      flags: vector of flags (0 or 1), of size nods.");
     
    1817WRAPPER(ContourToNodes){
    1918
    20         int i,j;
    21 
    22         /* required input: */
    23         int     edgevalue;
    24         double *x          = NULL;
    25         double *y          = NULL;
    26         char   *interptype = NULL;
     19        /* input: */
     20        int      edgevalue,nods;
     21        double  *x           = NULL;
     22        double  *y           = NULL;
     23        char    *contourname = NULL;
     24        DataSet *contours    = NULL;
    2725
    2826        /* output: */
    2927        SeqVec<double> *flags = NULL;
    30         int  nods;
    31 
    32         /*contours*/
    33         int numcontours;
    34         mxArray         *matlabstructure = NULL;
    35         Contour<double> **contours       = NULL;
    36         Contour<double> *contouri        = NULL;
    3728
    3829        /*Boot module: */
     
    4031
    4132        /*checks on arguments on the matlab side: */
    42         CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&ContourToNodesUsage);
     33        CHECKARGUMENTS(NLHS,NRHS,&ContourToNodesUsage);
    4334       
    4435        /*Fetch inputs: */
     
    4637        FetchData(&y,NULL,NULL,YHANDLE);
    4738        FetchData(&edgevalue,EDGEVALUEHANDLE);
     39        FetchData(&contourname,CONTOURNAME);
     40        contours=DomainOutlineRead<double>(contourname);
    4841
    49         /*Fetch contours*/
    50         if(mxIsChar(FILENAME)){
    51                 /*Call expread on filename to build a contour array in the matlab workspace: */
    52                 mexCallMATLAB(1,&matlabstructure,1,(mxArray**)&FILENAME,"expread");
    53         }
    54         else{
    55                 /*FILENAME is actually a structure, coming directly from expread: */
    56                 matlabstructure=(mxArray*)FILENAME;
    57         }
    58 
    59         numcontours=mxGetNumberOfElements(matlabstructure);
    60         contours=xNew<Contour<double>*>(numcontours);
    61         for(i=0;i<numcontours;i++){
    62                 //allocate
    63                 contouri=xNew<Contour<double> >(1);
    64                 //retrieve dimension of this contour.
    65                 contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods"));
    66                 //set pointers.
    67                 contouri->x=mxGetPr(mxGetField(matlabstructure,i,"x"));
    68                 contouri->y=mxGetPr(mxGetField(matlabstructure,i,"y"));
    69                 *(contours+i)=contouri;
    70         }
    71 
    72         /*Run interpolation routine: */
    73         ContourToNodesx(&flags,x,y,nods,contours,numcontours,edgevalue);
     42        /*Run x layer */
     43        ContourToNodesx(&flags,x,y,nods,contours,edgevalue);
    7444
    7545        /* output: */
  • issm/trunk-jpl/src/modules/ContourToNodes/ContourToNodes.h

    r13236 r13330  
    3030#define XHANDLE         prhs[0]
    3131#define YHANDLE         prhs[1]
    32 #define FILENAME        prhs[2]
     32#define CONTOURNAME     prhs[2]
    3333#define EDGEVALUEHANDLE prhs[3]
    3434
     
    4141#define XHANDLE         PyTuple_GetItem(args,0)
    4242#define YHANDLE         PyTuple_GetItem(args,1)
    43 #define FILENAME        PyTuple_GetItem(args,2)
     43#define CONTOURNAME     PyTuple_GetItem(args,2)
    4444#define EDGEVALUEHANDLE PyTuple_GetItem(args,3)
    4545
  • issm/trunk-jpl/src/modules/python/Makefile.am

    r13287 r13330  
    77lib_LTLIBRARIES = BamgConvertMesh.la\
    88                                                BamgMesher.la\
     9                                                ContourToNodes.la\
    910                                                ElementConnectivity.la\
    1011                                                EnumToString.la\
     
    6465BamgMesher_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
    6566
     67ContourToNodes_la_SOURCES = ../ContourToNodes/ContourToNodes.cpp\
     68                                                                         ../ContourToNodes/ContourToNodes.h
     69ContourToNodes_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB)
     70
    6671ElementConnectivity_la_SOURCES = ../ElementConnectivity/ElementConnectivity.cpp\
    6772                                                                                        ../ElementConnectivity/ElementConnectivity.h
Note: See TracChangeset for help on using the changeset viewer.