10 int i,j,k,ipt=0,jpt=0,nnodes;
14 char indent[81] =
" ";
17 bool ncfree=
false, edfree=
false;
23 clock_t clock0,clock1,clock0a,clock0b,clock0c;
24 time_t time0, time1, time0a, time0b, time0c;
28 _printf0_(
"\nKMLMeshWritex Module -- " << ctime(&time0));
33 sprintf(kdoc->
name ,
"ISSM Mesh: %s",name);
43 sprintf(klsty->
color ,
"ff000000");
47 sprintf(kpsty->
color ,
"%02xffffff",(
int)floor(popac*255+0.5));
50 kstyle->
AddAttrib(
"id",
"BlackLineRandomPoly");
56 sprintf(klsty->
color ,
"ff000000");
60 sprintf(kpsty->
color ,
"00ffffff");
63 kstyle->
AddAttrib(
"id",
"BlackLineEmptyPoly");
69 sprintf(klsty->
color ,
"ff0000ff");
73 sprintf(kpsty->
color ,
"%02x0000ff",(
int)floor(popac*255+0.5));
82 _printf0_(
"Writing " << mcmap <<
" Matlab colors as KML style templates.\n");
84 for (i=0; i<mcmap; i++) {
87 sprintf(klsty->
color ,
"%02x%02x%02x%02x",
89 (
int)floor(cmap[ipt+2]*255+0.5),
90 (
int)floor(cmap[ipt+1]*255+0.5),
91 (
int)floor(cmap[ipt ]*255+0.5));
95 sprintf(kpsty->
color ,
"%02x%02x%02x%02x",
96 (
int)floor(popac*255+0.5),
97 (
int)floor(cmap[ipt+2]*255+0.5),
98 (
int)floor(cmap[ipt+1]*255+0.5),
99 (
int)floor(cmap[ipt ]*255+0.5));
102 sprintf(cstr,
"MatlabColor%d",i+1);
117 _printf0_(
"Creating the node connectivity table.\n");
119 nodecon=xNewZeroInit<int>(mncon*nncon);
123 for (i=0; i<melem; i++) {
124 for (j=0; j<nelem; j++) {
126 ipt=(elem[jpt]-1)*nncon;
127 if (nodecon[ipt+(nncon-1)] < mxepg) {
128 nodecon[ipt+nodecon[ipt+(nncon-1)]]=i+1;
129 nodecon[ipt+(nncon-1)]++;
132 _error_(
"Nodal connectivity table needs more than specified " << mxepg <<
" columns.\n");
147 else if (mdata == mncon) {
148 _printf0_(
"Averaging nodal data to element data.\n");
149 edata=xNewZeroInit<double>(melem*ndata);
154 for (i=0; i<melem; i++) {
156 for (j=0; j<nelem; j++) {
158 for (k=0; k<ndata; k++)
159 edata[ipt+k]+=data[(elem[jpt]-1)*ndata+k];
165 for (k=0; k<ndata; k++)
166 edata[ipt+k]/=(
double)nnodes;
172 _error_(
"Data matrix has incorrect number of " << mdata <<
" rows.\n");
183 if(edfree) xDelete<double>(edata);
184 if(ncfree) xDelete<int>(nodecon);
187 _printf_(
" Constructed kml document -- " << ((
double)(clock0a-clock0))/CLOCKS_PER_SEC <<
" CPU seconds; " << difftime(time0a,time0) <<
" elapsed seconds.\n\n\n");
191 _printf0_(
"Writing kml document to file.\n");
192 fprintf(fid,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
193 fprintf(fid,
"<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n");
194 kdoc->
Write(fid,indent);
195 fprintf(fid,
"</kml>\n");
198 _printf_(
" Wrote kml file -- " << ((
double)(clock0b-clock0a))/CLOCKS_PER_SEC <<
" CPU seconds; " << difftime(time0b,time0a) <<
" elapsed seconds.\n\n\n");
204 _printf_(
" Deleted kml document -- " << ((
double)(clock0c-clock0b))/CLOCKS_PER_SEC <<
" CPU seconds; " << difftime(time0c,time0b) <<
" elapsed seconds.\n\n\n");
208 _printf_(
"KMLMeshWritex Module -- " << ((
double)(clock1-clock0))/CLOCKS_PER_SEC <<
" CPU seconds; " << difftime(time1,time0) <<
" elapsed seconds.\n\n\n");