1 | /*!\file: DomainOutlineWrite.cpp
|
---|
2 | * \brief DomainOutlineWrite.c: write the vertex coordinates defined in a domain
|
---|
3 | * 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.
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include <stdio.h>
|
---|
9 | #include "../Alloc/alloc.h"
|
---|
10 | #include "../../include/include.h"
|
---|
11 | #include "../Exceptions/exceptions.h"
|
---|
12 |
|
---|
13 | int DomainOutlineWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,bool* closed,char* domainname,bool whole=true){
|
---|
14 |
|
---|
15 |
|
---|
16 | /*Error management: */
|
---|
17 | int noerr=1;
|
---|
18 | int i,counter;
|
---|
19 |
|
---|
20 | /*I/O: */
|
---|
21 | FILE* fid=NULL;
|
---|
22 |
|
---|
23 | /*input: */
|
---|
24 | // int nprof; //number of profiles in the domainname file
|
---|
25 | // int* profnvertices=NULL; //array holding the number of vertices for the nprof profiles
|
---|
26 | // double** pprofx=NULL; //array of profiles x coordinates
|
---|
27 | // double** pprofy=NULL; //array of profiles y coordinates
|
---|
28 | // bool* closed=NULL; //array holding closed flags for the nprof profiles
|
---|
29 |
|
---|
30 | /*open domain outline file for writing: */
|
---|
31 | if ((fid=fopen(domainname,"w"))==NULL){
|
---|
32 | _error_("%s%s","could not open domain file ",domainname);
|
---|
33 | noerr=0; goto cleanupandreturn;
|
---|
34 | }
|
---|
35 |
|
---|
36 | /*Start writing profiles: */
|
---|
37 | for(counter=0;counter<nprof;counter++){
|
---|
38 |
|
---|
39 | /*Write header: */
|
---|
40 | fprintf(fid,"%s %s\n","##","Name:");
|
---|
41 | fprintf(fid,"%s %s\n","##","Icon:0");
|
---|
42 | fprintf(fid,"%s %s %s %s\n","#","Points","Count","Value");
|
---|
43 |
|
---|
44 | /*Write number of profile vertices: */
|
---|
45 | if(closed[counter] && !whole)
|
---|
46 | fprintf(fid,"%u %s\n",profnvertices[counter]+1,"1.");
|
---|
47 | else
|
---|
48 | fprintf(fid,"%u %s\n",profnvertices[counter] ,"1.");
|
---|
49 |
|
---|
50 | /*Write next line: */
|
---|
51 | fprintf(fid,"%s %s %s %s %s\n","#","X","pos","Y","pos");
|
---|
52 |
|
---|
53 | /*Write vertices: */
|
---|
54 | for (i=0;i<profnvertices[counter];i++){
|
---|
55 | fprintf(fid,"%lf\t%lf\n",pprofx[counter][i],pprofy[counter][i]);
|
---|
56 | }
|
---|
57 |
|
---|
58 | /*Now check that we are dealing with open contours: */
|
---|
59 | if(closed[counter] && !whole)
|
---|
60 | fprintf(fid,"%lf\t%lf\n",pprofx[counter][0],pprofy[counter][0]);
|
---|
61 |
|
---|
62 | /*Write blank line: */
|
---|
63 | if(counter < nprof-1) fprintf(fid,"\n");
|
---|
64 | }
|
---|
65 |
|
---|
66 | /*close domain outline file: */
|
---|
67 | fclose(fid);
|
---|
68 |
|
---|
69 | cleanupandreturn:
|
---|
70 | return noerr;
|
---|
71 | }
|
---|
72 |
|
---|