Changeset 13353


Ignore:
Timestamp:
09/13/12 10:42:06 (13 years ago)
Author:
Mathieu Morlighem
Message:

NEW: FtechData can now retrieve contours either from a file or from a matlab structure (python equivalent needs to be implemented

Location:
issm/trunk-jpl/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/matlab/io/FetchMatlabData.cpp

    r13216 r13353  
    609609}
    610610/*}}}*/
    611 /*FUNCTION FetchData(Options** poptions,const mxArray* dataref){{{*/
     611/*FUNCTION FetchData(Options** poptions,const mxArray** pdataref){{{*/
    612612void FetchData(Options** poptions,int istart, int nrhs,const mxArray** pdataref){
    613613
     
    634634}
    635635/*}}}*/
     636/*FUNCTION FetchData(DataSet** pcontours,const mxArray* dataref){{{*/
     637void FetchData(DataSet** pcontours,const mxArray* dataref){
     638
     639        int              numcontours,index,test1,test2;
     640        char            *contourname = NULL;
     641        DataSet         *contours    = NULL;
     642        Contour<double> *contouri    = NULL;
     643
     644        if (mxIsClass(dataref,"char")){
     645                FetchData(&contourname,dataref);
     646                contours=DomainOutlineRead<double>(contourname);
     647        }
     648        else if(mxIsClass(dataref,"struct")){
     649
     650                contours=new DataSet(0);
     651                numcontours=mxGetNumberOfElements(dataref);
     652
     653                for(int i=0;i<numcontours;i++){
     654
     655                        contouri=xNew<Contour<double> >(1);
     656
     657                        index = mxGetFieldNumber(dataref,"nods");
     658                        if(index==-1) _error_("input structure does not have a 'nods' field");
     659                        FetchData(&contouri->nods,mxGetFieldByNumber(dataref,i,index));
     660
     661                        index = mxGetFieldNumber(dataref,"x");
     662                        if(index==-1) _error_("input structure does not have a 'x' field");
     663                        FetchData(&contouri->x,&test1,&test2,mxGetFieldByNumber(dataref,i,index));
     664                        if(test1!=contouri->nods || test2!=1) _error_("field x should be of size ["<<contouri->nods<<" 1]");
     665
     666                        index = mxGetFieldNumber(dataref,"y");
     667                        if(index==-1) _error_("input structure does not have a 'y' field");
     668                        FetchData(&contouri->y,&test1,&test2,mxGetFieldByNumber(dataref,i,index));
     669                        if(test1!=contouri->nods || test2!=1) _error_("field y should be of size ["<<contouri->nods<<" 1]");
     670
     671                        contours->AddObject(contouri);
     672                }
     673        }
     674        else{
     675                _error_("Contour is neither a string nor a structure and cannot be loaded ("<<mxGetClassName(dataref)<<" not supported)");
     676        }
     677
     678        /*clean-up and assign output pointer*/
     679        xDelete<char>(contourname);
     680        *pcontours=contours;
     681}
     682/*}}}*/
  • issm/trunk-jpl/src/c/matlab/io/matlabio.h

    r13267 r13353  
    4949void FetchData(BamgOpts** bamgopts,const mxArray* dataref);
    5050void FetchData(Options** poptions,int istart, int nrhs,const mxArray** pdataref);
     51void FetchData(DataSet** pcontours,const mxArray* dataref);
    5152
    5253Option* OptionParse(char* name, const mxArray* prhs[]);
  • issm/trunk-jpl/src/c/python/io/FetchPythonData.cpp

    r13310 r13353  
    235235}
    236236/*}}}*/
     237/*FUNCTION FetchData(DataSet** pcontours,PyObject* py_dict){{{*/
     238void FetchData(DataSet** pcontours,PyObject* py_dict){
     239
     240        _error_("not supported yet");
     241}
     242/*}}}*/
    237243
    238244/*Python version dependent: */
  • issm/trunk-jpl/src/c/python/io/pythonio.h

    r13310 r13353  
    3535void FetchData(BamgOpts** bamgopts,PyObject* py_dict);
    3636void FetchData(Options** poptions,int istart, int nrhs,PyObject* arguments);
     37void FetchData(DataSet** pcontours,PyObject* py_dict);
    3738
    3839int CheckNumPythonArguments(PyObject* inputs,int NRHS, void (*function)( void ));
  • issm/trunk-jpl/src/c/shared/Exp/DomainOutlineWrite.cpp

    r13056 r13353  
    1212
    1313int DomainOutlineWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,bool* closed,char* domainname){
    14 
    1514       
    1615        /*Error management: */
     
    5655        return noerr;
    5756}
    58 
  • issm/trunk-jpl/src/c/shared/Exp/exp.h

    r13293 r13353  
    175175
    176176        /*intermediary: */
    177         int       nprof;
    178         int      *profnvertices = NULL;
    179         doubletype  **pprofx        = NULL;
    180         doubletype  **pprofy        = NULL;
    181         Contour<doubletype>* contour       = NULL;
     177        int                  nprof;
     178        int                 *profnvertices = NULL;
     179        doubletype         **pprofx        = NULL;
     180        doubletype         **pprofy        = NULL;
     181        Contour<doubletype> *contour       = NULL;
    182182
    183183        /*output: */
    184         DataSet* domain=NULL;
     184        DataSet *domain = NULL;
    185185
    186186        /*If domainname is an empty string, return empty dataset*/
  • issm/trunk-jpl/src/m/mesh/bamg.m

    r13329 r13353  
    6666        domain=expread(domainfile);
    6767
    68         %Write temporary file, with only the domain outline (exclude holes)
    69         expwrite(domain(1),[domainfile '_TEMPouterboundary.exp']);
    70 
    7168        %Build geometry
    7269        count=0;
     
    8077                %Checks that all holes are INSIDE the principle domain outline
    8178                if i>1,
    82                         flags=ContourToNodes(domain(i).x,domain(i).y,[domainfile '_TEMPouterboundary.exp'],0);
     79                        flags=ContourToNodes(domain(i).x,domain(i).y,domain(1),0);
    8380                        if any(~flags),
    8481                                error('bamg error message: All holes should be stricly inside the principal domain');
     
    109106
    110107                        %detect wether all points of the rift are inside the domain
    111                         flags=ContourToNodes(rift(i).x,rift(i).y,[domainfile '_TEMPouterboundary.exp'],0);
     108                        flags=ContourToNodes(rift(i).x,rift(i).y,domain(1),0);
    112109                        if ~flags,
    113110                                error('one Rift has all his points outside of the domain outline'),
     
    241238       
    242239                %only keep those inside
    243                 flags=ContourToNodes(requiredvertices(:,1),requiredvertices(:,2),[domainfile '_TEMPouterboundary.exp'],0);
     240                flags=ContourToNodes(requiredvertices(:,1),requiredvertices(:,2),domain(1),0);
    244241                requiredvertices=requiredvertices(find(flags),:);
    245242
     
    255252        %process geom
    256253        %bamg_geometry=processgeometry(bamg_geometry,getfieldvalue(options,'tol',NaN),domain(1));
    257         delete([domainfile '_TEMPouterboundary.exp']);
    258254
    259255elseif isstruct(md.private.bamg) & isfield(md.private.bamg,'geometry'),
  • issm/trunk-jpl/src/modules/ContourToNodes/ContourToNodes.cpp

    r13330 r13353  
    3636        FetchData(&x,&nods,NULL,XHANDLE);
    3737        FetchData(&y,NULL,NULL,YHANDLE);
    38         FetchData(&edgevalue,EDGEVALUEHANDLE);
    39         FetchData(&contourname,CONTOURNAME);
    40         contours=DomainOutlineRead<double>(contourname);
     38        FetchData(&edgevalue,EDGEVALUE);
     39        FetchData(&contours,CONTOUR);
    4140
    4241        /*Run x layer */
  • issm/trunk-jpl/src/modules/ContourToNodes/ContourToNodes.h

    r13330 r13353  
    2828#ifdef _HAVE_MATLAB_MODULES_
    2929/* input macros: */
    30 #define XHANDLE         prhs[0]
    31 #define YHANDLE         prhs[1]
    32 #define CONTOURNAME     prhs[2]
    33 #define EDGEVALUEHANDLE prhs[3]
     30#define XHANDLE   prhs[0]
     31#define YHANDLE   prhs[1]
     32#define CONTOUR   prhs[2]
     33#define EDGEVALUE prhs[3]
    3434
    3535/* serial output macros: */
     
    3939#ifdef _HAVE_PYTHON_MODULES_
    4040/* input macros: */
    41 #define XHANDLE         PyTuple_GetItem(args,0)
    42 #define YHANDLE         PyTuple_GetItem(args,1)
    43 #define CONTOURNAME     PyTuple_GetItem(args,2)
    44 #define EDGEVALUEHANDLE PyTuple_GetItem(args,3)
     41#define XHANDLE   PyTuple_GetItem(args,0)
     42#define YHANDLE   PyTuple_GetItem(args,1)
     43#define CONTOUR   PyTuple_GetItem(args,2)
     44#define EDGEVALUE PyTuple_GetItem(args,3)
    4545
    4646/* serial output macros: */
Note: See TracChangeset for help on using the changeset viewer.