Ignore:
Timestamp:
04/16/12 16:06:52 (13 years ago)
Author:
cborstad
Message:

merged trunk-jpl into trunk-jpl-damage through revision 11990

Location:
issm/branches/trunk-jpl-damage
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/branches/trunk-jpl-damage

  • issm/branches/trunk-jpl-damage/src/c/shared/Exp/DomainOutlineRead.cpp

    r9320 r12004  
    99#include "../Alloc/alloc.h"
    1010#include "../../include/include.h"
     11#include "../../objects/objects.h"
    1112#include "../Exceptions/exceptions.h"
     13#include "../../Container/DataSet.h"
    1214
    1315int DomainOutlineRead(int* pnprof,int** pprofnvertices,double*** ppprofx,double*** ppprofy,bool** pclosed,char* domainname,bool whole=true){
    1416
    1517       
    16         /*Error management: */
    17         int noerr=1;
     18        /*indexing: */
    1819        int i,counter;
    1920
     
    3940        if ((fid=fopen(domainname,"r"))==NULL){
    4041                _error_("%s%s","could not find domain file ",domainname);
    41                 noerr=0; goto cleanupandreturn;
    4242        }
    4343
     
    9595                /*Read vertices: */
    9696                for (i=0;i<n;i++){
    97                         fscanf(fid,"%20lf %20lf\n",x+i,y+i);
     97                        fscanf(fid,"%20lf %20lf\n",&x[i],&y[i]);
    9898                }
    9999
     
    117117        fclose(fid);
    118118
    119         cleanupandreturn:
    120         /*Free ressources: */
    121         if(!noerr){
    122                 xfree((void**)&x);
    123                 xfree((void**)&y);
    124                 n=-1;
    125         }
    126        
    127119        /*Assign output pointers: */
    128120        *pnprof=nprof;
     
    132124        if(pclosed)*pclosed=closed;
    133125        else       xfree((void**)&closed);
    134         return noerr;
    135126}
    136127
     128DataSet* DomainOutlineRead(char* domainname,bool whole=true){
     129
     130        /*indexing: */
     131        int i;
     132
     133        /*intermediary: */
     134        int nprof;
     135        int* profnvertices=NULL;
     136        double** pprofx=NULL;
     137        double** pprofy=NULL;
     138
     139        Contour* contour=NULL;
     140
     141        /*output: */
     142        DataSet* domain=NULL;
     143
     144        /*get domain outline from intermediary function:*/
     145        DomainOutlineRead(&nprof,&profnvertices,&pprofx, &pprofy, NULL,domainname,whole);
     146
     147        /*now create dataset of contours: */
     148        domain=new DataSet(0);
     149
     150        for(i=0;i<nprof;i++){
     151                domain->AddObject(new Contour(i,profnvertices[i],pprofx[i],pprofy[i],1));
     152        }
     153
     154        return domain;
     155}
Note: See TracChangeset for help on using the changeset viewer.