Changeset 12127


Ignore:
Timestamp:
04/25/12 09:36:49 (13 years ago)
Author:
Eric.Larour
Message:

Starting conversion of SetIceShelfBC
Needs ContourToMesh python module, so converted this module to python interface.
Also simplified Contours* treatment.

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  
    1111#include "./ContourToMeshx.h"
    1212
    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) {
     13int ContourToMeshx( Vector** pin_nod,Vector** pin_elem, double* index, double* x, double* y,DataSet* contours,char* interptype,int nel,int nods, int edgevalue) {
    1414
    1515        int noerr=1;
     
    3737
    3838        /*initialize thread parameters: */
    39         gate.numcontours=numcontours;
    4039        gate.contours=contours;
    4140        gate.nods=nods;
  • issm/trunk-jpl/src/c/modules/ContourToMeshx/ContourToMeshx.h

    r11695 r12127  
    1313typedef struct{
    1414
    15         int numcontours;
    16         Contour** contours;
     15        DataSet* contours;
    1716        int nods;
    1817        int edgevalue;
     
    2524
    2625/* 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);
     26int ContourToMeshx( Vector** pin_nods,Vector** pin_elem, double* index, double* x, double* y,DataSet* contours,char* interptype,int nel,int nods, int edgevalue);
    2827
    2928void* ContourToMeshxt(void* vContourToMeshxThreadStruct);
  • issm/trunk-jpl/src/c/modules/ContourToMeshx/ContourToMeshxt.cpp

    r11695 r12127  
    2626
    2727        /*Contour:*/
    28         Contour* contouri=NULL;
    29         int      numnodes;
    30         double*  xc=NULL;
    31         double*  yc=NULL;
    32 
     28        DataSet* contours=NULL;
    3329
    3430        /*parameters: */
    35         int numcontours;
    36         Contour** contours=NULL;
    3731        int nods;
    3832        int edgevalue;
     
    4943
    5044        /*recover parameters :*/
    51         numcontours=gate->numcontours;
    5245        contours=gate->contours;
    5346        nods=gate->nods;
     
    6154
    6255        /*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);
    6959        }
    7060
  • issm/trunk-jpl/src/modules/ContourToMesh/ContourToMesh.cpp

    r12060 r12127  
    2121#include "./ContourToMesh.h"
    2222
    23 void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) {
     23WRAPPER(ContourToMesh){
    2424
    2525        int i,j;
     
    2828        int     edgevalue;
    2929        double *index      = NULL;
     30        int     nel;
    3031        double *x          = NULL;
     32        int     nods;
    3133        double *y          = NULL;
    3234        char   *interptype = NULL;
     35        char* contourname  = NULL;
     36        DataSet* contours  = NULL;
    3337
    3438        /* output: */
    3539        Vector *in_nod  = NULL;
    36         int     nods;
    3740        Vector *in_elem = NULL;
    38         int     nel;
    39 
    40         //contours
    41         mxArray  *matlabstructure = NULL;
    42         int       numcontours;
    43         Contour **contours        = NULL;
    44         Contour  *contouri        = NULL;
    4541
    4642        /*Boot module: */
    4743        MODULEBOOT();
    4844
    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){
    5254                ContourToMeshUsage();
    5355                _error_(" usage. See above");
    5456        }
    5557
    56         /*First, call expread on filename to build a contour array in the matlab workspace: */
    57         mexCallMATLAB( 1, &matlabstructure, 1, (mxArray**)&FILENAME, "expread");
    5858
    5959        /*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);
    7866
    7967        /*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);
    9269
    9370        /*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);
    9572
    9673        /* output: */
     
    11289}
    11390
    114 void ContourToMeshUsage(void)
     91void ContourToMeshUsage(void)//{{{1
    11592{
    11693        printf("CONTOURTOMESH - Flag the elements or nodes inside a contour\n");
     
    134111        printf("\n");
    135112}
     113//}}}
  • issm/trunk-jpl/src/modules/ContourToMesh/ContourToMesh.h

    r12013 r12127  
    88#define _CONTOURTOMESH_H
    99
    10 /* local prototypes: */
    11 void ContourToMeshUsage(void);
    1210
     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: */
    1323#include "../../c/include/globals.h"
     24#include "../../c/toolkits/toolkits.h"
     25#include "../../c/include/include.h"
    1426#include "../../c/modules/modules.h"
    1527#include "../../c/Container/Container.h"
    1628#include "../../c/shared/shared.h"
    1729#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
    1858
    1959#undef __FUNCT__
    2060#define __FUNCT__ "ContourToMesh"
    21 
    22 
    23 #ifndef ALL
    24 #define ALL 0
    25 #endif
    26 
    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]
    3861
    3962/* serial arg counts: */
     
    4366#define NRHS 6
    4467
     68/* local prototypes: */
     69void ContourToMeshUsage(void);
    4570
    4671#endif  /* _CONTOURTOMESH_H */
Note: See TracChangeset for help on using the changeset viewer.