forked from VB6Hobbyst7/cgx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cgx.c
6845 lines (6154 loc) · 223 KB
/
cgx.c
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
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* -------------------------------------------------------------------- */
/* CALCULIX */
/* - GRAPHICAL INTERFACE - */
/* */
/* A 3-dimensional pre- and post-processor for finite elements */
/* Copyright (C) 1996 Klaus Wittig */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU General Public License as */
/* published by the Free Software Foundation; version 2 of */
/* the License. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* -------------------------------------------------------------------- */
#include <cgx.h>
#include <time.h>
#include <sys/utsname.h>
#define VERSION "2.17"
#define TEST 0
#define GLUT_WEEL_UP 3
#define GLUT_WEEL_DOWN 4
/* special cases: */
/* temporary conversion from old to new bias definition */
int OLD_BIAS_DEF=0;
/* generate sets from pressure-loads */
int MAKE_SETS_DEF=1;
void generalinfo()
{
printf(" -------------------------------------------------------------------- \n");
printf(" CALCULIX \n");
printf(" - GRAPHICAL INTERFACE - \n");
printf(" Version %s \n", VERSION);
printf(" \n");
printf(" \n");
printf(" A 3-dimensional pre- and post-processor for finite elements \n");
printf(" Copyright (C) 1996, 2002 Klaus Wittig \n");
printf(" \n");
printf(" This program is free software; you can redistribute it and/or \n");
printf(" modify it under the terms of the GNU General Public License as \n");
printf(" published by the Free Software Foundation; version 2 of \n");
printf(" the License. \n");
printf(" \n");
printf(" This program is distributed in the hope that it will be useful, \n");
printf(" but WITHOUT ANY WARRANTY; without even the implied warranty of \n");
printf(" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the \n");
printf(" GNU General Public License for more details. \n");
printf(" \n");
printf(" You should have received a copy of the GNU General Public License \n");
printf(" along with this program; if not, write to the Free Software \n");
printf(" Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. \n");
printf(" -------------------------------------------------------------------- \n");
printf("\n usage: cgx [parameter] filename [ccxfile] \n\n");
printf(" Parameters: \n");
printf(" -a auto-mode, geometry file derived from a cad-file must be provided \n");
printf(" -ansl reads a concatenated ansys list file (nodes,elems,temps) \n");
printf(" -b build-mode, geometry (command) file must be provided \n");
printf(" -bg background, suppress creation of graphic output \n");
printf(" otherwhise as -b, geometry (command) file must be provided \n");
printf(" -c read an solver input file (ccx) \n");
printf(" -duns2d read duns result files (2D) \n");
printf(" -duns3d read duns result files (3D) \n");
printf(" -duns2dl read duns result files (2D) (long format) \n");
printf(" -duns3dl read duns result files (3D) (long format) \n");
printf(" -foam read openFoam result files \n");
printf(" -isaac2d [-pref<val> -tref<val> -R<val>] read isaac result files (2D) \n");
printf(" -isaac3d [-pref<val> -tref<val> -R<val>] read isaac result files (3D) \n");
printf(" -f06 read Nastran f06 file \n");
printf(" -ng read Netgen native format \n");
printf(" -tg read Tetgen native format \n");
printf(" -step read a step file (only points and lines) \n");
printf(" -stepsplit read step and write its single parts to the filesystem \n");
printf(" -stl read stl triangles \n");
printf(" -v (default) read a result file in frd-format and optional a solver \n");
printf(" input file (ccx) which provides the sets and loads used in the \n");
printf(" calculation. \n");
printf(" \n");
printf(" special purpose options: \n");
printf(" -mksets make node-sets from *DLOAD-values (setname:''_<value>'')\n");
printf(" -read forces the program to read the complete result-file \n");
printf(" at startup \n");
printf(" \n");
}
/*
Necessary system-routines and libs:
glut
openGL, libGL and libGLU (the one from SGI which handles nurbs)
system
sort
rm
*/
/*
Necessary stand alone programs:
- for postscript Hardcopys
convert
- for multi-picture postscript Hardcopys
convert, pstops (from psutils), ghostscript (new version (2015) replace -sDEVICE=pswrite with ps2write)
- for 2D plots
gnuplot
- for online-help
netscape, or other html-browser
*/
/*
TODO:
- "big" node and element numbers should be possible, hash-table has to be implemented
*/
/*
POSSIBLE TROUBLE:
- if(flipflop) etc. was commented. might cause trouble on some systems with movi and hcpy
- some points and sets might use the same name. This leads to problems with lines. The line command
determines if it is a center-point or a sequence (seqa) based on the name of the track-parameter.
If a point and a seqa use both the specified name then only a sraight line can be generated.
In the moment the problem is dealed with in a way that the seqa-names start with an "A" and points start with a "D"
But if the user has named this entities himself then a crash might still happen.
- seach NEWELEM: This block might be unnecessary. Has to be checked
*/
/*
Known bugs:
- search for debug
*/
/* keyboard history */
char **key_history=(char **)NULL;
int nkey_history=0, key_pointer, curshft=0;
char keystroke[MAX_LINE_LENGTH];
/* Display-lists */
GLuint list_model_edges, list_surf_edges, list_elem_edges ;
GLuint list_elem_light, list_elem_load, list_elem_elstress;
GLuint list_surf_light, list_surf_load;
GLuint list_anim_light, list_anim_model_edges, list_anim_surf_edges, list_anim_elem_edges;
GLuint *list_animate=NULL, *list_animate_model_edges=NULL, *list_animate_surf_edges=NULL, *list_animate_elem_edges=NULL;
GLint range_animate_light;
Summen anz[1];
SumGeo anzGeo[1];
SumAsci sumAsci[1];
SpecialSet specialset[1];
int set_bsur, set_nomesh, set_glur, set_blr;
Nodes *node=NULL;
Datasets *lcase=NULL;
NodeBlocks *nBlock;
Alias *alias=NULL;
Sets *set=NULL;
Shapes *shape=NULL;
Materials *material=NULL;
Amplitudes *amplitude=NULL;
Psets *pset=NULL;
Values *value=NULL;
Points *point=NULL;
Lines *line=NULL;
Lcmb *lcmb=NULL;
Gsur *surf=NULL;
Gbod *body=NULL;
Nurbl *nurbl=NULL;
Nurbs *nurbs=NULL;
BGpicture *bgpicture;
Elements *e_enqire=NULL; /* elem-array indexed by elem-number */
double *vp=NULL;
Scale scale[1];
Faces *face;
Edges *edge=NULL; /* model-edges */
Texts *ntext=NULL; /* user texts */
Meshp meshp={ALPHA,BETA,NADAPT,TETMESHER}; /* mesh parameters for tr3u elements. Used in mesh2d and the brand of the tetmesher */
double *colNr;
GLfloat *contur_tex=NULL;
/* for CFD-meshing */
double pref=1.e5, tref=288., R_GAS=287.1;
struct utsname cursys[1];
int bitplanes; /* colorbuffer depth */
Display *dpy;
int dpycells;
Colormap cmap;
XColor *xcolor;
unsigned long *pixels_return;
unsigned int npixels;
double priv_cmap[256][3];
/* Main-Prog and GLUT-Window Management */
char datin[MAX_LINE_LENGTH]; /* cgx input file */
char ccxfile[MAX_LINE_LENGTH]; /* ccx input file */
char browser[MAX_LINE_LENGTH]=BROWSER; /* html-browser */
char psviewer[MAX_LINE_LENGTH]=PSVIEWER; /* postscript viewer */
char helpfile[10][MAX_LINE_LENGTH]=HELPFILE; /* help-file */
char initfile[MAX_LINE_LENGTH]=INITFILE; /* commands executed at startup */
char homepath[MAX_LINE_LENGTH]; /* path to the home dir */
int width_ini={INI_SCREEN}, height_ini={INI_SCREEN}; /* Grafik-Fensterbreite/hoehe */
int width_menu={INI_MENU_WIDTH}, height_menu={INI_MENU_HEIGHT};
int width_w0=0, height_w0=0;
int width_w1, height_w1;
double aspectRatio_w1=1.; /* width_w1/height_w1 */
int open_cgxs; /* No. of cgx-sessions on that screen */
int w0, w1, w2, w3; /* window identifier */
int activWindow={-1}; /* das aktuelle Fenster */
int animList=0; /* die aktuelle Displayliste fuer animation */
//void (*currDisplayFunc)(void)=NULL; /* pointer to the current glutDisplayFunc() */
int col_maxc=DEF_COL,col_minc=DEF_COL; /* colors of the regions with clipped colors (commands maxc,minc) */
int defScalMethod=0; /* method to display the scale */
int basCol[3]={0,1,2}; /* color indexes due to basic colormap: 0=black 1=white 2=neutral (grey) */
int foregrndcol=0, backgrndcol=1; /* default fore- and background color */
double foregrndcol_rgb[4]={0.,0.,0.,1.};
double backgrndcol_rgb[4]={1.,1.,1.,1.};
char entity_k[SET_COLS]={'k','w','n','r','g','b','y','m','t','c','o'}; /* predefined colors of entities */
GLfloat entity_r[SET_COLS]={ 0., 1., .6, 1., 0., 0., 1., 1., 0., .6, 1. };
GLfloat entity_g[SET_COLS]={ 0., 1., .6, .0, 1., 0., 1., 0., 1., .3, .5 };
GLfloat entity_b[SET_COLS]={ 0., 1., .6, .0, 0., 1., 0., 1., 1., .0, 0. };
int entitycols;
Entitycol *entitycol;
GLfloat edgeWidth=2; /* width of the model edges, changed with 'view' */
int submenu_load=-1, submenu_view=-1, mainmenu=-1; /* menu identifier */
int submenu_scala=-1, submenu_animate=-1, submenu_cut=-1, submenu_graph=-1, submenu_help=-1;
int submenu_orientation=-1, submenu_hardcopy=-1, submenu_user=-1;
int subsubmenu_entity=-1, subsubmenu_parameter=-1;
int subsubmenu_animTune=-1, subsubmenu_animSteps=-1;
int subsubmenu_animPeriod=-1;
int userCommands=0;
char **userCommand=NULL;
GLfloat lmodel_twoside = GL_TRUE ;
GLfloat lmodel_oneside = GL_FALSE ;
double dx ,dy; /* Mauskoordinaten im bereich +-1*/
int xpixels ,ypixels; /* Mauskoordinaten in pixel, links unten 0,0 */
double beginx, beginy; /* letzter mousepoint */
double trackbsize={0.8}; /* TRACKBALLSIZE */
double curquat[4]; /* Matrix aus Trackball */
double lastquat[4]; /* letzte Matrix aus Trackball*/
GLint gl_max_eval_order=8; /* max order of NURBS */
int MouseMode; /* status maustasten */
GLdouble dx_cur={PICK_LENGTH}, dy_cur={PICK_LENGTH}; /* pick-cursor Area */
GLdouble R[4][4]; /* Rotationsmatrix */
GLdouble dR[4][4]; /* dR= R-Rmem fuer center */
GLdouble Rmem[4][4];
double v[4]; /* drehkorrekturen fuer centerPkt */
double vmem[4]; /* kor. bis auswahl eines neuen drehpkts */
char v_dim=0; /* 1: scalar plot, 2: a 2D vector plot, 3: a 3D vectorplot, 4: a 3D vectorplot with signed vals */
int movieFrames=0; /* if >0 number of frames until the movie is created. frame generation stops then. */
char movieCommandFile[MAX_LINE_LENGTH]; /* stores the file name of a command file which will be executed after the movie is created (frames option only) */
int seqLC[4], seq_nlc=0; /* selected ds for sequence (1. start, 2. defines step-with, 3. end, seq_nlc might be 1 to 3 */
DsSequence dsSequence; /* datasets (ds) for sequence of results */
int lcase_animList={-1}; /* additional lcase for the values of the animation */
int read_mode=0; /* if 1 read data immediatelly, else read on demand */
int step_mode=0; /* if 1 read step data and write the single parts from an assembly to the filesystem */
int centerNode=0; /* Nr of center Node, 0:no centernode */
// Colormap name
// Possible values: "classic", "viridis", "turbo", "inferno"
char cmap_name[] = "classic";
char inpformat=0; /* defines the start-up mode of cgx */
char allowSysFlag=ALLOW_SYS_FLAG; /* 1: allow the execution of system calls (sys command) */
char autoDivFlag=1; /* The div command will set it to 0 and no auto-div is executed */
char autoEltyFlag=1; /* The elty command will set it to 0 and no auto-elty is executed */
char fixBadDivFlag=0; /* 1: mesh routine loops until a limit is reached (MAX_REFINEMENT_LOOPS) or all surfs are meshed */
char cullFlag=0; /* 1: front face culling */
char iniActionsFlag=0; /* if set to 1 actions during idle will be performed */
char readfbdFlag=0; /* 1: currently reading a command file */
char frameFlag={1}; /* mit (1) oder ohne Rahmen um das Grafikfenster */
char captionFlag={1}; /* mit (1) oder ohne filename im Menufenster */
char textFlag={1}; /* mit (1) oder ohne text im Menufenster */
char commandLineFlag={0}; /* mit (1) oder ohne Kommandozeile im Menufenster */
char printFlag=0; /* printf on/off on=1 (kommando 'msg' 'on'|'off' )*/
char scalaFlag={1}; /* mit (1) oder ohne scala und wertetexte */
char sequenceFlag=0; /* 1: play a sequence of LC */
char vectorFlag=0; /* 0: scalar plot, 1: vector plot */
char addDispFlag=0; /* 0: original node-coordinates, 1: node-coordinates+displacements */
char flipColorFlag=0; /* 0: high values use red, low use blue in scale; 1: flipped */
char graphFlag=0; /* 0:out, 1:graph line, 2: graph n, 3: graph t */
char cutFlag=0; /* 0:out, 1: last node selected, cut structure */
char illumFlag=0; /* sequence with illumination */
char illumResultFlag=ILLUMINATE_RESULTS; /* results with illumination */
char movieFlag=0; /* >0: save sequence of gif pictures */
char rulerFlag=0; /* 1: drawRu1er in window w1 */
char rulerString[MAX_LINE_LENGTH]; /* units */
char automode=0; /* set to 1 to perform various automatic actions as determining of divisions etc. during reading of command files */
char animFlag={0}; /* animation of the selected Dataset */
char blendFlag={0}; /* 1: transparent representation */
char surfFlag={1}; /* zeichne nur Oberflaechenelemente (1), sonst (0)*/
char modelEdgeFlag={1}; /* zeichne mit Kanten (1), sonst (0)*/
char elemEdgeFlag={0}; /* zeichne mit Surface Kanten (1), sonst (0)*/
char modelEdgeFlag_Static={0}; /* zeichne mit Kanten (1), sonst (0), stehende Kanten waerend animationen */
char elemEdgeFlag_Static={0}; /* zeichne mit Surface Kanten (1), sonst (0)*, stehende Kanten waerend animationen */
char drawMode={2}; /* actual draw-function (Load=1, Light=2, 3 not used, Preprocessor=4, Vector=5)*/
char stopFlag=0; /* stop/start animation */
char zoomFlag={0}; /* (1) zoom Modus */
char centerFlag={0}; /* (1) search centerPnt */
char enquireFlag={0}; /* (1) enquire node-values */
char movezFlag={0}; /* (1) move Model in Z Direction through the cuting plane */
char pickfunc[MAX_LINE_LENGTH]; /* pick-function like "qenq" "qadd" "qrem" .. */
char pickFlag={0}; /* 1 if picking is active */
char delPntFlag={0}; /* 1: deleted points exists */
char delShapeFlag={0}; /* 1: deleted shapes exists */
char delLineFlag={0}; /* 1: deleted lines exists */
char delLcmbFlag={0}; /* 1: deleted lcmbs exists */
char delSurfFlag={0}; /* 1: deleted surfs exists */
char delBodyFlag={0}; /* 1: deleted bodys exists */
char delNursFlag={0}; /* 1: deleted Nurbs exists */
char delSetFlag={0}; /* 1: deleted sets exists */
char hcpyFlag={0}; /* triggers createHardcopy if !=0 */
int frameSetFlag={-2}; /* triggers frameSet() */
char mode[2]={'i'}; /* pickmode */
double minvalue, maxvalue; /* Wertebereich */
int steps={21}; /* Schrittweite der Farbscala */
int offset, maxIndex; /* offset+steps-1 = maxIndex */
int anim_steps={8}; /* Animationen pro Schwingung */
double anim_faktor={1.}; /* Scalierung der Amplitude */
int *anim_alfa; /* amplitude der Animation fuer Bildbeschriftung */
int time_per_period={MILLISECONDS_PER_PERIOD}; /* fuer Animation */
int frameNr={0}; /* zaehlt alle animierten Bilder */
int halfperiod={0}; /* 1:Animation nur der posit. Halbperiod */
int hcpy={0}; /* hcpy=1 Hardcopy angefordert */
double dtx={0.}, dty={0.}, dtz={0.}, drx, dry, drz, ds={0.5}; /* Verschiebungen */
double centerPnt[3]; /* Rotationszentrum */
int cur_entity={0}; /* aktive entity (component), entity in menu= cur_entity+1*/
int entity_v[6]; /* components of a vector-entity */
double v_factor; /* scaling-factor for the vectors in the vector-plot */
double v_scale={1.}; /* additional scaling-factor for the vectors */
int pre_lc={0}; /* pre-selected Dataset, active after entity is selected */
int cur_lc={0}; /* aktive Dataset */
int entity_buf=0;
void *glut_font[]=GLUT_FONT; /* glut fonts */
int pixPerCharx[]=GLUT_FONT_WIDTH;
int pixPerChary[]=GLUT_FONT_HEIGHT;
int legend_font=DEF_GLUT_FONT; /* active font for the legend */
int draw_font=DEF_GLUT_FONT; /* active font for the annotation of entities */
int menu_font=SUM_GLUT_FONTS-1; /* active font for the menu */
int elemMat[MAX_MATERIALS]={1,1}; /* Material Numbers, Number of Materials stored in elemMat[0] */
int nasMpc=1; /* 1: areampc generates mpcs; 0: rbes with optional heat-expansion-coefficient */
double nasRbeHec=0.;
char picture_caption[MAX_LINE_LENGTH]= {""}; /* Caption on window base line */
char picture_text[MAX_LINE_LENGTH]= {""}; /* Text on window base line */
double gtol={GTOL}, gtol_buf; /* geometric tolerance for merging in absolute coordinates */
int ddiv={DEF_LINE_DIV};
double dbias=1;
int neqn={0}; /* start-number of equations in ansys, MID in nastran */
int setall=0; /* setNr of the default set "all" */
/* nr of hardcopies */
int psNr=0, tgaNr=0, gifNr=0, pngNr=0;
/* track the open sets */
OpenSets openSets[1];
/* the copied node-sets which have to be filled with values from new loaded Datasets */
CopiedNodeSets copiedNodeSets[1];
/* element quality thresholds */
Eqal eqal={0.,0.,0.};
/* buffer to store related infos for the temporory qcut-nodes, used for data-interpolation */
Qcut_nodes *qcut_nod=NULL;
/* buffer to store values */
char **valuestack=NULL;
int valuestack_ptr=0, valuestackFlag=0;
/* buffer to write to stack */
char **parameter;
/* string buffer */
char buffer[MAX_LINE_LENGTH];
/* threading */
sem_t sem_n;
sem_t sem_g;
sem_t sem_rep;
sem_t sem_stn;
int askGLError(char buffer[MAX_LINE_LENGTH])
{
GLenum error = glGetError();
if (error == (GLenum)GL_NO_ERROR) return(1);
else if (error == (GLenum)GL_INVALID_ENUM) printf ("in:%s GL_INVALID_ENUM\n",buffer);
else if (error == (GLenum)GL_INVALID_VALUE) printf ("in:%s GL_INVALID_VALUE \n",buffer);
else if (error == (GLenum)GL_INVALID_OPERATION) printf("in:%s GL_INVALID_OPERATION\n",buffer);
else if (error == (GLenum)GL_STACK_OVERFLOW) printf ("in:%s GL_STACK_OVERFLOW\n",buffer);
else if (error == (GLenum)GL_STACK_UNDERFLOW) printf ("in:%s GL_STACK_UNDERFLOW\n",buffer);
else if (error == (GLenum)GL_OUT_OF_MEMORY) printf ("in:%s GL_OUT_OF_MEMORY\n",buffer);
else {printf("glGetError detects unknown error %d in:%s\n", error, buffer); return (-1);}
return (0);
}
/* realloc_colNr() must be executed before the call to nodalDataset() and each time new nodes were created */
void realloc_colNr(void)
{
int i;
if ( (colNr = (double *)realloc((double *)colNr, (anz->nmax+1) * sizeof(double))) == NULL )
printf("\n\n ERROR: realloc failed colNr\n\n") ;
else
for(i=0; i<=anz->nmax; i++) colNr[i]=0.;
}
/* the node pointer must not be changed inside the function. Since that is the case the *node is changed to *node_dummy
and the global *node is used which is always correct so far */
/* realloc_colNr() must be executed before the call to this function and each time new nodes were created */
void nodalDataset( int entity, int lc, Summen *anz, Scale *scale, Nodes *node_dummy, Datasets *lcase, double *colNr, int scalaFlag )
{
int i,j,n;
int n1, n2, settmp, allNodesFlag;
int nmax=0, nmin=0;
double vmax=0, vmin=0; /* max,min Werte der values */
double ds,max,min,divisor;
#if TEST
printf ("in nodalDataset drawMode:%d\n",drawMode );
#endif
if(!anz->l)
{
printf(" WARNING: No values available (should not come to this point)\n");
return;
}
/* check if the data of the specified lcase (Dataset) are already available */
if (!lcase[lc].loaded)
{
if( pre_readfrdblock(copiedNodeSets , lc, anz, node, lcase )==-1)
{
printf("ERROR in nodalDataset: Could not read data for Dataset:%d\n", lc+1);
return;
}
calcDatasets( lc, anz, node, lcase );
recompileEntitiesInMenu(lc);
}
/* if currently a section (qcut) is in use realloc the lcase and generate the necessary values */
settmp=getSetNr("-qcut");
if(settmp>-1) updLcase(lc, settmp);
else
{
if ( (lcase[lc].dat[entity] = (float *)realloc(lcase[lc].dat[entity], (anz->nmax+1) * sizeof(float))) == NULL )
{ printf("\n\n ERROR: realloc failure updLcase\n\n" ); return; }
}
/* check if the specified lcase-component is allocated */
if (entity>=lcase[lc].ncomps )
{
errMsg("ERROR: Component not available\n");
return;
}
/* remove the displacements on node-coords if the time-step has changed */
// TBD: do only if (lcase[selection].step_number!=lcase[cur_lc].step_number)
if(addDispFlag==1)
{
printf("\n displacements will be updated\n");
addDispToCoordinates(node);
addDispToCoordinates(node);
}
for (i=0; i<anz->n; i++ )
{
if(node[node[i].nr].pflag==0) continue;
lcase[lc].dat[entity][node[i].nr] = 9999999999;
}
for ( i=0; i<anz->e; i++ )
{
switch(e_enqire[e_enqire[i].nr].type)
{
case 4:
for (n=0; n<3; n++) /* create new vals at nodes in center of areas */
{
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[20+n]] = -0.25* (
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[0+n]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[1+n]] +
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[5+n]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[4+n]] ) + 0.5*(
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[8+n]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[13+n]] +
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[16+n]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[12+n]]) ;
}
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[23]] = -0.25* (
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[3]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[0]] +
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[4]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[7]] ) + 0.5*(
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[11]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[12]] +
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[19]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[15]]) ;
for (n=0; n<2; n++)
{
n1=n*4;
n2=n*8;
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[24+n]] = -0.25* (
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[0+n1]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[1+n1]] +
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[2+n1]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[3+n1]] ) + 0.5*(
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[8+n2]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[9+n2]] +
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[10+n2]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[11+n2]]) ;
}
break;
case 5:
for (n=0; n<2; n++)
{
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[15+n]] = -0.25* (
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[0+n]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[1+n]] +
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[4+n]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[3+n]] ) + 0.5*(
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[6+n]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[10+n]] +
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[12+n]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[ 9+n]]) ;
}
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[17]] = -0.25* (
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[2]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[0]] +
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[3]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[5]] ) + 0.5*(
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[ 8]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[ 9]] +
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[14]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[11]]) ;
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[18]] = -0.25* (
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[0]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[2]] +
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[1]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[0]] ) + 0.5*(
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[ 8]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[ 7]] +
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[ 6]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[ 0]]) ;
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[19]] = -0.25* (
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[3]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[4]] +
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[5]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[3]] ) + 0.5*(
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[12]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[13]] +
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[14]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[ 3]]) ;
break;
case 10:
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[8]] = -0.25* (
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[0]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[1]] +
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[3]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[2]])+0.5*(
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[4]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[6]] +
lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[7]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[5]]);
break;
}
}
/* ------------ Darstellung scalieren ------------------- */
if(scalaFlag)
{
/* scan all nodes of all entities which are used on the display */
allNodesFlag=0;
for (j=0; j<anzGeo->psets; j++ )
{
if ((set[pset[j].nr].name[0] == 'a')&&(set[pset[j].nr].name[1] == 'l')&&(set[pset[j].nr].name[2] == 'l')&&(set[pset[j].nr].name[3] == 0))
{
allNodesFlag=1;
break;
}
}
if((allNodesFlag)||(anzGeo->psets==0))
{
vmax=lcase[lc].max[entity];
vmin=lcase[lc].min[entity];
nmax=lcase[lc].nmax[entity];
nmin=lcase[lc].nmin[entity];
}
else
{
/* adjust the scala */
vmin=MAX_FLOAT;
vmax=-MAX_FLOAT;
delSet(specialset->tmp);
if( (settmp=pre_seta( specialset->tmp, "i", 0 )) <0 ) return;
for (j=0; j<anzGeo->psets; j++ )
{
if (pset[j].type[1]=='v')
{
if (pset[j].type[0]=='f') for(i=0; i<set[pset[j].nr].anz_f; i++) seta( settmp, "f", set[pset[j].nr].face[i] );
if (pset[j].type[0]=='e') for(i=0; i<set[pset[j].nr].anz_e; i++) seta( settmp, "e", set[pset[j].nr].elem[i] );
//if (pset[j].type[0]=='n') for(i=0; i<set[pset[j].nr].anz_n; i++) seta( settmp, "n", set[pset[j].nr].node[i] );
}
}
completeSet( specialset->tmp, "do");
for (i=0; i<set[settmp].anz_n; i++ )
{
if(lcase[lc].dat[entity][set[settmp].node[i]] < vmin ) { vmin = lcase[lc].dat[entity][set[settmp].node[i]]; nmin=set[settmp].node[i]; }
if(lcase[lc].dat[entity][set[settmp].node[i]] > vmax ) { vmax = lcase[lc].dat[entity][set[settmp].node[i]]; nmax=set[settmp].node[i]; }
}
delSet(specialset->tmp);
/* if no plotset is defined */
if(vmin==MAX_FLOAT)
{
vmax=lcase[lc].max[entity];
vmin=lcase[lc].min[entity];
nmin=lcase[lc].nmin[entity];
nmax=lcase[lc].nmax[entity];
}
}
if(scale->smin==scale->smax)
{
scale->smin=vmin;
scale->smax=vmax;
}
printf ("\n%d %s %f %s %s %s\n", lc+1, lcase[lc].dataset_name, lcase[lc].value, lcase[lc].dataset_text, lcase[lc].name, lcase[lc].compName[entity] );
printf (" Extremal values from displayed mesh-entities:\n max:%e at node:%d\n min:%e at node:%d\n", vmax, nmax, vmin, nmin);
sprintf(parameter[0],"%d", lc+1);
sprintf(parameter[1],"%s", lcase[lc].dataset_name);
sprintf(parameter[2],"%e", lcase[lc].value);
sprintf(parameter[3],"%s", lcase[lc].dataset_text);
sprintf(parameter[4],"%s", lcase[lc].name);
sprintf(parameter[5],"%s", lcase[lc].compName[entity]);
sprintf(parameter[6],"%e", vmax);
sprintf(parameter[7],"%d", nmax);
sprintf(parameter[8],"%e", vmin);
sprintf(parameter[9],"%d", nmin);
write2stack(10, parameter);
/* recalculate max,min if a clipped scale is to be used (as in scala_tex())*/
max=scale->smax;
min=scale->smin;
divisor=steps;
if(scale->smaxr) divisor--;
if(scale->sminr) divisor--;
ds=(max-min)/divisor;
if(scale->smaxr) max+=ds;
if(scale->sminr) min-=ds;
for (i=0; i<anz->n; i++ )
{
if(node[node[i].nr].pflag==-1) continue;
//printf("i:%d n:%d e:%d lc:%d smin:%f v:%f\n", i,node[i].nr,entity,lc,scale->smin,lcase[lc].dat[entity][node[i].nr]);
if ( lcase[lc].dat[entity][node[i].nr] <= min )
{
colNr[node[i].nr] = 0.;
}
else if ( lcase[lc].dat[entity][node[i].nr] >= max )
{
colNr[node[i].nr] = (double)steps/(double)TEX_PIXELS;
}
else
{
colNr[node[i].nr] = (lcase[lc].dat[entity][node[i].nr]-min)/(max-min) *(double)steps/(double)TEX_PIXELS;
}
}
}
}
void elementDataset( int entity, int lc, Summen *anz, Scale *scale, Datasets *lcase, int offset, int maxIndex, int steps )
{
int i;
double **vp;
//double vmax, vmin; /* max,min Werte der values */
//int nmax, nmin; /* nodes der max/min-Werte */
if(!anz->l)
{
printf(" WARNING: No values available\n");
return;
}
if ( (vp = (double **)malloc( (anz->emax+1) * sizeof(double))) == NULL )
printf("\n\n ERROR: malloc failed vp\n");
for (i=0; i<(anz->emax+1); i++)
if ( (vp[i] = (double *)malloc( (2) * sizeof(double))) == NULL )
printf("\n\n ERROR: malloc failed vp[%d]\n", i);
/* check if the specified lcase-component is allocated */
/*
if (lcase[lc].edat[entity] == NULL )
errMsg("ERROR: Component not available\n");
else
{
for (i=0; i<num_etype[11]; i++ )
{
for (j=0; j<2; j++ )
{
vp[i][j] = lcase[lc].edat[entity][cbeam[i].elem_nr][j];
}
}
}
vmax=lcase[lc].max[entity];
vmin=lcase[lc].min[entity];
printf ("\nDataset:%d name= %s", lc+1, lcase[lc].name);
printf (" entity:%s\n", lcase[lc].compName[entity] );
printf (" maxvalue:%e\n minvalue:%e \n", vmax, vmin);
for (i=0; i<num_etype[11]; i++ )
{
for (j=0; j<2; j++ )
{
if (scale->smin==0)
{
scale->smin = vmin;
}
if (scale->smax==0)
{
scale->smax = vmax;
}
if ( vp[i][j] <= scale->smin )
{
cbeam[i].ncol[j][0] = 0.;
}
if ( vp[i][j] >= scale->smax )
{
cbeam[i].ncol[j][0] = 1.;
}
if ( (vp[i][j] > scale->smin) && (vp[i][j] < scale->smax) )
{
cbeam[i].ncol[j][0] = (vp[i][j]-scale->smin)/(scale->smax-scale->smin);
}
printf ("v:%lf col:%lf \n", vp[i][j], cbeam[i].ncol[j][0] );
}
}
*/
for (i=0; i<(anz->emax+1); i++) if (vp[i]) free(vp[i]);
if (vp) free(vp);
}
/* from j. baylor for tga-screen-shot */
int WriteTGA(char *filename,
short int width,
short int height,
char *imageData) {
char cGarbage = 0;
char pixelDepth = 32;
char type = 2; // type = 2 for pixelDepth = 32 | 24, type = 3 for greyscale
char mode = 4; // mode = pixelDepth / 8
char aux;
short int iGarbage = 0;
FILE *file;
int i;
// open file and check for errors
file = fopen(filename, "wb");
if (file == NULL) return(-1);
// write the header
fwrite(&cGarbage, sizeof(char), 1, file);
fwrite(&cGarbage, sizeof(char), 1, file);
fwrite(&type, sizeof(char), 1, file);
fwrite(&iGarbage, sizeof(short int), 1, file);
fwrite(&iGarbage, sizeof(short int), 1, file);
fwrite(&cGarbage, sizeof(char), 1, file);
fwrite(&iGarbage, sizeof(short int), 1, file);
fwrite(&iGarbage, sizeof(short int), 1, file);
fwrite(&width, sizeof(short int), 1, file);
fwrite(&height, sizeof(short int), 1, file);
fwrite(&pixelDepth, sizeof(char), 1, file);
fwrite(&cGarbage, sizeof(char), 1, file);
// convert the image data from RGB(a) to BGR(A)
if (mode >= 3)
for (i=0; i < width * height * mode ; i+= mode) {
aux = imageData[i];
imageData[i] = imageData[i+2];
imageData[i+2] = aux;
}
// save the image data
fwrite(imageData, sizeof(char), width * height * mode, file);
fclose(file);
return(0);
}
/* This will save a screen shot to a file. */
void SaveTGAScreenShot(char *filename, int w, int h)
{
char *imageData;
imageData = (char *)malloc(sizeof(char) * w * h * 4);
glReadPixels(0, 0, w, h,GL_RGBA,GL_UNSIGNED_BYTE, (GLvoid *)imageData);
WriteTGA(filename,w,h,imageData);
// release the memory
free(imageData);
}
void getTGAScreenShot(int nr)
{
char buffer[MAX_LINE_LENGTH];
if(!inpformat) return;
glutSetWindow(w0);
SaveTGAScreenShot("0__.tga", glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
glutSetWindow(w1);
SaveTGAScreenShot("1__.tga", glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
glutSetWindow(w2);
SaveTGAScreenShot("2__.tga", glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
glutSetWindow(activWindow);
while( access( "0__.tga", F_OK ) != 0 );
while( access( "1__.tga", F_OK ) != 0 );
while( access( "2__.tga", F_OK ) != 0 );
//sprintf( buffer, "composite -compose atop -gravity SouthWest -geometry +1+1 2__.tga 1__.tga 3__.tga");
sprintf( buffer, "composite -gravity SouthWest -geometry +1+1 2__.tga 1__.tga 3__.tga");
system (buffer);
while( access( "3__.tga", F_OK ) != 0 );
//sprintf( buffer, "composite -compose atop -gravity NorthWest -geometry +%d+%d 3__.tga 0__.tga hcpy_%d.tga",
sprintf( buffer, "composite -alpha off -gravity NorthWest -geometry +%d+%d 3__.tga 0__.tga hcpy_%d.tga",
(GLint)width_menu*19/20, (GLint)height_menu/10, nr);
system (buffer);
//printf("%s",buffer);
sprintf( buffer, "rm -f *__.tga %s",DEV_NULL);
system (buffer);
}
/* end tga-screen-shot */
void createHardcopy( int selection, char *filePtr )
{
char buffer[MAX_LINE_LENGTH];
char fileName[MAX_LINE_LENGTH];
if(!inpformat) return;
if(selection==0)
{
/* generate movie from single gif files */
sprintf( buffer, "make 1. %lf",(double)gifNr);
pre_movie(buffer);
sprintf( buffer, "clean");
pre_movie(buffer);
gifNr=0;
}
else
{
/* Hardcopy */
if(selection==1)
{
psNr++;
if(filePtr!=NULL) sprintf(fileName,"%s.ps",filePtr); else sprintf(fileName,"hcpy_%d.ps",psNr);
printf("create %s\n ",fileName);
getTGAScreenShot(psNr);
/* on some systems PS has to be changed to PS2 */
//sprintf( buffer, "convert -density %dx%d -page +49+196 -gamma %lf hcpy_%d.tga PS:hcpy_%d.ps ", (int)((double)(PS_DENSITY*width_w0)/(double)(INI_SCREEN+INI_MENU_WIDTH)),(int)((double)(PS_DENSITY*width_w0)/(double)(INI_SCREEN+INI_MENU_WIDTH)) , GAMMA, psNr, psNr);
sprintf( buffer, "convert hcpy_%d.tga -page A4 %s", psNr, fileName);
system (buffer);
printf("%s\n", buffer);
sprintf( buffer, "rm -f hcpy_%d.tga %s",psNr,DEV_NULL);
system (buffer);
sprintf( parameter[0], "%s", fileName);
sprintf( parameter[1], "%d", psNr);
write2stack(2, parameter);
printf ("ready\n");
}
if(selection==2)
{
tgaNr++;
getTGAScreenShot(tgaNr);
if(filePtr!=NULL)
{
sprintf(fileName,"%s.tga",filePtr);
sprintf( buffer, "mv -f hcpy_%d.tga %s", tgaNr, fileName);
system (buffer);
}
else sprintf(fileName,"hcpy_%d.tga",tgaNr);
printf("create %s\n ",fileName);
sprintf( parameter[0], "%s", fileName);
sprintf( parameter[1], "%d", tgaNr);
write2stack(2, parameter);
printf ("ready\n");
}
if(selection==3)
{
/* movie gif files */
getTGAScreenShot(0);
while( access( "hcpy_0.tga", F_OK ) != 0 );
gifNr++;
sprintf( buffer, "convert hcpy_0.tga _%d.gif",gifNr);
printf("%s\n",buffer);
system (buffer);
if((movieFrames)&&(gifNr>=movieFrames))
{
animList=0;
movieFrames=0;
movieFlag=0;
sprintf( buffer, "rm -f hcpy_0.tga %s", DEV_NULL2);
system (buffer);
createHardcopy(0, NULL);
/* read a cgx-command file which will be executed after the movie is created */
if(strlen(movieCommandFile))
{
pre_read(movieCommandFile);
}
}
}
if(selection==4)
{
gifNr++;
if(filePtr!=NULL) sprintf(fileName,"%s.gif",filePtr); else sprintf(fileName,"hcpy_%d.gif",gifNr);
printf("create %s\n ",fileName);
getTGAScreenShot(gifNr);
sprintf( buffer, "convert hcpy_%d.tga %s", gifNr, fileName);
system (buffer);
sprintf( buffer, "rm -f hcpy_%d.tga %s",gifNr,DEV_NULL);
system (buffer);
sprintf( parameter[0], "%s", fileName);
sprintf( parameter[1], "%d", gifNr);
write2stack(2, parameter);
printf ("ready\n");
}
if(selection==5)
{
pngNr++;
if(filePtr!=NULL) sprintf(fileName,"%s.png",filePtr); else sprintf(fileName,"hcpy_%d.png",pngNr);
printf("create %s\n ",fileName);
getTGAScreenShot(pngNr);
sprintf( buffer, "convert hcpy_%d.tga %s", pngNr, fileName);
system (buffer);
sprintf( buffer, "rm -f hcpy_%d.tga %s",pngNr,DEV_NULL);
system (buffer);
sprintf( parameter[0], "%s", fileName);
sprintf( parameter[1], "%d", pngNr);
write2stack(2, parameter);
printf ("ready\n");
}
}
}
void entryfunktion( int state )
{
if (state==GLUT_ENTERED)
{
activWindow=w1;
glutSetWindow(activWindow );
glutPostRedisplay();
glutSetWindow( w2);
glutPostRedisplay();
}
else
{
activWindow=w0;
glutSetWindow(activWindow );
glutPostRedisplay();
}
}
void WindowState( int state )
{
if (state==GLUT_NOT_VISIBLE)
activWindow=w0;
}
void Mouse( int x, int y )
{
if (glutGet(GLUT_WINDOW_HEIGHT)==height_w1) activWindow=w1;
else return;
xpixels=x; ypixels=y-height_w1;
dx= (width_w1/2.-(double)x)/width_w1*-2. *aspectRatio_w1;
dy= (height_w1/2.-(double)y)/height_w1*2.;
//printf("xy:%d %d dxy:%f %f\n", x,y, dx,dy);
if (MouseMode == 3)
{
trackball( 0, trackbsize, curquat, beginx, beginy, dx, dy);
add_quats(curquat, lastquat, lastquat);
build_rotmatrix( R, lastquat );
}
if (MouseMode == 1)
{