Changeset 8741


Ignore:
Timestamp:
06/28/11 12:07:29 (14 years ago)
Author:
jschierm
Message:

DomainOutlineRead.cpp: Added whole argument for input and modified functions that called it.

Location:
issm/trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/modules/Exp2Kmlx/Exp2Kmlx.cpp

    r8737 r8741  
    4141        KML_Polygon*       kpoly =NULL;
    4242        KML_LinearRing*    kring =NULL;
     43        KML_LineString*    kline =NULL;
    4344
    4445        FILE*   fid=NULL;
     
    5354/*  read exp file  */
    5455
    55         if (!DomainOutlineRead(&nprof,&pnvert,&pprofx,&pprofy,&closed,filexp))
     56        if (!DomainOutlineRead(&nprof,&pnvert,&pprofx,&pprofy,&closed,filexp,false))
    5657                _error_("Error reading exp file.");
    5758
     
    7071
    7172        kfold =new KML_Folder();
    72         sprintf(kfold->name      ,"Polygons translated from file \"%s\".",filexp);
     73        sprintf(kfold->name      ,"Profiles translated from file \"%s\".",filexp);
    7374        kfold->open      =1;
    7475
    7576/*  polygon with multiple holes  */
     77
     78        if (holes && nprof && !closed[0]) {
     79                _printf_(true,"Warning -- Outer profile is not closed, so \"holes\" option will be ignored.\n");
     80                holes=false;
     81        }
    7682
    7783        if (holes) {
     
    102108
    103109                for (i=1; i<nprof; i++) {
     110                        if (!closed[i]) {
     111                                _printf_(true,"Warning -- Inner profile %d is not closed with \"holes\" specified, so it will be ignored.\n",i+1);
     112                                continue;
     113                        }
     114
    104115                        kring =new KML_LinearRing();
    105116
     
    127138        }
    128139
    129 /*  multiple polygons */
     140/*  multiple polygons or linestrings */
    130141
    131142        else {
    132143                for (i=0; i<nprof; i++) {
    133144                        kplace=new KML_Placemark();
    134                         sprintf(kplace->name      ,"Polygon %d",i);
    135                         kplace->visibility=true;
    136 
    137                         kpoly =new KML_Polygon();
    138                         kring =new KML_LinearRing();
    139 
    140                         lat=(double *) xmalloc(pnvert[i]*sizeof(double));
    141                         lon=(double *) xmalloc(pnvert[i]*sizeof(double));
    142                         Xy2llx(lat,lon,pprofx[i],pprofy[i],pnvert[i],sgn,cm,sp);
    143 
    144                         kring->ncoord    =pnvert[i];
    145                         kring->coords    =(double (*)[3]) xmalloc(pnvert[i]*3*sizeof(double));
    146                         for (j=0; j<pnvert[i]; j++) {
    147                                 kring->coords[j][0]=lon[j];
    148                                 kring->coords[j][1]=lat[j];
    149                                 kring->coords[j][2]=0.;
    150                         }
    151                         xfree((void**)&lon);
    152                         xfree((void**)&lat);
    153 
    154                         (kpoly ->outer     )->AddObject((Object*)kring);
    155                         kring =NULL;
    156 
    157                         (kplace->geometry  )->AddObject((Object*)kpoly);
    158                         kpoly =NULL;
     145
     146                        if (closed[i]) {
     147                                sprintf(kplace->name      ,"Polygon %d",i+1);
     148                                kplace->visibility=true;
     149
     150                                kpoly =new KML_Polygon();
     151                                kring =new KML_LinearRing();
     152
     153                                lat=(double *) xmalloc(pnvert[i]*sizeof(double));
     154                                lon=(double *) xmalloc(pnvert[i]*sizeof(double));
     155                                Xy2llx(lat,lon,pprofx[i],pprofy[i],pnvert[i],sgn,cm,sp);
     156
     157                                kring->ncoord    =pnvert[i];
     158                                kring->coords    =(double (*)[3]) xmalloc(pnvert[i]*3*sizeof(double));
     159                                for (j=0; j<pnvert[i]; j++) {
     160                                        kring->coords[j][0]=lon[j];
     161                                        kring->coords[j][1]=lat[j];
     162                                        kring->coords[j][2]=0.;
     163                                }
     164                                xfree((void**)&lon);
     165                                xfree((void**)&lat);
     166
     167                                (kpoly ->outer     )->AddObject((Object*)kring);
     168                                kring =NULL;
     169
     170                                (kplace->geometry  )->AddObject((Object*)kpoly);
     171                                kpoly =NULL;
     172                        }
     173
     174                        else {
     175                                sprintf(kplace->name      ,"LineString %d",i+1);
     176                                kplace->visibility=true;
     177
     178                                kline =new KML_LineString();
     179
     180                                lat=(double *) xmalloc(pnvert[i]*sizeof(double));
     181                                lon=(double *) xmalloc(pnvert[i]*sizeof(double));
     182                                Xy2llx(lat,lon,pprofx[i],pprofy[i],pnvert[i],sgn,cm,sp);
     183
     184                                kline->ncoord    =pnvert[i];
     185                                kline->coords    =(double (*)[3]) xmalloc(pnvert[i]*3*sizeof(double));
     186                                for (j=0; j<pnvert[i]; j++) {
     187                                        kline->coords[j][0]=lon[j];
     188                                        kline->coords[j][1]=lat[j];
     189                                        kline->coords[j][2]=0.;
     190                                }
     191                                xfree((void**)&lon);
     192                                xfree((void**)&lat);
     193
     194                                (kplace->geometry  )->AddObject((Object*)kline);
     195                                kline =NULL;
     196                        }
     197
    159198                        (kfold ->feature   )->AddObject((Object*)kplace);
    160199                        kplace=NULL;
  • issm/trunk/src/c/shared/Exp/DomainOutlineRead.cpp

    r8737 r8741  
    1111#include "../Exceptions/exceptions.h"
    1212
    13 int DomainOutlineRead(int* pnprof,int** pprofnvertices,double*** ppprofx,double*** ppprofy,bool** pclosed,char* domainname){
     13int DomainOutlineRead(int* pnprof,int** pprofnvertices,double*** ppprofx,double*** ppprofy,bool** pclosed,char* domainname,bool whole){
    1414
    1515       
     
    102102                cl=false;
    103103                if((x[0]==x[n-1]) && (y[0]==y[n-1])){
    104                         n=n-1;
    105104                        cl=true;
     105                        if (!whole) {
     106                                n=n-1;
     107                        }
    106108                }
    107109
  • issm/trunk/src/c/shared/Exp/exp.h

    r8737 r8741  
    1212int IsOutsidePoly(Vec in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue);
    1313int IsInPolySerial(double* in,double* xc,double* yc,int numvertices,double* x,double* y,int nods, int edgevalue);
    14 int DomainOutlineRead(int* pnprof,int** pprofnvertices,double*** ppprofx,double*** ppprofy,bool** pclosed,char* domainname);
     14int DomainOutlineRead(int* pnprof,int** pprofnvertices,double*** ppprofx,double*** ppprofy,bool** pclosed,char* domainname,bool whole);
    1515int pnpoly(int npol, double *xp, double *yp, double x, double y, int edgevalue);
    1616
  • issm/trunk/src/mex/TriMesh/TriMesh.cpp

    r8737 r8741  
    9696       
    9797        /*Start reading the domain outline file: */
    98         if(!DomainOutlineRead(&nprof,&profnvertices,&pprofx,&pprofy,NULL,domainname)){
     98        if(!DomainOutlineRead(&nprof,&profnvertices,&pprofx,&pprofy,NULL,domainname,false)){
    9999                printf("%s%s%s\n",__FUNCT__," error message reading domain outline ",domainname);
    100100                mexErrMsgTxt(" ");
     
    103103        /*Read rifts file if present: */
    104104        if(riftname){
    105                 if(!DomainOutlineRead(&numrifts,&riftsnumvertices,&riftsverticesx,&riftsverticesy,NULL,riftname)){
     105                if(!DomainOutlineRead(&numrifts,&riftsnumvertices,&riftsverticesx,&riftsverticesy,NULL,riftname,false)){
    106106                        printf("%s%s%s\n",__FUNCT__," error message reading rifts outline ",riftname);
    107107                        mexErrMsgTxt(" ");
  • issm/trunk/src/mex/TriMeshNoDensity/TriMeshNoDensity.cpp

    r8737 r8741  
    8686       
    8787        /*Start reading the domain outline file: */
    88         if(!DomainOutlineRead(&nprof,&profnvertices,&pprofx,&pprofy,NULL,domainname)){
     88        if(!DomainOutlineRead(&nprof,&profnvertices,&pprofx,&pprofy,NULL,domainname,false)){
    8989                printf("%s%s%s\n",__FUNCT__," error message reading domain outline ",domainname);
    9090                mexErrMsgTxt(" ");
     
    9393        /*Read rifts file if present: */
    9494        if(riftname){
    95                 if(!DomainOutlineRead(&numrifts,&riftsnumvertices,&riftsverticesx,&riftsverticesy,NULL,riftname)){
     95                if(!DomainOutlineRead(&numrifts,&riftsnumvertices,&riftsverticesx,&riftsverticesy,NULL,riftname,false)){
    9696                        printf("%s%s%s\n",__FUNCT__," error message reading rifts outline ",riftname);
    9797                        mexErrMsgTxt(" ");
Note: See TracChangeset for help on using the changeset viewer.