1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683
|
/************************************************************************
* *
* GLE - Graphics Layout Engine <http://www.gle-graphics.org/> *
* *
* Modified BSD License *
* *
* Copyright (C) 2009 GLE. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above *
* copyright notice, this list of conditions and the following *
* disclaimer in the documentation and/or other materials provided with *
* the distribution. *
* *
* 3. The name of the author may not be used to endorse or promote *
* products derived from this software without specific prior written *
* permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR *
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED *
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE *
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY *
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL *
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE *
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER *
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR *
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN *
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
************************************************************************/
/*
* Trying to add surface support back into GLE
* Jan Struyf 2005
*/
#include "../all.h"
#include "../tokens/Tokenizer.h"
#include "../core.h"
#include "../file_io.h"
#include "../texinterface.h"
#include "../cutils.h"
#include "../cmdline.h"
#include "../config.h"
#include "../mem_limits.h"
#include "../token.h"
#include "../gprint.h"
#include "../cutils.h"
#include "../gle-block.h"
#define BEGINDEF extern
#include "../begin.h"
#include "gsurface.h"
extern int gle_debug;
FILE *df;
void hide(float *z,int nx, int ny, float minz, float maxz, struct surface_struct *sff);
void hide_enddefaults(void);
void text_expand(int x);
void hide_defaults();
void pass_line() throw(ParserError);
void pass_title();
void pass_cube();
void pass_top();
void pass_bot();
void pass_marker();
void pass_droplines();
void pass_riselines();
void pass_back();
void pass_right();
void pass_base();
void pass_axis();
void pass_anytitle();
void pass_zclip();
void pass_points(string);
void getstr(char *s);
float getf(void);
int geton(void);
//void pass_data(int *nx, int *ny, float *zmin, float *zmax);
void pass_data(bool force_zdata);
void pass_zdata(string,int *nx, int *ny, double *zmin, double *zmax);
bool alloc_zdata(int nx, int ny);
extern int trace_on,this_line;
char input_file[80];
static int xsample,ysample;
static struct surface_struct sf;
static double zmin = 10e10,zmax = -10e10;
static float *z;
static int nx,ny;
static double dxmin,dymin,dxmax,dymax;
double zclipmin,zclipmax;
int zclipminset,zclipmaxset;
int ct;
surface_struct* GLEInterface::getSurface() {
return &sf;
}
void clean_surface() {
sf.z = NULL;
}
class GLESurfaceBlockInstance : public GLEBlockInstance {
public:
GLESurfaceBlockInstance(GLESurfaceBlockBase* parent);
virtual ~GLESurfaceBlockInstance();
virtual void executeLine(GLESourceLine& sline);
virtual void endExecuteBlock();
private:
GLEPoint m_origin;
};
GLESurfaceBlockInstance::GLESurfaceBlockInstance(GLESurfaceBlockBase* parent):
GLEBlockInstance(parent)
{
g_get_xy(&m_origin);
hide_defaults();
}
GLESurfaceBlockInstance::~GLESurfaceBlockInstance() {
}
void GLESurfaceBlockInstance::executeLine(GLESourceLine& sline) {
token_space();
begin_init();
int st = begin_token(sline, srclin, tk, &ntk, outbuff, true);
if (!st) {
return;
}
ct = 1;
pass_line();
}
void GLESurfaceBlockInstance::endExecuteBlock() {
if (nx==0 || ny==0) {
// Create fake dataset for now...
nx = ny = 2;
alloc_zdata(nx,ny);
z[0] = z[1] = z[2] = z[3] = -GLE_INF;
}
if (zclipminset || zclipmaxset) {
for (int li = 0; li< nx*ny; li++) {
if (zclipminset) if (z[li]<zclipmin) z[li] = zclipmin;
if (zclipmaxset) if (z[li]>zclipmax) z[li] = zclipmax;
}
if (zclipminset) zmin = zclipmin;
if (zclipmaxset) zmax = zclipmax;
}
hide_enddefaults();
if (sf.zaxis.min != sf.zaxis.max) {
zmin = sf.zaxis.min;
zmax = sf.zaxis.max;
}
sf.nx = nx;
sf.ny = ny;
sf.z = z;
sf.zmin = zmin;
sf.zmax = zmax;
hide(z,nx,ny,zmin,zmax,&sf);
g_move(m_origin);
}
GLESurfaceBlockBase::GLESurfaceBlockBase():
GLEBlockWithSimpleKeywords("surface", false)
{
const char* commands[] = {
"SIZE", "TITLE", "CUBE", "DATA", "ZDATA", "ROTATE", "EYE",
"VIEW", "HARRAY", "ZCLIP", "SKIRT", "XLINES", "YLINES",
"TOP", "UNDERNEATH", "HIDDEN", "MARKER", "POINTS", "DROPLINES",
"RISELINES", "BASE", "BACK", "RIGHT", "ZCOLOUR", "ZCOLOR", "" };
for (int i = 0; commands[i][0] != 0; ++i) {
addKeyWord(commands[i]);
}
const char* axis[] = { "X", "Y", "Z", "" };
for (int i = 0; axis[i][0] != 0; ++i) {
addKeyWord(std::string(axis[i]) + "AXIS");
addKeyWord(std::string(axis[i]) + "TITLE");
}
}
GLESurfaceBlockBase::~GLESurfaceBlockBase() {
}
GLEBlockInstance* GLESurfaceBlockBase::beginExecuteBlockImpl(GLESourceLine& /* sline */, int* /* pcode */, int* /* cp */) {
return new GLESurfaceBlockInstance(this);
}
#define kw(k) if (str_i_equals(tk[ct],k))
char* getstrv() {
if (ct >= ntk) {
gprint("Expecting string \n");
return NULL;
}
string result;
pass_file_name(tk[++ct], result);
return sdup((char*)result.c_str());
}
void getstr(char *s) {
if (ct>=ntk) { gprint("Expecting Color or Lstyle\n"); return;}
strncpy(s,tk[++ct],11);
}
float getf() {
if (ct>=ntk) gprint("Expecting Number\n");
return atof(tk[++ct]);
}
int geton() {
if (ct>=ntk) gprint("Expecting ON | OFF\n");
ct++;
if (str_i_equals(tk[ct],"ON")) return true;
if (str_i_equals(tk[ct],"OFF")) return false;
gprint("Expecting ON | OFF, assuming ON\n");
return true;
}
void pass_line() throw(ParserError) {
if (ntk<1) return;
kw("SIZE") {sf.screenx = getf(); sf.screeny = getf();}
else kw("TITLE") pass_title();
else kw("CUBE") pass_cube();
// else kw("DATA") { pass_data(&nx,&ny,&zmin,&zmax); }
else kw("DATA") { pass_data(false); }
else kw("ZDATA") { pass_data(true); }
else kw("ROTATE") {sf.xrotate = getf(); sf.yrotate = getf(); sf.zrotate = getf();}
else kw("EYE") {sf.eye_x = getf(); sf.eye_y = getf(); sf.vdist = getf();}
else kw("VIEW") {sf.eye_x = getf(); sf.eye_y = getf(); sf.vdist = getf();}
else kw("HARRAY") sf.maxh = (int)getf();
else kw("ZCLIP") pass_zclip();
else kw("SKIRT") sf.skirt_on = geton();
else kw("XLINES") sf.xlines_on = geton();
else kw("YLINES") sf.ylines_on = geton();
else kw("TOP") pass_top();
else kw("UNDERNEATH") pass_bot();
else kw("HIDDEN") sf.hidden_on = geton();
else kw("MARKER") pass_marker();
else kw("POINTS") pass_data(false);
else kw("DROPLINES") pass_droplines();
else kw("RISELINES") pass_riselines();
else kw("BASE") pass_base();
else kw("BACK") pass_back();
else kw("RIGHT") pass_right();
else kw("ZCOLOUR") getstr(sf.zcolour);
else kw("ZCOLOR") getstr(sf.zcolour);
else if (str_i_str(tk[1],"AXIS")!=NULL) pass_axis();
else if (str_i_str(tk[1],"TITLE")!=NULL) pass_anytitle();
else {
stringstream err;
err << "illegal keyword in surface block: '" << tk[ct] << "'";
g_throw_parser_error(err.str());
}
if (ct<ntk) {
stringstream err;
err << "extra parameters on end of line: '" << tk[ct] << "'";
g_throw_parser_error(err.str());
}
}
void pass_title() {
sf.title = getstrv();
for (ct++;ct<=ntk;ct++) {
kw("HEI") sf.title_hei = getf();
else kw("DIST") sf.title_dist = getf();
else kw("COLOR") getstr(sf.title_color);
else gprint("Expecting one of HEI, DIST, COLOR , found {%s} \n",tk[ct]);
}
}
void pass_anytitle() {
struct GLEAxis3D *ax = NULL;
if (toupper(*tk[ct])=='X') ax = &sf.xaxis;
else if (toupper(*tk[ct])=='Y') ax = &sf.yaxis;
else if (toupper(*tk[ct])=='Z') ax = &sf.zaxis;
else return;
ax->title = getstrv();
for (ct++;ct<=ntk;ct++) {
kw("HEI") ax->title_hei = getf();
else kw("DIST") ax->title_dist = getf();
else kw("COLOR") getstr(ax->title_color);
else gprint("Expecting one of HEI, DIST, COLOR , found {%s} \n",tk[ct]);
}
}
void pass_cube() {
for (ct++;ct<=ntk;ct++) {
kw("ON") sf.cube_on = true;
else kw("OFF") sf.cube_on = false;
else kw("NOFRONT") sf.cube_front_on = false;
else kw("FRONT") sf.cube_front_on = geton();
else kw("LSTYLE") getstr(sf.cube_lstyle);
else kw("COLOR") getstr(sf.cube_color);
else kw("XLEN") sf.sizex = getf();
else kw("YLEN") sf.sizey = getf();
else kw("ZLEN") sf.sizez = getf();
else gprint("Expecting one of OFF, XLEN, YLEN, ZLEN, FRONT, LSTYLE, COLOR, found {%s} \n",tk[ct]);
}
}
void pass_zclip() {
for (ct++;ct<=ntk;ct++) {
kw("MIN") { zclipmin = getf(); zclipminset = true; }
else kw("MAX") { zclipmax = getf(); zclipmaxset = true; }
else gprint("Expecting one of MIN, MAX found {%s} \n",tk[ct]);
}
}
void pass_back() {
for (ct++;ct<=ntk;ct++) {
kw("YSTEP") sf.back_ystep = getf();
else kw("ZSTEP") sf.back_zstep = getf();
else kw("LSTYLE") getstr(sf.back_lstyle);
else kw("COLOR") getstr(sf.back_color);
else kw("NOHIDDEN") sf.back_hidden = false;
else gprint("Expecting one of YSTEP, ZSTEP, LSTYLE, COLOR found {%s} \n",tk[ct]);
}
}
void pass_right() {
for (ct++;ct<=ntk;ct++) {
kw("ZSTEP") sf.right_zstep = getf();
else kw("XSTEP") sf.right_xstep = getf();
else kw("LSTYLE") getstr(sf.right_lstyle);
else kw("COLOR") getstr(sf.right_color);
else kw("NOHIDDEN") sf.right_hidden = false;
else gprint("Expecting one of ZSTEP, XSTEP, LSTYLE, COLOR found {%s} \n",tk[ct]);
}
}
void pass_base() {
for (ct++;ct<=ntk;ct++) {
kw("XSTEP") sf.base_xstep = getf();
else kw("YSTEP") sf.base_ystep = getf();
else kw("LSTYLE") getstr(sf.base_lstyle);
else kw("COLOR") getstr(sf.base_color);
else kw("NOHIDDEN") sf.base_hidden = false;
else gprint("Expecting one of XSTEP, YSTEP, LSTYLE, COLOR found {%s} \n",tk[ct]);
}
}
/* toplines lstyle color hidden */
void pass_droplines() {
sf.droplines = true;
for (ct++;ct<=ntk;ct++) {
kw("LSTYLE") getstr(sf.droplines_lstyle);
else kw("COLOR") getstr(sf.droplines_color);
else kw("HIDDEN") sf.droplines_hidden = true;
else gprint("Expecting one of LSTYLE, COLOR , found {%s} \n",tk[ct]);
}
}
/* toplines lstyle color hidden */
void pass_riselines() {
sf.riselines = true;
for (ct++;ct<=ntk;ct++) {
kw("LSTYLE") getstr(sf.riselines_lstyle);
else kw("COLOR") getstr(sf.riselines_color);
else kw("HIDDEN") sf.riselines_hidden = true;
else gprint("Expecting one of LSTYLE, COLOR , found {%s} \n",tk[ct]);
}
}
/* top lstyle color off */
void pass_top() {
for (ct++;ct<=ntk;ct++) {
kw("LSTYLE") getstr(sf.top_lstyle);
else kw("COLOR") getstr(sf.top_color);
else kw("ON") sf.top_on = true;
else kw("OFF") sf.top_on = false;
else gprint("Expecting one of OFF, LSTYLE, COLOR , found {%s} \n",tk[ct]);
}
}
void pass_bot() {
sf.bot_on = true;
for (ct++;ct<=ntk;ct++) {
kw("LSTYLE") getstr(sf.bot_lstyle);
else kw("COLOR") getstr(sf.bot_color);
else kw("ON") sf.bot_on = true;
else kw("OFF") sf.bot_on = false;
else gprint("Expecting one of ON, OFF, LSTYLE, COLOR , found {%s} \n",tk[ct]);
}
}
void pass_marker() {
getstr(sf.marker);
for (ct++;ct<=ntk;ct++) {
kw("COLOR") getstr(sf.marker_color);
else kw("HEI") sf.marker_hei = getf();
else gprint("Expecting MARKER markername COLOR c HEI h, found {%s} \n",tk[ct]);
}
}
void pass_axis() {
struct GLEAxis3D *ax=NULL;
if (toupper(*tk[ct])=='X') ax = &sf.xaxis;
if (toupper(*tk[ct])=='Y') ax = &sf.yaxis;
if (toupper(*tk[ct])=='Z') ax = &sf.zaxis;
if (ax==NULL) { gprint("Expecting xaxis,yaxis,zaxis, \n"); return;}
for (ct++;ct<=ntk;ct++) {
kw("MIN") {ax->min = getf(); ax->minset = true;}
else kw("MAX") {ax->max = getf(); ax->maxset = true;}
else kw("DTICKS") ax->step = getf();
else kw("TICKLEN") ax->ticklen = getf();
else kw("LEN") ax->ticklen = getf();
else kw("COLOR") getstr(ax->color);
else kw("STEP") ax->step = getf();
else kw("HEI") ax->hei = getf();
else kw("OFF") ax->on = false;
else kw("ON") ax->on = true;
else kw("NOFIRST") ax->nofirst = true;
else kw("NOLAST") ax->nolast = true;
else gprint("Expecting HEI, DIST, COLOR , TICKLEN, MIN, MAX, STEP, found {%s} \n",tk[ct]);
}
}
static char buff[2032];
bool alloc_zdata(int nx, int ny) {
if (z!=NULL) free(z);
z = (float*)malloc(nx * (ny+1) * sizeof(float));
if (z==NULL) {
gprint("Unable to allocate enough memory for datafile\n");
return true;
}
return false;
}
double getkeyval(char *buff,const char *k) {
char *s;
s = str_i_str(buff,k);
if (s!=NULL) return atof(s+strlen(k));
return 0.0;
}
void pass_data(bool force_zdata) {
string fname = getstrv();
if (str_i_ends_with(fname, ".z") || force_zdata) {
pass_zdata(fname,&nx,&ny,&zmin,&zmax);
} else {
pass_points(fname);
}
}
/* data test.z [nx ny] */
//void pass_data(int *nx, int *ny, float *zmin, float *zmax) {
void pass_zdata(string fname,int *nx, int *ny, double *zmin, double *zmax) {
double v;
int x,y,xx,yy;
int c,b,mx = 0,my = 0,xcnt,ycnt;
char *s;
xx = yy = x = y = 0;
*nx = 0; *ny = 0;
for (ct++;ct<=ntk;ct++) {
kw("NX") *nx = (int)getf();
else kw("NY") *ny = (int)getf();
else kw("XSAMPLE") xsample = (int)getf();
else kw("YSAMPLE") ysample = (int)getf();
else kw("SAMPLE") {xsample = (int)getf(); ysample = xsample; }
else gprint("Wanted DATA file.Z XSAMPLE YSAMPLE SAMPLE NX NY. Found {%s} \n",tk[ct]);
}
if (*nx != 0) {
mx = (*nx - 1)/xsample + 1;
my = (*ny - 1)/ysample + 1;
}
xcnt = xsample; ycnt = ysample;
if (nx==NULL || ny==0) printf("nx or ny is zero \n");
if (*nx!=0 && *ny != 0) if (alloc_zdata(*nx,*ny)) return;
df = validate_fopen(fname.c_str(), "r", true);
if (df==NULL) {*nx = 0; *ny = 0; return;}
for (;!feof(df);) {
if (fgets(buff,2000,df)!=NULL) {
if (*nx==0) {
*nx = (int)getkeyval(buff,"NX");
*ny = (int)getkeyval(buff,"NY");
dxmin = getkeyval(buff,"XMIN");
dymin = getkeyval(buff,"YMIN");
dxmax = getkeyval(buff,"XMAX");
dymax = getkeyval(buff,"YMAX");
if (*nx==0 || *ny==0) {
gprint("Expecting ! NX 10 NY 10 in first line of data file \n");
return;
}
mx = (*nx - 1)/xsample + 1;
my = (*ny - 1)/ysample + 1;
if (alloc_zdata(mx,my)) return;
if (fgets(buff,2000,df) == 0) {
return;
}
}
check_again:
b = strlen(buff);
c = buff[b-1];
if (strchr(" \n\t",c)==NULL) { /* we're halfway through a number */
buff[b] = getc(df);
buff[b+1] = 0;
goto check_again;
}
s = strchr(buff,'!');
if (s!=NULL) *s = 0;
s = strtok(buff," \t\n,");
for (;s!=NULL;) {
v = atof(s);
if (isdigit(*s) || *s=='-' || *s=='+' || *s=='.') {
if (x>= *nx) {
if (ycnt==ysample) {ycnt = 0; yy++;}
x = 0; y++; ycnt++; xx = 0; xcnt = xsample;
}
if (y>= *ny) {
gprint("Too much data in data file %ld %d \n",y,*ny);
return;
}
if (v < *zmin) *zmin = v;
if (v > *zmax) *zmax = v;
if (xx<mx && xcnt==xsample && ycnt==ysample) {
z[xx + yy * mx] = v;
xx++;
xcnt = 0;
}
xcnt++;
x++;
} else gprint("Not a number {%s} \n",s);
s = strtok(NULL," \t\n,");
}
}
}
fclose(df);
*ny = my;
*nx = mx;
return;
}
float *pntxyz;
int npnts;
void pnt_alloc(int size) {
static int cursize;
void *d;
if (size+10<cursize) return;
size = size*2;
d = malloc(size*sizeof(float));
if (d==NULL) {
gprint("Unable to allocate storage for POINTS data\n");
gle_abort("memory shortage\n");
}
if (cursize>0) memcpy(d,pntxyz,cursize*sizeof(float));
cursize = size;
pntxyz = (float*)d;
}
void pass_points(string fname) {
double v;
char *s;
int nd,nc;
pnt_alloc(30);
if (ct>ntk) {
gprint("Expecting POINTS filename.xyz \n");
return;
}
df = validate_fopen(fname.c_str(), "r", true);
if (df==NULL) return;
nd = 0;
for (;!feof(df);) {
if (fgets(buff,2000,df)!=NULL) {
s = strchr(buff,'!');
if (s!=NULL) *s = 0;
nc = 0;
s = strtok(buff," \t\n,");
for (;s!=NULL;) {
v = atof(s);
pnt_alloc(nd);
if (isdigit(*s) || *s=='-' || *s=='+' || *s=='.') {
pntxyz[nd++] = v; nc++;
} else gprint("Not a number {%s} \n",s);
s = strtok(NULL," \t\n,");
}
if (nc>0 && nc!=3) {
gprint("Expecting 3 columns in data file, found %d (FATAL ERROR) \n",nc);
}
}
}
fclose(df);
npnts = nd;
sf.pntxyz = pntxyz;
sf.npnts = npnts;
}
/* defaults after data and commands read */
void hide_enddefaults() {
if (dxmin==dxmax) dxmax = nx-1;
if (dymin==dymax) dymax = ny-1;
if (!sf.xaxis.maxset) sf.xaxis.max = dxmax;
if (!sf.yaxis.maxset) sf.yaxis.max = dymax;
if (!sf.xaxis.minset) sf.xaxis.min = dxmin;
if (!sf.yaxis.minset) sf.yaxis.min = dymin;
if (!sf.zaxis.minset) sf.zaxis.min = zmin;
if (!sf.zaxis.maxset) sf.zaxis.max = zmax;
if (sf.zrotate==0 && sf.xrotate==0 && sf.yrotate==0) {
sf.xrotate = 60;
sf.yrotate = 50;
sf.zrotate = 20; /* not needed as is corrected later*/
}
if (sf.eye_x== -1) {
sf.eye_x = sf.sizex/2.0;
sf.eye_y = sf.sizex/2.0;
}
}
void hide_defaults() {
/* Setup some defaults, */
memset(&sf,0,sizeof(sf));
sf.sizey = sf.sizex = 18;
sf.sizey = sf.sizex = sf.sizez = 18;
sf.screenx = 18; sf.screeny = 18;
sf.eye_x = -1;
sf.zaxis.type = 2;
sf.yaxis.type = 1;
sf.xaxis.on = sf.yaxis.on = sf.zaxis.on = true;
sf.xaxis.min = 0;
sf.xaxis.max = 10;
sf.yaxis.min = 0;
sf.yaxis.max = 10;
sf.zaxis.min = 0;
sf.zaxis.max = 10;
sf.cube_hidden_on = true;
sf.cube_on = true;
sf.cube_front_on = false;
sf.xlines_on = true;
sf.ylines_on = true;
sf.hidden_on = true;
sf.top_on = true;
sf.bot_on = false;
sf.base_hidden = sf.right_hidden = sf.back_hidden = true;
strcpy(sf.title_color, "BLACK");
strcpy(sf.cube_color, "BLACK");
strcpy(sf.droplines_color, "BLACK");
strcpy(sf.riselines_color, "BLACK");
strcpy(sf.marker_color, "BLACK");
strcpy(sf.xaxis.color, "BLACK");
strcpy(sf.xaxis.title_color, "BLACK");
strcpy(sf.yaxis.color, "BLACK");
strcpy(sf.yaxis.title_color, "BLACK");
strcpy(sf.zaxis.color, "BLACK");
strcpy(sf.zaxis.title_color, "BLACK");
nx = 0;
ny = 0;
xsample = 1;
ysample = 1;
zclipmin = 0;
zclipminset = false;
zclipmax = 0;
zclipmaxset = false;
zmin = GLE_INF;
zmax = -GLE_INF;
}
|