Changeset 14293


Ignore:
Timestamp:
01/31/13 10:25:24 (12 years ago)
Author:
Mathieu Morlighem
Message:

NEW: renamed DomainOutlineWrite -> ExpWrite and added printarray for booleans

Location:
issm/trunk-jpl/src/c
Files:
4 edited
1 moved

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/Makefile.am

    r14279 r14293  
    741741                        ./shared/Exp/IsInPoly.cpp\
    742742                        ./shared/Exp/IsInPolySerial.cpp\
    743                         ./shared/Exp/DomainOutlineWrite.cpp\
     743                        ./shared/Exp/ExpWrite.cpp\
    744744                        ./shared/TriMesh/trimesh.h\
    745745                        ./shared/TriMesh/AssociateSegmentToElement.cpp\
  • issm/trunk-jpl/src/c/shared/Elements/PrintArrays.cpp

    r13914 r14293  
    3939        _printLine_("");
    4040}
     41void printarray(bool* array,int lines,int cols){
     42        _printLine_("");
     43        for(int i=0;i<lines;i++){ 
     44                _printString_("   [ ");
     45                for(int j=0;j<cols;j++) _printString_( " " << array[i*cols+j]?1:0);
     46                _printLine_(" ]");
     47        } 
     48        _printLine_("");
     49}
    4150void printbinary(int n){
    4251        unsigned int i=1L<<(sizeof(n)*8-1);
  • issm/trunk-jpl/src/c/shared/Elements/elements.h

    r13901 r14293  
    4040void printarray(IssmPDouble* array,int lines,int cols=1);
    4141void printarray(int* array,int lines,int cols=1);
     42void printarray(bool* array,int lines,int cols=1);
    4243void printsparsity(IssmPDouble* array,int lines,int cols=1);
    4344void printbinary(int n);
  • issm/trunk-jpl/src/c/shared/Exp/ExpWrite.cpp

    r14292 r14293  
    1 /*!\file:  DomainOutlineWrite.cpp
    2  * \brief DomainOutlineWrite.c: write the vertex coordinates defined in a domain
     1/*!\file:  Exp.cpp
     2 * \brief Exp.cpp: write the vertex coordinates defined in a domain
    33 * outline from Argus (.exp file). The first contour in the file is for
    4  * the outside domain outline. The following contours represent holes in
    5  * the domain.
     4 * the outside domain outline.
    65 */
    7 
    86#include <stdio.h>
    97#include "../Alloc/alloc.h"
    108#include "../../include/include.h"
    119#include "../Exceptions/exceptions.h"
     10#include "../../Container/DataSet.h"
     11#include "../../classes/objects/Contour.h"
    1212
    13 int DomainOutlineWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,bool* closed,char* domainname){
    14 
    15         /*Error management: */
    16         int noerr=1;
    17         int i,counter;
     13int ExpWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,char* domainname){/*{{{*/
    1814
    1915        /*I/O: */
     
    2117
    2218        /*open domain outline file for writing: */
    23         if ((fid=fopen(domainname,"w"))==NULL){
    24                 _error_("could not open domain file " << domainname);
    25                 noerr=0; goto cleanupandreturn;
    26         }
     19        if((fid=fopen(domainname,"w"))==NULL) _error_("could not open domain file " << domainname);
    2720
    2821        /*Start writing profiles: */
    29         for(counter=0;counter<nprof;counter++){
     22        for(int counter=0;counter<nprof;counter++){
    3023
    3124                /*Write header: */
    32                 fprintf(fid,"%s %s\n","##","Name:");
    33                 fprintf(fid,"%s %s\n","##","Icon:0");
    34                 fprintf(fid,"%s %s %s %s\n","#","Points","Count","Value");
    35 
    36                 /*Write number of profile vertices: */
     25                fprintf(fid,"## Name:%s\n",domainname);
     26                fprintf(fid,"## Icon:0\n");
     27                fprintf(fid,"# Points Count     Value\n");
    3728                fprintf(fid,"%u %s\n",profnvertices[counter]  ,"1.");
    38 
    39                 /*Write next line: */
    40                 fprintf(fid,"%s %s %s %s %s\n","#","X","pos","Y","pos");
     29                fprintf(fid,"# X pos    Y pos\n");
    4130
    4231                /*Write vertices: */
    43                 for (i=0;i<profnvertices[counter];i++){
     32                for(int i=0;i<profnvertices[counter];i++){
    4433                        fprintf(fid,"%lf\t%lf\n",pprofx[counter][i],pprofy[counter][i]);
    4534                }
    4635
    4736                /*Write blank line: */
    48                 if(counter < nprof-1) fprintf(fid,"\n");
     37                if(counter<nprof-1) fprintf(fid,"\n");
    4938        }
    5039
    51         /*close domain outline file: */
     40        /*close Exp file: */
    5241        fclose(fid);
    5342
    54         cleanupandreturn:
    55         return noerr;
    56 }
     43        return 1;
     44}/*}}}*/
     45int ExpWrite(DataSet* contours,char* domainname){/*{{{*/
     46
     47        /*I/O: */
     48        FILE* fid=NULL;
     49        Contour<double>* contour = NULL;
     50
     51        /*open domain outline file for writing: */
     52        if((fid=fopen(domainname,"w"))==NULL) _error_("could not open domain file " << domainname);
     53
     54        for(int counter=0;counter<contours->Size();counter++){
     55                contour=(Contour<double>*)contours->GetObjectByOffset(counter);
     56
     57                /*Write header: */
     58                fprintf(fid,"## Name:%s\n",domainname);
     59                fprintf(fid,"## Icon:0\n");
     60                fprintf(fid,"# Points Count     Value\n");
     61                fprintf(fid,"%u %s\n",contour->nods  ,"1.");
     62                fprintf(fid,"# X pos    Y pos\n");
     63
     64                /*Write vertices: */
     65                for(int i=0;i<contour->nods;i++){
     66                        fprintf(fid,"%lf\t%lf\n",contour->x[i],contour->y[i]);
     67                }
     68
     69                /*Write blank line: */
     70                if(counter<contours->Size()-1) fprintf(fid,"\n");
     71        }
     72
     73        /*close Exp file: */
     74        fclose(fid);
     75
     76        return 1;
     77}/*}}}*/
  • issm/trunk-jpl/src/c/shared/Exp/exp.h

    r13813 r14293  
    1212
    1313int IsInPolySerial(double* in,double* xc,double* yc,int numvertices,double* x,double* y,int nods, int edgevalue);
    14 int DomainOutlineWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,bool* closed,char* domainname);
     14int ExpWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,char* domainname);
     15int ExpWrite(DataSet* contours,char* domainname);
    1516int pnpoly(int npol, double *xp, double *yp, double x, double y, int edgevalue);
    1617
Note: See TracChangeset for help on using the changeset viewer.