1 /* --------------------------------------------------------------------  */
2 /*                          CALCULIX                                     */
3 /*                   - GRAPHICAL INTERFACE -                             */
4 /*                                                                       */
5 /*     A 3-dimensional pre- and post-processor for finite elements       */
6 /*              Copyright (C) 1996 Klaus Wittig                          */
7 /*                                                                       */
8 /*     This program is free software; you can redistribute it and/or     */
9 /*     modify it under the terms of the GNU General Public License as    */
10 /*     published by the Free Software Foundation; version 2 of           */
11 /*     the License.                                                      */
12 /*                                                                       */
13 /*     This program is distributed in the hope that it will be useful,   */
14 /*     but WITHOUT ANY WARRANTY; without even the implied warranty of    */
15 /*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the      */
16 /*     GNU General Public License for more details.                      */
17 /*                                                                       */
18 /*     You should have received a copy of the GNU General Public License */
19 /*     along with this program; if not, write to the Free Software       */
20 /*     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.         */
21 /* --------------------------------------------------------------------  */
22 
23 #include <cgx.h>
24 #include <time.h>
25 #include <sys/utsname.h>
26 
27 #define     VERSION         "2.18"
28 #define     TEST            0
29 
30 #define   GLUT_WEEL_UP 3
31 #define   GLUT_WEEL_DOWN 4
32 
33 /* special cases: */
34 /* temporary conversion from old to new bias definition */
35 int OLD_BIAS_DEF=0;
36 /* generate sets from pressure-loads */
37 int MAKE_SETS_DEF=1;
38 
39 
generalinfo()40 void generalinfo()
41 {
42   printf("  --------------------------------------------------------------------  \n");
43   printf("                           CALCULIX                                     \n");
44   printf("                    - GRAPHICAL INTERFACE -                             \n");
45   printf("      Version %s                                                        \n", VERSION);
46   printf("                                                                        \n");
47   printf("                                                                        \n");
48   printf("      A 3-dimensional pre- and post-processor for finite elements       \n");
49   printf("               Copyright (C) 1996, 2002 Klaus Wittig                    \n");
50   printf("                                                                        \n");
51   printf("      This program is free software; you can redistribute it and/or     \n");
52   printf("      modify it under the terms of the GNU General Public License as    \n");
53   printf("      published by the Free Software Foundation; version 2 of           \n");
54   printf("      the License.                                                      \n");
55   printf("                                                                        \n");
56   printf("      This program is distributed in the hope that it will be useful,   \n");
57   printf("      but WITHOUT ANY WARRANTY; without even the implied warranty of    \n");
58   printf("      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the      \n");
59   printf("      GNU General Public License for more details.                      \n");
60   printf("                                                                        \n");
61   printf("      You should have received a copy of the GNU General Public License \n");
62   printf("      along with this program; if not, write to the Free Software       \n");
63   printf("      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.         \n");
64   printf("  --------------------------------------------------------------------  \n");
65   printf("\n usage: cgx [parameter] filename [ccxfile]                            \n\n");
66   printf(" Parameters:                                                            \n");
67   printf("  -a  auto-mode, geometry file derived from a cad-file must be provided \n");
68   printf("  -ansl reads a concatenated ansys list file (nodes,elems,temps)        \n");
69   printf("  -b  build-mode, geometry (command) file must be provided              \n");
70   printf("  -bg background, suppress creation of graphic output                   \n");
71   printf("      otherwhise as -b, geometry (command) file must be provided        \n");
72   printf("  -c  read an solver input file (ccx)                                   \n");
73   printf("  -duns2d  read duns result files (2D)                                  \n");
74   printf("  -duns3d  read duns result files (3D)                                  \n");
75   printf("  -duns2dl  read duns result files (2D)  (long format)                  \n");
76   printf("  -duns3dl  read duns result files (3D)  (long format)                  \n");
77   printf("  -foam    read openFoam result files                                   \n");
78   printf("  -isaac2d  read isaac result files (2D) \n");
79   printf("  -isaac3d  read isaac result files (3D) \n");
80   printf("  -f06  read Nastran f06 file                                           \n");
81   printf("  -ng   read Netgen native format                                       \n");
82   printf("  -tg   read Tetgen native format                                       \n");
83   printf("  -step read a step file (only points and lines)                        \n");
84   printf("  -stepsplit read step and write its single parts to the filesystem     \n");
85   printf("  -stl  read stl triangles                                              \n");
86   printf("  -v  (default) read a result file in frd-format and optional a solver  \n");
87   printf("      input file (ccx) which provides the sets and loads used in the    \n");
88   printf("      calculation.                                                      \n");
89   printf("                                                                        \n");
90   printf("  special purpose options:                                              \n");
91   printf("  -mksets       make node-sets from *DLOAD-values (setname:''_<value>'')\n");
92   printf("  -read         forces the program to read the complete result-file     \n");
93   printf("                at startup                                              \n");
94   printf("                                                                        \n");
95 }
96 
97 /*
98 Necessary system-routines and libs:
99     glut
100     openGL, libGL and libGLU (the one from SGI which handles nurbs)
101     system
102     sort
103     rm
104 */
105 /*
106 Necessary stand alone programs:
107 - for postscript Hardcopys
108     convert
109 - for multi-picture postscript Hardcopys
110     convert, pstops (from psutils), ghostscript (new version (2015) replace -sDEVICE=pswrite with ps2write)
111 - for 2D plots
112     gnuplot
113 - for online-help
114     netscape, or other html-browser
115 */
116 /*
117 TODO:
118 - "big" node and element numbers should be possible, hash-table has to be implemented
119 */
120 /*
121 POSSIBLE TROUBLE:
122 - if(flipflop) etc. was commented. might cause trouble on some systems with movi and hcpy
123 - some points and sets might use the same name. This leads to problems with lines. The line command
124   determines if it is a center-point or a sequence (seqa) based on the name of the track-parameter.
125   If a point and a seqa use both the specified name then only a sraight line can be generated.
126 
127   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"
128   But if the user has named this entities himself then a crash might still happen.
129 
130 - seach NEWELEM: This block might be unnecessary. Has to be checked
131 */
132 /*
133 Known bugs:
134 - search for debug
135 */
136 
137 /* keyboard history */
138 char **key_history=(char **)NULL;
139 int nkey_history=0, key_pointer, curshft=0;
140 char  keystroke[MAX_LINE_LENGTH];
141 
142 
143 /* Display-lists */
144 GLuint list_model_edges, list_surf_edges, list_elem_edges ;
145 GLuint list_elem_light, list_elem_load, list_elem_elstress;
146 GLuint list_surf_light, list_surf_load;
147 GLuint list_anim_light, list_anim_model_edges, list_anim_surf_edges, list_anim_elem_edges;
148 GLuint *list_animate=NULL, *list_animate_model_edges=NULL, *list_animate_surf_edges=NULL, *list_animate_elem_edges=NULL;
149 GLint  range_animate_light;
150 
151 Summen    anz[1];
152 SumGeo    anzGeo[1];
153 SumAsci   sumAsci[1];
154 
155 SpecialSet specialset[1];
156 int  set_bsur, set_nomesh, set_glur, set_blr;
157 
158 Nodes     *node=NULL;
159 Datasets *lcase=NULL;
160 NodeBlocks *nBlock;
161 Alias     *alias=NULL;
162 Sets      *set=NULL;
163 Shapes    *shape=NULL;
164 Materials *material=NULL;
165 Amplitudes *amplitude=NULL;
166 Psets     *pset=NULL;
167 Values    *value=NULL;
168 Points    *point=NULL;
169 Lines     *line=NULL;
170 Lcmb      *lcmb=NULL;
171 Gsur      *surf=NULL;
172 Gbod      *body=NULL;
173 Nurbl     *nurbl=NULL;
174 Nurbs     *nurbs=NULL;
175 BGpicture *bgpicture;
176 
177 
178 Elements  *e_enqire=NULL;     /* elem-array indexed by elem-number */
179 double     *vp=NULL;
180 Scale     scale[1];
181 Faces     *face;
182 Edges     *edge=NULL;             /* model-edges           */
183 Texts     *ntext=NULL;             /* user texts           */
184 
185 Meshp meshp={ALPHA,BETA,NADAPT,TETMESHER};   /* mesh parameters for tr3u elements. Used in mesh2d and the brand of the tetmesher */
186 
187 
188 double     *colNr;
189 GLfloat   *contur_tex=NULL;
190 
191 struct utsname  cursys[1];
192 int             bitplanes;            /*  colorbuffer depth */
193 
194 Display       *dpy;
195 int           dpycells;
196 Colormap      cmap;
197 XColor        *xcolor;
198 unsigned long *pixels_return;
199 unsigned int  npixels;
200 double         priv_cmap[256][3];
201 
202 
203 /* Main-Prog and GLUT-Window Management */
204 char  datin[MAX_LINE_LENGTH];                           /* cgx input file */
205 char  ccxfile[MAX_LINE_LENGTH];                         /* ccx input file */
206 char  browser[MAX_LINE_LENGTH]=BROWSER;  /* html-browser */
207 char  psviewer[MAX_LINE_LENGTH]=PSVIEWER;  /* postscript viewer */
208 char  helpfile[10][MAX_LINE_LENGTH]=HELPFILE;  /* help-file */
209 char  initfile[MAX_LINE_LENGTH]=INITFILE;  /* commands executed at startup */
210 char  homepath[MAX_LINE_LENGTH];           /* path to the home dir */
211 int   width_ini={INI_SCREEN}, height_ini={INI_SCREEN}; /* Grafik-Fensterbreite/hoehe */
212 int   width_menu={INI_MENU_WIDTH}, height_menu={INI_MENU_HEIGHT};
213 int   width_w0=0, height_w0=0;
214 int   width_w1, height_w1;
215 double   aspectRatio_w1=1.;         /* width_w1/height_w1 */
216 int   open_cgxs;              /* No. of cgx-sessions on that screen */
217 int   w0=0, w1, w2, w3;                           /* window identifier  */
218 int   activWindow=0;                     /* das aktuelle Fenster */
219 int   animList=0;                           /* die aktuelle Displayliste fuer animation */
220 //void  (*currDisplayFunc)(void)=NULL;                /* pointer to the current glutDisplayFunc() */
221 
222 int   col_maxc=DEF_COL,col_minc=DEF_COL;  /* colors of the regions with clipped colors (commands maxc,minc) */
223 int   defScalMethod=0;         /* method to display the scale */
224 int   basCol[3]={0,1,2};       /* color indexes due to basic colormap: 0=black 1=white 2=neutral (grey) */
225 int   foregrndcol=0, backgrndcol=1;          /* default fore- and background color */
226 double foregrndcol_rgb[4]={0.,0.,0.,1.};
227 double backgrndcol_rgb[4]={1.,1.,1.,1.};
228 char          entity_k[SET_COLS]={'k','w','n','r','g','b','y','m','t','c','o'};  /* predefined colors of entities */
229 GLfloat       entity_r[SET_COLS]={ 0., 1., .6, 1., 0., 0., 1., 1., 0., .6, 1. };
230 GLfloat       entity_g[SET_COLS]={ 0., 1., .6, .0, 1., 0., 1., 0., 1., .3, .5 };
231 GLfloat       entity_b[SET_COLS]={ 0., 1., .6, .0, 0., 1., 0., 1., 1., .0, 0. };
232 int entitycols;
233 Entitycol *entitycol;
234 GLfloat   edgeWidth=2;             /* width of the model edges, changed with 'view' */
235 
236 int   submenu_load=-1, submenu_view=-1, mainmenu=-1;        /* menu identifier */
237 int   submenu_scala=-1, submenu_animate=-1, submenu_cut=-1, submenu_graph=-1, submenu_help=-1;
238 int   submenu_orientation=-1, submenu_hardcopy=-1, submenu_user=-1;
239 int   subsubmenu_entity=-1, subsubmenu_parameter=-1;
240 int   subsubmenu_animTune=-1, subsubmenu_animSteps=-1;
241 int   subsubmenu_animPeriod=-1, subsubmenu_colormap=-1;
242 int   userCommands=0;
243 char  **userCommand=NULL;
244 
245 GLfloat lmodel_twoside =  GL_TRUE ;
246 GLfloat lmodel_oneside =  GL_FALSE ;
247 double dx ,dy;                                      /* Mauskoordinaten im bereich +-1*/
248 int   xpixels ,ypixels;                            /* Mauskoordinaten in pixel, links unten 0,0 */
249 double beginx, beginy;                              /* letzter mousepoint */
250 double trackbsize={0.8};                            /* TRACKBALLSIZE */
251 double curquat[4];                                  /* Matrix aus Trackball */
252 double lastquat[4];                                 /* letzte Matrix aus Trackball*/
253 GLint   gl_max_eval_order=8;                         /* max order of NURBS */
254 int   MouseMode;                                   /* status maustasten */
255 GLdouble dx_cur={PICK_LENGTH}, dy_cur={PICK_LENGTH};   /* pick-cursor Area */
256 GLdouble R[4][4];                                   /* Rotationsmatrix */
257 GLdouble dR[4][4];                                  /* dR= R-Rmem fuer center */
258 GLdouble Rmem[4][4];
259 double v[4];                                        /* drehkorrekturen fuer centerPkt */
260 double vmem[4];                                     /* kor. bis auswahl eines neuen drehpkts */
261 
262 char  v_dim=0;                         /* 1: scalar plot, 2: a 2D vector plot, 3: a 3D vectorplot, 4: a 3D vectorplot with signed vals */
263 int   movieFrames=0;                   /* if >0 number of frames until the movie is created. frame generation stops then. */
264 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) */
265 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 */
266 DsSequence dsSequence;                 /* datasets (ds) for sequence of results */
267 int   lcase_animList={-1};                       /* additional lcase for the values of the animation */
268 int   read_mode=0;                               /* if 1 read data immediatelly, else read on demand */
269 int   step_mode=0;                               /* if 1 read step data and write the single parts from an assembly to the filesystem */
270 int   centerNode=0;                    /* Nr of center Node, 0:no centernode */
271 int   cmaps=5;                         /* nr of colormap names */
272 char *cmap_names[] = {"classic", "jet", "turbo", "viridis", "inferno"};   /* Colormap names */
273 char  cmap_name[] = "classic";         /* default Colormap */
274 char  inpformat=0;                     /* defines the start-up mode of cgx */
275 char  allowSysFlag=ALLOW_SYS_FLAG;                  /* 1: allow the execution of system calls (sys command) */
276 char  autoDivFlag=1;                   /* The div command will set it to 0 and no auto-div is executed */
277 char  autoEltyFlag=1;                   /* The elty command will set it to 0 and no auto-elty is executed */
278 char  fixBadDivFlag=0;                 /* 1: mesh routine loops until a limit is reached (MAX_REFINEMENT_LOOPS) or all surfs are meshed */
279 char  cullFlag=0;                      /* 1: front face culling */
280 char  iniActionsFlag=0;                /* if set to 1 actions during idle will be performed */
281 int   cur_commandFile;                   /* >0: current open command file  */
282 char  frameFlag={1};                   /* mit (1) oder ohne Rahmen um das Grafikfenster */
283 char  captionFlag={1};                 /* mit (1) oder ohne filename im Menufenster */
284 char  textFlag={1};                    /* mit (1) oder ohne text im Menufenster */
285 char  commandLineFlag={0};             /* mit (1) oder ohne Kommandozeile im Menufenster */
286 char  printFlag=0;                     /* printf on/off on=1 (kommando 'msg' 'on'|'off' )*/
287 char  scalaFlag={1};                   /* mit (1) oder ohne scala und wertetexte */
288 char  sequenceFlag=0;                  /* 1: play a sequence of LC */
289 char  vectorFlag=0;                    /* 0: scalar plot, 1: vector plot */
290 char  addDispFlag=0;                   /* 0: original node-coordinates, 1: node-coordinates+displacements */
291 char  flipColorFlag=0;                 /* 0: high values use red, low use blue in scale; 1: flipped */
292 char  graphFlag=0;                     /* 0:out, 1:graph line, 2: graph n, 3: graph t */
293 char  cutFlag=0;                       /* 0:out, 1: last node selected, cut structure */
294 char  illumFlag=0;                     /* sequence with illumination */
295 char  illumResultFlag=ILLUMINATE_RESULTS;              /* results with illumination */
296 char  movieFlag=0;                     /* >0: save sequence of gif pictures */
297 char  rulerFlag=0;                     /* 1: drawRu1er in window w1 */
298 char  rulerString[MAX_LINE_LENGTH];    /* units */
299 char  automode=0;                      /* set to 1 to perform various automatic actions as determining of divisions etc. during reading of command files */
300 char  animFlag={0};                    /* animation of the selected Dataset */
301 char  blendFlag={0};                    /* 1: transparent representation */
302 char  surfFlag={1};                     /* zeichne nur Oberflaechenelemente (1), sonst (0)*/
303 char  modelEdgeFlag={1};                /* zeichne mit Kanten (1), sonst (0)*/
304 char  elemEdgeFlag={0};                 /* zeichne mit Surface Kanten (1), sonst (0)*/
305 char  modelEdgeFlag_Static={0};         /* zeichne mit Kanten (1), sonst (0), stehende Kanten waerend animationen */
306 char  elemEdgeFlag_Static={0};          /* zeichne mit Surface Kanten (1), sonst (0)*, stehende Kanten waerend animationen */
307 char  drawMode={2};                     /* actual draw-function (Load=1, Light=2, 3 not used, Preprocessor=4, Vector=5)*/
308 char  stopFlag=0;                      /* stop/start animation */
309 char  zoomFlag={0};                    /* (1) zoom Modus */
310 char  centerFlag={0};                  /* (1) search centerPnt */
311 char  enquireFlag={0};                 /* (1) enquire node-values */
312 char  movezFlag={0};                     /* (1) move Model in Z Direction through the cuting plane */
313 char  pickfunc[MAX_LINE_LENGTH];       /* pick-function like "qenq" "qadd" "qrem" ..   */
314 char  pickFlag={0};                    /* 1 if picking is active */
315 char  delPntFlag={0};                  /* 1: deleted points exists */
316 char  delShapeFlag={0};                /* 1: deleted shapes exists */
317 char  delLineFlag={0};                 /* 1: deleted lines exists */
318 char  delLcmbFlag={0};                 /* 1: deleted lcmbs exists */
319 char  delSurfFlag={0};                 /* 1: deleted surfs exists */
320 char  delBodyFlag={0};                 /* 1: deleted bodys exists */
321 char  delNursFlag={0};                 /* 1: deleted Nurbs exists */
322 char  delSetFlag={0};                  /* 1: deleted sets exists */
323 char  hcpyFlag={0};                    /* triggers createHardcopy if !=0 */
324 int   frameSetFlag={-2};               /* triggers frameSet() */
325 
326 char  mode[2]={'i'};                      /* pickmode */
327 double minvalue, maxvalue;                         /* Wertebereich */
328 int   steps={21};                                  /* Schrittweite der Farbscala */
329 int   offset, maxIndex;                            /* offset+steps-1 = maxIndex */
330 int   anim_steps={8};                              /* Animationen pro Schwingung */
331 double anim_faktor={1.};                           /* Scalierung der Amplitude */
332 int   *anim_alfa;                                  /* amplitude der Animation fuer Bildbeschriftung */
333 int   time_per_period={MILLISECONDS_PER_PERIOD}; /* fuer Animation */
334 int   frameNr={0};                                 /* zaehlt alle animierten Bilder */
335 int   halfperiod={0};                             /* 1:Animation nur der posit. Halbperiod */
336 int   hcpy={0};                                    /* hcpy=1 Hardcopy angefordert */
337 double dtx={0.}, dty={0.}, dtz={0.}, drx, dry, drz, ds={0.5};            /* Verschiebungen */
338 double centerPnt[3];                                /* Rotationszentrum */
339 int   cur_entity={0};                                       /* aktive entity (component), entity in menu= cur_entity+1*/
340 int   entity_v[6];                                         /* components of a vector-entity */
341 double v_factor;                                    /* scaling-factor for the vectors in the vector-plot */
342 double v_scale={1.};                                     /* additional scaling-factor for the vectors */
343 int       pre_lc={0};                                      /* pre-selected Dataset, active after entity is selected */
344 int       cur_lc={0};                                          /* aktive Dataset */
345 int       entity_buf=0;
346 void      *glut_font[]=GLUT_FONT;                      /* glut fonts */
347 int       pixPerCharx[]=GLUT_FONT_WIDTH;
348 int       pixPerChary[]=GLUT_FONT_HEIGHT;
349 int       legend_font=DEF_GLUT_FONT;                         /* active font for the legend */
350 int       draw_font=DEF_GLUT_FONT;                         /* active font for the annotation of entities */
351 int       menu_font=SUM_GLUT_FONTS-1;                         /* active font for the menu */
352 int       elemMat[MAX_MATERIALS]={1,1};      /*  Material Numbers, Number of Materials stored in elemMat[0]  */
353 int       nasMpc=1;                                       /* 1: areampc generates mpcs; 0: rbes with optional heat-expansion-coefficient */
354 double    nasRbeHec=0.;
355 char  picture_caption[MAX_LINE_LENGTH]= {""};               /* Caption on window base line */
356 char  picture_text[MAX_LINE_LENGTH]= {""};               /* Text on window base line */
357 
358 double     gtol={GTOL}, gtol_buf;    /* geometric tolerance for merging in absolute coordinates */
359 int     ddiv={DEF_LINE_DIV};
360 double     dbias=1;
361 int       neqn={0};              /* start-number of equations in ansys, MID in nastran */
362 int       setall=0;              /* setNr of the default set "all" */
363 
364 /* nr of graph 2d plot */
365 int graph_Nr=-1;
366 int graph_on=1;  // 1:
367 
368 /* nr of hardcopies */
369 int psNr=0, tgaNr=0, gifNr=0, pngNr=0;
370 
371 /* track the open sets */
372 OpenSets openSets[1];
373 
374 /* the copied node-sets which have to be filled with values from new loaded Datasets */
375 CopiedNodeSets copiedNodeSets[1];
376 
377 /* element quality thresholds */
378 Eqal eqal={0.,0.,0.};
379 
380 /* buffer to store related infos for the temporory qcut-nodes, used for data-interpolation */
381 Qcut_nodes *qcut_nod=NULL;
382 
383 /* buffer to store values */
384 char **valuestack=NULL;
385 int valuestack_ptr=0, valuestackFlag=0;
386 
387 /* buffer to write to stack */
388 char **parameter;
389 
390 /* string buffer */
391 char  buffer[MAX_LINE_LENGTH];
392 
393 /* threading */
394 sem_t   sem_n;
395 sem_t   sem_g;
396 sem_t   sem_rep;
397 sem_t   sem_stn;
398 
399 
askGLError(char buffer[MAX_LINE_LENGTH])400 int askGLError(char buffer[MAX_LINE_LENGTH])
401 {
402   GLenum error = glGetError();
403   if (error == (GLenum)GL_NO_ERROR) return(1);
404   else if (error == (GLenum)GL_INVALID_ENUM) printf ("in:%s GL_INVALID_ENUM\n",buffer);
405   else if (error == (GLenum)GL_INVALID_VALUE) printf ("in:%s GL_INVALID_VALUE \n",buffer);
406   else if (error == (GLenum)GL_INVALID_OPERATION) printf("in:%s GL_INVALID_OPERATION\n",buffer);
407   else if (error == (GLenum)GL_STACK_OVERFLOW) printf ("in:%s  GL_STACK_OVERFLOW\n",buffer);
408   else if (error == (GLenum)GL_STACK_UNDERFLOW) printf ("in:%s  GL_STACK_UNDERFLOW\n",buffer);
409   else if (error == (GLenum)GL_OUT_OF_MEMORY) printf ("in:%s  GL_OUT_OF_MEMORY\n",buffer);
410   else {printf("glGetError detects unknown error %d in:%s\n", error, buffer); return (-1);}
411   return (0);
412 }
413 
414 
415 
416 /* realloc_colNr() must be executed before the call to nodalDataset() and each time new nodes were created */
realloc_colNr(void)417 void realloc_colNr(void)
418 {
419   int i;
420   if ( (colNr = (double *)realloc((double *)colNr, (anz->nmax+1) * sizeof(double))) == NULL )
421     printf("\n\n ERROR: realloc failed colNr\n\n") ;
422   else
423     for(i=0; i<=anz->nmax; i++) colNr[i]=0.;
424 }
425 
426 
427 
428 /* the node pointer must not be changed inside the function. Since that is the case the *node is changed to *node_dummy
429    and the global *node is used which is always correct so far */
430 /* realloc_colNr() must be executed before the call to this function and each time new nodes were created */
nodalDataset(int entity,int lc,Summen * anz,Scale * scale,Nodes * node_dummy,Datasets * lcase,double * colNr,int scalaFlag)431 void nodalDataset( int entity, int lc, Summen *anz, Scale *scale, Nodes *node_dummy, Datasets *lcase, double *colNr, int scalaFlag )
432 {
433   int i,j,n;
434   int n1, n2, settmp, allNodesFlag;
435   int nmax=0, nmin=0;
436   double vmax=0, vmin=0;                            /* max,min Werte der values */
437   double ds,max,min,divisor;
438 #if TEST
439   printf ("in nodalDataset drawMode:%d\n",drawMode );
440 #endif
441 
442   if(!anz->l)
443   {
444       printf(" WARNING: No values available (should not come to this point)\n");
445       return;
446   }
447 
448   /* check if the data of the specified lcase (Dataset) are already available */
449   if (!lcase[lc].loaded)
450   {
451     if( pre_readfrdblock(copiedNodeSets , lc, anz, node, lcase )==-1)
452     {
453       printf("ERROR in nodalDataset: Could not read data for Dataset:%d\n", lc+1);
454       return;
455     }
456     calcDatasets( lc, anz, node, lcase );
457     recompileEntitiesInMenu(lc);
458   }
459 
460   /* if currently a section (qcut) is in use realloc the lcase and generate the necessary values */
461   settmp=getSetNr("-qcut");
462   if(settmp>-1) updLcase(lc, settmp);
463   else
464   {
465     if ( (lcase[lc].dat[entity] = (float *)realloc(lcase[lc].dat[entity], (anz->nmax+1) * sizeof(float))) == NULL )
466       {  printf("\n\n ERROR: realloc failure updLcase\n\n" ); return; }
467   }
468 
469   /* check if the specified lcase-component is allocated */
470   if (entity>=lcase[lc].ncomps )
471   {
472     errMsg("ERROR: Component not available\n");
473     return;
474   }
475 
476   /* remove the displacements on node-coords if the time-step has changed */
477   // TBD: do only if (lcase[selection].step_number!=lcase[cur_lc].step_number)
478   if(addDispFlag==1)
479   {
480     printf("\n displacements will be updated\n");
481     addDispToCoordinates(node);
482     addDispToCoordinates(node);
483   }
484 
485   for (i=0; i<anz->n; i++ )
486   {
487     if(node[node[i].nr].pflag==0) continue;
488     lcase[lc].dat[entity][node[i].nr] = 9999999999;
489   }
490 
491   for ( i=0; i<anz->e; i++ )
492   {
493     switch(e_enqire[e_enqire[i].nr].type)
494     {
495       case 4:
496       for (n=0; n<3; n++)  /* create new vals at nodes in center of areas */
497       {
498         lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[20+n]] = -0.25* (
499           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]]    +
500           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*(
501           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]]   +
502           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]]) ;
503       }
504         lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[23]] = -0.25* (
505           lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[3]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[0]]    +
506           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*(
507           lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[11]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[12]]   +
508           lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[19]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[15]]) ;
509       for (n=0; n<2; n++)
510       {
511         n1=n*4;
512         n2=n*8;
513         lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[24+n]] = -0.25* (
514           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]]    +
515           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*(
516           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]]   +
517           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]]) ;
518       }
519       break;
520 
521 
522       case 5:
523       for (n=0; n<2; n++)
524       {
525         lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[15+n]] = -0.25* (
526           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]]    +
527           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*(
528           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]]   +
529           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]]) ;
530       }
531         lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[17]] = -0.25* (
532           lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[2]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[0]]    +
533           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*(
534           lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[ 8]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[ 9]]   +
535           lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[14]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[11]]) ;
536         lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[18]] = -0.25* (
537           lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[0]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[2]]    +
538           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*(
539           lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[ 8]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[ 7]]   +
540           lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[ 6]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[ 0]]) ;
541         lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[19]] = -0.25* (
542           lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[3]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[4]]    +
543           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*(
544           lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[12]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[13]]   +
545           lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[14]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[ 3]]) ;
546       break;
547 
548 
549       case 10:
550       lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[8]] = -0.25* (
551       lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[0]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[1]] +
552       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*(
553       lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[4]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[6]] +
554       lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[7]]+lcase[lc].dat[entity][e_enqire[e_enqire[i].nr].nod[5]]);
555       break;
556     }
557   }
558 
559   /* ------------  Darstellung scalieren -------------------  */
560 
561   if(scalaFlag)
562   {
563     /* scan all nodes of all entities which are used on the display */
564 
565     allNodesFlag=0;
566     for (j=0; j<anzGeo->psets; j++ )
567     {
568       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))
569       {
570         allNodesFlag=1;
571         break;
572       }
573     }
574 
575     if((allNodesFlag)||(anzGeo->psets==0))
576     {
577       vmax=lcase[lc].max[entity];
578       vmin=lcase[lc].min[entity];
579       nmax=lcase[lc].nmax[entity];
580       nmin=lcase[lc].nmin[entity];
581     }
582     else
583     {
584       /* adjust the scala */
585       vmin=MAX_FLOAT;
586       vmax=-MAX_FLOAT;
587 
588       delSet(specialset->tmp);
589       if( (settmp=pre_seta( specialset->tmp, "i", 0 )) <0 ) return;
590       for (j=0; j<anzGeo->psets; j++ )
591       {
592         if (pset[j].type[1]=='v')
593 	{
594           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] );
595           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] );
596           //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] );
597 	}
598       }
599       completeSet( specialset->tmp, "do");
600       for (i=0; i<set[settmp].anz_n; i++ )
601       {
602         if(lcase[lc].dat[entity][set[settmp].node[i]] < vmin ) { vmin = lcase[lc].dat[entity][set[settmp].node[i]]; nmin=set[settmp].node[i]; }
603         if(lcase[lc].dat[entity][set[settmp].node[i]] > vmax ) { vmax = lcase[lc].dat[entity][set[settmp].node[i]]; nmax=set[settmp].node[i]; }
604       }
605       delSet(specialset->tmp);
606 
607       /* if no plotset is defined */
608       if(vmin==MAX_FLOAT)
609       {
610         vmax=lcase[lc].max[entity];
611         vmin=lcase[lc].min[entity];
612         nmin=lcase[lc].nmin[entity];
613         nmax=lcase[lc].nmax[entity];
614       }
615     }
616     if(scale->smin==scale->smax)
617     {
618       if(scale->format=='l')
619       {
620         scale->smin=log10(vmin);
621         scale->smax=log10(vmax);
622       }
623       else
624       {
625         scale->smin=vmin;
626         scale->smax=vmax;
627       }
628     }
629 
630     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] );
631     printf (" Extremal values from displayed mesh-entities:\n max:%e at node:%d\n min:%e at node:%d\n", vmax, nmax, vmin, nmin);
632     sprintf(parameter[0],"%d", lc+1);
633     sprintf(parameter[1],"%s", lcase[lc].dataset_name);
634     sprintf(parameter[2],"%e", lcase[lc].value);
635     sprintf(parameter[3],"%s", lcase[lc].dataset_text);
636     sprintf(parameter[4],"%s", lcase[lc].name);
637     sprintf(parameter[5],"%s", lcase[lc].compName[entity]);
638     sprintf(parameter[6],"%e", vmax);
639     sprintf(parameter[7],"%d", nmax);
640     sprintf(parameter[8],"%e", vmin);
641     sprintf(parameter[9],"%d", nmin);
642     write2stack(10, parameter);
643 
644     /* recalculate max,min if a clipped scale is to be used (as in scala_tex())*/
645     max=scale->smax;
646     min=scale->smin;
647     divisor=steps;
648     if(scale->smaxr) divisor--;
649     if(scale->sminr) divisor--;
650     ds=(max-min)/divisor;
651     if(scale->smaxr) max+=ds;
652     if(scale->sminr) min-=ds;
653 
654     if(scale->format=='l')
655     {
656      for (i=0; i<anz->n; i++ )
657      {
658       if(node[node[i].nr].pflag==-1) continue;
659       if ( log10(lcase[lc].dat[entity][node[i].nr]) <= min )
660       {
661         colNr[node[i].nr] = 0.;
662       }
663       else if ( log10(lcase[lc].dat[entity][node[i].nr]) >= max )
664       {
665         colNr[node[i].nr] = (double)steps/(double)TEX_PIXELS;
666       }
667       else
668       {
669         if(lcase[lc].dat[entity][node[i].nr]>=0.) colNr[node[i].nr] = (log10(lcase[lc].dat[entity][node[i].nr])-min)/(max-min) *(double)steps/(double)TEX_PIXELS;
670 	else colNr[node[i].nr] = 0.;
671       }
672       //printf("i:%d n:%d e:%d lc:%d smin:%f v:%f log10(v):%f c:%f\n", i,node[i].nr,entity,lc,scale->smin,lcase[lc].dat[entity][node[i].nr],log10(lcase[lc].dat[entity][node[i].nr]),colNr[node[i].nr]);
673      }
674     }
675     else
676     {
677      for (i=0; i<anz->n; i++ )
678      {
679       if(node[node[i].nr].pflag==-1) continue;
680       if ( lcase[lc].dat[entity][node[i].nr] <= min )
681       {
682         colNr[node[i].nr] = 0.;
683       }
684       else if ( lcase[lc].dat[entity][node[i].nr] >= max )
685       {
686         colNr[node[i].nr] = (double)steps/(double)TEX_PIXELS;
687       }
688       else
689       {
690         colNr[node[i].nr] = (lcase[lc].dat[entity][node[i].nr]-min)/(max-min) *(double)steps/(double)TEX_PIXELS;
691       }
692       //printf("i:%d n:%d e:%d lc:%d smin:%f v:%f c:%f\n", i,node[i].nr,entity,lc,scale->smin,lcase[lc].dat[entity][node[i].nr],colNr[node[i].nr]);
693      }
694     }
695   }
696 }
697 
698 
699 
elementDataset(int entity,int lc,Summen * anz,Scale * scale,Datasets * lcase,int offset,int maxIndex,int steps)700 void elementDataset( int entity, int lc, Summen *anz, Scale *scale, Datasets *lcase, int offset, int maxIndex, int steps )
701 {
702   int   i;
703   double **vp;
704   //double vmax, vmin;                            /* max,min Werte der values */
705   //int   nmax, nmin;                            /* nodes der max/min-Werte  */
706 
707   if(!anz->l)
708   {
709       printf(" WARNING: No values available\n");
710       return;
711   }
712 
713   if ( (vp = (double **)malloc( (anz->emax+1) * sizeof(double))) == NULL )
714     printf("\n\n ERROR: malloc failed vp\n");
715   for (i=0; i<(anz->emax+1); i++)
716     if ( (vp[i] = (double *)malloc( (2) * sizeof(double))) == NULL )
717       printf("\n\n ERROR: malloc failed vp[%d]\n", i);
718 
719   /* check if the specified lcase-component is allocated */
720 
721 /*
722   if (lcase[lc].edat[entity] == NULL )
723     errMsg("ERROR: Component not available\n");
724   else
725   {
726     for (i=0; i<num_etype[11]; i++ )
727     {
728       for (j=0; j<2; j++ )
729       {
730         vp[i][j]  = lcase[lc].edat[entity][cbeam[i].elem_nr][j];
731       }
732     }
733   }
734   vmax=lcase[lc].max[entity];
735   vmin=lcase[lc].min[entity];
736   printf ("\nDataset:%d name= %s", lc+1, lcase[lc].name);
737   printf (" entity:%s\n", lcase[lc].compName[entity] );
738   printf (" maxvalue:%e\n minvalue:%e \n", vmax, vmin);
739 
740   for (i=0; i<num_etype[11]; i++ )
741   {
742     for (j=0; j<2; j++ )
743     {
744       if (scale->smin==0)
745       {
746         scale->smin = vmin;
747       }
748       if (scale->smax==0)
749       {
750         scale->smax = vmax;
751       }
752       if ( vp[i][j] <= scale->smin )
753       {
754         cbeam[i].ncol[j][0] = 0.;
755       }
756       if ( vp[i][j] >= scale->smax )
757       {
758         cbeam[i].ncol[j][0] = 1.;
759       }
760       if ( (vp[i][j] > scale->smin) && (vp[i][j] < scale->smax) )
761       {
762         cbeam[i].ncol[j][0] = (vp[i][j]-scale->smin)/(scale->smax-scale->smin);
763       }
764       printf ("v:%lf col:%lf  \n", vp[i][j], cbeam[i].ncol[j][0] );
765     }
766   }
767 */
768 
769   for (i=0; i<(anz->emax+1); i++) if (vp[i]) free(vp[i]);
770   if (vp) free(vp);
771 }
772 
773 
774 
775 /* from j. baylor for tga-screen-shot */
WriteTGA(char * filename,short int width,short int height,char * imageData)776 int WriteTGA(char *filename,
777              short int width,
778              short int height,
779              char *imageData) {
780 
781    char cGarbage = 0;
782    char pixelDepth = 32;
783    char type = 2; // type = 2 for pixelDepth = 32 | 24, type = 3 for greyscale
784    char mode = 4; // mode = pixelDepth / 8
785    char aux;
786    short int iGarbage = 0;
787    FILE *file;
788    int i;
789 
790    // open file and check for errors
791    file = fopen(filename, "wb");
792    if (file == NULL) return(-1);
793 
794    // write the header
795    fwrite(&cGarbage, sizeof(char), 1, file);
796    fwrite(&cGarbage, sizeof(char), 1, file);
797    fwrite(&type, sizeof(char), 1, file);
798    fwrite(&iGarbage, sizeof(short int), 1, file);
799    fwrite(&iGarbage, sizeof(short int), 1, file);
800    fwrite(&cGarbage, sizeof(char), 1, file);
801    fwrite(&iGarbage, sizeof(short int), 1, file);
802    fwrite(&iGarbage, sizeof(short int), 1, file);
803    fwrite(&width, sizeof(short int), 1, file);
804    fwrite(&height, sizeof(short int), 1, file);
805    fwrite(&pixelDepth, sizeof(char), 1, file);
806    fwrite(&cGarbage, sizeof(char), 1, file);
807 
808    // convert the image data from RGB(a) to BGR(A)
809    if (mode >= 3)
810    for (i=0; i < width * height * mode ; i+= mode) {
811       aux = imageData[i];
812       imageData[i] = imageData[i+2];
813       imageData[i+2] = aux;
814    }
815 
816    // save the image data
817    fwrite(imageData, sizeof(char), width * height * mode, file);
818    fclose(file);
819 
820    return(0);
821 }
822 
823 
824 
825 /* This will save a screen shot to a file. */
SaveTGAScreenShot(char * filename,int w,int h)826 void SaveTGAScreenShot(char *filename, int w, int h)
827 {
828    char *imageData;
829    imageData = (char *)malloc(sizeof(char) * w * h * 4);
830    glReadPixels(0, 0, w, h,GL_RGBA,GL_UNSIGNED_BYTE, (GLvoid *)imageData);
831    WriteTGA(filename,w,h,imageData);
832    // release the memory
833    free(imageData);
834 }
835 
836 
837 
getTGAScreenShot(int nr)838 void getTGAScreenShot(int nr)
839 {
840     char buffer[MAX_LINE_LENGTH];
841 
842     if(!inpformat) return;
843 
844     glutSetWindow(w0);
845     SaveTGAScreenShot("0__.tga", glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
846 
847     glutSetWindow(w1);
848     SaveTGAScreenShot("1__.tga", glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
849 
850     glutSetWindow(w2);
851     SaveTGAScreenShot("2__.tga", glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
852 
853     glutSetWindow(activWindow);
854     while( access( "0__.tga", F_OK ) != 0 );
855     while( access( "1__.tga", F_OK ) != 0 );
856     while( access( "2__.tga", F_OK ) != 0 );
857     //sprintf( buffer, "composite -compose atop -gravity SouthWest -geometry +1+1 2__.tga 1__.tga 3__.tga");
858     sprintf( buffer, "composite -gravity SouthWest -geometry +1+1 2__.tga 1__.tga 3__.tga");
859     system (buffer);
860     while( access( "3__.tga", F_OK ) != 0 );
861     //sprintf( buffer, "composite -compose atop -gravity NorthWest -geometry +%d+%d 3__.tga 0__.tga hcpy_%d.tga",
862     sprintf( buffer, "composite -alpha off -gravity NorthWest -geometry +%d+%d 3__.tga 0__.tga hcpy_%d.tga",
863 		(GLint)width_menu*19/20, (GLint)height_menu/10, nr);
864     system (buffer);
865     //printf("%s",buffer);
866     sprintf( buffer, "rm -f *__.tga %s",DEV_NULL);
867     system (buffer);
868 }
869 /* end tga-screen-shot */
870 
871 
872 
873 
874 
createHardcopy(int selection,char * filePtr)875 void createHardcopy( int selection, char *filePtr )
876 {
877   char buffer[MAX_LINE_LENGTH];
878   char fileName[MAX_LINE_LENGTH];
879 
880   if(!inpformat) return;
881   /*
882   glutSetWindow( w0);
883   glutSwapBuffers();
884   glutSetWindow( w1);
885   glutSwapBuffers();
886   glutSetWindow( w2);
887   glutSwapBuffers();
888   */
889   if(selection==0)
890   {
891     /* generate movie from single gif files */
892     sprintf( buffer, "make 1. %lf",(double)gifNr);
893     pre_movie(buffer);
894     sprintf( buffer, "clean");
895     pre_movie(buffer);
896     gifNr=0;
897   }
898   else
899   {
900     /* Hardcopy         */
901     if(selection==1)
902     {
903       psNr++;
904       if(filePtr!=NULL) sprintf(fileName,"%s.ps",filePtr); else sprintf(fileName,"hcpy_%d.ps",psNr);
905       printf("create %s\n ",fileName);
906       getTGAScreenShot(psNr);
907       /* on some systems PS has to be changed to PS2 */
908       //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);
909       sprintf( buffer, "convert hcpy_%d.tga -page A4 %s", psNr, fileName);
910       system (buffer);
911       printf("%s\n", buffer);
912       sprintf( buffer, "rm -f hcpy_%d.tga %s",psNr,DEV_NULL);
913       system (buffer);
914       sprintf( parameter[0], "%s", fileName);
915       sprintf( parameter[1], "%d", psNr);
916       write2stack(2, parameter);
917       printf ("ready\n");
918     }
919     if(selection==2)
920     {
921       tgaNr++;
922       getTGAScreenShot(tgaNr);
923       if(filePtr!=NULL)
924       {
925         sprintf(fileName,"%s.tga",filePtr);
926         sprintf( buffer, "mv -f hcpy_%d.tga %s", tgaNr, fileName);
927         system (buffer);
928       }
929       else sprintf(fileName,"hcpy_%d.tga",tgaNr);
930       printf("create %s\n ",fileName);
931       sprintf( parameter[0], "%s", fileName);
932       sprintf( parameter[1], "%d", tgaNr);
933       write2stack(2, parameter);
934       printf ("ready\n");
935     }
936     if(selection==3)
937     {
938       /* movie gif files */
939       getTGAScreenShot(0);
940       while( access( "hcpy_0.tga", F_OK ) != 0 );
941       gifNr++;
942       sprintf( buffer, "convert hcpy_0.tga _%d.gif",gifNr);
943       printf("%s\n",buffer);
944       system (buffer);
945       if((movieFrames)&&(gifNr>=movieFrames))
946       {
947         animList=0;
948         movieFrames=0;
949         movieFlag=0;
950         sprintf( buffer, "rm -f  hcpy_0.tga %s", DEV_NULL2);
951         system (buffer);
952         createHardcopy(0, NULL);
953         /* read a cgx-command file which will be executed after the movie is created */
954         if(strlen(movieCommandFile))
955         {
956           pre_read(movieCommandFile);
957         }
958       }
959     }
960     if(selection==4)
961     {
962       gifNr++;
963       if(filePtr!=NULL) sprintf(fileName,"%s.gif",filePtr); else sprintf(fileName,"hcpy_%d.gif",gifNr);
964       printf("create %s\n ",fileName);
965       getTGAScreenShot(gifNr);
966       sprintf( buffer, "convert hcpy_%d.tga %s", gifNr, fileName);
967       system (buffer);
968       sprintf( buffer, "rm -f hcpy_%d.tga %s",gifNr,DEV_NULL);
969       system (buffer);
970       sprintf( parameter[0], "%s", fileName);
971       sprintf( parameter[1], "%d", gifNr);
972       write2stack(2, parameter);
973       printf ("ready\n");
974     }
975     if(selection==5)
976     {
977       pngNr++;
978       if(filePtr!=NULL) sprintf(fileName,"%s.png",filePtr); else sprintf(fileName,"hcpy_%d.png",pngNr);
979       printf("create %s\n ",fileName);
980       getTGAScreenShot(pngNr);
981       sprintf( buffer, "convert hcpy_%d.tga %s", pngNr, fileName);
982       system (buffer);
983       sprintf( buffer, "rm -f hcpy_%d.tga %s",pngNr,DEV_NULL);
984       system (buffer);
985       sprintf( parameter[0], "%s", fileName);
986       sprintf( parameter[1], "%d", pngNr);
987       write2stack(2, parameter);
988       printf ("ready\n");
989     }
990   }
991   /*
992   glutSetWindow( w0);
993   glutSwapBuffers();
994   glutSetWindow( w1);
995   glutSwapBuffers();
996   glutSetWindow( w2);
997   glutSwapBuffers();
998   */
999   glutSetWindow( activWindow);
1000 }
1001 
1002 
1003 
entryfunktion(int state)1004 void entryfunktion( int state )
1005 {
1006   if (state==GLUT_ENTERED)
1007   {
1008     activWindow=w1;
1009     glutSetWindow(activWindow );
1010     glutPostRedisplay();
1011     glutSetWindow( w2);
1012     glutPostRedisplay();
1013   }
1014   else
1015   {
1016     activWindow=w0;
1017     glutSetWindow(activWindow );
1018     glutPostRedisplay();
1019   }
1020 }
1021 
1022 
1023 
WindowState(int state)1024 void WindowState( int state )
1025 {
1026   if (state==GLUT_NOT_VISIBLE)
1027     activWindow=w0;
1028 }
1029 
1030 
1031 
Mouse(int x,int y)1032 void Mouse( int x, int y )
1033 {
1034   if (glutGet(GLUT_WINDOW_HEIGHT)==height_w1) activWindow=w1;
1035   else return;
1036 
1037   xpixels=x; ypixels=y-height_w1;
1038   dx= (width_w1/2.-(double)x)/width_w1*-2.  *aspectRatio_w1;
1039   dy= (height_w1/2.-(double)y)/height_w1*2.;
1040   //printf("xy:%d %d dxy:%f %f\n", x,y, dx,dy);
1041 
1042   if (MouseMode == 3)
1043   {
1044     trackball( 0, trackbsize, curquat, beginx, beginy, dx, dy);
1045     add_quats(curquat, lastquat, lastquat);
1046     build_rotmatrix( R, lastquat );
1047   }
1048   if (MouseMode == 1)
1049   {
1050     dtx+= (dx-beginx);
1051     dty+= (dy-beginy);
1052   }
1053   if (MouseMode == 2)
1054   {
1055     if (movezFlag)
1056     {
1057       dtz+= (dy-beginy);
1058     }
1059     else
1060     {
1061     dtx*=ds;
1062     dty*=ds;
1063     ds-= (beginy-dy)*ds;
1064     dtx/=ds;
1065     dty/=ds;
1066     }
1067   }
1068   beginx = dx;
1069   beginy = dy;
1070 
1071   if ( activWindow == w1 )
1072   {
1073     glutPostRedisplay();
1074     glutSetWindow( w2);
1075     glutPostRedisplay();
1076     glutSetWindow(activWindow );
1077   }
1078 }
1079 
1080 
1081 
qzoom()1082 void qzoom()
1083 {
1084   static int i=0;
1085   static double xcur[2], ycur[2];
1086 
1087   xcur[i]=dx; ycur[i]=dy;
1088   if (i)
1089   {
1090     i=0;
1091     zoom(xcur[0], ycur[0], xcur[1], ycur[1]);
1092   }
1093   else i=1;
1094   printf ("P%d\n", i);
1095 }
1096 
1097 
1098 
qcenter(int x,int y)1099 void qcenter(int x, int y)
1100 {
1101   int i;
1102   double puf[3];
1103 
1104   for (i=0;i<3;i++) puf[i]=centerPnt[i];
1105   centerFlag=!centerFlag;
1106   printf ("pic new center\n");
1107 
1108   mode[0]='i';
1109   strcpy( pickfunc, "qcnt");
1110   glutSetWindow( w1);
1111   dx_cur=PICK_LENGTH*2; dy_cur=PICK_LENGTH*2;
1112   pick( (char)'n', x, y );
1113   if( (puf[0]==centerPnt[0])&&(puf[1]==centerPnt[1])&&(puf[2]==centerPnt[2]) )
1114   {
1115     pick( (char)'p', x, y );
1116     if( (puf[0]==centerPnt[0])&&(puf[1]==centerPnt[1])&&(puf[2]==centerPnt[2]) )
1117     {
1118       printf (" found no node/point, reset center location\n");
1119       centerNode=0;
1120       centerPnt[0]=centerPnt[1]=centerPnt[2]=0;
1121       center( centerPnt[0], centerPnt[1], centerPnt[2]);
1122     }
1123   }
1124   dx_cur=PICK_LENGTH; dy_cur=PICK_LENGTH;
1125   pick( (char)'q', x, y );
1126   glutSetWindow( activWindow );
1127 }
1128 
1129 
1130 
qcutNodes(int x,int y)1131 void qcutNodes(int x, int y)
1132 {
1133   int i;
1134   int anz_n;
1135   extern int setNrbuf;
1136   static int cutnode[3]={0,0,0};
1137 
1138   setNrbuf=pre_seta( specialset->plot2d, "i", 0);
1139   set[setNrbuf].type=1;
1140 
1141   //pickFlag=1;
1142   mode[0]='i';
1143   strcpy( pickfunc, "qadd");
1144   glutSetWindow( w1);
1145 
1146   anz_n=set[setNrbuf].anz_n;
1147   printf ("pic node\n");
1148 
1149   dx_cur=PICK_LENGTH*2; dy_cur=PICK_LENGTH*2;
1150   pick( (char)'n', x, y );
1151   dx_cur=PICK_LENGTH; dy_cur=PICK_LENGTH;
1152 
1153   //printf("anz_n:%d set[setNrbuf].anz_n:%d\n", anz_n, set[setNrbuf].anz_n);
1154   //for(i=0; i<set[setNrbuf].anz_n; i++)  printf("n:%d\n",set[setNrbuf].node[i]);
1155   if( anz_n==set[setNrbuf].anz_n )
1156   {
1157     printf (" found no node, try again\n");
1158   }
1159   else
1160   {
1161     if(cutFlag==4) { pre_cut( set[setNrbuf].node[set[setNrbuf].anz_n-1], 'v' ); setr(setNrbuf, "n", set[setNrbuf].node[set[setNrbuf].anz_n-1]); }
1162     else cutnode[cutFlag-1]=set[setNrbuf].node[set[setNrbuf].anz_n-1];
1163     if(cutFlag==3) for (i=0; i<3; i++) pre_cut( cutnode[i], 'n' );
1164     cutFlag=0;
1165   }
1166   pick( (char)'q', x, y );
1167   glutSetWindow( activWindow );
1168 }
1169 
1170 
qsequence(int x,int y)1171 void qsequence(int x, int y)
1172 {
1173   int anz_n;
1174   extern int setNrbuf;
1175 
1176   setNrbuf=pre_seta( specialset->plot2d, "i", 0);
1177   set[setNrbuf].type=1;
1178 
1179   //pickFlag=1;
1180   mode[0]='i';
1181   strcpy( pickfunc, "qadd");
1182   glutSetWindow( w1);
1183 
1184   anz_n=set[setNrbuf].anz_n;
1185   printf ("pic node\n");
1186 
1187   dx_cur=PICK_LENGTH*2; dy_cur=PICK_LENGTH*2;
1188   pick( (char)'n', x, y );
1189   dx_cur=PICK_LENGTH; dy_cur=PICK_LENGTH;
1190   if( anz_n==set[setNrbuf].anz_n )
1191   {
1192     printf (" found no node, try again\n");
1193   }
1194   //pick( (char)'q', x, y );
1195   glutSetWindow( activWindow );
1196 }
1197 
1198 
1199 
qgraph(int x,int y)1200 void qgraph(int x, int y)
1201 {
1202   int i,j,n;
1203   char buffer[MAX_LINE_LENGTH];
1204 
1205   /* look if the selection was done for a 2D-plot (triggered in selectGraphMode) */
1206 
1207   pick( (char)'q', x, y );
1208   printf("\n Sequence %s created. This sequence will be kept for further use (see: prnt sq, graph)\n", specialset->plot2d);
1209   sprintf(buffer,"%s", specialset->plot2d);
1210   i=getSetNr(buffer);
1211   if((i<0)||set[i].anz_n==0)
1212   {
1213     j=getSetNr(specialset->copy);
1214     if(j>-1)
1215     {
1216       i=pre_seta(specialset->plot2d, "i", 0);
1217       for(n=0; n<set[j].anz_n; n++) seta(i,"n",set[j].node[n]);
1218     }
1219   }
1220   if((i>-1)&&set[i].anz_n>0)
1221   {
1222     if(graphFlag==1) sprintf(buffer,"%s l", specialset->plot2d);
1223     if(graphFlag==2) sprintf(buffer,"%s n", specialset->plot2d);
1224     if(graphFlag==3) sprintf(buffer,"%s t", specialset->plot2d);
1225     graph(buffer);
1226   }
1227   graphFlag=0;
1228 }
1229 
1230 
1231 
MouseState(int button,int state,int x,int y)1232 void MouseState( int button, int state, int x, int y )
1233 {
1234   static int  weelWasUsedFlag=0;
1235 
1236   xpixels=x; ypixels=y-height_w1;
1237   dx= (width_w1/2.-(double)x)/width_w1*-2.  *aspectRatio_w1;
1238   dy= (height_w1/2.-(double)y)/height_w1*2.;
1239   beginx = dx;
1240   beginy = dy;
1241   MouseMode = 0;
1242 
1243   if (glutGet(GLUT_WINDOW_HEIGHT)==height_w1) activWindow=w1;
1244   else activWindow=w0;
1245 
1246   //printf("button:%d state:%d %d %d\n", button,state,x,y);
1247   if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
1248   {
1249     MouseMode = 3;
1250     if (zoomFlag) qzoom();
1251     if (centerFlag) qcenter(x, y);
1252     if (graphFlag) qsequence(x, y);
1253     if (cutFlag) qcutNodes(x, y);
1254     if (enquireFlag)
1255     {
1256       strcpy( pickfunc, "qenq");
1257       glutSetWindow( w1);
1258       printf ("pic node\n");
1259       dx_cur=PICK_LENGTH*2; dy_cur=PICK_LENGTH*2;
1260       mode[0]='i';
1261       pick( (char)'n', x, y );
1262       dx_cur=PICK_LENGTH; dy_cur=PICK_LENGTH;
1263       glutSetWindow( activWindow );
1264       pick( (char)'q', x, y );
1265       enquireFlag=0 ;
1266     }
1267   }
1268   else
1269   if (button == GLUT_MIDDLE_BUTTON && state == GLUT_DOWN)
1270   { MouseMode = 2; }
1271   else
1272   if (button == GLUT_WEEL_UP )
1273   {
1274     weelWasUsedFlag=1;
1275     if (movezFlag)
1276     {
1277       dtz+= (0.05);
1278     }
1279     else
1280     {
1281     dtx*=ds;
1282     dty*=ds;
1283     ds+= (0.05)*ds;
1284     dtx/=ds;
1285     dty/=ds;
1286     }
1287   }
1288   else
1289   if (button == GLUT_WEEL_DOWN )
1290   {
1291     weelWasUsedFlag=1;
1292     if (movezFlag)
1293     {
1294       dtz-= (0.05);
1295     }
1296     else
1297     {
1298     dtx*=ds;
1299     dty*=ds;
1300     ds-= (0.05)*ds;
1301     dtx/=ds;
1302     dty/=ds;
1303     }
1304   }
1305   else
1306   if (button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN)
1307   {
1308     MouseMode = 1;
1309     if (graphFlag) qgraph(x, y);
1310   }
1311 
1312   /* update the elem-edges in case the view was zoomed */
1313   if( (button == GLUT_MIDDLE_BUTTON && state == GLUT_UP)||
1314       ( ((button == GLUT_RIGHT_BUTTON && state == GLUT_UP)||(button == GLUT_LEFT_BUTTON && state == GLUT_UP))&&(weelWasUsedFlag) ))
1315   {
1316     weelWasUsedFlag=0;
1317     /* printf("GLUT_MIDDLE_BUTTON && state == GLUT_UP\n"); */
1318     if (elemEdgeFlag)
1319     {
1320       if (surfFlag) drawDispListEdges(list_surf_edges, basCol[0], 1., 'f', node );
1321       else          drawDispListEdges(list_elem_edges, basCol[0], 1., 'e', node );
1322     }
1323   }
1324 
1325   if(( MouseMode==1 )&&( activWindow==w0 ))
1326   {
1327     stopFlag=1;
1328     glutSetWindow( w1);
1329     glutPostRedisplay();
1330     glutSetWindow( activWindow );
1331     if((movieFlag>0)&&(stopFlag))
1332     {
1333       movieFrames=0;
1334       movieFlag=0;
1335       printf("movie stopped, please wait for ready (might take a while)\n");
1336       sprintf( buffer, "rm -f hcpy_0.tga %s",DEV_NULL);
1337       system (buffer);
1338       createHardcopy(0, NULL);
1339       printf("movie.gif ready\n");
1340     }
1341     else
1342     {
1343       animList++;
1344       if (((sequenceFlag)||(vectorFlag))&&( animList>=dsSequence.nds)) animList=0;
1345       if ((!sequenceFlag)&&( animList>=anim_steps)) animList=0;
1346     }
1347   }
1348   if(( MouseMode==2 )&&( activWindow==w0 ))
1349   {
1350     stopFlag=!stopFlag;
1351     if(animList>0) animList--;
1352     else
1353     {
1354       if (sequenceFlag) animList=dsSequence.nds-1;
1355       if (!sequenceFlag) animList=anim_steps-1;
1356     }
1357   }
1358   if ( activWindow == w1 )
1359   {
1360     glutPostRedisplay();
1361     glutSetWindow( w2);
1362     glutPostRedisplay();
1363     glutSetWindow(activWindow );
1364   }
1365 }
1366 
1367 
1368 
frame(void)1369 void frame(void)
1370 {
1371   int i;
1372 
1373   if(!inpformat) return;
1374 
1375   /* nodes in definierten wertebereich scalieren wg. beleuchtung!  */
1376   descalNodes( anz->n, node, scale);
1377   descalPoints( anzGeo->p, point, scale);
1378   descalSurfs( anzGeo->s, surf, scale);
1379   getScaleValues( setall, set, point, node, scale);
1380   scalPoints ( anzGeo->p, point, scale );
1381   scalNodes ( anz->n, node, scale );
1382   scalSurfs( anzGeo->s, surf, scale);
1383   dtx=0.; dty=0.; dtz=0.; ds=0.5;
1384   for (i=0; i<4; i++) vmem[i]=0; /* reset all kompensations (center()) */
1385   /* recalculate the line-shapes */
1386   for (i=0; i<anzGeo->l; i++) repLine(i);
1387   for (i=0; i<anzGeo->nurl; i++) repNurl(i);
1388   for (i=0; i<anzGeo->nurs; i++) repNurs(i);
1389   redraw();
1390 }
1391 
1392 
1393 
frameSet(int setNrbuf)1394 void frameSet(int setNrbuf)
1395 {
1396   int i, setNr;
1397   Scale scaleSet[1];
1398   GLint    viewport[4];
1399   GLdouble mvmatrix[16], projmatrix[16];
1400   static GLdouble wx, wy, wz;  /*  returned window x, y, z coords  */
1401   static int flag;
1402 
1403   delSet(specialset->tmp);
1404   setNr=pre_seta(specialset->tmp, "i", 0 );
1405   if(setNrbuf==-1)
1406   {
1407     if(anzGeo->psets<1) { delSet(specialset->tmp); return; }
1408     for(i=0; i<anzGeo->psets; i++)
1409     {
1410       seta( setNr, "se", pset[i].nr );
1411       completeSet_frame(setNr, pset[i].type[0] );
1412     }
1413   }
1414   else
1415   {
1416     seta( setNr, "se", setNrbuf );
1417     completeSet_frame(setNr, 0);
1418   }
1419   getScaleValues( setNr, set, point, node, scaleSet);
1420 
1421   center( scaleSet->x, scaleSet->y, scaleSet->z);
1422   // zoom
1423   ds=0.5*scaleSet->w;
1424   // determine the pos of setnr on the screen
1425   glutSetWindow( w1);
1426   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
1427   glLoadIdentity();
1428   moveModel();
1429   glGetIntegerv (GL_VIEWPORT, viewport);
1430   glGetDoublev (GL_MODELVIEW_MATRIX, mvmatrix);
1431   glGetDoublev (GL_PROJECTION_MATRIX, projmatrix);
1432   flag=gluProject( scaleSet->x, scaleSet->y, scaleSet->z, mvmatrix, projmatrix, viewport,  &wx, &wy, &wz);
1433   if (flag==GL_FALSE) printf("WARNING: Malfunction, please reselect\n");
1434   dtx-=(wx-width_w1*.5)/(width_w1*.5);
1435   dty-=(wy-height_w1*.5)/(height_w1*.5);
1436 
1437   delSet(specialset->tmp);
1438 }
1439 
1440 
1441 
menu(int selection)1442 void menu( int selection )
1443 {
1444   switch (selection) {
1445   case 1:
1446     frame();
1447     frameSetFlag=-1;
1448     break;
1449   case 2:
1450     zoomFlag=!zoomFlag;
1451     break;
1452   case 3:
1453     centerFlag=!centerFlag;
1454     pre_view("elem");
1455     break;
1456   case 4:
1457     enquireFlag=!enquireFlag;
1458     pre_view("elem");
1459     break;
1460   case 5:
1461     commandLineFlag=!commandLineFlag;
1462     /* Kommandozeile-Fenster-index im w0 fenster  */
1463     if(commandLineFlag)
1464     {
1465       glutInitDisplayMode ( GLUT_RGBA | GLUT_DOUBLE  );
1466       activWindow= w3 = glutCreateSubWindow ( w0, 0, height_w0-pixPerChary[menu_font], width_w0, pixPerChary[menu_font] );
1467       glutDisplayFunc ( updCommandLine );
1468       glDisable(GL_DITHER);
1469       glShadeModel ( GL_FLAT );
1470     }
1471     else glutDestroyWindow(w3);
1472     break;
1473   case 6:
1474     exit(0);
1475     break;
1476   }
1477 }
1478 
1479 
1480 
orientModel(int selection)1481 void orientModel( int selection )
1482 {
1483   switch (selection) {
1484   case 1:
1485     /* Trackballfunktion inizialisieren, Blickrichtung +x (rot_x)*/
1486     rot_x(1);
1487     break;
1488   case 2:
1489     /* Trackballfunktion inizialisieren, Blickrichtung -x (rot_x)*/
1490     rot_x(-1);
1491     break;
1492   case 3:
1493     /* Trackballfunktion inizialisieren, Blickrichtung +y (rot_y)*/
1494     rot_y(1);
1495     break;
1496   case 4:
1497     /* Trackballfunktion inizialisieren, Blickrichtung -y (rot_y)*/
1498     rot_y(1);
1499     rot_r(90.);
1500     rot_r(90.);
1501     break;
1502   case 5:
1503     /* Trackballfunktion inizialisieren, Blickrichtung +z (rot_z)*/
1504     rot_z(1);
1505     rot_c(-90);
1506     break;
1507   case 6:
1508     /* Trackballfunktion inizialisieren, Blickrichtung -z (rot_z)*/
1509     rot_z(-1);
1510     rot_c(90);
1511     break;
1512   }
1513 }
1514 
1515 
1516 
markHardcopy(int selection)1517 void markHardcopy( int selection )
1518 {
1519   if(!inpformat) return;
1520 
1521   if(selection==3)
1522   {
1523     movieFlag=1;
1524     printf(" start recording movie\n");
1525     printf("   stop recording with right mouse key while in menu area of the window\n");
1526     sprintf( buffer, "rm -f _*.gif %s",DEV_NULL);
1527     system (buffer);
1528     sprintf( buffer, "rm -f movie.gif %s",DEV_NULL);
1529     system (buffer);
1530     stopFlag=0;
1531   }
1532   else
1533   {
1534     hcpyFlag=selection;
1535     printf("Please wait\n");
1536     glutPostRedisplay();
1537   }
1538 }
1539 
1540 
uncut(int surfFlagBuffer)1541 void uncut(int surfFlagBuffer)
1542 {
1543   char addDispFlagLocal=0;
1544 
1545   if(!inpformat) return;
1546 
1547   if(getSetNr("-qcut")>-1)
1548   {
1549     if(addDispFlag==1) { addDispToCoordinates(node); addDispFlagLocal=2; }
1550     zap("-qcut");
1551     if(addDispFlagLocal==2) { addDispToCoordinates(node); }
1552     surfFlag=surfFlagBuffer;
1553     glutSetWindow( w1);
1554 
1555     /* the following lines must not appear in ConfigureAndShowWindow_Load(). Else each time called all is displayed instead of a certain set */
1556     elemEdgeFlag=1;
1557     if(vectorFlag) pre_view("vector off");
1558     if(surfFlag)  plot("fv all");
1559     else          plot("ev all");
1560   }
1561 }
1562 
1563 
selectCutNode(int selection)1564 void selectCutNode( int selection )
1565 {
1566   static int surfFlagBuffer=1;
1567 
1568   pre_view("elem");
1569   switch (selection) {
1570   case 1:
1571     cutFlag=1;
1572     printf("\n Select 1st node with 'left mouse button'\n");
1573     break;
1574   case 2:
1575     cutFlag=2;
1576     printf("\n Select 2nd node with 'left mouse button'\n");
1577     break;
1578   case 3:
1579     cutFlag=3;
1580     printf("\n Select 3rd node with 'left mouse button'\n");
1581     surfFlagBuffer=surfFlag;
1582     break;
1583   case 4:
1584     uncut(surfFlagBuffer);
1585     break;
1586   case 5:
1587     cutFlag=4;
1588     printf("\n Select one node with 'left mouse button'\n");
1589     break;
1590   }
1591 }
1592 
1593 
1594 
selectGraphMode(int selection)1595 void selectGraphMode( int selection )
1596 {
1597   int i,j,n;
1598   char buffer[MAX_LINE_LENGTH];
1599 
1600   pre_view("elem");
1601   switch (selection) {
1602   case 1:
1603     printf("\n Values over length. Select nodes with 'left mouse button' then quit with 'right mouse button'\n");
1604     graphFlag=1;
1605     break;
1606   case 2:
1607     if(!sequenceFlag)
1608     {
1609       printf(" No sequence was defined. Define a sequence (menu: animate->toggle dataset sequence) then start again\n");
1610       return;
1611     }
1612     printf("\n Values over datasets. Select nodes with 'left mouse button' then quit with 'right mouse button'\n");
1613     graphFlag=2;
1614     break;
1615   case 3:
1616     if(!sequenceFlag)
1617     {
1618       printf(" No sequence was defined. Define a sequence (menu: animate->toggle dataset sequence) then start again\n");
1619       return;
1620     }
1621     printf("\n Values over time. Select nodes with 'left mouse button' then quit with 'right mouse button'\n");
1622     graphFlag=3;
1623     break;
1624   }
1625   sprintf(buffer,"se %s", specialset->copy);
1626   pre_del(buffer);
1627   sprintf(buffer,"%s", specialset->plot2d);
1628   i=getSetNr(buffer);
1629   if(i>-1)
1630   {
1631     j=pre_seta(specialset->copy, "i", 0);
1632     set[j].type=1;
1633     for(n=0; n<set[i].anz_n; n++) seta(j,"n",set[i].node[n]);
1634     sprintf(buffer,"se %s", specialset->plot2d);
1635     pre_del(buffer);
1636   }
1637   sprintf(buffer,"%s s", specialset->plot2d);
1638 
1639   /* next time the left mouse-button is used, functon qsequence is called and nodes are stored in specialset->copy */
1640   /* next time the right mouse-button is used, functon qgraph is called and a graph is created with nodes in specialset->copy */
1641 }
1642 
1643 
1644 
showHelp(int selection)1645 void showHelp( int selection )
1646 {
1647   char buffer[MAX_LINE_LENGTH];
1648 
1649   switch (selection) {
1650   case 1:
1651     help();
1652     break;
1653   case 2:
1654     sprintf( buffer, "%s %s& ", browser, helpfile[0]);
1655     printf("starting help: %s %s\n", browser, helpfile[0]);
1656     system (buffer);
1657     break;
1658   case 3:
1659     sprintf( buffer, "%s %s& ", browser, helpfile[1]);
1660     printf("starting help: %s %s\n", browser, helpfile[1]);
1661     system (buffer);
1662     break;
1663   case 4:
1664     sprintf( buffer, "%s %s& ", browser, helpfile[2]);
1665     printf("starting help: %s %s\n", browser, helpfile[2]);
1666     system (buffer);
1667     break;
1668   }
1669 }
1670 
1671 
1672 
updateDispLists()1673 void updateDispLists()
1674 {
1675 #if TEST
1676   printf ("in updateDispLists drawMode=%d \n",drawMode );
1677 #endif
1678   if(!inpformat) return;
1679 
1680   glutSetWindow( w1);
1681   /* update the element and face normals */
1682   if (drawMode==1)
1683   {
1684     if (surfFlag)
1685     {
1686       if (lcase[cur_lc].irtype == 3) printf("ERROR: Element-results are not supported so far!\n");
1687       else drawDispList( list_surf_load, 'f', node, colNr );
1688     }
1689     else
1690     {
1691       if (lcase[cur_lc].irtype == 3) printf("ERROR: Element-results are not supported so far!\n");
1692       else drawDispList( list_elem_load, 'e', node, colNr );
1693     }
1694   }
1695   else if (drawMode==2)
1696   {
1697     if (surfFlag)
1698     {
1699       getFaceNormalen( face, node, anz );
1700       drawDispList( list_surf_light, 'f', node, colNr );
1701     }
1702     if (!surfFlag)
1703     {
1704       getElemNormalen( e_enqire, node, anz->e );
1705       drawDispList( list_elem_light, 'e', node, colNr );
1706     }
1707   }
1708 
1709   if (modelEdgeFlag) drawModelEdges( list_model_edges, basCol[0], edgeWidth, anz->g, node );
1710   if (surfFlag) drawDispListEdges(list_surf_edges, basCol[0], 1., 'f', node );
1711   else          drawDispListEdges(list_elem_edges, basCol[0], 1., 'e', node );
1712 #if TEST
1713   printf (" end updateDispLists drawMode=%d \n",drawMode );
1714 #endif
1715 }
1716 
1717 
1718 
set_cur_lc(int lc)1719 void set_cur_lc(int lc)
1720 {
1721   int i;
1722   // eventually free dataset[cur_lc]
1723   if((cur_lc!=lc)&&(anz->free))
1724   {
1725     printf(" free lc[%d] ncomps:%d\n",cur_lc,lcase[cur_lc].ncomps);
1726     if(lcase[cur_lc].loaded)
1727     {
1728       for(i=0; i<lcase[cur_lc].ncomps; i++) free(lcase[cur_lc].dat[i]);
1729     }
1730     /* always allocated */
1731     free(lcase[cur_lc].dat);
1732     lcase[cur_lc].dat=NULL;
1733     lcase[cur_lc].loaded=0;
1734   }
1735   cur_lc=lc;
1736 }
1737 
1738 
1739 
ConfigureAndShowWindow_Light()1740 void ConfigureAndShowWindow_Light()
1741 {
1742   int j;
1743 #if TEST
1744   printf(" in ConfigureAndShowWindow_Light\n");
1745 #endif
1746 
1747   if(!inpformat) return;
1748 
1749   glutSetWindow( w2);
1750   DrawAxes();
1751 
1752   if(sequenceFlag)
1753   {
1754     ConfigureAndShowWindow_Sequence(1);
1755     return;
1756   }
1757 
1758   glutPostRedisplay();
1759  reselect:;
1760   glutSetWindow( w0);
1761   if (animFlag==0) { glutDisplayFunc ( DrawMenuLight ); DrawMenuLight();  }
1762   else
1763   {
1764     if(drawMode==2)
1765     {
1766       /* change the color to "illuminated" */
1767       for (j=0; j<anzGeo->psets; j++ )
1768       {
1769         if((pset[j].type[0]=='e')||(pset[j].type[0]=='f'))
1770 	{
1771           if(pset[j].type[1]==0) pset[j].type[2]=0;
1772           if(pset[j].type[1]=='b');
1773           else if(pset[j].type[2]=='b') { pset[j].type[1]='b'; pset[j].type[2]=0; }
1774           else { pset[j].type[1]=0; pset[j].type[2]=0; }
1775 	}
1776       }
1777       glutDisplayFunc ( DrawMenuAnimate ); DrawMenuAnimate();
1778     }
1779     else { glutDisplayFunc ( DrawMenuLoad ); DrawMenuLoad(); }
1780   }
1781 
1782   glutSetWindow( w1 );
1783   activWindow = w1;
1784   if (animFlag==0)
1785   {
1786     /* reset entities */
1787     if(surfFlag)
1788     {
1789       if(blendFlag) sprintf(buffer,"fb all %s", entitycol[DEF_COL].name);
1790       else          sprintf(buffer,"f all %s",  entitycol[DEF_COL].name);
1791     }
1792     else
1793     {
1794       if(blendFlag) sprintf(buffer,"eb all %s", entitycol[DEF_COL].name);
1795       else          sprintf(buffer,"e all %s", entitycol[DEF_COL].name);
1796     }
1797     plot(buffer);
1798 
1799     /* change to disp-lists */
1800     drawMode=2;
1801     updateDispLists();
1802     glutDisplayFunc ( DrawGraficLight );
1803     DrawGraficLight();
1804   }
1805   else if (animFlag==1)
1806   {
1807     if((drawMode!=2)&&(cur_entity>=lcase[pre_lc].ncomps))
1808     {
1809       printf(" Warning: No valid entity or shaded view selected\n\n");
1810       cur_entity=lcase[pre_lc].ncomps-1;
1811       if(drawMode!=4) drawMode=2;
1812       goto reselect;
1813     }
1814     set_cur_lc(pre_lc);
1815 
1816     printf ("\nDataset:%d name= %s\n", cur_lc+1, lcase[cur_lc].name);
1817 
1818     glDeleteLists( (GLuint)list_anim_light, (GLint)range_animate_light );
1819     glDeleteLists( (GLuint)list_anim_model_edges, (GLint)range_animate_light );
1820     glDeleteLists( (GLuint)list_anim_surf_edges, (GLint)range_animate_light );
1821     glDeleteLists( (GLuint)list_anim_elem_edges, (GLint)range_animate_light );
1822     range_animate_light = anim_steps;
1823     list_anim_light = glGenLists( (GLint)(range_animate_light) );
1824     list_anim_model_edges = glGenLists( (GLint)(range_animate_light) );
1825     list_anim_surf_edges = glGenLists( (GLint)(range_animate_light) );
1826     list_anim_elem_edges = glGenLists( (GLint)(range_animate_light) );
1827 
1828     if((anim_alfa=(int *)realloc((int *)anim_alfa, (range_animate_light+1)*sizeof(char *)))==NULL)
1829     { printf("\n\n ERROR: malloc failure\n\n" ); exit(1); }
1830 
1831     updateDispLists();
1832     calcAnimation( anim_steps, anim_faktor, anim_alfa, halfperiod, centerNode, anz, node, e_enqire, lcase, cur_lc, scale, surfFlag, colNr, steps );
1833     glutDisplayFunc ( DrawGraficAnimate );
1834     DrawGraficAnimate();
1835   }
1836 }
1837 
1838 
1839 
ConfigureAndShowWindow_Plot(void)1840 void ConfigureAndShowWindow_Plot( void )
1841 {
1842   int i;
1843 #if TEST
1844   printf(" in ConfigureAndShowWindow_Plot\n");
1845 #endif
1846 
1847   if(!inpformat)
1848   {
1849     if(cur_lc<anz->l) nodalDataset( cur_entity, cur_lc, anz, scale, node, lcase, colNr, 1 );
1850     return;
1851   }
1852 
1853   glutSetWindow( w2);
1854   DrawAxes();
1855 
1856   for(i=0; i<anzGeo->psets; i++)
1857   {
1858     if ((pset[i].type[1]=='v')&&(anz->l)) break;
1859   }
1860   if (i==anzGeo->psets)
1861   {
1862     glutSetWindow( w0);
1863     glutDisplayFunc ( DrawMenuSet );
1864     DrawMenuSet();
1865   }
1866   else
1867   {
1868     if(cur_lc<anz->l) nodalDataset( cur_entity, cur_lc, anz, scale, node, lcase, colNr, 1 );
1869     glutSetWindow( w0);
1870     glutDisplayFunc ( DrawMenuLoad );
1871     DrawMenuLoad();
1872   }
1873   glutSetWindow( w1);
1874   glutDisplayFunc ( DrawPickedItems );
1875   DrawPickedItems();
1876 }
1877 
1878 
1879 
ConfigureAndShowWindow_Load(void)1880 void ConfigureAndShowWindow_Load( void )
1881 {
1882 #if TEST
1883   printf(" in ConfigureAndShowWindow_Load\n");
1884 #endif
1885 
1886   if(sequenceFlag)
1887   {
1888     if(inpformat) ConfigureAndShowWindow_Sequence(0);
1889     else { printf("ERROR in ConfigureAndShowWindow_Load: not possible in -bg mode.\n"); }
1890     return;
1891   }
1892 
1893   if(inpformat)
1894   {
1895     glutSetWindow( w2);
1896     DrawAxes();
1897 
1898     glutSetWindow( w1 );
1899   }
1900 
1901   if (lcase[cur_lc].irtype == 3) /* element data */
1902   {
1903     elementDataset( cur_entity, cur_lc, anz, scale, lcase, offset, maxIndex, steps );
1904   }
1905   else
1906   {
1907     nodalDataset( cur_entity, cur_lc, anz, scale, node, lcase, colNr, 1 );
1908   }
1909 
1910   if(inpformat)
1911   {
1912     glutSetWindow( w0);
1913     glutDisplayFunc ( DrawMenuLoad );
1914     DrawMenuLoad();
1915 
1916     /* change to disp-lists */
1917     drawMode=1;
1918     updateDispLists();
1919     glutSetWindow( w1);
1920     glutDisplayFunc ( DrawGraficLoad );
1921     DrawGraficLoad();
1922   }
1923 }
1924 
1925 
1926 
ConfigureAndShowWindow_Sequence(int dispFlag)1927 void ConfigureAndShowWindow_Sequence( int dispFlag )
1928 {
1929 #if TEST
1930   printf(" in ConfigureAndShowWindow_Sequence\n");
1931 #endif
1932   int i,j, n;
1933   int nmax=0, nmin=0;
1934   double vmax=-MAX_FLOAT, vmin=MAX_FLOAT;
1935 
1936   if(!inpformat) return;
1937 
1938   /* make sure the 1st frame uses the 1st ds */
1939   animList=0;
1940 
1941   glutSetWindow(w1);
1942   glDeleteLists( (GLuint)list_anim_light, (GLint)range_animate_light );
1943   glDeleteLists( (GLuint)list_anim_model_edges, (GLint)range_animate_light );
1944   glDeleteLists( (GLuint)list_anim_surf_edges, (GLint)range_animate_light );
1945   glDeleteLists( (GLuint)list_anim_elem_edges, (GLint)range_animate_light );
1946   range_animate_light = dsSequence.nds;
1947   list_anim_light = glGenLists( (GLint)(range_animate_light) );
1948   list_anim_model_edges = glGenLists( (GLint)(range_animate_light) );
1949   list_anim_surf_edges = glGenLists( (GLint)(range_animate_light) );
1950   list_anim_elem_edges = glGenLists( (GLint)(range_animate_light) );
1951 
1952   /* load the loadcases for the sequence, has to be loaded prior to lcase allocation because the ncomps have to be extended before */
1953 
1954   printf("Loading data, please wait\n");
1955 
1956   for(i=0; i<dsSequence.nds; i++)
1957   {
1958     //printf("ds[%d]:%d %s\n",i+1,dsSequence.ds[i]+1, lcase[dsSequence.ds[i]].name );
1959 
1960     /* check if the data of the specified lcase (Dataset) are already available */
1961     if (!lcase[dsSequence.ds[i]].loaded)
1962     {
1963       if( pre_readfrdblock(copiedNodeSets, dsSequence.ds[i], anz, node, lcase )==-1)
1964       {
1965         printf("ERROR in nodalDataset: Could not read data for Dataset:%d\n", dsSequence.ds[i]+1);
1966         return;
1967       }
1968       calcDatasets( dsSequence.ds[i], anz, node, lcase );
1969       recompileEntitiesInMenu(dsSequence.ds[i]);
1970     }
1971 
1972     if(vmax<lcase[dsSequence.ds[i]].max[cur_entity])
1973     { vmax=lcase[dsSequence.ds[i]].max[cur_entity]; nmax=lcase[dsSequence.ds[i]].nmax[cur_entity]; }
1974     if(vmin>lcase[dsSequence.ds[i]].min[cur_entity])
1975     { vmin=lcase[dsSequence.ds[i]].min[cur_entity]; nmin=lcase[dsSequence.ds[i]].nmin[cur_entity]; }
1976   }
1977   /* set to the max-vals in range */
1978   if((scale->smin ==scale->smax )&&(scale->lock!='l'))
1979   {
1980     scale->smin = vmin;
1981     scale->smax = vmax;
1982   }
1983 
1984   if(drawMode==2) /* light */
1985   {
1986     /* switch the psets to the shaded mode */
1987     for (j=0; j<anzGeo->psets; j++ )
1988     {
1989       if((pset[j].type[0]=='e')||(pset[j].type[0]=='f'))
1990       {
1991         if(pset[j].type[1]==0) pset[j].type[2]=0;
1992         if(pset[j].type[1]=='b');
1993         else if(pset[j].type[2]=='b') { pset[j].type[1]='b'; pset[j].type[2]=0; }
1994         else pset[j].type[1]=0;
1995       }
1996     }
1997 
1998     illumFlag=1;
1999     glutSetWindow( w1 );
2000 
2001     if(lcase_animList<0)
2002     {
2003       /* create an additional lcase for the vector length of all steps */
2004       if ( (lcase = (Datasets *)realloc((Datasets *)lcase, (anz->l+2) * sizeof(Datasets))) == NULL )
2005       { printf("\n\n ERROR: malloc failure\n\n" ); exit(1); }
2006 
2007       lcase[anz->l].ncomps = dsSequence.nds;
2008       lcase[anz->l].irtype = 1;
2009       lcase[anz->l].npheader = 0;
2010       if(( lcase[anz->l].pheader=(char **)malloc( sizeof(char *))) == NULL )
2011         printf("\n\n ERROR: malloc failure\n\n" );
2012       lcase[anz->l].fileptr = NULL;
2013       lcase[anz->l].loaded = 1;
2014       lcase[anz->l].value=0;
2015       strcpy(lcase[anz->l].analysis_name,"");
2016       strcpy(lcase[anz->l].dataset_name,"");
2017       strcpy(lcase[anz->l].dataset_text,"");
2018       lcase[anz->l].step_number=0;
2019       lcase[anz->l].analysis_type=1;
2020 
2021       if ( (lcase[anz->l].nmax = (int *)malloc( lcase[anz->l].ncomps * sizeof(int))) == NULL )
2022         printf("\n\n ERROR: malloc failure\n\n" );
2023       if ( (lcase[anz->l].nmin = (int *)malloc( lcase[anz->l].ncomps * sizeof(int))) == NULL )
2024         printf("\n\n ERROR: malloc failure\n\n" );
2025       if ( (lcase[anz->l].max = (float *)malloc( lcase[anz->l].ncomps * sizeof(float))) == NULL )
2026         printf("\n\n ERROR: malloc failure\n\n" );
2027       if ( (lcase[anz->l].min = (float *)malloc( lcase[anz->l].ncomps * sizeof(float))) == NULL )
2028         printf("\n\n ERROR: malloc failure\n\n" );
2029       if ( (lcase[anz->l].dat = (float **)malloc( lcase[anz->l].ncomps * sizeof(float *))) == NULL )
2030         printf("\n\n ERROR: malloc failure\n\n" );
2031       if ( (lcase[anz->l].compName = (char **)malloc( lcase[anz->l].ncomps * sizeof(char *))) == NULL )
2032         printf("\n\n ERROR: malloc failure\n\n" );
2033       if ( (lcase[anz->l].icname = (char **)malloc( lcase[anz->l].ncomps * sizeof(char *))) == NULL )
2034         printf("\n\n ERROR: malloc failure\n\n" );
2035       for(j=0; j<lcase[anz->l].ncomps; j++)
2036       {
2037         if ( (lcase[anz->l].dat[j] = (float *)malloc( (anz->nmax+1) * sizeof(float))) == NULL )
2038           printf("\n\n ERROR: malloc failure\n\n" );
2039         if ( (lcase[anz->l].compName[j] = (char *)malloc( MAX_LINE_LENGTH * sizeof(char))) == NULL )
2040            printf("\n\n ERROR: malloc failed\n\n" );
2041         if ( (lcase[anz->l].icname[j] = (char *)malloc( MAX_LINE_LENGTH * sizeof(char))) == NULL )
2042            printf("\n\n ERROR: malloc failed\n\n" );
2043         lcase[anz->l].max[j]=-MAX_FLOAT;
2044         lcase[anz->l].min[j]=MAX_FLOAT;
2045       }
2046       if ( (lcase[anz->l].menu = (int *)malloc( lcase[anz->l].ncomps * sizeof(int))) == NULL )
2047         printf("\n\n ERROR: malloc failure\n\n" );
2048       if ( (lcase[anz->l].ictype = (int *)malloc( lcase[anz->l].ncomps * sizeof(int))) == NULL )
2049         printf("\n\n ERROR: malloc failure\n\n" );
2050       if ( (lcase[anz->l].icind1 = (int *)malloc( lcase[anz->l].ncomps * sizeof(int))) == NULL )
2051         printf("\n\n ERROR: malloc failure\n\n" );
2052       if ( (lcase[anz->l].icind2 = (int *)malloc( lcase[anz->l].ncomps * sizeof(int))) == NULL )
2053         printf("\n\n ERROR: malloc failure\n\n" );
2054       if ( (lcase[anz->l].iexist = (int *)malloc( lcase[anz->l].ncomps * sizeof(int))) == NULL )
2055         printf("\n\n ERROR: malloc failure\n\n" );
2056 
2057       for(j=0; j<lcase[anz->l].ncomps; j++)
2058       {
2059         lcase[anz->l].menu[j] = 1;
2060         lcase[anz->l].ictype[j] = 2;
2061         lcase[anz->l].icind1[j] = j+1;
2062         lcase[anz->l].icind2[j] = 0;
2063         lcase[anz->l].iexist[j] = 0;
2064         sprintf(lcase[anz->l].compName[j], "step");
2065       }
2066       lcase_animList=anz->l;
2067     }
2068     else
2069     {
2070       /* realloc the additional lcase after for the vector length of all steps */
2071       for(j=0; j<lcase[lcase_animList].ncomps; j++)
2072       {
2073         free(lcase[lcase_animList].dat[j]);
2074         free(lcase[lcase_animList].compName[j]);
2075         free(lcase[lcase_animList].icname[j]);
2076       }
2077 
2078       lcase[lcase_animList].ncomps = dsSequence.nds;
2079       lcase[lcase_animList].irtype = 1;
2080       for(j=0; j<lcase[lcase_animList].npheader; j++) free(lcase[lcase_animList].pheader[j]);
2081       lcase[lcase_animList].npheader = 0;
2082       lcase[lcase_animList].fileptr = NULL;
2083       lcase[lcase_animList].loaded = 1;
2084 
2085       if ( (lcase[lcase_animList].nmax = (int *)realloc( lcase[lcase_animList].nmax, lcase[lcase_animList].ncomps * sizeof(int))) == NULL )
2086         printf("\n\n ERROR: realloc failure\n\n" );
2087       if ( (lcase[lcase_animList].nmin = (int *)realloc( lcase[lcase_animList].nmin, lcase[lcase_animList].ncomps * sizeof(int))) == NULL )
2088         printf("\n\n ERROR: realloc failure\n\n" );
2089       if ( (lcase[lcase_animList].max = (float *)realloc( lcase[lcase_animList].max, lcase[lcase_animList].ncomps * sizeof(float))) == NULL )
2090         printf("\n\n ERROR: realloc failure\n\n" );
2091       if ( (lcase[lcase_animList].min = (float *)realloc( lcase[lcase_animList].min, lcase[lcase_animList].ncomps * sizeof(float))) == NULL )
2092         printf("\n\n ERROR: realloc failure\n\n" );
2093       if ( (lcase[lcase_animList].dat = (float **)realloc( lcase[lcase_animList].dat, lcase[lcase_animList].ncomps * sizeof(float *))) == NULL )
2094         printf("\n\n ERROR: realloc failure\n\n" );
2095       if ( (lcase[lcase_animList].compName = (char **)realloc( lcase[lcase_animList].compName, lcase[lcase_animList].ncomps * sizeof(char *))) == NULL )
2096         printf("\n\n ERROR: realloc failure\n\n" );
2097       if ( (lcase[lcase_animList].icname = (char **)realloc( lcase[lcase_animList].icname, lcase[lcase_animList].ncomps * sizeof(char *))) == NULL )
2098         printf("\n\n ERROR: realloc failure\n\n" );
2099       for(j=0; j<lcase[lcase_animList].ncomps; j++)
2100       {
2101         if ( (lcase[lcase_animList].dat[j] = (float *)malloc( (anz->nmax+1) * sizeof(float))) == NULL )
2102           printf("\n\n ERROR: malloc failure\n\n" );
2103         if ( (lcase[lcase_animList].compName[j] = (char *)malloc( MAX_LINE_LENGTH * sizeof(char))) == NULL )
2104            printf("\n\n ERROR: malloc failed\n\n" );
2105         if ( (lcase[lcase_animList].icname[j] = (char *)malloc( MAX_LINE_LENGTH * sizeof(char))) == NULL )
2106            printf("\n\n ERROR: malloc failed\n\n" );
2107         lcase[lcase_animList].max[j]=-MAX_FLOAT;
2108         lcase[lcase_animList].min[j]=MAX_FLOAT;
2109       }
2110       if ( (lcase[lcase_animList].menu = (int *)realloc( lcase[lcase_animList].menu, lcase[lcase_animList].ncomps * sizeof(int))) == NULL )
2111         printf("\n\n ERROR: realloc failure\n\n" );
2112       if ( (lcase[lcase_animList].ictype = (int *)realloc( lcase[lcase_animList].ictype, lcase[lcase_animList].ncomps * sizeof(int))) == NULL )
2113         printf("\n\n ERROR: realloc failure\n\n" );
2114       if ( (lcase[lcase_animList].icind1 = (int *)realloc( lcase[lcase_animList].icind1, lcase[lcase_animList].ncomps * sizeof(int))) == NULL )
2115         printf("\n\n ERROR: realloc failure\n\n" );
2116       if ( (lcase[lcase_animList].icind2 = (int *)realloc( lcase[lcase_animList].icind2, lcase[lcase_animList].ncomps * sizeof(int))) == NULL )
2117         printf("\n\n ERROR: realloc failure\n\n" );
2118       if ( (lcase[lcase_animList].iexist = (int *)realloc( lcase[lcase_animList].iexist, lcase[lcase_animList].ncomps * sizeof(int))) == NULL )
2119         printf("\n\n ERROR: realloc failure\n\n" );
2120 
2121       for(j=0; j<lcase[lcase_animList].ncomps; j++)
2122       {
2123         lcase[lcase_animList].menu[j] = 1;
2124         lcase[lcase_animList].ictype[j] = 2;
2125         lcase[lcase_animList].icind1[j] = j+1;
2126         lcase[lcase_animList].icind2[j] = 0;
2127         lcase[lcase_animList].iexist[j] = 0;
2128         sprintf(lcase[lcase_animList].compName[j], "step");
2129       }
2130     }
2131     calcSequence( dsSequence, anim_faktor, halfperiod, centerNode, anz, node, e_enqire, lcase, scale, surfFlag, colNr, steps, lcase_animList, dispFlag);
2132     glutSetWindow( w0);
2133 
2134     strcpy(lcase[lcase_animList].name,lcase[dsSequence.ds[0]].name);
2135     strcpy(lcase[lcase_animList].dataset_text,lcase[dsSequence.ds[0]].dataset_text);
2136     lcase[lcase_animList].step_number=lcase[anz->l-1].step_number+1;
2137     lcase[lcase_animList].analysis_type=lcase[anz->l-1].analysis_type;
2138 
2139     glutDisplayFunc ( DrawMenuAnimate );
2140     DrawMenuAnimate();
2141     activWindow = w1;
2142   }
2143   else /* load */
2144   {
2145     drawMode=1;
2146     illumFlag=0;
2147     glutSetWindow( w1 );
2148 
2149     if(lcase_animList<0)
2150     {
2151       /* create an additional lcase after for the vector length of all steps */
2152       if ( (lcase = (Datasets *)realloc((Datasets *)lcase, (anz->l+2) * sizeof(Datasets))) == NULL )
2153       { printf("\n\n ERROR: malloc failure\n\n" ); exit(1); }
2154 
2155       lcase[anz->l].ncomps = dsSequence.nds;
2156       lcase[anz->l].irtype = 1;
2157       lcase[anz->l].npheader = 0;
2158       if(( lcase[anz->l].pheader=(char **)malloc( sizeof(char *))) == NULL )
2159         printf("\n\n ERROR: malloc failure\n\n" );
2160 
2161       if ( (lcase[anz->l].nmax = (int *)malloc( lcase[anz->l].ncomps * sizeof(int))) == NULL )
2162         printf("\n\n ERROR: malloc failure\n\n" );
2163       if ( (lcase[anz->l].nmin = (int *)malloc( lcase[anz->l].ncomps * sizeof(int))) == NULL )
2164         printf("\n\n ERROR: malloc failure\n\n" );
2165       if ( (lcase[anz->l].max = (float *)malloc( lcase[anz->l].ncomps * sizeof(float))) == NULL )
2166         printf("\n\n ERROR: malloc failure\n\n" );
2167       if ( (lcase[anz->l].min = (float *)malloc( lcase[anz->l].ncomps * sizeof(float))) == NULL )
2168         printf("\n\n ERROR: malloc failure\n\n" );
2169       if ( (lcase[anz->l].dat = (float **)malloc( lcase[anz->l].ncomps * sizeof(float *))) == NULL )
2170         printf("\n\n ERROR: malloc failure\n\n" );
2171       if ( (lcase[anz->l].compName = (char **)malloc( lcase[anz->l].ncomps * sizeof(char *))) == NULL )
2172         printf("\n\n ERROR: malloc failure\n\n" );
2173       if ( (lcase[anz->l].icname = (char **)malloc( lcase[anz->l].ncomps * sizeof(char *))) == NULL )
2174         printf("\n\n ERROR: malloc failure\n\n" );
2175       for(j=0; j<lcase[anz->l].ncomps; j++)
2176       {
2177         if ( (lcase[anz->l].dat[j] = (float *)malloc( (anz->nmax+1) * sizeof(float))) == NULL )
2178           printf("\n\n ERROR: malloc failure\n\n" );
2179         if ( (lcase[anz->l].compName[j] = (char *)malloc( MAX_LINE_LENGTH * sizeof(char))) == NULL )
2180            printf("\n\n ERROR: malloc failed\n\n" );
2181         if ( (lcase[anz->l].icname[j] = (char *)malloc( MAX_LINE_LENGTH * sizeof(char))) == NULL )
2182            printf("\n\n ERROR: malloc failed\n\n" );
2183         lcase[anz->l].max[j]=-MAX_FLOAT;
2184         lcase[anz->l].min[j]=MAX_FLOAT;
2185       }
2186       if ( (lcase[anz->l].menu = (int *)malloc( lcase[anz->l].ncomps * sizeof(int))) == NULL )
2187         printf("\n\n ERROR: malloc failure\n\n" );
2188       if ( (lcase[anz->l].ictype = (int *)malloc( lcase[anz->l].ncomps * sizeof(int))) == NULL )
2189         printf("\n\n ERROR: malloc failure\n\n" );
2190       if ( (lcase[anz->l].icind1 = (int *)malloc( lcase[anz->l].ncomps * sizeof(int))) == NULL )
2191         printf("\n\n ERROR: malloc failure\n\n" );
2192       if ( (lcase[anz->l].icind2 = (int *)malloc( lcase[anz->l].ncomps * sizeof(int))) == NULL )
2193         printf("\n\n ERROR: malloc failure\n\n" );
2194       if ( (lcase[anz->l].iexist = (int *)malloc( lcase[anz->l].ncomps * sizeof(int))) == NULL )
2195         printf("\n\n ERROR: malloc failure\n\n" );
2196 
2197       for(j=0; j<lcase[anz->l].ncomps; j++)
2198       {
2199         lcase[anz->l].menu[j] = 1;
2200         lcase[anz->l].ictype[j] = 2;
2201         lcase[anz->l].icind1[j] = j+1;
2202         lcase[anz->l].icind2[j] = 0;
2203         lcase[anz->l].iexist[j] = 0;
2204       }
2205       lcase_animList=anz->l;
2206     }
2207     else
2208     {
2209       /* realloc the additional lcase after for the vector length of all steps */
2210       for(j=0; j<lcase[lcase_animList].ncomps; j++)
2211       {
2212         free(lcase[lcase_animList].dat[j]);
2213         free(lcase[lcase_animList].compName[j]);
2214         free(lcase[lcase_animList].icname[j]);
2215       }
2216 
2217       lcase[lcase_animList].ncomps = dsSequence.nds;
2218       lcase[lcase_animList].irtype = 1;
2219       for(j=0; j<lcase[lcase_animList].npheader; j++) free(lcase[lcase_animList].pheader[j]);
2220       lcase[lcase_animList].npheader = 0;
2221 
2222       if ( (lcase[lcase_animList].nmax = (int *)realloc( lcase[lcase_animList].nmax, lcase[lcase_animList].ncomps * sizeof(int))) == NULL )
2223         printf("\n\n ERROR: realloc failure\n\n" );
2224       if ( (lcase[lcase_animList].nmin = (int *)realloc( lcase[lcase_animList].nmin, lcase[lcase_animList].ncomps * sizeof(int))) == NULL )
2225         printf("\n\n ERROR: realloc failure\n\n" );
2226       if ( (lcase[lcase_animList].max = (float *)realloc( lcase[lcase_animList].max, lcase[lcase_animList].ncomps * sizeof(float))) == NULL )
2227         printf("\n\n ERROR: realloc failure\n\n" );
2228       if ( (lcase[lcase_animList].min = (float *)realloc( lcase[lcase_animList].min, lcase[lcase_animList].ncomps * sizeof(float))) == NULL )
2229         printf("\n\n ERROR: realloc failure\n\n" );
2230       if ( (lcase[lcase_animList].dat = (float **)realloc( lcase[lcase_animList].dat, lcase[lcase_animList].ncomps * sizeof(float *))) == NULL )
2231         printf("\n\n ERROR: realloc failure\n\n" );
2232       if ( (lcase[lcase_animList].compName = (char **)realloc( lcase[lcase_animList].compName, lcase[lcase_animList].ncomps * sizeof(char *))) == NULL )
2233         printf("\n\n ERROR: realloc failure\n\n" );
2234       if ( (lcase[lcase_animList].icname = (char **)realloc( lcase[lcase_animList].icname, lcase[lcase_animList].ncomps * sizeof(char *))) == NULL )
2235         printf("\n\n ERROR: realloc failure\n\n" );
2236       for(j=0; j<lcase[lcase_animList].ncomps; j++)
2237       {
2238         if ( (lcase[lcase_animList].dat[j] = (float *)malloc( (anz->nmax+1) * sizeof(float))) == NULL )
2239           printf("\n\n ERROR: malloc failure\n\n" );
2240         if ( (lcase[lcase_animList].compName[j] = (char *)malloc( MAX_LINE_LENGTH * sizeof(char))) == NULL )
2241            printf("\n\n ERROR: malloc failed\n\n" );
2242         if ( (lcase[lcase_animList].icname[j] = (char *)malloc( MAX_LINE_LENGTH * sizeof(char))) == NULL )
2243            printf("\n\n ERROR: malloc failed\n\n" );
2244         lcase[lcase_animList].max[j]=-MAX_FLOAT;
2245         lcase[lcase_animList].min[j]=MAX_FLOAT;
2246       }
2247       if ( (lcase[lcase_animList].menu = (int *)realloc( lcase[lcase_animList].menu, lcase[lcase_animList].ncomps * sizeof(int))) == NULL )
2248         printf("\n\n ERROR: realloc failure\n\n" );
2249       if ( (lcase[lcase_animList].ictype = (int *)realloc( lcase[lcase_animList].ictype, lcase[lcase_animList].ncomps * sizeof(int))) == NULL )
2250         printf("\n\n ERROR: realloc failure\n\n" );
2251       if ( (lcase[lcase_animList].icind1 = (int *)realloc( lcase[lcase_animList].icind1, lcase[lcase_animList].ncomps * sizeof(int))) == NULL )
2252         printf("\n\n ERROR: realloc failure\n\n" );
2253       if ( (lcase[lcase_animList].icind2 = (int *)realloc( lcase[lcase_animList].icind2, lcase[lcase_animList].ncomps * sizeof(int))) == NULL )
2254         printf("\n\n ERROR: realloc failure\n\n" );
2255       if ( (lcase[lcase_animList].iexist = (int *)realloc( lcase[lcase_animList].iexist, lcase[lcase_animList].ncomps * sizeof(int))) == NULL )
2256         printf("\n\n ERROR: realloc failure\n\n" );
2257 
2258       for(j=0; j<lcase[lcase_animList].ncomps; j++)
2259       {
2260         lcase[lcase_animList].menu[j] = 1;
2261         lcase[lcase_animList].ictype[j] = 2;
2262         lcase[lcase_animList].icind1[j] = j+1;
2263         lcase[lcase_animList].icind2[j] = 0;
2264         lcase[lcase_animList].iexist[j] = 0;
2265       }
2266     }
2267 
2268     calcSequence( dsSequence, anim_faktor, halfperiod, centerNode, anz, node, e_enqire, lcase, scale, surfFlag, colNr, steps, lcase_animList, dispFlag);
2269     glutSetWindow( w0);
2270 
2271     strcpy(lcase[lcase_animList].name,lcase[dsSequence.ds[0]].name);
2272     strcpy(lcase[lcase_animList].dataset_text,lcase[dsSequence.ds[0]].dataset_text);
2273     lcase[lcase_animList].step_number=lcase[anz->l-1].step_number+1;
2274     lcase[lcase_animList].analysis_type=lcase[anz->l-1].analysis_type;
2275     // cur_lc needed in DrawMenuSequence to plot max/min value in legend
2276     set_cur_lc(lcase_animList);
2277     lcase[lcase_animList].value=0;
2278     lcase[lcase_animList].max[0]=vmax;
2279     lcase[lcase_animList].min[0]=vmin;
2280     lcase[lcase_animList].nmax[0]=nmax;
2281     lcase[lcase_animList].nmin[0]=nmin;
2282 
2283     glutDisplayFunc ( DrawMenuSequence );
2284     DrawMenuSequence();
2285     activWindow = w1;
2286   }
2287 
2288   for(n=0; n<lcase[lcase_animList].ncomps; n++)
2289   {
2290     lcase[lcase_animList].dat[n][0]=lcase[dsSequence.ds[n]].value;
2291     if(( lcase[lcase_animList].pheader=(char **)realloc((char **)lcase[lcase_animList].pheader, (lcase[lcase_animList].npheader+1) * sizeof(char *))) == NULL )
2292       printf("\n\n ERROR: realloc failure\n\n" );
2293     if(( lcase[lcase_animList].pheader[lcase[lcase_animList].npheader]=(char *)malloc(MAX_LINE_LENGTH * sizeof(char))) == NULL )
2294       printf("\n\n ERROR: malloc failure\n\n" );
2295     sprintf(lcase[lcase_animList].pheader[lcase[lcase_animList].npheader],"%s",lcase[dsSequence.ds[n]].dataset_text);
2296     lcase[lcase_animList].npheader++;
2297   }
2298   glutSetWindow( w1 );
2299   glutDisplayFunc ( DrawGraficSequence );
2300   DrawGraficSequence();
2301 }
2302 
2303 
2304 
ConfigureAndShowWindow_Vector(void)2305 void ConfigureAndShowWindow_Vector( void )
2306 {
2307 #if TEST
2308   printf(" in ConfigureAndShowWindow_Vector\n");
2309 #endif
2310   int i,j,k,n;
2311   int nmax=0, nmin=0;
2312   double vmax=-MAX_FLOAT, vmin=MAX_FLOAT;
2313 
2314   if(!inpformat) return;
2315   if(!dsSequence.nds) {  printf("ERROR: No ds selected:%d\n",dsSequence.nds); return; }
2316 
2317   /* make sure the 1st frame uses the 1st ds */
2318   animList=0;
2319 
2320   glutSetWindow(w1);
2321   if(!sequenceFlag)
2322   {
2323     drawModelEdges( list_model_edges, basCol[0], edgeWidth, anz->g, node );
2324     if (surfFlag) drawDispListEdges(list_surf_edges, basCol[0], 1., 'f', node );
2325     else          drawDispListEdges(list_elem_edges, basCol[0], 1., 'e', node );
2326   }
2327   glDeleteLists( (GLuint)list_anim_light, (GLint)range_animate_light );
2328   range_animate_light=dsSequence.nds;
2329   list_anim_light = glGenLists( (GLint)(range_animate_light) );
2330 
2331   illumFlag=0;
2332 
2333   /* load the loadcases for the vectors, has to be loaded prior to lcase allocation because the ncomps have to be extended before */
2334 
2335   printf("Loading data, please wait\n");
2336 
2337   for(i=0; i<dsSequence.nds; i++)
2338   {
2339     printf("ds[%d]:%d %s\n",i+1,dsSequence.ds[i]+1, lcase[dsSequence.ds[i]].name );
2340 
2341     /* check if the data of the specified lcase (Dataset) are already available */
2342     if (!lcase[dsSequence.ds[i]].loaded)
2343     {
2344       if( pre_readfrdblock(copiedNodeSets , dsSequence.ds[i], anz, node, lcase )==-1)
2345       {
2346         printf("ERROR in nodalDataset: Could not read data for Dataset:%d\n", dsSequence.ds[i]+1);
2347         return;
2348       }
2349       calcDatasets( dsSequence.ds[i], anz, node, lcase );
2350       recompileEntitiesInMenu(dsSequence.ds[i]);
2351     }
2352   }
2353 
2354   if(lcase_animList<0)
2355   {
2356     /* create an additional lcase for the vector length of all steps */
2357     if ( (lcase = (Datasets *)realloc((Datasets *)lcase, (anz->l+2) * sizeof(Datasets))) == NULL )
2358       printf("\n\n ERROR: realloc failed, lcase\n\n") ;
2359     strcpy(lcase[anz->l].name,lcase[dsSequence.ds[0]].name);
2360     lcase[anz->l].ncomps = dsSequence.nds;
2361     strcpy(lcase[anz->l].dataset_name,"");
2362     strcpy(lcase[anz->l].dataset_text,"");
2363     lcase[anz->l].value = 0.;
2364     lcase[anz->l].irtype = 1;
2365     if(( lcase[anz->l].pheader=(char **)malloc( sizeof(char *))) == NULL )
2366       printf("\n\n ERROR: malloc failure\n\n" );
2367     lcase[anz->l].npheader = 0;
2368     lcase[anz->l].fileptr = NULL;
2369     lcase[anz->l].loaded = 1;
2370     lcase[anz->l].step_number=0;
2371 
2372     if ( (lcase[anz->l].nmax = (int *)malloc( lcase[anz->l].ncomps * sizeof(int))) == NULL )
2373       printf("\n\n ERROR: malloc failure\n\n" );
2374     if ( (lcase[anz->l].nmin = (int *)malloc( lcase[anz->l].ncomps * sizeof(int))) == NULL )
2375       printf("\n\n ERROR: malloc failure\n\n" );
2376     if ( (lcase[anz->l].max = (float *)malloc( lcase[anz->l].ncomps * sizeof(float))) == NULL )
2377       printf("\n\n ERROR: malloc failure\n\n" );
2378     if ( (lcase[anz->l].min = (float *)malloc( lcase[anz->l].ncomps * sizeof(float))) == NULL )
2379       printf("\n\n ERROR: malloc failure\n\n" );
2380     if ( (lcase[anz->l].dat = (float **)malloc( lcase[anz->l].ncomps * sizeof(float *))) == NULL )
2381       printf("\n\n ERROR: malloc failure\n\n" );
2382     if ( (lcase[anz->l].compName = (char **)malloc( lcase[anz->l].ncomps * sizeof(char *))) == NULL )
2383       printf("\n\n ERROR: malloc failure\n\n" );
2384     if ( (lcase[anz->l].icname = (char **)malloc( lcase[anz->l].ncomps * sizeof(char *))) == NULL )
2385       printf("\n\n ERROR: malloc failure\n\n" );
2386     for(j=0; j<lcase[anz->l].ncomps; j++)
2387     {
2388       if ( (lcase[anz->l].dat[j] = (float *)malloc( (anz->nmax+1) * sizeof(float))) == NULL )
2389         printf("\n\n ERROR: malloc failure\n\n" );
2390       if ( (lcase[anz->l].compName[j] = (char *)malloc( MAX_LINE_LENGTH * sizeof(char))) == NULL )
2391          printf("\n\n ERROR: malloc failed\n\n" );
2392       if ( (lcase[anz->l].icname[j] = (char *)malloc( MAX_LINE_LENGTH * sizeof(char))) == NULL )
2393          printf("\n\n ERROR: malloc failed\n\n" );
2394       lcase[anz->l].max[j]=-MAX_FLOAT;
2395       lcase[anz->l].min[j]=MAX_FLOAT;
2396     }
2397     if ( (lcase[anz->l].menu = (int *)malloc( lcase[anz->l].ncomps * sizeof(int))) == NULL )
2398       printf("\n\n ERROR: malloc failure\n\n" );
2399     if ( (lcase[anz->l].ictype = (int *)malloc( lcase[anz->l].ncomps * sizeof(int))) == NULL )
2400       printf("\n\n ERROR: malloc failure\n\n" );
2401     if ( (lcase[anz->l].icind1 = (int *)malloc( lcase[anz->l].ncomps * sizeof(int))) == NULL )
2402       printf("\n\n ERROR: malloc failure\n\n" );
2403     if ( (lcase[anz->l].icind2 = (int *)malloc( lcase[anz->l].ncomps * sizeof(int))) == NULL )
2404       printf("\n\n ERROR: malloc failure\n\n" );
2405     if ( (lcase[anz->l].iexist = (int *)malloc( lcase[anz->l].ncomps * sizeof(int))) == NULL )
2406       printf("\n\n ERROR: malloc failure\n\n" );
2407 
2408     for(j=0; j<lcase[anz->l].ncomps; j++)
2409     {
2410       lcase[anz->l].menu[j] = 1;
2411       lcase[anz->l].ictype[j] = 2;
2412       lcase[anz->l].icind1[j] = j+1;
2413       lcase[anz->l].icind2[j] = 0;
2414       lcase[anz->l].iexist[j] = 0;
2415     }
2416     lcase_animList=anz->l;
2417   }
2418   else
2419   {
2420     /* realloc the additional lcase for the vector length of all steps */
2421     for(j=0; j<lcase[lcase_animList].ncomps; j++)
2422     {
2423       free(lcase[lcase_animList].dat[j]);
2424       free(lcase[lcase_animList].compName[j]);
2425       free(lcase[lcase_animList].icname[j]);
2426     }
2427 
2428     lcase[lcase_animList].ncomps = dsSequence.nds;
2429     lcase[lcase_animList].irtype = 1;
2430     for(j=0; j<lcase[lcase_animList].npheader; j++) free(lcase[lcase_animList].pheader[j]);
2431     lcase[lcase_animList].npheader = 0;
2432     lcase[lcase_animList].fileptr = NULL;
2433     lcase[lcase_animList].loaded = 1;
2434 
2435     if ( (lcase[lcase_animList].nmax = (int *)realloc( lcase[lcase_animList].nmax, lcase[lcase_animList].ncomps * sizeof(int))) == NULL )
2436       printf("\n\n ERROR: realloc failure\n\n" );
2437     if ( (lcase[lcase_animList].nmin = (int *)realloc( lcase[lcase_animList].nmin, lcase[lcase_animList].ncomps * sizeof(int))) == NULL )
2438       printf("\n\n ERROR: realloc failure\n\n" );
2439     if ( (lcase[lcase_animList].max = (float *)realloc( lcase[lcase_animList].max, lcase[lcase_animList].ncomps * sizeof(float))) == NULL )
2440       printf("\n\n ERROR: realloc failure\n\n" );
2441     if ( (lcase[lcase_animList].min = (float *)realloc( lcase[lcase_animList].min, lcase[lcase_animList].ncomps * sizeof(float))) == NULL )
2442       printf("\n\n ERROR: realloc failure\n\n" );
2443     if ( (lcase[lcase_animList].dat = (float **)realloc( lcase[lcase_animList].dat, lcase[lcase_animList].ncomps * sizeof(float *))) == NULL )
2444       printf("\n\n ERROR: realloc failure\n\n" );
2445     if ( (lcase[lcase_animList].compName = (char **)realloc( lcase[lcase_animList].compName, lcase[lcase_animList].ncomps * sizeof(char *))) == NULL )
2446       printf("\n\n ERROR: realloc failure\n\n" );
2447     if ( (lcase[lcase_animList].icname = (char **)realloc( lcase[lcase_animList].icname, lcase[lcase_animList].ncomps * sizeof(char *))) == NULL )
2448       printf("\n\n ERROR: realloc failure\n\n" );
2449     for(j=0; j<lcase[lcase_animList].ncomps; j++)
2450     {
2451       if ( (lcase[lcase_animList].dat[j] = (float *)malloc( (anz->nmax+1) * sizeof(float))) == NULL )
2452         printf("\n\n ERROR: malloc failure\n\n" );
2453       if ( (lcase[lcase_animList].compName[j] = (char *)malloc( MAX_LINE_LENGTH * sizeof(char))) == NULL )
2454          printf("\n\n ERROR: malloc failed\n\n" );
2455       if ( (lcase[lcase_animList].icname[j] = (char *)malloc( MAX_LINE_LENGTH * sizeof(char))) == NULL )
2456          printf("\n\n ERROR: malloc failed\n\n" );
2457       lcase[lcase_animList].max[j]=-MAX_FLOAT;
2458       lcase[lcase_animList].min[j]=MAX_FLOAT;
2459     }
2460     if ( (lcase[lcase_animList].menu = (int *)realloc( lcase[lcase_animList].menu, lcase[lcase_animList].ncomps * sizeof(int))) == NULL )
2461       printf("\n\n ERROR: realloc failure\n\n" );
2462     if ( (lcase[lcase_animList].ictype = (int *)realloc( lcase[lcase_animList].ictype, lcase[lcase_animList].ncomps * sizeof(int))) == NULL )
2463       printf("\n\n ERROR: realloc failure\n\n" );
2464     if ( (lcase[lcase_animList].icind1 = (int *)realloc( lcase[lcase_animList].icind1, lcase[lcase_animList].ncomps * sizeof(int))) == NULL )
2465       printf("\n\n ERROR: realloc failure\n\n" );
2466     if ( (lcase[lcase_animList].icind2 = (int *)realloc( lcase[lcase_animList].icind2, lcase[lcase_animList].ncomps * sizeof(int))) == NULL )
2467       printf("\n\n ERROR: realloc failure\n\n" );
2468     if ( (lcase[lcase_animList].iexist = (int *)realloc( lcase[lcase_animList].iexist, lcase[lcase_animList].ncomps * sizeof(int))) == NULL )
2469       printf("\n\n ERROR: realloc failure\n\n" );
2470 
2471     for(j=0; j<lcase[lcase_animList].ncomps; j++)
2472     {
2473       lcase[lcase_animList].menu[j] = 1;
2474       lcase[lcase_animList].ictype[j] = 2;
2475       lcase[lcase_animList].icind1[j] = j+1;
2476       lcase[lcase_animList].icind2[j] = 0;
2477       lcase[lcase_animList].iexist[j] = 0;
2478     }
2479   }
2480   //cur_lc=lcase_animList;  // not active because some functions need the original dataset and use cur_lc to find it (cut)
2481   set_cur_lc(dsSequence.ds[0]);
2482 
2483   /* store and calculate the vector length */
2484   for(n=0; n<dsSequence.nds; n++)
2485   {
2486     i=dsSequence.ds[n];
2487     if(v_dim==4) sprintf(lcase[lcase_animList].compName[n], lcase[i].compName[cur_entity]);
2488     else
2489     {
2490       if(v_dim==3) sprintf(lcase[lcase_animList].compName[n], "v(%s,%s,%s)", lcase[i].compName[entity_v[0]], lcase[i].compName[entity_v[1]], lcase[i].compName[entity_v[2]]);
2491       else         sprintf(lcase[lcase_animList].compName[n], "v(%s,%s)", lcase[i].compName[entity_v[0]], lcase[i].compName[entity_v[1]]);
2492       /* delete blanks */
2493       k=0; for(j=0; j<strlen(lcase[lcase_animList].compName[n]); j++) if(lcase[lcase_animList].compName[n][j]!=' ') { lcase[lcase_animList].compName[n][k++]=lcase[lcase_animList].compName[n][j]; }
2494       lcase[lcase_animList].compName[n][k]='\0';
2495     }
2496     /* select the vector length (color plot) */
2497     if (lcase[i].irtype == 3) { printf("Element results are not supported\n"); return; }
2498 
2499     for(j=0; j<anz->n; j++)
2500     {
2501       if(node[node[j].nr].pflag==-1) continue;
2502       if(v_dim==4)
2503       {
2504         lcase[lcase_animList].dat[n][node[j].nr]=lcase[i].dat[entity_v[3]][node[j].nr];
2505       }
2506       else
2507       {
2508         lcase[lcase_animList].dat[n][node[j].nr]=0.;
2509         for(k=0; k<v_dim; k++)
2510           lcase[lcase_animList].dat[n][node[j].nr]+=lcase[i].dat[entity_v[k]][node[j].nr]*lcase[i].dat[entity_v[k]][node[j].nr];
2511         lcase[lcase_animList].dat[n][node[j].nr]=sqrt(lcase[lcase_animList].dat[n][node[j].nr]);
2512       }
2513     }
2514   }
2515 
2516   /* max and min for plotting */
2517   for(k=0; k<lcase[lcase_animList].ncomps; k++)
2518   {
2519     for(j=0; j<anz->n; j++)
2520     {
2521       if(node[node[j].nr].pflag==-1) continue;
2522       if(lcase[lcase_animList].dat[k][node[j].nr] > vmax)
2523       {
2524         vmax=lcase[lcase_animList].dat[k][node[j].nr];
2525         nmax=node[j].nr;
2526       }
2527       if(lcase[lcase_animList].dat[k][node[j].nr] < vmin)
2528       {
2529         vmin=lcase[lcase_animList].dat[k][node[j].nr];
2530         nmin=node[j].nr;
2531       }
2532     }
2533   }
2534   //printf (" maxval:%e at node:%d\n minval:%e at node:%d  cur_lc:%d cur_entity:%d\n", vmax, nmax, vmin, nmin, cur_lc, cur_entity);
2535 
2536   /* set to the max-vals in range */
2537   if(scale->smin ==scale->smax )
2538   {
2539     scale->smin = vmin;
2540     scale->smax = vmax;
2541   }
2542 
2543   /* save the overall values for the drawing */
2544   lcase[lcase_animList].max[0] =vmax;
2545   lcase[lcase_animList].nmax[0]=nmax;
2546   lcase[lcase_animList].min[0] =vmin;
2547   lcase[lcase_animList].nmin[0]=nmin;
2548 
2549   if(vmax*vmax>vmin*vmin) v_factor=1./vmax;
2550   else v_factor=1./vmin;
2551 
2552   /* prepare the color values */
2553   for(k=0; k<lcase[lcase_animList].ncomps; k++)
2554   {
2555     nodalDataset( k, lcase_animList, anz, scale, node, lcase, colNr, 1 );
2556     lcase[lcase_animList].dat[k][0]=lcase[dsSequence.ds[k]].value;
2557     if(( lcase[lcase_animList].pheader=(char **)realloc((char **)lcase[lcase_animList].pheader, (lcase[lcase_animList].npheader+1) * sizeof(char *))) == NULL )
2558       printf("\n\n ERROR: realloc failure\n\n" );
2559     if(( lcase[lcase_animList].pheader[lcase[lcase_animList].npheader]=(char *)malloc(MAX_LINE_LENGTH * sizeof(char))) == NULL )
2560       printf("\n\n ERROR: malloc failure\n\n" );
2561     sprintf(lcase[lcase_animList].pheader[lcase[lcase_animList].npheader],"%s",lcase[dsSequence.ds[k]].dataset_text);
2562     lcase[lcase_animList].npheader++;
2563 
2564     glutSetWindow( w1);
2565     if ( (list_animate = (GLuint *)realloc( list_animate, (k+1) * sizeof(GLuint))) == NULL )
2566       printf("\n\n ERROR: realloc failure\n\n" );
2567     list_animate[k]=list_anim_light+k;
2568     if (surfFlag)   drawDispList( list_animate[k], 'f', node, colNr );
2569     if (!surfFlag)  drawDispList( list_animate[k], 'e', node, colNr );
2570   }
2571   lcase[lcase_animList].value=0;
2572   lcase[lcase_animList].dataset_text[0]=0;
2573   strcpy(lcase[lcase_animList].name,lcase[dsSequence.ds[0]].name);
2574   lcase[lcase_animList].step_number=lcase[anz->l-1].step_number+1;
2575   lcase[lcase_animList].analysis_type=lcase[anz->l-1].analysis_type;
2576 
2577   glutSetWindow( w0);
2578   glutDisplayFunc ( DrawMenuSequence );
2579   DrawMenuSequence();
2580   glutSetWindow( w1 );
2581   glutDisplayFunc ( DrawGraficSequence );
2582   DrawGraficSequence();
2583 }
2584 
2585 
2586 
zoom(double xcur0,double ycur0,double xcur1,double ycur1)2587 void zoom(double xcur0, double ycur0, double xcur1, double ycur1)
2588 {
2589   double  dx_cur, dy_cur, dso;
2590 
2591   if(!inpformat) return;
2592 
2593       dx_cur= xcur1-xcur0;
2594       dx_cur= sqrt( dx_cur*dx_cur );
2595       dy_cur= ycur1-ycur0;
2596       dy_cur= sqrt( dy_cur*dy_cur );
2597       dso=ds;
2598       if (dx_cur<dy_cur) ds*=dy_cur/2.;
2599       else ds*=dx_cur/2.;
2600       dtx=(dtx- (xcur1+xcur0)/2.)*dso/ds ;
2601       dty=(dty- (ycur1+ycur0)/2.)*dso/ds ;
2602       zoomFlag=0;
2603     redraw();
2604 }
2605 
2606 
selectUserFunc(int selection)2607 void selectUserFunc( int selection )
2608 {
2609   FILE *handle1=NULL;
2610   int  na, gtolFlag=0, addFlag=0;
2611   char type[MAX_LINE_LENGTH];
2612   char string[MAX_LINE_LENGTH];
2613 
2614   strcpy(string,userCommand[selection-1]);
2615   type[0]=0;
2616   na=0; while(string[na]==' ') na++;
2617   na+= sword( string, type);
2618   commandoInterpreter( type, string, na, strlen(string), handle1, addFlag, &gtolFlag );
2619 }
2620 
2621 
2622 /* create a menu entry to execute a cgx-command */
pre_menu(char * record)2623 void pre_menu( char *record)
2624 {
2625   int  i, length;
2626   static char  **name=NULL;
2627 
2628   if(!inpformat) return;
2629 
2630   if((name=(char **)realloc((char **)name, (userCommands+1)*sizeof(char *)))==NULL)
2631   { printf("\n\nERROR: realloc failure\n\n"); }
2632   if((name[userCommands]= (char *)malloc( MAX_LINE_LENGTH * sizeof(char))) == NULL )
2633   { printf("\n\nERROR: malloc failure\n\n"); }
2634   if((userCommand=(char **)realloc((char **)userCommand, (userCommands+1)*sizeof(char *)))==NULL)
2635   { printf("\n\nERROR: realloc failure\n\n"); }
2636   if((userCommand[userCommands]= (char *)malloc( MAX_LINE_LENGTH * sizeof(char))) == NULL )
2637   { printf("\n\nERROR: malloc failure\n\n"); }
2638 
2639   length = sword( record, name[userCommands] );
2640   strcpy(userCommand[userCommands],&record[length+1]);
2641   printf(" add userCommand: name:%s command:%s\n",name[userCommands],userCommand[userCommands]);
2642   userCommands++;
2643 
2644   /* create a menu entry in submenu_user */
2645 
2646   submenu_user = glutCreateMenu( selectUserFunc );
2647   for(i=0; i<userCommands; i++)
2648     glutAddMenuEntry( name[i], i+1);
2649 
2650   createDatasetEntries();
2651 }
2652 
2653 
pre_rot(char * record)2654 void pre_rot( char *record)
2655 {
2656   int  i,length;
2657   double angle;
2658   char type[MAX_LINE_LENGTH];
2659 
2660   if(!inpformat) return;
2661 
2662   length = sword( record, type );
2663   angle = atof( &record[length+1]);
2664   if (type[0]=='u') rot_u(angle);
2665   else if (type[0]=='r') rot_r(angle);
2666   else if (type[0]=='c') rot_c(angle);
2667   else if (type[0]=='d') rot_u(-angle);
2668   else if (type[0]=='l') rot_r(-angle);
2669   else if (type[0]=='x') rot_x(1.);
2670   else if (type[0]=='y') rot_y(1.);
2671   else if (type[0]=='z') rot_z(1.);
2672   else if (type[0]=='n')
2673   {
2674     i=checkIfNumber(&record[length+1]);
2675     if(i==1) i=rot_norm(atoi(&record[length+1]));
2676     else
2677     { i=getSetNr(&record[length+1]);
2678       if(i>-1) { if(set[i].anz_n>0) i=rot_norm(set[i].node[0]); }
2679     }
2680     if(i==0)
2681     {
2682       strcpy(parameter[0],"TRUE");
2683     }
2684     else
2685     {
2686       printf(" WARNING: node not on the surface\n");
2687       strcpy(parameter[0],"FALSE");
2688     }
2689     write2stack(1, parameter);
2690   }
2691   else if (type[0]=='-')
2692   {
2693     if (type[1]=='x') rot_x(-1.);
2694     else if (type[1]=='y') rot_y(-1.);
2695     else if (type[1]=='z') rot_z(-1.);
2696     else errMsg(" rot type:%s not known\n", type);
2697   }
2698   else errMsg(" rot type:%s not known\n", type);
2699   glutSetWindow( w2 );
2700   glutPostRedisplay();
2701   glutSetWindow( w1);
2702   glutPostRedisplay();
2703 }
2704 
2705 
2706 
plot(char * record)2707 int plot( char *record )
2708 {
2709   int  i,n,setNr;
2710   int  index;
2711   char typ[MAX_LINE_LENGTH];
2712   char setnam[MAX_LINE_LENGTH];
2713   char col[MAX_LINE_LENGTH];
2714   int  ewidth=0;
2715 
2716   if(!inpformat) return(-1);
2717 
2718   col[0]=0;
2719   sscanf(record,"%s %s %s %d",typ,setnam,col,&ewidth);
2720   if (typ[0]=='m') typ[0]='e';
2721 
2722   operateAlias( setnam, "se" );
2723 
2724   /* get the bad elements in set */
2725   if (typ[1]=='q')
2726   {
2727     i=calcBadElements(setnam);
2728     if (i>0) { printf("found %d bad elements in set:%s (stored in set:%s)\n", i,setnam, specialset->njby); strcpy(setnam,specialset->njby); }
2729     else { printf("found no bad element in set:%s\n", setnam); delSet(specialset->njby); }
2730     typ[1]=typ[2];
2731   }
2732   setNr=getSetNr(setnam);
2733   if (setNr<0)
2734   {
2735     printf (" plot: set:%s does not exist\n", setnam);
2736     return (-1);
2737   }
2738 
2739   if ((pset = (Psets *)realloc( (Psets *)pset, (1)*sizeof(Psets)) ) == NULL )
2740   {
2741     printf(" ERROR: realloc failure in plot, pset not installed\n\n");
2742     return(-1);
2743   }
2744   anzGeo->psets=1;
2745 
2746   n=0;
2747   for(i=0; i<entitycols; i++) if(compareStrings(col,entitycol[i].name)>0) { pset[0].col=i; n=1; }
2748   /* if no valid color was set */
2749   if (n==0)
2750   {
2751     if        (typ[0]=='n') pset[0].col=3;
2752     else if   (typ[0]=='e') pset[0].col=4;
2753     else if   (typ[0]=='f') pset[0].col=6;
2754     else if   (typ[0]=='p') pset[0].col=5;
2755     else if   (typ[0]=='l') pset[0].col=foregrndcol;
2756     else if   (typ[0]=='s') pset[0].col=8;
2757     else if   (typ[0]=='b') pset[0].col=4;
2758     else if   (typ[0]=='L') pset[0].col=foregrndcol;
2759     else if   (typ[0]=='S') pset[0].col=2;
2760     else                    pset[0].col=6;
2761     /* check if the color was actually an entity width */
2762     ewidth=atoi(col);
2763   }
2764   pset[0].nr= setNr;
2765   strcpy( pset[0].type, "    ");
2766   strcpy( pset[0].type, typ);
2767   pset[0].width=ewidth;
2768 
2769   drawMode=4;
2770   if((typ[0]=='e')||(typ[0]=='f'))
2771   {
2772     glutSetWindow( w1);
2773     if(typ[0]=='e') surfFlag=0;
2774     updateDispLists();
2775   }
2776 
2777   /* show links to related sets */
2778   if((typ[0]=='n')||(typ[0]=='f'))
2779   {
2780     if(set[setNr].anz_se)
2781     {
2782       index=2;
2783       for(i=1; i<anz->sets; i++) if(!set[i].type) set[i].index=index++;
2784       printf("->[ ");
2785       for(i=0; i<set[setNr].anz_se; i++)
2786         printf("%s(%d) ",set[set[setNr].set[i]].name,set[set[setNr].set[i]].index);
2787       printf("]\n");
2788     }
2789   }
2790 
2791   ConfigureAndShowWindow_Plot();
2792   return(1);
2793 }
2794 
2795 
2796 
plus(char * record)2797 int plus( char *record )
2798 {
2799   int  i,n, setNr;
2800   int  index;
2801   char typ[MAX_LINE_LENGTH];
2802   char setnam[MAX_LINE_LENGTH];
2803   char col[MAX_LINE_LENGTH];
2804   int  ewidth=0;
2805 
2806   if(!inpformat) return(-1);
2807 
2808   col[0]=0;
2809   sscanf(record,"%s %s %s %d",typ,setnam,col,&ewidth);
2810   if (typ[0]=='m') typ[0]='e';
2811 
2812   operateAlias( setnam, "se" );
2813 
2814   /* get the bad elements in set */
2815   if (typ[1]=='q')
2816   {
2817     i=calcBadElements(setnam);
2818     if (i>0) { printf("found %d bad elements in set:%s (stored in set:%s)\n", i,setnam, specialset->njby); strcpy(setnam,specialset->njby); }
2819     else { printf("found no bad element in set:%s\n", setnam); delSet(specialset->njby); }
2820     typ[1]=typ[2];
2821   }
2822   setNr=getSetNr(setnam);
2823   if (setNr<0)
2824   {
2825     printf (" plus: set:%s does not exist\n", setnam);
2826     return (-1);
2827   }
2828 
2829   if ((pset = (Psets *)realloc( (Psets *)pset, (anzGeo->psets+1)*sizeof(Psets)) ) == NULL )
2830   {
2831     printf(" ERROR: realloc failure in plot, pset not installed\n\n");
2832     return(-1);
2833   }
2834 
2835   n=0;
2836   for(i=0; i<entitycols; i++) if(compareStrings(col,entitycol[i].name)>0) { pset[anzGeo->psets].col=i; n=1; }
2837   /* if no valid color was set */
2838   if (n==0)
2839   {
2840     if        (typ[0]=='n') pset[anzGeo->psets].col=3;
2841     else if   (typ[0]=='e') pset[anzGeo->psets].col=4;
2842     else if   (typ[0]=='f') pset[anzGeo->psets].col=6;
2843     else if   (typ[0]=='p') pset[anzGeo->psets].col=5;
2844     else if   (typ[0]=='l') pset[anzGeo->psets].col=foregrndcol;
2845     else if   (typ[0]=='s') pset[anzGeo->psets].col=8;
2846     else if   (typ[0]=='b') pset[anzGeo->psets].col=4;
2847     else if   (typ[0]=='L') pset[anzGeo->psets].col=foregrndcol;
2848     else if   (typ[0]=='S') pset[anzGeo->psets].col=2;
2849     else                    pset[anzGeo->psets].col=6;
2850     /* check if the color was actually an entity width */
2851     ewidth=atoi(col);
2852   }
2853   pset[anzGeo->psets].nr= setNr;
2854   strcpy( pset[anzGeo->psets].type, "    ");
2855   strcpy( pset[anzGeo->psets].type, typ);
2856   pset[anzGeo->psets].width=ewidth;
2857   anzGeo->psets++;
2858   drawMode=4;
2859   if((typ[0]=='e')||(typ[0]=='f'))
2860   {
2861     if(typ[0]=='e') surfFlag=0;
2862     updateDispLists();
2863   }
2864 
2865   /* show links to related sets */
2866   if((typ[0]=='n')||(typ[0]=='f'))
2867   {
2868     if(set[setNr].anz_se)
2869     {
2870       index=2;
2871       for(i=1; i<anz->sets; i++) if(!set[i].type) set[i].index=index++;
2872       printf("->[ ");
2873       for(i=0; i<set[setNr].anz_se; i++)
2874         printf("%s(%d) ",set[set[setNr].set[i]].name,set[set[setNr].set[i]].index);
2875       printf("]\n");
2876     }
2877   }
2878 
2879   ConfigureAndShowWindow_Plot();
2880   return(1);
2881 }
2882 
2883 
2884 
minus(char * record)2885 int minus( char *record )
2886 {
2887   int   setNr;
2888   int  length, i, flag=0;
2889   char typ[MAX_LINE_LENGTH];
2890   char setnam[MAX_LINE_LENGTH];
2891 
2892   if(!inpformat) return(-1);
2893 
2894   length = sword( record, typ );
2895   length = 1+length + sword( &record[length], setnam );
2896   if   (typ[0]=='m') typ[0]='e';
2897 
2898   operateAlias( setnam, "se" );
2899   setNr=getSetNr(setnam);
2900   if (setNr<0)
2901   {
2902     printf (" minus: set:%s does not exist\n", setnam);
2903     return (-1);
2904   }
2905 
2906   /* look for the pset to remove */
2907   for(i=0; i<anzGeo->psets; i++)
2908   {
2909     if(pset[i].nr==setNr)
2910     {
2911       if(pset[i].type[0]==typ[0])
2912       {
2913         printf (" set:%s type:%s removed\n", setnam, pset[i].type);
2914         strcpy( pset[i].type, "    ");
2915       }
2916     }
2917     updateDispLists();
2918     flag=1;
2919   }
2920   if(flag==0) printf (" set:%s is not on the screen\n", setnam);
2921 
2922   ConfigureAndShowWindow_Plot();
2923   return(1);
2924 }
2925 
2926 
2927 
changeAnimation(int selection)2928 void changeAnimation( int selection )
2929 {
2930   /* more options in separate submenus, not listed here */
2931   if(anz->l<1) return;
2932 
2933   switch (selection) {
2934   case 1:
2935       animFlag=1;
2936       ConfigureAndShowWindow_Light();
2937     break;
2938   case 2:
2939       animFlag=1;
2940       halfperiod=!halfperiod;
2941       ConfigureAndShowWindow_Light();
2942     break;
2943   case 3:
2944       modelEdgeFlag_Static=!modelEdgeFlag_Static;
2945       if (modelEdgeFlag_Static) /* copy from updateDispLists() */
2946         drawModelEdges( list_model_edges, basCol[0], edgeWidth, anz->g, node );
2947     break;
2948   case 4:
2949       elemEdgeFlag_Static=!elemEdgeFlag_Static;
2950       if (elemEdgeFlag_Static)
2951       {
2952 	updateDispLists();
2953         //if (surfFlag) drawDispListEdges(list_surf_edges, basCol[0], 1., 'f', node );
2954         //else          drawDispListEdges(list_elem_edges, basCol[0], 1., 'e', node );
2955       }
2956     break;
2957   case 5:
2958       seq_nlc=0;
2959       seqLC[1]=0;
2960       seqLC[2]=anz->l-1;
2961       animList=0;
2962       sequenceFlag=!sequenceFlag;
2963       if(sequenceFlag)
2964       {
2965         printf(" choose 1st Dataset (optionally 2nd and last Dataset) and the entity\n");
2966       }
2967       else
2968       {
2969         ConfigureAndShowWindow_Load();
2970         printf(" sequence off\n");
2971       }
2972     break;
2973   }
2974 }
2975 
2976 
2977 
changeColormap(int selection)2978 void changeColormap( int selection )
2979 {
2980   strcpy(buffer,cmap_names[selection-1]);
2981   strcpy(cmap_name, buffer);
2982   printf("\nSetting \'%s\' colormap.\n\n",cmap_name);
2983   defineColTextur_load(1.);
2984   redraw();
2985 }
2986 
2987 
2988 
newTimePerPeriod(int selection)2989 void newTimePerPeriod( int selection )
2990 {
2991   switch (selection) {
2992   case 1:
2993       time_per_period=1;
2994     break;
2995   case 2:
2996       time_per_period=1000;
2997     break;
2998   case 3:
2999       time_per_period=1200;
3000     break;
3001   case 4:
3002       time_per_period=1500;
3003     break;
3004   case 5:
3005       time_per_period=2000;
3006     break;
3007   case 6:
3008       time_per_period=5000;
3009     break;
3010   }
3011   redraw();
3012 }
3013 
3014 
3015 
tuneAnimation(int selection)3016 void tuneAnimation( int selection )
3017 {
3018   switch (selection) {
3019   case 0:
3020     anim_faktor=1.;
3021     break;
3022   case 1:
3023     anim_faktor*= 10.;
3024     break;
3025   case 2:
3026     anim_faktor*= 5.;
3027     break;
3028   case 3:
3029     anim_faktor*= 2;
3030     break;
3031   case 4:
3032     anim_faktor/= 2;
3033     break;
3034   case 5:
3035     anim_faktor/= 5.;
3036     break;
3037   case 6:
3038     anim_faktor/= 10.;
3039     break;
3040   }
3041   /* remove the displacements and use the scaled ones */
3042   if(addDispFlag==1)
3043   {
3044      addDispToCoordinates(node);
3045      addDispToCoordinates(node);
3046   }
3047   redraw();
3048 }
3049 
3050 
3051 
stepsAnimation(int selection)3052 void stepsAnimation( int selection )
3053 {
3054   anim_steps=selection;
3055   redraw();
3056 }
3057 
3058 
3059 
redraw(void)3060 void redraw(void)
3061 {
3062   if(!inpformat) return;
3063 #if TEST
3064   printf("in redraw: drawMode:%d animFlag:%d\n", drawMode, animFlag);
3065 #endif
3066   if ((drawMode==1)&&(!animFlag))
3067   {
3068     ConfigureAndShowWindow_Load();
3069   }
3070   if ((drawMode==1)&&(animFlag))
3071   {
3072     ConfigureAndShowWindow_Load();
3073     ConfigureAndShowWindow_Light();
3074   }
3075   if (drawMode==2)
3076   {
3077     ConfigureAndShowWindow_Light();
3078   }
3079   if (drawMode==4)
3080   {
3081     ConfigureAndShowWindow_Plot();
3082     if (animFlag) ConfigureAndShowWindow_Light();
3083   }
3084   if (drawMode==5)
3085   {
3086     ConfigureAndShowWindow_Vector();
3087   }
3088   drawModelEdges( list_model_edges, basCol[0], edgeWidth, anz->g, node );
3089   // it might be necessary to shift drawElem_edge+drawFaces_edge from drawSets to this loc.
3090   glutPostRedisplay();
3091 }
3092 
3093 
3094 
createDsSequence(int seq_nlc,int * seqLC)3095 void createDsSequence(int seq_nlc, int *seqLC)
3096 {
3097   int i,j, freq=0;
3098 
3099   dsSequence.nds=0;
3100   if( seq_nlc<3) seqLC[2]=anz->l-1;
3101   /* remove the displacements if its not a single vector plot  */
3102   if( seq_nlc>0)  if(addDispFlag==1) addDispToCoordinates(node);;
3103 
3104   //printf("seqLC %d %d %d\n",seqLC[0],seqLC[1],seqLC[2]);
3105 
3106   /* determine the frequency */
3107   for(i=seqLC[0]; i<=seqLC[2]; i++)
3108   {
3109     if(i>=seqLC[1]) break;
3110     if(compareStrings(lcase[i].name, lcase[seqLC[0]].name)>0) freq++;
3111   }
3112   //printf("freq:%d\n",freq);
3113 
3114   j=freq-1;
3115   for(i=seqLC[0]; i<=seqLC[2]; i++)
3116   {
3117     if(compareStrings(lcase[i].name, lcase[seqLC[0]].name)>0)
3118     {
3119       j++;
3120       if(j==freq)
3121       {
3122         j=0;
3123         if((dsSequence.ds=(int *)realloc((int *)dsSequence.ds, (dsSequence.nds+1)*sizeof(int)))==NULL) printf("\nERROR realloc in createDsSequence\n\n");
3124         dsSequence.ds[dsSequence.nds]=i;
3125         //printf("nr:%d ds:%d i:%d\n", dsSequence.nds, dsSequence.ds[dsSequence.nds], i);
3126         dsSequence.nds++;
3127       }
3128     }
3129   }
3130 }
3131 
3132 
3133 
selectParameter(int selection)3134 void selectParameter( int selection )
3135 {
3136   char  buffer[MAX_LINE_LENGTH],  parameter[MAX_LINE_LENGTH];
3137 
3138   sscanf(&lcase[pre_lc].pheader[selection-1][6],"%s",parameter );
3139   //printf("%s selected:%d %s\n", lcase[pre_lc].name, selection, parameter );
3140   sprintf(buffer, "-p nr %s %s %d", lcase[pre_lc].name, parameter, pre_lc+1);
3141   graph(buffer);
3142 }
3143 
3144 
3145 
selectEntity(int selection)3146 void selectEntity( int selection )
3147 {
3148   int i,j,e[4];
3149 #if TEST
3150   printf (" in selectEntity sequenceFlag:%d animFlag:%d\n",sequenceFlag, animFlag);
3151 #endif
3152 
3153   /* change the element and face mode to 'value' (if not translucent and if not a single one does not already show results ('v') ) */
3154   j=1;
3155   for(i=0; i<anzGeo->psets; i++) if(pset[i].type[1]=='v') j=0;
3156   if(j)
3157   {
3158     for(i=0; i<anzGeo->psets; i++)
3159     {
3160       if((pset[i].type[0]=='e')||(pset[i].type[0]=='f'))
3161       {
3162         if(pset[i].type[1]=='b') pset[i].type[2]='b';
3163         pset[i].type[1]='v';
3164       }
3165     }
3166   }
3167 
3168   cur_entity=selection-1;
3169   if(vectorFlag) entity_buf=cur_entity;
3170   set_cur_lc(pre_lc);
3171   v_scale=1.;
3172   if(scale->lock!='l') { scale->smin=scale->smax=0; scale->sminr=scale->smaxr=defScalMethod; }
3173 
3174   if(sequenceFlag)
3175   {
3176     /* if unselected seqLC[1] == 0 */
3177     /* if unselected seqLC[2] == anz->l */
3178     if(seqLC[1]<=seqLC[0]) seqLC[1]=seqLC[0]+1;
3179     seq_nlc=3;
3180 
3181     if((vectorFlag)&&(lcase[cur_lc].ictype[cur_entity]==2))
3182     {
3183       /* search all necessary entities */
3184       if (lcase[seqLC[0]].icind1[cur_entity]==1)      { e[0]=cur_entity+1; e[1]=cur_entity+2; e[2]=cur_entity+3; e[3]=-1;}
3185       else if (lcase[seqLC[0]].icind1[cur_entity]==2) { e[0]=cur_entity; e[1]=cur_entity+1; e[2]=cur_entity+2; e[3]=-1;}
3186       else if (lcase[seqLC[0]].icind1[cur_entity]==3) { e[0]=cur_entity-1; e[1]=cur_entity; e[2]=cur_entity+1; e[3]=-1;}
3187       else if (lcase[seqLC[0]].icind1[cur_entity]==0) { e[0]=cur_entity-2; e[1]=cur_entity-1; e[2]=cur_entity; e[3]=cur_entity+1;}
3188       else
3189       {
3190         /* vector-components not located before the vector-value */
3191 	printf("\n ERROR: entity is not part of a vector\n");
3192         return;
3193       }
3194       sprintf(buffer,"%d %d %d e", seqLC[0]+1, seqLC[1]+1, seqLC[2]+1);
3195       for(i=0; i<3; i++)
3196       {
3197         if((lcase[seqLC[0]].icind1[e[i]-1]==i+1)&&(lcase[seqLC[0]].ncomps>=e[i]))
3198           sprintf( &buffer[strlen(buffer)]," %d",e[i]);
3199         else
3200         {
3201           /* vector-components not located before the vector-value */
3202           printf("\n ERROR: entity is not part of a vector\n");
3203           return;
3204         }
3205       }
3206       if(e[3]>-1) sprintf( &buffer[strlen(buffer)]," %d",e[3]);
3207       selectData(buffer);
3208       return;
3209     }
3210     else
3211     {
3212       if((compare(lcase[seqLC[0]].name, "DISP", 4)==4)&&(cur_entity==3))
3213       {
3214         /* no fringe plot, just the animated deformation */
3215         sprintf(buffer,"%d %d %d a", seqLC[0]+1, seqLC[1]+1, seqLC[2]+1);
3216         selectData(buffer);
3217       }
3218       else
3219       {
3220         sprintf(buffer,"%d %d %d e", seqLC[0]+1, seqLC[1]+1, seqLC[2]+1);
3221         sprintf( &buffer[strlen(buffer)]," %d",cur_entity+1);
3222         selectData(buffer);
3223       }
3224       return;
3225     }
3226   }
3227   else
3228   {
3229     if((vectorFlag)&&(lcase[cur_lc].ictype[cur_entity]==2))
3230     {
3231       /* search all necessary entities */
3232       if (lcase[cur_lc].icind1[cur_entity]==1)      { e[0]=cur_entity+1; e[1]=cur_entity+2; e[2]=cur_entity+3; e[3]=-1;}
3233       else if (lcase[cur_lc].icind1[cur_entity]==2) { e[0]=cur_entity; e[1]=cur_entity+1; e[2]=cur_entity+2; e[3]=-1;}
3234       else if (lcase[cur_lc].icind1[cur_entity]==3) { e[0]=cur_entity-1; e[1]=cur_entity; e[2]=cur_entity+1; e[3]=-1;}
3235       else if (lcase[cur_lc].icind1[cur_entity]==0) { e[0]=cur_entity-2; e[1]=cur_entity-1; e[2]=cur_entity; e[3]=cur_entity+1;}
3236       else
3237       {
3238         /* components not located before the entity of the vector-length */
3239 	printf("\n ERROR: entity is not part of a vector\n");
3240         return;
3241       }
3242       sprintf(buffer,"%d e",cur_lc+1 );
3243       for(i=0; i<3; i++)
3244       {
3245         if((lcase[cur_lc].icind1[e[i]-1]==i+1)&&(lcase[cur_lc].ncomps>=e[i]))
3246           sprintf( &buffer[strlen(buffer)]," %d",e[i]);
3247         else
3248         {
3249           /* components not located before the entity of the vector-length */
3250           printf("\n ERROR: entity is not part of a vector\n");
3251           return;
3252 	}
3253       }
3254       if(e[3]>-1) sprintf( &buffer[strlen(buffer)]," %d",e[3]);
3255       selectData(buffer);
3256       return;
3257     }
3258   }
3259 
3260   if(drawMode==4)
3261   {
3262     if(!animFlag) ConfigureAndShowWindow_Plot();
3263   }
3264   else
3265   {
3266     drawMode=1;
3267     if(!animFlag) ConfigureAndShowWindow_Load();
3268   }
3269 }
3270 
3271 
3272 
selectDatasetMenu(int selection)3273 void selectDatasetMenu( int selection )
3274 {
3275   selectDataset( selection );
3276   if(lcase[pre_lc].ncomps==1) { animFlag=0; selectEntity(1); }
3277 }
3278 
3279 
3280 
selectEntityMenu(int selection)3281 void selectEntityMenu( int selection )
3282 {
3283 
3284 #if TEST
3285   printf (" in selectEntityMenu\n");
3286 #endif
3287   animFlag=0;
3288   selectEntity(selection);
3289 }
3290 
3291 
3292 
3293 /* Dataset creation */
createDatasetEntries(void)3294 void createDatasetEntries(void)
3295 {
3296   int  i,j,k, screen_height, lc_per_menu, lc_per_basmenu;
3297   static int  menus, steps;
3298   static int  *mds=NULL;
3299   static int  *subsubmenu_load, *sub3menu_load;
3300 
3301   if(!inpformat) return;
3302 
3303   glutSetWindow( w0);
3304   if(!anz->l)
3305   {
3306     createNewMainMenu();
3307     glutSetWindow( activWindow);
3308     return;
3309   }
3310 
3311   /* free the old menu */
3312   if (submenu_load>0) glutDestroyMenu( submenu_load );
3313   if(steps>1)
3314   {
3315     for (j=0; j<steps; j++ )
3316     {
3317       glutDestroyMenu( sub3menu_load[j] );
3318     }
3319   }
3320   for (j=0; j<menus; j++ )
3321   {
3322     glutDestroyMenu( subsubmenu_load[j] );
3323   }
3324 
3325   /* check how much Step_numbers we have */
3326   if ( (mds = (int *)realloc((int *)mds, (steps+1) * sizeof(int))) == NULL )
3327         printf("\n\n ERROR: realloc failed createDatasetEntries\n\n") ;
3328   mds[0]=0;
3329   steps=1;
3330   for(i=1; i<anz->l; i++)
3331   {
3332     if(lcase[i].step_number!=lcase[i-1].step_number)
3333     {
3334       if ( (mds = (int *)realloc((int *)mds, (steps+1) * sizeof(int))) == NULL )
3335         printf("\n\n ERROR: realloc failed createDatasetEntries\n\n") ;
3336       mds[steps]=i;
3337       steps++;
3338     }
3339   }
3340   //printf("ds:%d steps:%d\n", anz->l, steps);
3341 
3342 
3343   /* calculate how much lines of Steps can be displayed on the screen */
3344   screen_height=glutGet(GLUT_SCREEN_HEIGHT);
3345   if (!screen_height)
3346   { screen_height=800; printf(" screen not known, assume screen_height of 800 pixels\n"); }
3347   lc_per_menu=screen_height/GLUT_MENU_POINT_HEIGHT ;
3348 
3349 #if TEST
3350   printf ("lc_per_menu:%d \n",lc_per_menu);
3351 #endif
3352 
3353   submenu_load = glutCreateMenu( selectDatasetMenu );
3354   glutAddSubMenu( "-Entity- ", subsubmenu_entity );
3355   if(steps>1)
3356   {
3357     /* check if the remaining lc's fit in the remaining space of the basmenu */
3358     menus=steps/lc_per_menu;
3359     if( lc_per_menu-menus < steps%lc_per_menu ) menus++;
3360     lc_per_basmenu=steps - menus*lc_per_menu;
3361 
3362     /* define the Datasets */
3363     if ( (sub3menu_load = (int *)realloc((int *)sub3menu_load, (steps+1) * sizeof(int))) == NULL )
3364         printf("\n\n ERROR: realloc failed createDatasetEntries\n\n") ;
3365     i=0;
3366     for (j=0; j<steps; j++ )
3367     {
3368       sub3menu_load[j] = glutCreateMenu( selectDatasetMenu );
3369       do
3370       {
3371         sprintf (buffer,"%d %.8s", i+1, lcase[i].name);
3372         glutAddMenuEntry( buffer, i);
3373         i++;
3374         if (i>=anz->l) break;
3375       }while(lcase[i-1].step_number==lcase[i].step_number);
3376     }
3377 
3378     /* define the additional submenus */
3379     if ( (subsubmenu_load = (int *)realloc((int *)subsubmenu_load, (steps+1) * sizeof(int))) == NULL )
3380         printf("\n\n ERROR: realloc failed createDatasetEntries\n\n") ;
3381     i=lc_per_basmenu; if(i<0) i=0;
3382     for (j=0; j<menus; j++ )
3383     {
3384       subsubmenu_load[j] = glutCreateMenu( NULL );
3385       for (k=0; k<lc_per_menu; k++ )
3386       {
3387         if (i>=steps)
3388         {
3389           printf (" WARNING: To much Datasets for the menu. Please use the 'ds' command to access the Datasets %d to %d\n", mds[i], anz->l);
3390           break;
3391 	}
3392         //sprintf (buffer,"%d %.8s %lf %s", i+1, lcase[mds[i]].dataset_name, lcase[mds[i]].value, lcase[mds[i]].dataset_text );
3393         sprintf (buffer,"%d %.8s %lf %s", lcase[mds[i]].step_number, lcase[mds[i]].dataset_name, lcase[mds[i]].value, lcase[mds[i]].dataset_text );
3394         glutAddSubMenu( buffer, sub3menu_load[i] );
3395         i++;
3396       }
3397     }
3398 
3399     /* define the main-lc-menu */
3400     glutSetMenu( submenu_load );
3401     for (i=0; i<lc_per_basmenu; i++ )
3402     {
3403       //sprintf (buffer,"%d %.8s %lf %s", i+1, lcase[mds[i]].dataset_name, lcase[mds[i]].value, lcase[mds[i]].dataset_text );
3404       sprintf (buffer,"%d %.8s %lf %s", lcase[mds[i]].step_number, lcase[mds[i]].dataset_name, lcase[mds[i]].value, lcase[mds[i]].dataset_text );
3405       glutAddSubMenu( buffer, sub3menu_load[i] );
3406     }
3407     for (i=0; i<menus; i++)
3408     {
3409       glutAddSubMenu( "-MORE- ", subsubmenu_load[i] );
3410       if(i>lc_per_menu) break;
3411     }
3412   }
3413   else
3414   {
3415     /* check if the remaining lc's fit in the remaining space of the basmenu */
3416     menus=anz->l/lc_per_menu;
3417     if( lc_per_menu-menus < anz->l%lc_per_menu ) menus++;
3418     lc_per_basmenu=anz->l-menus*lc_per_menu;
3419 
3420 #if TEST
3421     printf ("lc_per_menu:%d lc_per_basmenu:%d menus:%d\n",lc_per_menu, lc_per_basmenu, menus );
3422 #endif
3423 
3424     /* define the additional submenus */
3425     if ( (subsubmenu_load = (int *)realloc((int *)subsubmenu_load, (menus+1) * sizeof(int))) == NULL )
3426         printf("\n\n ERROR: realloc failed createDatasetEntries\n\n") ;
3427     i=lc_per_basmenu; if(i<0) i=0;
3428     for (j=0; j<menus; j++ )
3429     {
3430       subsubmenu_load[j] = glutCreateMenu( selectDatasetMenu );
3431       for (k=0; k<lc_per_menu; k++ )
3432       {
3433         if (i>=anz->l) break;
3434         sprintf (buffer,"%d %.8s %lf %s", i+1, lcase[i].name, lcase[i].value, lcase[i].dataset_text );
3435         glutAddMenuEntry( buffer, i);
3436         i++;
3437       }
3438     }
3439 
3440     /* define the main-lc-menu */
3441     glutSetMenu( submenu_load );
3442     for (i=0; i<lc_per_basmenu; i++ )
3443     {
3444         sprintf (buffer,"%d %.8s %lf %s", i+1, lcase[i].name, lcase[i].value, lcase[i].dataset_text );
3445         glutAddMenuEntry( buffer, i);
3446     }
3447     for (i=0; i<menus; i++)
3448     {
3449         glutAddSubMenu( "-MORE- ", subsubmenu_load[i] );
3450         if(i>lc_per_menu) break;
3451     }
3452   }
3453   selectDataset(cur_lc);
3454   createNewMainMenu();
3455   glutSetWindow( activWindow);
3456 }
3457 
3458 
3459 /* selection is the menu-nr of the selected dataset (lc), starting with 0 */
selectDataset(int selection)3460 void selectDataset( int selection )
3461 {
3462   pre_lc=selection;
3463 
3464   /* check if the data of the specified lcase (Dataset) are already available */
3465   if (!lcase[pre_lc].loaded)
3466   {
3467     if( pre_readfrdblock(copiedNodeSets , pre_lc, anz, node, lcase )==-1)
3468     {
3469       printf("ERROR in selectDataset: Could not read data for Dataset:%d\n", pre_lc+1);
3470       return;
3471     }
3472     calcDatasets( pre_lc, anz, node, lcase );
3473   }
3474 
3475   if(sequenceFlag)
3476   {
3477     if (seq_nlc>2) {seq_nlc=0; seqLC[1]=0; seqLC[2]=anz->l-1; }
3478     seqLC[seq_nlc]=pre_lc;
3479     if ((seq_nlc>0)&&(compareStrings(lcase[seqLC[0]].name,lcase[seqLC[seq_nlc]].name)<1))
3480     {
3481       errMsg(" WARNING: selected Dataset %s is of different name than the 1st selected %s\n", lcase[seqLC[seq_nlc]].name,lcase[seqLC[0]].name);
3482     }
3483     if (seq_nlc>1)
3484     {
3485       printf(" selection finished, select entity\n");
3486     }
3487     seq_nlc++;
3488   }
3489   else {
3490       seq_nlc=0;
3491       seqLC[1]=0;
3492       seqLC[2]=anz->l-1;
3493   }/* no sequence until a new entity is selected and all data are prepared */
3494 
3495   recompileEntitiesInMenu(pre_lc);
3496 }
3497 
3498 
createNewMainMenu(void)3499 void createNewMainMenu(void)
3500 {
3501   if(!inpformat) return;
3502 
3503   glutSetWindow( w0);
3504   if (mainmenu>0) glutDestroyMenu( mainmenu );
3505     mainmenu = glutCreateMenu( menu );
3506     if(anz->l>0) glutAddSubMenu  ( "Datasets   ", submenu_load );
3507     glutAddSubMenu  ( "Viewing     ", submenu_view );
3508     glutAddSubMenu  ( "Animate     ", submenu_animate );
3509     glutAddMenuEntry( "Frame       ", 1);
3510     glutAddMenuEntry( "Zoom        ", 2);
3511     glutAddMenuEntry( "Center      ", 3);
3512     glutAddMenuEntry( "Enquire     ", 4);
3513     glutAddSubMenu  ( "Cut         ", submenu_cut  );
3514     glutAddSubMenu  ( "Graph       ", submenu_graph);
3515     if(submenu_user!=-1) glutAddSubMenu  ( "User        ", submenu_user);
3516     glutAddSubMenu  ( "Orientation ", submenu_orientation );
3517     glutAddSubMenu  ( "Hardcopy    ", submenu_hardcopy);
3518     glutAddSubMenu  ( "Help        ", submenu_help);
3519     glutAddMenuEntry( "Toggle CommandLine", 5);
3520     glutAddMenuEntry( " -QUIT-     ", 6);
3521     glutAttachMenu(GLUT_LEFT_BUTTON);
3522   glutSetWindow( activWindow);
3523 }
3524 
3525 
3526 
recompileEntitiesInMenu(int lc)3527 void recompileEntitiesInMenu(int lc)
3528 {
3529   int i, entries;
3530 
3531   if(!inpformat) return;
3532 
3533   glutSetMenu( submenu_load );
3534   if(lcase[lc].npheader)
3535   {
3536     glutSetMenu( subsubmenu_parameter );
3537     entries=glutGet(GLUT_MENU_NUM_ITEMS);
3538     for (i=entries; i>0; i--) glutRemoveMenuItem(i);
3539     for (i=1; i<=lcase[lc].npheader; i++)
3540     {
3541       sprintf (buffer,"%d %s", i, &lcase[lc].pheader[i-1][6] );
3542       glutAddMenuEntry( buffer, i);
3543     }
3544   }
3545 
3546   glutSetMenu( subsubmenu_entity );
3547   entries=glutGet(GLUT_MENU_NUM_ITEMS);
3548   for (i=entries; i>0; i--) glutRemoveMenuItem(i);
3549 
3550   for (i=1; i<=lcase[lc].ncomps; i++)
3551   {
3552     if(lcase[lc].menu[i-1])
3553     {
3554       sprintf (buffer,"%d %s", i, lcase[lc].compName[i-1] );
3555       glutAddMenuEntry( buffer, i);
3556     }
3557   }
3558   if(lcase[lc].npheader)
3559     glutAddSubMenu( "-Parameter- ", subsubmenu_parameter );
3560 }
3561 
3562 
3563 
addDispToCoordinates(Nodes * node_local)3564 void addDispToCoordinates( Nodes *node_local)
3565 {
3566   int i,j,k,lc;
3567   int foundDisp=0, mode=0, dir[3]={0.,0.,0.}, compareChars;
3568   static Nodes *n_disp=NULL, *orig_nodes;
3569   static char buffer[2][MAX_LINE_LENGTH];
3570   static Summen orig[1];
3571   double amplitude;
3572   char method[MAX_LINE_LENGTH], axis[MAX_LINE_LENGTH];
3573   double p1[3], phi=0.,rad,dx,dy,dz;
3574   char key[MAX_LINE_LENGTH]={"ADDDISP"}, text[MAX_LINE_LENGTH];
3575 
3576   if(!addDispFlag)
3577   {
3578     strcpy(buffer[0],"DISP ");
3579     strcpy(buffer[1],"DISPI");
3580     lc=pre_lc;
3581     sprintf(text,"DS:%d",lc+1);
3582     createUSERparam(key, text);
3583     /* if the selected lc is not a disp lc, search a related disp lc */
3584     if(((compare(lcase[lc].dataset_name, "DISP", 4)==4)||(compare(lcase[lc].name, "DISP", 4)==4))&&(lcase[lc].ictype[0]!= 12)) foundDisp=1;
3585     else
3586     {
3587       /* since real and imaginary part use different names since ccx_2.9 it is necessary to compare the
3588          names only for the length excluding the last char if its a 'I' */
3589       compareChars=strlen(lcase[lc].name)-1;
3590       for(k=compareChars;k>0; k--) if(lcase[lc].name[k]!=' ') break;
3591       compareChars=k+1;
3592       if(lcase[lc].name[compareChars-1]=='I') j=1; else j=0;;
3593 
3594       if(lc) { for (i=lc-1; i>=0; i--) { if(lcase[i].step_number!=lcase[lc].step_number) break; } i++; }
3595       else i=1;
3596       while((i<anz->l)&&(lcase[i].step_number==lcase[lc].step_number))
3597       {
3598         if((compare(lcase[i].name, buffer[j], 5)==5)&&(lcase[i].ictype[0]!= 12))
3599         {
3600 	  //printf("lcase[i].name:%s lcase[lc].name:%s compareChars:%d\n", lcase[i].name,lcase[lc].name,compareChars);
3601           lc=i;
3602           foundDisp=1;
3603 
3604           /* check if the data of the specified lcase (Dataset) are already available */
3605           if (!lcase[lc].loaded)
3606           {
3607             if( pre_readfrdblock(copiedNodeSets , lc, anz, node_local, lcase )==-1)
3608             {
3609               printf("ERROR in nodalDataset: Could not read data for Dataset:%d\n", lc+1);
3610               return;
3611             }
3612             calcDatasets( lc, anz, node_local, lcase );
3613           }
3614           break;
3615 	}
3616         i++;
3617       }
3618     }
3619     if (foundDisp)
3620     {
3621       /* add displacements to the node-coords and return a pointer to the changed nodes */
3622 
3623       /* create new nodes */
3624       if ( (n_disp = (Nodes *)realloc((Nodes *)n_disp, (anz->nmax+1) * sizeof(Nodes))) == NULL )
3625         printf("\n\n ERROR: malloc failed n_disp\n");
3626       else
3627         if(printFlag) printf (" n_disp allocated \n");
3628       amplitude= anim_faktor;
3629 
3630       /* check if the data of the specified lcase (Dataset) are already available */
3631       if (!lcase[lc].loaded)
3632       {
3633         if( pre_readfrdblock(copiedNodeSets , lc, anz, node_local, lcase )==-1)
3634         {
3635           printf("ERROR in nodalDataset: Could not read data for Dataset:%d\n", lc+1);
3636           scalNodes ( anz->n, node_local, scale );
3637           return;
3638         }
3639         calcDatasets( lc, anz, node_local, lcase );
3640         recompileEntitiesInMenu(lc);
3641       }
3642       descalNodes ( anz->n, node_local, scale );
3643 
3644 
3645       /* check in which system (cyl, rec) the displacements are defined */
3646       for(i=0;i<lcase[lc].npheader; i++)
3647       {
3648         if(compare(&lcase[lc].pheader[i][5],"PTRFM", 5)==5)
3649         {
3650           sscanf(lcase[lc].pheader[i],"%*s %s %s", method, axis);
3651           printf("trfm %s %s", method, axis);
3652           if(compare(method, "CYL", 3) == 3)
3653           {
3654             if (toupper(axis[0])=='X')      mode =1;
3655             else if (toupper(axis[0])=='Y') mode =2;
3656             else if (toupper(axis[0])=='Z') mode =3;
3657             if(mode==1) { dir[0]=0; dir[1]=1; dir[2]=2; }
3658             else if(mode==2) { dir[0]=1; dir[1]=2; dir[2]=0; }
3659             else if(mode==3) { dir[0]=2; dir[1]=0; dir[2]=1; }
3660           }
3661           break;
3662         }
3663       }
3664 
3665       for ( i=0; i<anz->n; i++ )
3666       {
3667         n_disp[node[i].nr].indx = i;
3668         n_disp[i].nr = node[i].nr;
3669         n_disp[node[i].nr].pflag = node[node[i].nr].pflag;
3670         if(!node[node[i].nr].pflag)
3671         {
3672           if(mode==0)
3673           {
3674             n_disp[node[i].nr].nx = node[node[i].nr].nx + lcase[lc].dat[0][node[i].nr] * amplitude;
3675             n_disp[node[i].nr].ny = node[node[i].nr].ny + lcase[lc].dat[1][node[i].nr] * amplitude;
3676             n_disp[node[i].nr].nz = node[node[i].nr].nz + lcase[lc].dat[2][node[i].nr] * amplitude;
3677           }
3678           else
3679 	  {
3680             /* calc the node coordinates in r,phi,x */
3681             p1[0] = node[node[i].nr].nx;
3682             p1[1] = node[node[i].nr].ny;
3683             p1[2] = node[node[i].nr].nz;
3684 
3685             rad=sqrt(p1[dir[1]]*p1[dir[1]]+p1[dir[2]]*p1[dir[2]]);
3686             if(rad)
3687             {
3688               phi= p_angle(p1[dir[1]], p1[dir[2]]);
3689 	    }
3690             else phi=0.;
3691 
3692             if(mode==1)
3693             {
3694               dy=cos(phi)*lcase[lc].dat[0][node[i].nr] - sin(phi)*lcase[lc].dat[1][node[i].nr];
3695               dz=sin(phi)*lcase[lc].dat[0][node[i].nr] + cos(phi)*lcase[lc].dat[1][node[i].nr];
3696               dx=lcase[lc].dat[2][node[i].nr];
3697             }
3698             else if(mode==2)
3699             {
3700               dz=cos(phi)*lcase[lc].dat[0][node[i].nr] - sin(phi)*lcase[lc].dat[1][node[i].nr];
3701               dx=sin(phi)*lcase[lc].dat[0][node[i].nr] + cos(phi)*lcase[lc].dat[1][node[i].nr];
3702               dy=lcase[lc].dat[2][node[i].nr];
3703             }
3704             else if(mode==3)
3705             {
3706               dx=cos(phi)*lcase[lc].dat[0][node[i].nr] - sin(phi)*lcase[lc].dat[1][node[i].nr];
3707               dy=sin(phi)*lcase[lc].dat[0][node[i].nr] + cos(phi)*lcase[lc].dat[1][node[i].nr];
3708               dz=lcase[lc].dat[2][node[i].nr];
3709             }
3710             n_disp[node[i].nr].nx = node[node[i].nr].nx + dx*amplitude;
3711             n_disp[node[i].nr].ny = node[node[i].nr].ny + dy*amplitude;
3712             n_disp[node[i].nr].nz = node[node[i].nr].nz + dz*amplitude;
3713           }
3714         }
3715       }
3716 
3717       /* calculate the position of the additional drawing nodes in the deformed mesh */
3718       posMidsideNodes(n_disp);
3719 
3720       scalNodes ( anz->n, n_disp, scale );
3721 
3722       addDispFlag=!addDispFlag;
3723       orig_nodes=node_local;
3724       orig->orign=    anz->orign;
3725       orig->n=	  anz->n;
3726       orig->e=	  anz->e;
3727       orig->f=	  anz->f;
3728       orig->g=	  anz->g;
3729       orig->t=	  anz->t;
3730       orig->l=	  anz->l;
3731       orig->olc=	  anz->olc;
3732       orig->orignmax= anz->orignmax;
3733       orig->nmax=	  anz->nmax;
3734       orig->nmin=	  anz->nmin;
3735       orig->emax=	  anz->emax;
3736       orig->emin=	  anz->emin;
3737       orig->sets=	  anz->sets;
3738       orig->mats=	  anz->mats;
3739       orig->amps=	  anz->amps;
3740       orig->nnext=	  anz->nnext;
3741       orig->enext=	  anz->enext;
3742 
3743       /* update node */
3744       node=n_disp;
3745       getFaceNormalen( face, node, anz );
3746       getElemNormalen( e_enqire, node, anz->e );
3747       updateDispLists();
3748       return;
3749     }
3750     else
3751     {
3752       errMsg ("\n ERROR: choose a Dataset with displacements before\n");
3753       printf ("\n  Remark: Before you use this option select the Dataset and the Entity you want to display and then the related Dataset of the displacements (but no entity).\n");
3754     }
3755   }
3756   else
3757   {
3758     addDispFlag=!addDispFlag;
3759     /* return the original pointer to the nodes  */
3760     sprintf(text,"NONE");
3761     createUSERparam(key, text);
3762     descalNodes ( anz->n, node_local, scale );
3763     free(node_local);
3764     n_disp=NULL;
3765 
3766     /* update node */
3767     node=orig_nodes;
3768     anz->orign=   orig->orign;
3769     anz->n=	orig->n;
3770     //anz->e=	orig->e;
3771     //anz->f=	orig->f;
3772     //anz->g=	orig->g;
3773     //anz->t=	orig->t;
3774     //anz->l=	orig->l;
3775     //anz->olc=	orig->olc;
3776     anz->orignmax=orig->orignmax;
3777     anz->nmax=	orig->nmax;
3778     anz->nmin=	orig->nmin;
3779     //anz->emax=	orig->emax;
3780     //anz->emin=	orig->emin;
3781     //anz->sets=	orig->sets;
3782     //anz->mats=	orig->mats;
3783     //anz->amps=	orig->amps;
3784     //anz->nnext=	orig->nnext;
3785     //anz->enext=	orig->enext;
3786     scalNodes ( anz->n, node, scale );
3787     getFaceNormalen( face, node, anz );
3788     getElemNormalen( e_enqire, node, anz->e );
3789     updateDispLists();
3790     return;
3791   }
3792 }
3793 
3794 
3795 
selectView(int selection)3796 void selectView( int selection )
3797 {
3798   int i;
3799   static GLint ipuf[2];
3800   static char  mem_elemEdgeFlag, mem_surfFlag;
3801   char addDispFlagLocal=0;
3802 
3803   glutSetWindow( w1);
3804   switch (selection) {
3805   case 1:
3806       if(getSetNr("-qcut"))
3807       {
3808         if(addDispFlag==1) { addDispToCoordinates(node); addDispFlagLocal=2; }
3809         zap("-qcut");
3810         if(addDispFlagLocal==2) { addDispToCoordinates(node); }
3811       }
3812       vectorFlag=0;
3813       sequenceFlag=0;
3814       animFlag=0;
3815       drawMode=2;
3816       glPointSize(1);
3817       glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
3818       ConfigureAndShowWindow_Light();
3819     break;
3820   case 2:
3821     /* show bad elements */
3822     i=calcBadElements("all");
3823     if (i>0)
3824     {
3825       printf("found %d bad elements in set:all (stored in set:%s)\n", i, specialset->njby);
3826       sprintf(buffer, "ea %s",specialset->njby);
3827       plot(buffer);
3828     }
3829     else
3830     {
3831       delSet(specialset->njby);
3832       printf("No bad elements in set:all\n");
3833     }
3834     if(drawMode==1) ConfigureAndShowWindow_Load();
3835     else if(drawMode<4) ConfigureAndShowWindow_Light();
3836     break;
3837   case 3:
3838     glPointSize (1);
3839     glGetIntegerv( GL_POLYGON_MODE, ipuf );
3840     if ( ipuf[1] != GL_FILL )
3841       glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
3842     break;
3843   case 4:
3844     glPointSize (1);
3845     glGetIntegerv( GL_POLYGON_MODE, ipuf );
3846     if ( ipuf[1] != GL_LINE )
3847       glPolygonMode(GL_FRONT_AND_BACK, GL_LINE );
3848     break;
3849   case 5:
3850     glPointSize (1);
3851     glGetIntegerv( GL_POLYGON_MODE, ipuf );
3852     if ( ipuf[1] != GL_POINT )
3853       glPolygonMode( GL_FRONT_AND_BACK, GL_POINT );
3854     break;
3855   case 6:
3856     glGetIntegerv( GL_CULL_FACE_MODE, ipuf );
3857     if ( ipuf[0] == GL_BACK )
3858       {
3859       glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
3860       glCullFace ( GL_FRONT );
3861       }
3862     else
3863       {
3864       glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, lmodel_oneside);
3865       glCullFace ( GL_BACK );
3866       }
3867     redraw();
3868     break;
3869   case 7:
3870       modelEdgeFlag=!modelEdgeFlag;
3871       if (modelEdgeFlag) /* copy from updateDispLists() */
3872         drawModelEdges( list_model_edges, basCol[0], edgeWidth, anz->g, node );
3873     break;
3874   case 8:
3875       elemEdgeFlag=!elemEdgeFlag;
3876       if (elemEdgeFlag)
3877       {
3878         updateDispLists();
3879         //if (surfFlag) drawDispListEdges(list_surf_edges, basCol[0], 1., 'f', node );
3880         //else          drawDispListEdges(list_elem_edges, basCol[0], 1., 'e', node );
3881       }
3882     break;
3883   case 9:
3884       /* change between element and face mode */
3885       surfFlag=!surfFlag;
3886       if(drawMode!=4)
3887       {
3888         if(surfFlag)
3889         {
3890           for(i=0; i<anzGeo->psets; i++ ) if(pset[i].type[0]=='e') pset[i].type[0]='f';
3891         }
3892         else
3893         {
3894           for(i=0; i<anzGeo->psets; i++ ) if(pset[i].type[0]=='f') pset[i].type[0]='e';
3895         }
3896       }
3897       redraw();
3898     break;
3899   case 10:
3900       movezFlag=!movezFlag;
3901       if( movezFlag)
3902       {
3903         glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
3904         mem_surfFlag=surfFlag;
3905         mem_elemEdgeFlag=elemEdgeFlag;
3906         surfFlag=0;
3907         elemEdgeFlag=1;
3908         printf ("press middle Mouse Button to move in Z Direction\n");
3909         if(drawMode!=4)
3910         {
3911           if(mem_surfFlag==1)
3912           {
3913             for(i=0; i<anzGeo->psets; i++ ) if(pset[i].type[0]=='f') pset[i].type[0]='e';
3914           }
3915         }
3916       }
3917       else
3918       {
3919         surfFlag=mem_surfFlag;
3920         elemEdgeFlag=mem_elemEdgeFlag;
3921         glGetIntegerv( GL_CULL_FACE_MODE, ipuf );
3922         if ( ipuf[0] == GL_BACK )
3923         {
3924           glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, lmodel_oneside);
3925         }
3926         else
3927         {
3928           glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
3929         }
3930         printf ("press middle Mouse Button to Zoom in and out\n");
3931         if(drawMode!=4)
3932         {
3933           if(mem_surfFlag==1)
3934           {
3935             for(i=0; i<anzGeo->psets; i++ ) if(pset[i].type[0]=='e') pset[i].type[0]='f';
3936           }
3937         }
3938       }
3939       askGLError("movezFlag, GL_CULL_FACE");
3940       redraw();
3941     break;
3942   case 11:
3943     if(foregrndcol) { foregrndcol=0; foregrndcol_rgb[0]=foregrndcol_rgb[1]=foregrndcol_rgb[2]=foregrndcol_rgb[3]=0.; }
3944     else            { foregrndcol=1; foregrndcol_rgb[0]=foregrndcol_rgb[1]=foregrndcol_rgb[2]=foregrndcol_rgb[3]=1.; }
3945     if(backgrndcol) { backgrndcol=0; backgrndcol_rgb[0]=backgrndcol_rgb[1]=backgrndcol_rgb[2]=backgrndcol_rgb[3]=0.; }
3946     else            { backgrndcol=1; backgrndcol_rgb[0]=backgrndcol_rgb[1]=backgrndcol_rgb[2]=backgrndcol_rgb[3]=1.; }
3947     for (i=0; i<anzGeo->psets; i++ )
3948     {
3949       if(pset[i].col==0) pset[i].col=1;
3950       else if(pset[i].col==1) pset[i].col=0;
3951     }
3952     updateDispLists();
3953     break;
3954   case 12:
3955     /* create a vector-plot */
3956     /* if one entity is choosen, check if it belongs to a vector (icind) */
3957     /* and choose also the other components */
3958     if(anz->l>0)
3959     {
3960       vectorFlag=!vectorFlag;
3961       if(vectorFlag)
3962       {
3963         entity_buf=cur_entity;
3964         selectEntity(cur_entity+1 );
3965         printf("\n Vector-plot selected. Works only for data marked internally as a vector. In other cases use the 'ds' command.\n");
3966       }
3967       else
3968       {
3969         cur_entity=entity_buf;
3970         selectEntity(cur_entity+1 );
3971         printf("\n Vector-plot off\n");
3972       }
3973     }
3974    break;
3975   case 13:
3976     /* add/remove the actual displacements to all node-coordinates multiplied by anim_faktor */
3977     if(!sequenceFlag)
3978     {
3979       addDispToCoordinates(node);
3980       if(addDispFlag) printf("\n displacements related to dataset:%d added. Scale them with 'scal d <value>'\n",pre_lc+1);
3981       else printf("\n displacements removed\n");
3982       redraw();
3983     }
3984     else printf("\n ERROR: 'Toggle Add-Displacement' can not be selected during animations.\n");
3985     break;
3986   case 14:
3987     illumResultFlag=!illumResultFlag;
3988     redraw();
3989     break;
3990   case 15:
3991     glGetIntegerv( GL_LIGHT_MODEL_TWO_SIDE, ipuf );
3992     if ( ipuf[0] == GL_FALSE )
3993       {
3994       glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
3995       }
3996     else
3997       {
3998       glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, lmodel_oneside);
3999       }
4000     break;
4001   case 16:
4002 
4003     if((!surfFlag)&&(!blendFlag))
4004     {
4005       printf(" Transparency works only in surface mode\n");
4006       return;
4007     }
4008 
4009     //printf("psettype:%s\n",pset[0].type);
4010     blendFlag=!blendFlag;
4011     //if((drawMode==1)||(drawMode==5))
4012     {
4013       if(blendFlag)
4014       {
4015         glDisable(GL_CULL_FACE);
4016         glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
4017         if(pset[0].type[1]=='v')
4018 	{
4019           if(pset[0].type[0]=='f') pset[0].type[2]='b';
4020           if(pset[0].type[0]=='e') pset[0].type[2]='b';
4021 	}
4022       }
4023       else
4024       {
4025         glEnable(GL_CULL_FACE);
4026         glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, lmodel_oneside);
4027         if(pset[0].type[1]=='v')
4028 	{
4029           if(pset[0].type[0]=='f') pset[0].type[2]=0;
4030           if(pset[0].type[0]=='e') pset[0].type[2]=0;
4031 	}
4032       }
4033     }
4034     if((drawMode==2)&&(blendFlag)) { pset[0].type[1]='b'; glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside); }
4035     else if((drawMode==2)&&(!blendFlag)) { pset[0].type[1]=0; }
4036     redraw();
4037     break;
4038   case 17:
4039     rulerFlag=!rulerFlag;
4040     break;
4041   }
4042   glutSetWindow( w0);
4043   glutPostRedisplay();
4044 }
4045 
4046 
pre_animate(char * string)4047 void pre_animate(char *string)
4048 {
4049   char type[MAX_LINE_LENGTH], param[MAX_LINE_LENGTH];
4050 
4051   if(!inpformat) return;
4052   param[0]=0;
4053   sscanf(string, "%s %s", type, param );
4054 
4055   glutSetWindow( w1);
4056   if (compare(type, "tune", 2)==2)
4057   {
4058     anim_faktor=atof(param);
4059     /* remove the displacements and use the scaled ones */
4060     if(addDispFlag==1)
4061     {
4062       addDispToCoordinates(node);
4063       addDispToCoordinates(node);
4064     }
4065   }
4066   else if (compare(type, "start", 3)==3) { changeAnimation(1); }
4067   else if (compare(type, "steps", 3)==3) anim_steps=atof(param);
4068   else if (compare(type, "time", 2)==2) time_per_period=atof(param)*1000.;
4069   else if (compare(type, "real", 2)==2)
4070   {
4071     if (compare(param, "off", 2)==2) halfperiod=0;
4072     else halfperiod=1;
4073   }
4074   else if (compare(type, "model", 2)==2)
4075   {
4076     if (compare(param, "off", 2)==2) modelEdgeFlag_Static=0;
4077     else modelEdgeFlag_Static=1;
4078     if (modelEdgeFlag_Static) /* copy from updateDispLists() */
4079       drawModelEdges( list_model_edges, basCol[0], edgeWidth, anz->g, node );
4080   }
4081   else if (compare(type, "elem", 2)==2)
4082   {
4083     if (compare(param, "off", 2)==2) elemEdgeFlag_Static=0;
4084     else elemEdgeFlag_Static=1;
4085     if (elemEdgeFlag_Static)
4086     {
4087       updateDispLists();
4088       //if (surfFlag) drawDispListEdges(list_surf_edges, basCol[0], 1., 'f', node );
4089       //else          drawDispListEdges(list_elem_edges, basCol[0], 1., 'e', node );
4090     }
4091   }
4092   redraw();
4093 }
4094 
4095 
pre_view(char * string)4096 void pre_view(char *string)
4097 {
4098   int i, length;
4099   char type[MAX_LINE_LENGTH], param[MAX_LINE_LENGTH];
4100   GLint ipuf[2];
4101   char addDispFlagLocal=0;
4102 
4103   param[0]=0;
4104   length=sscanf(string, "%s %s", type, param );
4105   if (compare(type, "disp", 3)==3)
4106   {
4107     if(addDispFlag==1)
4108     {
4109       if(length==2) if(compare(param, "off", 2)==2)
4110       {
4111         addDispToCoordinates(node);
4112       }
4113     }
4114     else
4115     {
4116       if((length==2)&&(compare(param, "off", 2)==2));
4117       else
4118       {
4119         addDispToCoordinates(node);
4120         printf("\n displacements of dataset:%d added. Scale them with 'scal d <value>'\n",pre_lc+1);
4121       }
4122     }
4123   }
4124   if(!inpformat) return;
4125 
4126   if (compare(type, "cl", 2)==2)
4127   {
4128     if((length==2)&&(compare(param, "off", 2)==2)) commandLineFlag=0;
4129     else commandLineFlag=1;
4130     /* Kommandozeile-Fenster-index im w0 fenster  */
4131     if(commandLineFlag)
4132     {
4133       glutInitDisplayMode ( GLUT_RGBA | GLUT_DOUBLE  );
4134       activWindow= w3 = glutCreateSubWindow ( w0, 0, height_w0-pixPerChary[menu_font], width_w0, pixPerChary[menu_font] );
4135       glutDisplayFunc ( updCommandLine );
4136       glDisable(GL_DITHER);
4137       glShadeModel ( GL_FLAT );
4138     }
4139     else glutDestroyWindow(w3);
4140   }
4141   glutSetWindow( w1);
4142   if (compare(type, "fill", 2)==2)
4143   {
4144     glPointSize (1);
4145     glGetIntegerv( GL_POLYGON_MODE, ipuf );
4146     if ( ipuf[1] != GL_FILL )
4147       glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
4148   }
4149   else if (compare(type, "line", 2)==2)
4150   {
4151     glGetIntegerv( GL_POLYGON_MODE, ipuf );
4152     if ( ipuf[1] != GL_LINE )
4153       glPolygonMode(GL_FRONT_AND_BACK, GL_LINE );
4154   }
4155   else if (compare(type, "point", 2)==2)
4156   {
4157     i=atoi(param);
4158     if(i<1) glPointSize(1);
4159     else glPointSize(i);
4160     glGetIntegerv( GL_POLYGON_MODE, ipuf );
4161     if ( ipuf[1] != GL_POINT )
4162       glPolygonMode( GL_FRONT_AND_BACK, GL_POINT );
4163   }
4164   else if (compare(type, "bg", 2)==2)
4165   {
4166     if(length==2)
4167     {
4168       if (compare(param, "k", 1)==1) { foregrndcol=0; backgrndcol=1; }
4169       else if (compare(param, "w", 1)==1) { foregrndcol=1; backgrndcol=0; }
4170     }
4171     if(foregrndcol) { foregrndcol=0; foregrndcol_rgb[0]=foregrndcol_rgb[1]=foregrndcol_rgb[2]=foregrndcol_rgb[3]=0.; }
4172     else            { foregrndcol=1; foregrndcol_rgb[0]=foregrndcol_rgb[1]=foregrndcol_rgb[2]=foregrndcol_rgb[3]=1.; }
4173     if(backgrndcol) { backgrndcol=0; backgrndcol_rgb[0]=backgrndcol_rgb[1]=backgrndcol_rgb[2]=backgrndcol_rgb[3]=0.; }
4174     else            { backgrndcol=1; backgrndcol_rgb[0]=backgrndcol_rgb[1]=backgrndcol_rgb[2]=backgrndcol_rgb[3]=1.; }
4175     for (i=0; i<anzGeo->psets; i++ )
4176     {
4177       if(pset[i].col==0) pset[i].col=1;
4178       else if(pset[i].col==1) pset[i].col=0;
4179     }
4180     updateDispLists();
4181   }
4182   else if (compare(type, "edge", 2)==2)
4183   {
4184     i=atoi(param);
4185     if(i<1) edgeWidth=2;
4186     else edgeWidth=i;
4187     modelEdgeFlag=1;
4188     if(length==2) { if (compare(param, "off", 2)==2) modelEdgeFlag=0; }
4189     if (modelEdgeFlag)
4190         drawModelEdges( list_model_edges, basCol[0], edgeWidth, anz->g, node );
4191   }
4192   else if (compare(type, "elem", 2)==2)
4193   {
4194     elemEdgeFlag=1;
4195     if(length==2) { if (compare(param, "off", 2)==2) elemEdgeFlag=0; }
4196     if (elemEdgeFlag)
4197     {
4198       updateDispLists();
4199       //if (surfFlag) drawDispListEdges(list_surf_edges, basCol[0], 1., 'f', node );
4200       //else          drawDispListEdges(list_elem_edges, basCol[0], 1., 'e', node );
4201     }
4202   }
4203   else if (compare(type, "surf", 2)==2)
4204   {
4205       if(getSetNr("-qcut"))
4206       {
4207         if(addDispFlag==1) { addDispToCoordinates(node); addDispFlagLocal=2; }
4208         zap("-qcut");
4209         if(addDispFlagLocal==2) { addDispToCoordinates(node); }
4210       }
4211       surfFlag=1;
4212       sequenceFlag=0;
4213       animFlag=0;
4214       drawMode=2;
4215       for(i=0; i<anzGeo->psets; i++ ) if(pset[i].type[0]=='e') pset[i].type[0]='f';
4216       ConfigureAndShowWindow_Light();
4217   }
4218   else if (compare(type, "volu", 2)==2)
4219   {
4220       if(getSetNr("-qcut"))
4221       {
4222         if(addDispFlag==1) { addDispToCoordinates(node); addDispFlagLocal=2; }
4223         zap("-qcut");
4224         if(addDispFlagLocal==2) { addDispToCoordinates(node); }
4225       }
4226       surfFlag=0;
4227       sequenceFlag=0;
4228       animFlag=0;
4229       drawMode=2;
4230       for(i=0; i<anzGeo->psets; i++ ) if(pset[i].type[0]=='f') pset[i].type[0]='e';
4231       ConfigureAndShowWindow_Light();
4232   }
4233   else if (compare(type, "front", 3)==3)
4234   {
4235       glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, lmodel_oneside);
4236       glCullFace ( GL_BACK );
4237     redraw();
4238   }
4239   else if (compare(type, "back", 3)==3)
4240   {
4241       glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
4242       glCullFace ( GL_FRONT );
4243     redraw();
4244   }
4245   else if (compare(type, "vector", 3)==3)
4246   {
4247     if(anz->l>0)
4248     {
4249       vectorFlag=1;
4250       if(length==2) { if (compare(param, "off", 2)==2) vectorFlag=0; }
4251       if(vectorFlag)
4252       {
4253         entity_buf=cur_entity;
4254         selectEntity(cur_entity+1 );
4255         printf("\n Vector-plot selected. Works only for data marked internally as a vector. In other cases use the 'ds' command.\n");
4256       }
4257       else
4258       {
4259         cur_entity=entity_buf;
4260         selectEntity(cur_entity+1 );
4261         printf("\n Vector-plot off\n");
4262       }
4263     }
4264   }
4265   else if (compare(type, "ru", 2)==2)
4266   {
4267     rulerFlag=1;
4268     rulerString[0]=0;
4269     if(length==2)
4270     {
4271       if (compare(param, "off", 2)==2) rulerFlag=0;
4272       else strcpy(rulerString, param);
4273     }
4274     redraw();
4275   }
4276   else if (compare(type, "sh", 2)==2)
4277   {
4278     illumResultFlag=1;
4279     if(length==2) { if (compare(param, "off", 2)==2) illumResultFlag=0; }
4280     redraw();
4281   }
4282   else if (compare(type, "ill", 2)==2)
4283   {
4284     glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
4285     if(length==2) { if (compare(param, "off", 2)==2) glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, lmodel_oneside); }
4286     redraw();
4287   }
4288   glutPostRedisplay();
4289   glutSetWindow( w2 );
4290   glutPostRedisplay();
4291   glutSetWindow( w0);
4292   glutPostRedisplay();
4293 }
4294 
4295 
4296 
scaldataset(int lc,double factor,int e)4297 void scaldataset(int lc, double factor, int e)
4298 {
4299   register int i,n;
4300   if(e==0)
4301   {
4302    for(i=0; i<lcase[lc].ncomps; i++)
4303    {
4304      for(n=0; n<anz->n; n++)
4305      {
4306        if(node[node[n].nr].pflag==-1) continue;
4307        lcase[lc].dat[i][node[n].nr]*=factor;
4308      }
4309      lcase[lc].max[i]*=factor;
4310      lcase[lc].min[i]*=factor;
4311    }
4312    scale->smin*=factor;
4313    scale->smax*=factor;
4314   }
4315   else
4316   {
4317     e--;
4318     for(n=0; n<anz->n; n++)
4319     {
4320       if(node[node[n].nr].pflag==-1) continue;
4321       lcase[lc].dat[e][node[n].nr]*=factor;
4322     }
4323     lcase[lc].max[e]*=factor;
4324     lcase[lc].min[e]*=factor;
4325   }
4326   if(cur_entity==e)
4327   {
4328     scale->smin*=factor;
4329     scale->smax*=factor;
4330   }
4331 }
4332 
4333 
4334 
offsetdataset(int lc,double offset,int e)4335 void offsetdataset(int lc, double offset, int e)
4336 {
4337   register int i,n;
4338   if(e==0)
4339   {
4340    for(i=0; i<lcase[lc].ncomps; i++)
4341    {
4342     for(n=0; n<anz->n; n++)
4343     {
4344       if(node[node[n].nr].pflag==-1) continue;
4345       lcase[lc].dat[i][node[n].nr]+=offset;
4346     }
4347     lcase[lc].max[i]+=offset;
4348     lcase[lc].min[i]+=offset;
4349    }
4350   }
4351   else
4352   {
4353     e--;
4354     for(n=0; n<anz->n; n++)
4355     {
4356       if(node[node[n].nr].pflag==-1) continue;
4357       lcase[lc].dat[e][node[n].nr]+=offset;
4358     }
4359     lcase[lc].max[e]+=offset;
4360     lcase[lc].min[e]+=offset;
4361   }
4362   if(cur_entity==e)
4363   {
4364     scale->smin+=offset;
4365     scale->smax+=offset;
4366   }
4367 }
4368 
4369 
4370 
expdataset(int lc,double factor,int e)4371 void expdataset(int lc, double factor, int e)
4372 {
4373   register int i,n;
4374   if(e==0)
4375   {
4376    for(i=0; i<lcase[lc].ncomps; i++)
4377    {
4378      for(n=0; n<anz->n; n++)
4379      {
4380        if(node[node[n].nr].pflag==-1) continue;
4381        lcase[lc].dat[i][node[n].nr]=pow(lcase[lc].dat[i][node[n].nr],factor);
4382      }
4383      lcase[lc].max[i]=pow(lcase[lc].max[i],factor);
4384      lcase[lc].min[i]=pow(lcase[lc].min[i],factor);
4385    }
4386    scale->smin=pow(scale->smin,factor);
4387    scale->smax=pow(scale->smax,factor);
4388   }
4389   else
4390   {
4391     e--;
4392     for(n=0; n<anz->n; n++)
4393     {
4394       if(node[node[n].nr].pflag==-1) continue;
4395       lcase[lc].dat[e][node[n].nr]=pow(lcase[lc].dat[e][node[n].nr],factor);
4396     }
4397     lcase[lc].max[e]=pow(lcase[lc].max[e],factor);
4398     lcase[lc].min[e]=pow(lcase[lc].min[e],factor);
4399   }
4400   if(cur_entity==e)
4401   {
4402     scale->smin=pow(scale->smin,factor);
4403     scale->smax=pow(scale->smax,factor);
4404   }
4405 }
4406 
4407 
4408 
4409 /* returns 1 if the parameter is already existing */
createUSERparam(char * key,char * text)4410 int createUSERparam(char *key, char *text)
4411 {
4412   int i;
4413 
4414   if(anz->u<1)
4415   {
4416     i=anz->u=0;
4417     if(( anz->uheader=(char **)realloc((char **)anz->uheader, (1)*sizeof(char *))) == NULL )
4418           printf("\n\n ERROR: realloc failed\n\n") ;
4419     if(( anz->uheader[anz->u]=(char *)malloc( MAX_LINE_LENGTH * sizeof(char))) == NULL )
4420           printf("\n\n ERROR: malloc failed\n\n") ;
4421     sprintf(anz->uheader[anz->u],"    1U%s %s", key, text);
4422     anz->u++;
4423   }
4424   else
4425   {
4426     /* check if the parameter exists */
4427     for (i=0; i<anz->u; i++)
4428     {
4429       if(compare(&anz->uheader[i][6], key, strlen(key)) == strlen(key))
4430       {
4431         if(compare(&anz->uheader[i][7+strlen(key)], text, 3) == 3) return(1);
4432         break;
4433       }
4434     }
4435     if(i==anz->u)
4436     {
4437       printf("add key:%s text:%s\n",key,text);
4438       if(( anz->uheader=(char **)realloc((char **)anz->uheader, (anz->u+1)*sizeof(char *))) == NULL )
4439           printf("\n\n ERROR: realloc failed\n\n") ;
4440       if(( anz->uheader[anz->u]=(char *)malloc( MAX_LINE_LENGTH * sizeof(char))) == NULL )
4441           printf("\n\n ERROR: malloc failed\n\n") ;
4442       sprintf(anz->uheader[anz->u],"    1U%s %s", key, text);
4443       anz->u++;
4444     }
4445   }
4446   sprintf(anz->uheader[i],"    1U%s %s", key, text);
4447   return(0);
4448 }
4449 
4450 
4451 
4452 /* returns 1 if the parameter is already existing */
createDSparam(int lc,char * key,char * text)4453 int createDSparam(int lc, char *key, char *text)
4454 {
4455   int i;
4456 
4457   printf("add key:%s %s\n",key,text);
4458   if(!lcase[lc].npheader)
4459   {
4460     if(( lcase[lc].pheader=(char **)malloc( sizeof(char *))) == NULL )
4461       printf("\n\n ERROR: malloc failed\n\n");
4462     if(( lcase[lc].pheader[lcase[lc].npheader]=(char *)malloc(MAX_LINE_LENGTH * sizeof(char))) == NULL )
4463       printf("\n\n ERROR: malloc failed\n\n");
4464     lcase[lc].npheader++;
4465     i=0;
4466   }
4467   else
4468   {
4469     /* check if the parameter 'key' exists */
4470     for(i=0; i<lcase[lc].npheader; i++)
4471     {
4472       if(compare(&lcase[lc].pheader[i][6], key, strlen(key)) == strlen(key))
4473       {
4474         if(compare(&lcase[lc].pheader[i][7+strlen(key)], text, 3) == 3) return(1);
4475         break;
4476       }
4477     }
4478     if(i==lcase[lc].npheader)
4479     {
4480       if(( lcase[lc].pheader=(char **)realloc((char **)lcase[lc].pheader, (lcase[lc].npheader+1) * sizeof(char *))) == NULL )
4481         printf("\n\n ERROR: realloc failed\n\n");
4482       if(( lcase[lc].pheader[lcase[lc].npheader]=(char *)malloc(MAX_LINE_LENGTH * sizeof(char))) == NULL )
4483         printf("\n\n ERROR: malloc failed\n\n");
4484       lcase[lc].npheader++;
4485     }
4486   }
4487   sprintf(lcase[lc].pheader[i],"    1P%s %s", key, text);
4488   return(0);
4489 }
4490 
4491 
4492 
selectData(char * record)4493 void selectData( char *record)
4494 {
4495   int i,j, dim, length, lc[3], e[4], nlc, ne=0;
4496   char data[8][MAX_LINE_LENGTH], historyFlag=0;
4497   double factor=1., offset=0.;
4498   char key[MAX_LINE_LENGTH], text[MAX_LINE_LENGTH];
4499 
4500 #if TEST
4501   printf (" in selectData\n");
4502 #endif
4503 
4504   //printf("record %s\n",record);
4505   length = sscanf( record,"%s %s %s %s %s %s %s %s", data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
4506 
4507   if(anz->l<1)
4508   {
4509     printf(" ERROR: no Datasets available\n");
4510     strcpy(parameter[0], "ERROR: no Datasets available");
4511     write2stack(1, parameter);
4512     return;
4513   }
4514 
4515   /* change the element and face mode to 'value' (if not translucent and if not a single one does not already show results ('v') ) */
4516   j=1;
4517   for(i=0; i<anzGeo->psets; i++) if(pset[i].type[1]=='v') j=0;
4518   if(j)
4519   {
4520     for(i=0; i<anzGeo->psets; i++)
4521       if(((pset[i].type[0]=='e')||(pset[i].type[0]=='f'))&&(pset[i].type[1]!='b')) pset[i].type[1]='v';
4522   }
4523 
4524   /* extract the selection */
4525   /* search for 'e', after 'e' appear the entities (up to 3 for a vector-plot) */
4526   dim=nlc=ne=e[0]=0;
4527   text[0]=0;
4528   for(i=0; i<length; i++)
4529   {
4530     if(dim) e[ne++]=atoi(data[i]);
4531     else if(data[i][0]=='a') { e[ne++]=data[i][0]; dim=1; if(data[i][1]=='h') historyFlag=1; if(length>i+1) e[ne++]=atoi(data[i+1]); break; }
4532     else if(data[i][0]=='s') { factor=atof(data[i+1]); dim=-1; if(length>i+2) e[ne++]=atoi(data[i+2]); break; }
4533     else if(data[i][0]=='o') { offset=atof(data[i+1]); dim=-2; if(length>i+2) e[ne++]=atoi(data[i+2]); break; }
4534     else if(data[i][0]=='p') { factor=atof(data[i+1]); dim=-3; if(length>i+2) e[ne++]=atoi(data[i+2]); break; }
4535     else if(data[i][0]=='r') { strcpy(key,data[i+1]);  dim=-4; for(j=i+2; j<length; j++) sprintf(&text[strlen(text)],"%s ",data[j]); break; }
4536     else if(data[i][0]=='e') { dim=length-i-1; if(data[i][1]=='h') historyFlag=1; }
4537     else if(!dim)
4538     {
4539       if(data[i][0]=='l') lc[nlc++]=anz->l;
4540       else if(data[i][0]=='-') lc[nlc++]=anz->l+atoi(data[i]);
4541       else lc[nlc++]=atoi(data[i]);
4542     }
4543   }
4544   /* check the selection */
4545   for(i=0; i<nlc; i++)
4546   {
4547     if( lc[i]<1)
4548     {
4549       errMsg ("ERROR: Dataset %d not known, min Dataset %d\n", lc[i], 1 );
4550       sprintf(parameter[0], "ERROR: Dataset %d not known, min Dataset %d\n", lc[i], 1 );
4551       write2stack(1, parameter);
4552       return;
4553     }
4554 
4555     if( lc[i]>anz->l)
4556     {
4557       errMsg ("ERROR: Dataset %d not known, max Dataset %d\n", lc[i], anz->l );
4558       sprintf(parameter[0], "ERROR: Dataset %d not known, max Dataset %d\n", lc[i], anz->l );
4559       write2stack(1, parameter);
4560       return;
4561     }
4562   }
4563 
4564   /* if parameters are provided */
4565   if(dim==-4)
4566   {
4567     if(nlc==1) createDSparam(lc[0]-1,key,text);
4568     else
4569     {
4570       for(i=lc[0]-1; i<lc[2]; i+=lc[1]-lc[0]) createDSparam(i,key,text);
4571     }
4572     return;
4573   }
4574 
4575   /* check if the data of the specified lcase (Dataset) are already available */
4576   for(i=0; i<nlc; i++)
4577   {
4578     if (!lcase[lc[i]-1].loaded)
4579     {
4580       if( pre_readfrdblock(copiedNodeSets , lc[i]-1, anz, node, lcase )==-1)
4581       {
4582         printf("ERROR in selectData: Could not read data for Dataset:%d\n", lc[i]);
4583         return;
4584       }
4585       calcDatasets( lc[i]-1, anz, node, lcase );
4586     }
4587   }
4588   for(j=0; j<ne; j++)
4589   {
4590     if ( ( e[j]=='a' ) || ( (e[j]<=lcase[lc[0]-1].ncomps) && (e[j]>0) ) ) ;
4591     else { printf("ERROR: entity not known %d from ds %d\n", e[j], lc[0]); return; }
4592   }
4593 
4594   /* if datasets are to be scaled */
4595   if(dim<0)
4596   {
4597     if(nlc==1)
4598     {
4599       for(i=0; i<lcase[lc[0]-1].ncomps; i++)
4600       {
4601         if (lcase[lc[0]-1].irtype == 3) /* element data */
4602         {
4603           elementDataset( i, lc[0]-1, anz, scale, lcase, offset, maxIndex, steps );
4604         }
4605         else
4606         {
4607           nodalDataset( i, lc[0]-1, anz, scale, node, lcase, colNr, 1 );
4608         }
4609       }
4610       if(dim==-1) scaldataset(lc[0]-1,factor, e[0]);
4611       if(dim==-2) offsetdataset(lc[0]-1,offset, e[0]);
4612       if(dim==-3) expdataset(lc[0]-1,factor, e[0]);
4613     }
4614     else
4615     {
4616       for(i=0; i<nlc; i++)
4617       {
4618         if((i>0)&&(compareStrings(lcase[lc[0]-1].name,lcase[lc[i]-1].name)<1))
4619         {
4620           errMsg(" WARNING: selected Dataset %s is of different name than the 1st selected %s\n", lcase[lc[i]-1].name, lcase[lc[0]-1].name);
4621           return;
4622         }
4623       }
4624       for(i=lc[0]-1; i<lc[2]; i+=lc[1]-lc[0])
4625       {
4626         for(j=0; j<lcase[i].ncomps; j++)
4627         {
4628           if (lcase[i].irtype == 3) /* element data */
4629           {
4630             elementDataset( j, i, anz, scale, lcase, offset, maxIndex, steps );
4631           }
4632           else
4633           {
4634             nodalDataset( j, i, anz, scale, node, lcase, colNr, 1 );
4635           }
4636         }
4637       }
4638       if(dim==-1) { for(i=lc[0]-1; i<lc[2]; i+=lc[1]-lc[0]) scaldataset(i,factor, e[0]); }
4639       if(dim==-2) { for(i=lc[0]-1; i<lc[2]; i+=lc[1]-lc[0]) offsetdataset(i,offset, e[0]); }
4640       if(dim==-3) { for(i=lc[0]-1; i<lc[2]; i+=lc[1]-lc[0]) expdataset(i,factor, e[0]); }
4641     }
4642     ConfigureAndShowWindow_Load();
4643     return;
4644   }
4645 
4646   /* no entity selected, just a single one or a sequence */
4647   if(!dim)
4648   {
4649     dim=1;
4650     if(nlc==1)
4651     {
4652       if(drawMode!=4) drawMode=1;
4653       selectDataset(lc[0]-1);
4654       printf ("\n%d %s %f %s %s %d\n", lc[0], lcase[lc[0]-1].dataset_name, lcase[lc[0]-1].value, lcase[lc[0]-1].dataset_text, lcase[lc[0]-1].name, lcase[lc[0]-1].ncomps );
4655       sprintf(parameter[0],"%d", lc[0]);
4656       sprintf(parameter[1],"%s", lcase[lc[0]-1].dataset_name);
4657       sprintf(parameter[2],"%e", lcase[lc[0]-1].value);
4658       sprintf(parameter[3],"%s", lcase[lc[0]-1].dataset_text);
4659       sprintf(parameter[4],"%s", lcase[lc[0]-1].name);
4660       sprintf(parameter[5],"%d", lcase[lc[0]-1].ncomps);
4661       write2stack(6, parameter);
4662     }
4663     /* select a sequence of Datasets */
4664     else
4665     {
4666       sequenceFlag=1;
4667       seq_nlc=nlc;
4668       for(i=0; i<seq_nlc; i++)
4669       {
4670         if((i>0)&&(compareStrings(lcase[lc[0]-1].name,lcase[lc[i]-1].name)<1))
4671         {
4672           errMsg(" WARNING: selected Dataset %s is of different name than the 1st selected %s\n", lcase[lc[i]-1].name, lcase[lc[0]-1].name);
4673         }
4674         else seqLC[i]=lc[i]-1;
4675       }
4676       createDsSequence(seq_nlc, seqLC);
4677     }
4678     return;
4679   }
4680 
4681   /* if nlc > 1 generate a sequence */
4682   /* if dim > 1 generate a vector plot */
4683   if((dim>1)&&(e[0]!='a')) vectorFlag=1; else vectorFlag=0;
4684   if(nlc>1) historyFlag=1;
4685   if(!historyFlag)
4686   {
4687     sequenceFlag=0;
4688     v_dim=0;
4689     selectDataset(lc[0]-1);
4690     if( e[0]=='a' )
4691     {
4692       animFlag=1;
4693       if(ne>1)
4694       {
4695         if(drawMode!=4) drawMode=1;
4696         selectEntity(e[1]);
4697         if(inpformat)
4698         {
4699           glutSetWindow( w1 );
4700         }
4701         if (lcase[cur_lc].irtype == 3) /* element data */
4702         {
4703           elementDataset( cur_entity, cur_lc, anz, scale, lcase, offset, maxIndex, steps );
4704         }
4705         else
4706 	{
4707           nodalDataset( cur_entity, cur_lc, anz, scale, node, lcase, colNr, 1 );
4708         }
4709       }
4710       else
4711       {
4712         if(drawMode!=4) drawMode=2;
4713       }
4714       if((drawMode!=4)||(animFlag==1)){ ConfigureAndShowWindow_Light(); }
4715       else { ConfigureAndShowWindow_Plot(); }
4716     }
4717 
4718     /* prepare a vector-plot */
4719     else if((ne>1)&&(e[0]!='a'))
4720     {
4721       animFlag=0;
4722       cur_entity=e[ne-1]-1;
4723       drawMode=5;
4724       v_dim=ne;
4725       //seq_nlc=3;
4726       seq_nlc=0;
4727       seqLC[0]=lc[0]-1;
4728       seqLC[1]=lc[0]-1;
4729       seqLC[2]=lc[0]-1;
4730       for(i=0; i<ne; i++) entity_v[i]=e[i]-1;
4731       if(scale->lock!='l') { scale->smin=scale->smax=0; scale->sminr=scale->smaxr=defScalMethod; }
4732       createDsSequence(seq_nlc, seqLC);
4733       ConfigureAndShowWindow_Vector();
4734       return;
4735     }
4736     /* prepare a scalar plot */
4737     else
4738     {
4739       animFlag=0;
4740       selectEntity(e[0]);
4741     }
4742   }
4743   else // prepare a sequence
4744   {
4745     /* store the sequence of Datasets */
4746     sequenceFlag=1;
4747     seq_nlc=nlc;
4748     seqLC[1]=0;
4749     for(i=0; i<seq_nlc; i++)
4750     {
4751       seqLC[i]=lc[i]-1;
4752     }
4753     if(seqLC[1]<=seqLC[0]) { seqLC[1]=seqLC[0]+1; seq_nlc++; }
4754     createDsSequence(seq_nlc, seqLC);
4755 
4756     /* prepare an vector-plot */
4757     if((ne>1)&&(e[0]!='a'))
4758     {
4759       cur_entity=e[ne-1]-1;
4760       drawMode=5;
4761       v_dim=ne;
4762       for(i=0; i<ne; i++) entity_v[i]=e[i]-1;
4763       if(scale->lock!='l') { scale->smin=scale->smax=0; scale->sminr=scale->smaxr=defScalMethod; }
4764       ConfigureAndShowWindow_Vector();
4765     }
4766     else
4767     {
4768       if( e[0]=='a' )
4769       {
4770         if(ne>1)
4771         {
4772           drawMode=1;
4773           cur_entity=e[1]-1;
4774         }
4775         else
4776         {
4777           cur_entity=lcase[lc[0]-1].ncomps-1;
4778           if(drawMode!=4) drawMode=2;
4779           /* change the color to "illuminated" */
4780           for (j=0; j<anzGeo->psets; j++ )
4781           {
4782             if((pset[j].type[0]=='e')||(pset[j].type[0]=='f')) pset[j].type[1]=0;
4783           }
4784 	}
4785         ConfigureAndShowWindow_Light();
4786       }
4787       else
4788       {
4789         drawMode=1;
4790         cur_entity=e[0]-1;
4791         ConfigureAndShowWindow_Load();
4792       }
4793     }
4794   }
4795 }
4796 
4797 
4798 
4799 /* keyboard history */
specialKeyboard(int gkey,int x,int y)4800 void specialKeyboard( int gkey, int x, int y )
4801 {
4802   char  echo;
4803   int i, j, pos, setNr, lc;
4804   static char  prognam[MAX_LINE_LENGTH], type[MAX_LINE_LENGTH], lastset[MAX_LINE_LENGTH], col[MAX_LINE_LENGTH];
4805   static char buffer[MAX_LINE_LENGTH], keystroke2[MAX_LINE_LENGTH];
4806 
4807   if((gkey==GLUT_KEY_UP)||(gkey==GLUT_KEY_DOWN))
4808   {
4809     if(!commandLineFlag) {
4810     for(i=0; i<strlen(keystroke); i++)
4811     {
4812       /* go left */
4813       echo=( char )0xff08;
4814       putchar(echo);
4815     }
4816     for(i=0; i<strlen(keystroke); i++)
4817     {
4818       /* overwrite old command */
4819       echo=' ';
4820       putchar(echo);
4821     }
4822     for(i=0; i<strlen(keystroke); i++)
4823     {
4824       /* go left */
4825       echo=( char )0xff08;
4826       putchar(echo);
4827     }
4828     }
4829 
4830     if(gkey==GLUT_KEY_UP)
4831     {
4832       key_pointer--;
4833     }
4834     if(gkey==GLUT_KEY_DOWN)
4835     {
4836       key_pointer++;
4837     }
4838     if (key_pointer<0) key_pointer=0;
4839     if (key_pointer>=nkey_history) key_pointer=nkey_history-1;
4840     for (i=0; i<MAX_LINE_LENGTH; i++) keystroke[i]='\0';
4841     if(key_history!=NULL) strcpy(keystroke,key_history[key_pointer]);
4842     curshft=0;
4843 
4844     if(!commandLineFlag) {
4845     printf("%s",keystroke);
4846     fflush(stdout);
4847     }
4848   }
4849   else if((gkey==GLUT_KEY_RIGHT)||(gkey==GLUT_KEY_LEFT))
4850   {
4851     if (gkey==GLUT_KEY_LEFT)
4852     {
4853       /* go left */
4854       //echo=( char )0xff08;
4855       curshft--;
4856       if(curshft < (-strlen(keystroke)) ) curshft=-strlen(keystroke);
4857       else
4858       {
4859         echo=( char )8;
4860         if(!commandLineFlag) putchar(echo);
4861       }
4862     }
4863     if (gkey==GLUT_KEY_RIGHT)
4864     {
4865       /* go right */
4866       //echo=( char )0xff0b;
4867       curshft++;
4868       if(curshft > 0)
4869       {
4870         curshft=0;
4871       }
4872       else
4873       {
4874         echo=( char )keystroke[strlen(keystroke)-1+curshft];
4875         if(!commandLineFlag) putchar(echo);
4876       }
4877     }
4878     fflush(stdout);
4879   }
4880 
4881   else if((gkey==GLUT_KEY_PAGE_UP)||(gkey==GLUT_KEY_PAGE_DOWN))
4882   {
4883     /* the purpose is to remove the last displayed set and to display the next set */
4884     /* or if the last command was no plot/plus to display the next loadcase */
4885 
4886     if(nkey_history)
4887     {
4888       pos = sword( key_history[nkey_history-1], prognam);
4889       for(j=0;j<strlen(prognam); j++) prognam[j]=toupper(prognam[j]);
4890 
4891       if (( compare(prognam, "PLUS", 4) == 4 )||( compare(prognam, "PLOT", 4) == 4 ))
4892       {
4893         strcpy(keystroke2,key_history[nkey_history-1]);
4894         generateSetIndexes();
4895 
4896         col[0]='\0';
4897         sscanf(keystroke2, "%*s %s %s %s", type, lastset, col);
4898         setNr=getSetNr(lastset);
4899 
4900         if(gkey==GLUT_KEY_PAGE_UP)
4901         {
4902           for(i=setNr-1; i>=0; i--)
4903           {
4904             if( ((set[i].name != (char *)NULL )&&(set[i].type==0))&&
4905     	  ( ( (type[0]=='n')&& (set[i].anz_n) ) ||
4906                 ( (type[0]=='e')&& (set[i].anz_e) ) ||
4907                 ( (type[0]=='f')&& (set[i].anz_f) ) ||
4908                 ( (type[0]=='p')&& (set[i].anz_p) ) ||
4909                 ( (type[0]=='l')&& (set[i].anz_l) ) ||
4910                 ( (type[0]=='s')&& (set[i].anz_s) ) ||
4911                 ( (type[0]=='b')&& (set[i].anz_b) ) ||
4912     	    ( (type[0]=='L')&& (set[i].anz_nurl) ) ||
4913     	    ( (type[0]=='S')&& (set[i].anz_nurs) ) ))  break;
4914           }
4915           if(i>=0) setNr=i;
4916         }
4917         if(gkey==GLUT_KEY_PAGE_DOWN)
4918         {
4919           for(i=setNr+1; i<anz->sets; i++)
4920           {
4921             if( ((set[i].name != (char *)NULL )&&(set[i].type==0))&&
4922     	  ( ( (type[0]=='n')&& (set[i].anz_n) ) ||
4923                 ( (type[0]=='e')&& (set[i].anz_e) ) ||
4924                 ( (type[0]=='f')&& (set[i].anz_f) ) ||
4925                 ( (type[0]=='p')&& (set[i].anz_p) ) ||
4926                 ( (type[0]=='l')&& (set[i].anz_l) ) ||
4927                 ( (type[0]=='s')&& (set[i].anz_s) ) ||
4928                 ( (type[0]=='b')&& (set[i].anz_b) ) ||
4929     	    ( (type[0]=='L')&& (set[i].anz_nurl) ) ||
4930     	    ( (type[0]=='S')&& (set[i].anz_nurs) ) ))  break;
4931           }
4932           if(i<anz->sets) setNr=i;
4933         }
4934         sprintf(buffer,"minus");
4935         commandoInterpreter( buffer, keystroke2, pos, 0, 0, 0, 0 );
4936         sprintf(keystroke2, "%s %s %s %s", prognam, type, set[setNr].name, col);
4937         printf("%s %s %s(%d) %s\n", prognam, type, set[setNr].name, set[setNr].index, col);
4938         commandoInterpreter( prognam, keystroke2, pos, 0, 0, 0, 0 );
4939 
4940         /* history */
4941         if((key_history= (char **)realloc((char **)key_history, (nkey_history+2)*sizeof(char *))) == NULL )
4942         { printf("ERROR: malloc failed in Keyboard\n\n" ); return; }
4943         if((key_history[nkey_history]= (char *)malloc((MAX_LINE_LENGTH)*sizeof(char))) == NULL )
4944         { printf("ERROR: malloc failed in Keyboard\n\n" ); return; }
4945         strcpy(key_history[nkey_history],keystroke2);
4946         nkey_history++;
4947         key_pointer=nkey_history;
4948         return;
4949       }
4950     }
4951 
4952     /* default: display other loadcase */
4953 
4954     if(gkey==GLUT_KEY_PAGE_UP)
4955     {
4956       /* display the previous LC */
4957       for(lc=cur_lc-1; lc>=0; lc--)
4958       {
4959         if( compareStrings( lcase[lc].name,lcase[cur_lc].name)>0)
4960 	{
4961           pre_lc=lc;
4962           break;
4963 	}
4964       }
4965     }
4966     else if(gkey==GLUT_KEY_PAGE_DOWN)
4967     {
4968       /* display the next LC */
4969       for(lc=cur_lc+1; lc<anz->l; lc++)
4970       {
4971         if( compareStrings( lcase[lc].name,lcase[cur_lc].name)>0)
4972 	{
4973           pre_lc=lc;
4974           break;
4975 	}
4976       }
4977     }
4978 
4979     set_cur_lc(pre_lc);
4980     if(addDispFlag==1)
4981     {
4982       addDispToCoordinates(node);
4983       addDispToCoordinates(node);
4984       printf("\n displacements of dataset:%d added. Scale them with 'scal d <value>'\n",pre_lc+1);
4985     }
4986     if (animFlag==1)
4987     {
4988       if(drawMode==1) sprintf(keystroke2, "ds %d a %d", pre_lc+1, cur_entity+1);
4989       else sprintf(keystroke2, "ds %d a", pre_lc+1);
4990       sprintf(prognam,"ds");
4991       commandoInterpreter( prognam, keystroke2, 2, 0, 0, 0, 0 );
4992     }
4993     else
4994     {
4995       selectDataset( pre_lc );
4996       selectEntity(cur_entity+1 );
4997     }
4998 
4999     /* history */
5000     if((key_history= (char **)realloc((char **)key_history, (nkey_history+2)*sizeof(char *))) == NULL )
5001     { printf("ERROR: malloc failed in Keyboard\n\n" ); return; }
5002     if((key_history[nkey_history]= (char *)malloc((MAX_LINE_LENGTH)*sizeof(char))) == NULL )
5003     { printf("ERROR: malloc failed in Keyboard\n\n" ); return; }
5004     strcpy(key_history[nkey_history],keystroke2);
5005     nkey_history++;
5006     key_pointer=nkey_history;
5007     return;
5008   }
5009   DrawCommandLine(keystroke, strlen(keystroke)+curshft);
5010 }
5011 
5012 
5013 
Keyboard(unsigned char gkey,int x,int y)5014 void Keyboard( unsigned char gkey, int x, int y )
5015 {
5016   int  i,j, pos, new_elems=0;
5017   int gtolFlag=0;
5018   static char  prognam[MAX_LINE_LENGTH];
5019 
5020   if ( parser( gkey, keystroke, &curshft, commandLineFlag) )
5021   {
5022     if(strlen(keystroke)<1) return;
5023 
5024     /* history */
5025     if((key_history= (char **)realloc((char **)key_history, (nkey_history+2)*sizeof(char *))) == NULL )
5026     { printf("ERROR: malloc failed in Keyboard\n\n" ); return; }
5027     if((key_history[nkey_history]= (char *)malloc((MAX_LINE_LENGTH)*sizeof(char))) == NULL )
5028     { printf("ERROR: malloc failed in Keyboard\n\n" ); return; }
5029     strcpy(key_history[nkey_history],keystroke);
5030     nkey_history++;
5031     key_pointer=nkey_history;
5032 
5033     /* parser */
5034     pos = sword( keystroke, prognam);
5035     for(j=0;j<strlen(prognam); j++) prognam[j]=toupper(prognam[j]);
5036 
5037     if ( compare(prognam, "HELP", 4) == 4 ) help();
5038     else if ( compare(prognam, "QADD", 4) == 4 ) qadd(&keystroke[pos+1]);
5039     else if ( compare(prognam, "QALI", 4) == 4 ) qali();
5040     else if ( compare(prognam, "QBIA", 4) == 4 ) qbia();
5041     else if ( compare(prognam, "QBOD", 4) == 4 ) qbod(&keystroke[pos+1]);
5042     else if ( compare(prognam, "QCNT", 4) == 4 ) qcnt();
5043     else if ( compare(prognam, "QCUT", 4) == 4 ) qcut();
5044     else if ( compare(prognam, "QDEL", 4) == 4 ) qdel();
5045     else if ( compare(prognam, "QDIV", 4) == 4 ) qdiv();
5046     else if ( compare(prognam, "QDIS", 4) == 4 ) qdis();
5047     else if ( compare(prognam, "QMSH", 4) == 4 ) qmsh();
5048     else if ( compare(prognam, "QENQ", 4) == 4 ) qenq();
5049     else if ( compare(prognam, "QFIL", 4) == 4 ) qfil(&keystroke[pos+1]);
5050     else if ( compare(prognam, "QFLP", 4) == 4 ) qflp();
5051     else if ( compare(prognam, "QINT", 4) == 4 ) qint();
5052     else if ( compare(prognam, "QLIN", 4) == 4 ) qlin(&keystroke[pos+1]);
5053     else if ( compare(prognam, "QPNT", 4) == 4 ) qpnt(&keystroke[pos+1]);
5054     else if ( compare(prognam, "QMOV", 4) == 4 ) qmov(&keystroke[pos+1]);
5055     else if ( compare(prognam, "QNOD", 4) == 4 ) qnod();
5056     else if ( compare(prognam, "QNOR", 4) == 4 ) qnor();
5057     else if ( compare(prognam, "QREM", 4) == 4 ) qrem(&keystroke[pos+1]);
5058     else if ( compare(prognam, "QSUR", 4) == 4 ) qsur(&keystroke[pos+1]);
5059     else if ( compare(prognam, "QSEQ", 4) == 4 ) qseq(&keystroke[pos+1]);
5060     else if ( compare(prognam, "QPLN", 4) == 4 ) qshp(&keystroke[pos+1]);
5061     else if ( compare(prognam, "QSHP", 4) == 4 ) qshp(&keystroke[pos+1]);
5062     else if ( compare(prognam, "QSPL", 4) == 4 ) qspl();
5063     else if ( compare(prognam, "QTXT", 4) == 4 ) qtxt();
5064     else
5065     {
5066       commandoInterpreter( prognam, keystroke, pos, 0, 0, 0, &gtolFlag );
5067       if ( compare(prognam, "ELEM", 4) == 4 ) new_elems=1;
5068     }
5069     for (j=0; j<MAX_LINE_LENGTH; j++) prognam[j]=keystroke[j]='\0';
5070     curshft=0;
5071     DrawCommandLine(keystroke, strlen(keystroke)+curshft);
5072 
5073     //NEWELEM:
5074     if(new_elems)
5075     {
5076       new_elems=0;
5077 
5078       /* das neue netz muss noch zur beleuchteten ansicht aufbereitet werden  */
5079       /* free the additional midside-nodes for higher order elements */
5080       for(i=anz->orign; i<anz->n; i++) node[node[i].nr].pflag=-1;
5081       anz->n= anz->orign;
5082       anz->nmax=anz->orignmax;
5083       adjustDrawNodes(1);
5084       getElemNormalen( e_enqire, node, anz->e );
5085       makeSurfaces();
5086       realloc_colNr();
5087       updateDispLists();
5088     }
5089   }
5090 }
5091 
5092 
5093 
initModel(char * string)5094 void initModel(char *string)
5095 {
5096   int i,j;
5097   int buf[4]={0,0,0,0};
5098   static GLint cull;
5099 
5100   sscanf(string, "%*s %d %d %d %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %d %d %d %d %d %d %d %d",&width_w0,&height_w0,&cull,&ds,&dtx,&dty,&dtz,&vmem[0],&vmem[1],&vmem[2],&vmem[3],&R[0][0],&R[0][1],&R[0][2],&R[0][3],&R[1][0],&R[1][1],&R[1][2],&R[1][3],&R[2][0],&R[2][1],&R[2][2],&R[2][3],&R[3][0],&R[3][1],&R[3][2],&R[3][3],&lastquat[0],&lastquat[1],&lastquat[2],&lastquat[3],&centerPnt[0],&centerPnt[1],&centerPnt[2],&backgrndcol,&legend_font,&draw_font,&menu_font,&buf[0],&buf[1],&buf[2],&buf[3]);
5101 
5102   modelEdgeFlag=buf[0];
5103   elemEdgeFlag=buf[1];
5104   surfFlag=buf[2];
5105   illumResultFlag=buf[3];
5106   foregrndcol=!backgrndcol;
5107   for (i=0; i<4; i++) for (j=0; j<4; j++) Rmem[i][j]=R[i][j];
5108 
5109   if(!inpformat) return;
5110   sprintf(buffer,"wsize %d %d",width_w0,height_w0);
5111   setWindowSize(buffer);
5112   if (cull==GL_BACK) cullFlag=0;
5113   else cullFlag=1;
5114 
5115   if(!foregrndcol) { foregrndcol_rgb[0]=foregrndcol_rgb[1]=foregrndcol_rgb[2]=foregrndcol_rgb[3]=0.; }
5116   else            { foregrndcol_rgb[0]=foregrndcol_rgb[1]=foregrndcol_rgb[2]=foregrndcol_rgb[3]=1.; }
5117   if(!backgrndcol) { backgrndcol_rgb[0]=backgrndcol_rgb[1]=backgrndcol_rgb[2]=backgrndcol_rgb[3]=0.; }
5118   else            { backgrndcol_rgb[0]=backgrndcol_rgb[1]=backgrndcol_rgb[2]=backgrndcol_rgb[3]=1.; }
5119   for (i=0; i<anzGeo->psets; i++ )
5120   {
5121     if(pset[i].col==0) pset[i].col=1;
5122     else if(pset[i].col==1) pset[i].col=0;
5123     if(surfFlag) {  if(pset[i].type[0]=='e') pset[i].type[0]='f'; }
5124     else         {  if(pset[i].type[0]=='f') pset[i].type[0]='e'; }
5125   }
5126 }
5127 
5128 
5129 
center(double x,double y,double z)5130 void center(double x, double y, double z)
5131 {
5132   int i;
5133 
5134   centerPnt[0]=x;
5135   centerPnt[1]=y;
5136   centerPnt[2]=z;
5137   m_copy( &Rmem[0][0], &R[0][0] );  /* remember all rotations to now (memory) */
5138   for (i=0; i<4; i++) vmem[i]+=v[i]; /* remember all kompensations to now (memory) */
5139 }
5140 
5141 
5142 
moveModel()5143 void moveModel()
5144 {
5145   glOrtho( -ds*aspectRatio_w1, ds*aspectRatio_w1, -ds, ds, -Z_DEPTH, Z_DEPTH ); /* nach glLoadIdentity() !! */
5146 
5147   v[0]= centerPnt[0] ;            /* nodes sind scaliert, sonst scalieren mit scalNodes() */
5148   v[1]= centerPnt[1] ;
5149   v[2]= centerPnt[2] ;
5150   v[3]=1.;
5151   m_sub( &dR[0][0], &R[0][0], &Rmem[0][0] );
5152   v_matmult( v, &dR[0][0] );
5153   glTranslated ( -v[0]-vmem[0], -v[1]-vmem[1], -v[2]-vmem[2] ); /* verschiebung durch verdrehung im Vorfeld */
5154                                             /* rueckgaengig machen */
5155   glTranslated ( dtx*ds, dty*ds, dtz );
5156   glMultMatrixd( &R[0][0] );
5157 }
5158 
5159 
5160 
drawRuler(void)5161 void drawRuler( void )
5162 {
5163   float dxscal;
5164   glColor3dv( foregrndcol_rgb );
5165   //printf(”window dx in model coords:%f\n", ds*aspectRatio_w1*scale->w*2);
5166   sprintf (buffer, "%.0e %s", ds*scale->w*.5, rulerString);
5167   dxscal=atof(buffer)/(ds*scale->w);
5168   //printf("dxscal:%f %s %.3e\n", dxscal, buffer, ds*scale->w*.5);
5169   text(1.-((0.7+strlen(buffer)*0.01)-dxscal*.5)/aspectRatio_w1, -0.96, -0.99,buffer, glut_font[legend_font]);
5170   glBegin ( GL_LINES );
5171     glVertex3d ( 1.-0.7/aspectRatio_w1, -.97, -0.99);
5172     glVertex3d ( 1.-(0.7-dxscal)/aspectRatio_w1, -.97, -0.99);
5173     glVertex3d ( 1.-0.68/aspectRatio_w1, -.95, -0.99);
5174     glVertex3d ( 1.-0.72/aspectRatio_w1, -.99, -0.99);
5175     glVertex3d ( 1.-(0.68-dxscal)/aspectRatio_w1, -.95, -0.99);
5176     glVertex3d ( 1.-(0.72-dxscal)/aspectRatio_w1, -.99, -0.99);
5177   glEnd();
5178 }
5179 
5180 
5181 
DrawGraficLoad(void)5182 void DrawGraficLoad( void )
5183 {
5184   int flipflop=0;
5185   double xc, yc, dxscal;
5186 #if TEST
5187   printf(" in DrawGraficLoad\n");
5188 #endif
5189  redraw:;
5190   flipflop=!flipflop;
5191   glClearColor ( backgrndcol_rgb[0], backgrndcol_rgb[1], backgrndcol_rgb[2], backgrndcol_rgb[3] );
5192   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
5193 
5194   glLoadIdentity();
5195   moveModel();
5196   if (modelEdgeFlag)     glCallList( list_model_edges );
5197   if (elemEdgeFlag)
5198   {
5199     if (surfFlag) glCallList( list_surf_edges );
5200     else          glCallList( list_elem_edges );
5201   }
5202   /* enable all colors  */
5203   glColor3d( 1,1,1);
5204   // glEnable(GL_TEXTURE_1D);
5205   if (lcase[cur_lc].irtype == 3)
5206   {
5207     glCallList( list_elem_elstress );
5208   }
5209   else
5210   {
5211     if (surfFlag)   glCallList( list_surf_load );
5212     else            glCallList( list_elem_load );
5213   }
5214 
5215   if (rulerFlag)
5216   {
5217     glLoadIdentity();
5218     drawRuler();
5219   }
5220   if (bgpicture)
5221   {
5222     glLoadIdentity();
5223     glRasterPos3f(-1., -1., 1.);
5224     glPixelZoom(bgpicture->zoom[0],bgpicture->zoom[1]);
5225     glDrawPixels( bgpicture->width, bgpicture->height, bgpicture->format, bgpicture->type, bgpicture->pixels);
5226   }
5227   if (pickFlag)
5228   {
5229     /* draw currend picking-Area  */
5230     xc= dx_cur/(double)width_w1;
5231     yc= dy_cur/(double)height_w1;
5232     //printf("dxy_cur:%f %f xyc:%f %f p:%f %f\n", dx_cur,dy_cur, xc,yc, dx-xc,dy+yc);
5233     glLoadIdentity();
5234     glColor3dv( foregrndcol_rgb );
5235     dxscal=dx*height_w1/width_w1;
5236     glLineWidth(1.);
5237     glBegin ( GL_LINE_LOOP );
5238     glVertex3d ( dxscal-xc, dy+yc, -1. );
5239     glVertex3d ( dxscal+xc, dy+yc, -1. );
5240     glVertex3d ( dxscal+xc, dy-yc, -1. );
5241     glVertex3d ( dxscal-xc, dy-yc, -1. );
5242     glEnd();
5243   }
5244   glutSwapBuffers();
5245   if(frameSetFlag>-2) { frameSet(frameSetFlag); frameSetFlag=-2; goto redraw; }
5246   if((cur_commandFile>-1)&&(flipflop)) goto redraw;
5247 
5248   if((movieFlag>0)&&(!stopFlag))
5249   {
5250     glutPostRedisplay();
5251     createHardcopy(3, NULL);
5252   }
5253   if(hcpyFlag)
5254   {
5255     createHardcopy(hcpyFlag, NULL); hcpyFlag=0;
5256   }
5257 }
5258 
5259 
5260 
DrawGraficLight(void)5261 void DrawGraficLight( void )
5262 {
5263   int flipflop=0;
5264   double xc, yc, dxscal;
5265 #if TEST
5266   printf(" in DrawGraficLight\n");
5267 #endif
5268  redraw:;
5269   flipflop=!flipflop;
5270   glClearColor ( backgrndcol_rgb[0], backgrndcol_rgb[1], backgrndcol_rgb[2], backgrndcol_rgb[3] );
5271   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
5272 
5273   glLoadIdentity();
5274   moveModel();
5275   if (modelEdgeFlag) glCallList( list_model_edges );
5276   if (elemEdgeFlag)
5277   {
5278      if (surfFlag) glCallList( list_surf_edges );
5279      else          glCallList( list_elem_edges );
5280   }
5281   if (surfFlag)    glCallList( list_surf_light );
5282   else             glCallList( list_elem_light );
5283 
5284   if (rulerFlag)
5285   {
5286     glLoadIdentity();
5287     drawRuler();
5288   }
5289   if (bgpicture)
5290   {
5291     glLoadIdentity();
5292     glRasterPos3f(-1., -1., 1.);
5293     glPixelZoom(bgpicture->zoom[0],bgpicture->zoom[1]);
5294     glDrawPixels( bgpicture->width, bgpicture->height, bgpicture->format, bgpicture->type, bgpicture->pixels);
5295   }
5296   if (pickFlag)
5297   {
5298     /* draw currend picking-Area  */
5299     xc= dx_cur/(double)width_w1;
5300     yc= dy_cur/(double)height_w1;
5301     glLoadIdentity();
5302     glColor3dv( foregrndcol_rgb );
5303 
5304     dxscal=dx*height_w1/width_w1;
5305     glBegin ( GL_LINE_LOOP );
5306       glVertex3d ( dxscal-xc, dy+yc, -1. );
5307       glVertex3d ( dxscal+xc, dy+yc, -1. );
5308       glVertex3d ( dxscal+xc, dy-yc, -1. );
5309       glVertex3d ( dxscal-xc, dy-yc, -1. );
5310     glEnd();
5311   }
5312   glutSwapBuffers();
5313   if(frameSetFlag>-2) { frameSet(frameSetFlag); frameSetFlag=-2;  goto redraw; }
5314   if((cur_commandFile>-1)&&(flipflop)) goto redraw;
5315 
5316   if((movieFlag>0)&&(!stopFlag))
5317   {
5318     glutPostRedisplay();
5319     createHardcopy(3, NULL);
5320   }
5321   if(hcpyFlag)
5322   {
5323     createHardcopy(hcpyFlag, NULL); hcpyFlag=0;
5324   }
5325 }
5326 
5327 
5328 
DrawGraficAnimate(void)5329 void DrawGraficAnimate( void )
5330 {
5331   static char buffer[MAX_LINE_LENGTH];
5332   static int t0, t1;
5333   int flipflop=0;
5334   static double freqb, freqb_soll;
5335   double xc, yc, dxscal;
5336 #if TEST
5337   printf(" in DrawGraficAnimate\n");
5338 #endif
5339  movieLoop:;
5340   flipflop=!flipflop;
5341 #if TEST
5342   frameNr++;
5343   /* Zeit stoppen  */
5344   if (frameNr==1) stopClock( frameNr );
5345   if (frameNr==100) {stopClock( frameNr ); frameNr=0;}
5346 #endif
5347 
5348   glClearColor ( backgrndcol_rgb[0], backgrndcol_rgb[1], backgrndcol_rgb[2], backgrndcol_rgb[3] );
5349   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
5350 
5351   glLoadIdentity();
5352   moveModel();
5353   if (modelEdgeFlag_Static)     glCallList( list_model_edges );
5354   if (modelEdgeFlag)     glCallList( list_animate_model_edges[animList] );
5355   if (elemEdgeFlag_Static)
5356   {
5357     if (surfFlag) glCallList( list_surf_edges );
5358     else          glCallList( list_elem_edges );
5359   }
5360   if (elemEdgeFlag)
5361   {
5362     if (surfFlag) glCallList( list_animate_surf_edges[animList] );
5363     else          glCallList( list_animate_elem_edges[animList] );
5364   }
5365   glCallList( list_animate[animList] );
5366 
5367   glLoadIdentity();
5368   sprintf (buffer,"%4d%%Amplitude     ", anim_alfa[animList]);
5369   glColor3dv( foregrndcol_rgb );
5370   text( -0.96, 0.96,-.99,buffer, glut_font[legend_font] );
5371 
5372   if (rulerFlag) drawRuler();
5373   if (bgpicture)
5374   {
5375     glRasterPos3f(-1., -1., 1.);
5376     glPixelZoom(bgpicture->zoom[0],bgpicture->zoom[1]);
5377     glDrawPixels( bgpicture->width, bgpicture->height, bgpicture->format, bgpicture->type, bgpicture->pixels);
5378   }
5379   if (pickFlag)
5380   {
5381     /* draw currend picking-Area  */
5382     xc= dx_cur/(double)width_w1;
5383     yc= dy_cur/(double)height_w1;
5384     glColor3dv( foregrndcol_rgb );
5385     dxscal=dx*height_w1/width_w1;
5386     glBegin ( GL_LINE_LOOP );
5387       glVertex3d ( dxscal-xc, dy+yc, -1. );
5388       glVertex3d ( dxscal+xc, dy+yc, -1. );
5389       glVertex3d ( dxscal+xc, dy-yc, -1. );
5390       glVertex3d ( dxscal-xc, dy-yc, -1. );
5391     glEnd();
5392   }
5393   glutSwapBuffers();
5394   if(frameSetFlag>-2) { frameSet(frameSetFlag); frameSetFlag=-2; goto movieLoop; }
5395   if((cur_commandFile>-1)&&(flipflop)) goto movieLoop;
5396 
5397   // keeps animation going when the mouse is in w1
5398   if ( activWindow==w1 )  glutPostRedisplay();
5399 
5400   if (!stopFlag)
5401   {
5402     animList++;
5403     if ( animList>=anim_steps) animList=0;
5404   }
5405 
5406   /* because of a sgi-problem only one side of the graphics-buffer can be used for hcpy */
5407   /* therefore each frame is displayed twice if a movie is recorded */
5408   if((movieFlag>0)&&(!stopFlag))
5409   {
5410     if(movieFrames==-1) movieFrames=anim_steps;
5411     printf("movieFrames:%d frameNr:%d animSteps:%d stepNr:%d\n", movieFrames,gifNr,anim_steps,animList);
5412     glutPostRedisplay();
5413     createHardcopy(3, NULL);
5414     if(animList<movieFrames) goto movieLoop;
5415   }
5416   if(hcpyFlag)
5417   {
5418     createHardcopy(hcpyFlag, NULL); hcpyFlag=0;
5419   }
5420 
5421   /* real-time wait */
5422   if(!movieFlag)
5423   {
5424     t0=t1;
5425     do {
5426       t1=glutGet(GLUT_ELAPSED_TIME);
5427       freqb = 1000 / ((t1-t0)+1) ;
5428       freqb_soll= anim_steps*1000 / time_per_period;
5429     } while ( freqb > freqb_soll );
5430   }
5431 }
5432 
5433 
5434 
DrawGraficSequence(void)5435 void DrawGraficSequence( void )
5436 {
5437   static int j;
5438   static char buffer[MAX_LINE_LENGTH];
5439   static int t0, t1;
5440   int flipflop=0;
5441   static double freqb, freqb_soll;
5442   double xc, yc, dxscal;
5443   char key;
5444 #if TEST
5445   printf(" in DrawGraficSequence\n");
5446 #endif
5447  movieLoop:;
5448   flipflop=!flipflop;
5449 #if TEST
5450   frameNr++;
5451   /* Zeit stoppen  */
5452   if (frameNr==1) stopClock( frameNr );
5453   if (frameNr==100) {stopClock( frameNr ); frameNr=0;}
5454 #endif
5455 
5456   glClearColor ( backgrndcol_rgb[0], backgrndcol_rgb[1], backgrndcol_rgb[2], backgrndcol_rgb[3] );
5457   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
5458 
5459   glLoadIdentity();
5460   moveModel();
5461   if(!sequenceFlag)
5462   {
5463     if (modelEdgeFlag)     glCallList( list_model_edges );
5464     if (elemEdgeFlag)
5465     {
5466       if (surfFlag) glCallList( list_surf_edges );
5467       else          glCallList( list_elem_edges );
5468     }
5469   }
5470   else
5471   {
5472     if (modelEdgeFlag_Static)     glCallList( list_model_edges );
5473     if (modelEdgeFlag)     glCallList( list_animate_model_edges[animList] );
5474     if (elemEdgeFlag_Static)
5475     {
5476       if (surfFlag) glCallList( list_surf_edges );
5477       else          glCallList( list_elem_edges );
5478     }
5479     if (elemEdgeFlag)
5480     {
5481       if (surfFlag) glCallList( list_animate_surf_edges[animList] );
5482       else          glCallList( list_animate_elem_edges[animList] );
5483     }
5484   }
5485 
5486   if (illumFlag);
5487   else
5488   {
5489     /* enable all colors */
5490     glColor3d( 1,1,1);
5491     glEnable(GL_TEXTURE_1D);
5492   }
5493   glCallList( list_animate[animList] );
5494   if (illumFlag);
5495   else
5496   {
5497     glDisable(GL_TEXTURE_1D);
5498   }
5499 
5500   /* immediate draw the vectors. no display-list used because vector-length should be updated immediately */
5501   if ((vectorFlag)&&(v_dim>1))
5502   {
5503     if(surfFlag) key='f';
5504     else         key='e';
5505     for (j=0; j<anzGeo->psets; j++ )
5506     {
5507       if (pset[j].type[0]==key)
5508       {
5509         /* vectors keep their length:*/
5510         //if(key=='f') drawFaces_vector( dsSequence.ds[animList], v_dim, entity_v, v_factor*ds*0.1*v_scale, set[pset[j].nr].anz_f, set[pset[j].nr].face, node, face);
5511         //if(key=='e') drawElements_vector( dsSequence.ds[animList], v_dim, entity_v, v_factor*ds*0.1*v_scale, set[pset[j].nr].anz_e, set[pset[j].nr].elem, node, e_enqire);
5512         /* scale vector length with zoom. */
5513         if(key=='f') drawFaces_vector( dsSequence.ds[animList], v_dim, entity_v, v_factor*0.025*v_scale, set[pset[j].nr].anz_f, set[pset[j].nr].face, node, face);
5514         if(key=='e') drawElements_vector( dsSequence.ds[animList], v_dim, entity_v, v_factor*0.025*v_scale, set[pset[j].nr].anz_e, set[pset[j].nr].elem, node, e_enqire);
5515       }
5516     }
5517   }
5518 
5519   glLoadIdentity();
5520   if(lcase[lcase_animList].analysis_type==2) sprintf (buffer,"Frame:%d Frequency:%e %s%c", animList+1, lcase[lcase_animList].dat[animList][0], lcase[lcase_animList].pheader[animList], '\0');
5521   else sprintf (buffer,"Frame:%d Time:%e %s%c", animList+1, lcase[lcase_animList].dat[animList][0], lcase[lcase_animList].pheader[animList], '\0');
5522   glColor3dv( foregrndcol_rgb );
5523   text( -0.96, 0.96, -0.99,buffer, glut_font[legend_font] );
5524 
5525   if (rulerFlag) drawRuler();
5526   if (bgpicture)
5527   {
5528     glRasterPos3f(-1., -1., 1.);
5529     glPixelZoom(bgpicture->zoom[0],bgpicture->zoom[1]);
5530     glDrawPixels( bgpicture->width, bgpicture->height, bgpicture->format, bgpicture->type, bgpicture->pixels);
5531   }
5532   if (pickFlag)
5533   {
5534     /* draw currend picking-Area  */
5535     xc= dx_cur/(double)width_w1;
5536     yc= dy_cur/(double)height_w1;
5537     //glLoadIdentity();
5538     glColor3dv( foregrndcol_rgb );
5539     dxscal=dx*height_w1/width_w1;
5540     glBegin ( GL_LINE_LOOP );
5541       glVertex3d ( dxscal-xc, dy+yc, -1. );
5542       glVertex3d ( dxscal+xc, dy+yc, -1. );
5543       glVertex3d ( dxscal+xc, dy-yc, -1. );
5544       glVertex3d ( dxscal-xc, dy-yc, -1. );
5545     glEnd();
5546   }
5547   glutSwapBuffers();
5548   if(frameSetFlag>-2) { frameSet(frameSetFlag); frameSetFlag=-2; goto movieLoop; }
5549   if((cur_commandFile>-1)&&(flipflop)) goto movieLoop;
5550 
5551   if ( activWindow==w1 )  glutPostRedisplay();
5552 
5553   if (!stopFlag)
5554   {
5555     animList++;
5556     if ( animList>=dsSequence.nds) animList=0;
5557   }
5558 
5559   /* because of a sgi-problem only one side of the graphics-buffer can be used for hcpy */
5560   /* therefore each frame is displayed twice if a movie is recorded */
5561   if((movieFlag>0)&&(!stopFlag))
5562   {
5563     if(movieFrames==-1) movieFrames=dsSequence.nds;
5564     printf("movieFrames:%d frameNr:%d seqSteps:%d stepNr:%d\n", movieFrames,gifNr,dsSequence.nds,animList);
5565     glutPostRedisplay();
5566     createHardcopy(3, NULL);
5567     if(animList<movieFrames) goto movieLoop;
5568   }
5569   if(hcpyFlag)
5570   {
5571     createHardcopy(hcpyFlag, NULL); hcpyFlag=0;
5572   }
5573 
5574   /* real-time wait */
5575   if(!movieFlag)
5576   {
5577     t0=t1;
5578     do {
5579     t1=glutGet(GLUT_ELAPSED_TIME);
5580     freqb = 1000 / ((t1-t0)+1) ;
5581     freqb_soll= anim_steps*1000 / time_per_period;
5582     } while ( freqb > freqb_soll );
5583   }
5584 }
5585 
5586 
5587 
DrawPickedItems()5588 void DrawPickedItems()
5589 {
5590   int flipflop=0;
5591   double xc, yc, dxscal;
5592 #if TEST
5593   printf(" in DrawPickedItems\n");
5594 #endif
5595  redraw:;
5596   flipflop=!flipflop;
5597   glClearColor ( backgrndcol_rgb[0], backgrndcol_rgb[1], backgrndcol_rgb[2], backgrndcol_rgb[3] );
5598   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
5599 
5600   glLoadIdentity();
5601   moveModel();
5602   if (modelEdgeFlag) glCallList( list_model_edges );
5603   drawSets(!PICK);
5604 
5605   if (rulerFlag)
5606   {
5607     glLoadIdentity();
5608     drawRuler();
5609   }
5610   if (bgpicture)
5611   {
5612     glLoadIdentity();
5613     glRasterPos3f(-1., -1., 1.);
5614     glPixelZoom(bgpicture->zoom[0],bgpicture->zoom[1]);
5615     glDrawPixels( bgpicture->width, bgpicture->height, bgpicture->format, bgpicture->type, bgpicture->pixels);
5616   }
5617   if (pickFlag)
5618   {
5619     /* draw currend picking-Area  */
5620     xc= dx_cur/(double)width_w1;
5621     yc= dy_cur/(double)height_w1;
5622     glLoadIdentity();
5623     glColor3dv( foregrndcol_rgb );
5624     dxscal=dx*height_w1/width_w1;
5625     glBegin ( GL_LINE_LOOP );
5626       glVertex3d ( dxscal-xc, dy+yc, -1. );
5627       glVertex3d ( dxscal+xc, dy+yc, -1. );
5628       glVertex3d ( dxscal+xc, dy-yc, -1. );
5629       glVertex3d ( dxscal-xc, dy-yc, -1. );
5630     glEnd();
5631   }
5632   glutSwapBuffers();
5633   if(frameSetFlag>-2) { frameSet(frameSetFlag); frameSetFlag=-2; DrawPickedItems(); goto redraw; }
5634   if((cur_commandFile>-1)&&(flipflop)) goto redraw;
5635 
5636   if((movieFlag>0)&&(!stopFlag))
5637   {
5638     glutPostRedisplay();
5639     createHardcopy(3, NULL);
5640   }
5641   if(hcpyFlag)
5642   {
5643     createHardcopy(hcpyFlag, NULL); hcpyFlag=0;
5644   }
5645 }
5646 
5647 
drawSets(int mode)5648 void drawSets(int mode)
5649 {
5650   int j;
5651   GLint ipuf[2];
5652   char typ;
5653 
5654 #if TEST
5655   printf(" in drawSets\n");
5656 #endif
5657 
5658   for (j=0; j<anzGeo->psets; j++ )
5659   {
5660     //printf("pset:%d type:%s\n",j,pset[j].type);
5661     /* don't draw the transparent faces */
5662     if(pset[j].type[0]=='f')
5663     {
5664       if(mode) drawFaceNodes_plot( set[pset[j].nr].anz_f, set[pset[j].nr].face, node, face, 2, 0 );
5665       if(elemEdgeFlag) drawFaces_edge( set[pset[j].nr].anz_f, set[pset[j].nr].face, node, face, basCol[0], pset[j].type[1] );
5666       if((pset[j].type[1]!='b')&&(pset[j].type[2]!='b'))
5667       {
5668         drawFaces_plot( set[pset[j].nr].anz_f, set[pset[j].nr].face, node, colNr, face, pset[j].col, pset[j].type[1], pset[j].width, mode );
5669       }
5670     }
5671     else if (pset[j].type[0]=='n')
5672     {
5673       drawNodes_plot( set[pset[j].nr].anz_n, set[pset[j].nr].node, node, pset[j].col, pset[j].type[1], pset[j].width );
5674       if ((vectorFlag)&&(v_dim>1))
5675       {
5676         /* vectors keep their length:*/
5677         // drawNodes_vector( dsSequence.ds[0], v_dim, entity_v, v_factor*ds*0.1*v_scale, set[pset[j].nr].anz_n, set[pset[j].nr].node, node);
5678         /* scale vector length with zoom. */
5679         drawNodes_vector( dsSequence.ds[0], v_dim, entity_v, v_factor*0.025*v_scale, set[pset[j].nr].anz_n, set[pset[j].nr].node, node);
5680       }
5681     }
5682     /* don't draw the transparent elements */
5683     else if (pset[j].type[0]=='e')
5684     {
5685       if(mode) drawElemNodes_plot( set[pset[j].nr].anz_e, set[pset[j].nr].elem, node, e_enqire, 2, 0 );
5686       if(elemEdgeFlag) drawElem_edge( set[pset[j].nr].anz_e, set[pset[j].nr].elem, node, e_enqire, basCol[0], pset[j].type[1] );
5687       if((pset[j].type[1]!='b')&&(pset[j].type[2]!='b'))
5688       {
5689         drawElements_plot( set[pset[j].nr].anz_e, set[pset[j].nr].elem, node, colNr, e_enqire, pset[j].col, pset[j].type[1], pset[j].width, mode );
5690       }
5691     }
5692     else if (pset[j].type[0]=='p')
5693     {
5694       drawPoints_plot( set[pset[j].nr].anz_p, set[pset[j].nr].pnt, point, pset[j].col, pset[j].type[1], pset[j].width );
5695     }
5696     else if (pset[j].type[0]=='l')
5697     {
5698       drawLines_plot( set[pset[j].nr].anz_l, set[pset[j].nr].line, line, point, pset[j].col, pset[j].type[1], pset[j].width );
5699     }
5700     else if (pset[j].type[0]=='s')
5701     {
5702       if(pset[j].type[1]=='h') drawShapes_plot( set[pset[j].nr].anz_sh, set[pset[j].nr].shp, shape, point, pset[j].col, pset[j].type[1]);
5703       else
5704       {
5705         drawSurfs_plot( set[pset[j].nr].anz_s, set[pset[j].nr].surf, surf, lcmb, line, point, pset[j].col, pset[j].type[1] );
5706       }
5707     }
5708     else if (pset[j].type[0]=='b')
5709     {
5710       drawBodys_plot( set[pset[j].nr].anz_b, set[pset[j].nr].body, body, surf, lcmb, line, point, pset[j].col, pset[j].type[1] );
5711     }
5712     else if (pset[j].type[0]=='L')
5713     {
5714       drawNurl_plot( set[pset[j].nr].anz_nurl, set[pset[j].nr].nurl, pset[j].col, pset[j].type[1], pset[j].width, mode );
5715     }
5716     else if (pset[j].type[0]=='S')
5717     {
5718       drawNurs_plot( set[pset[j].nr].anz_nurs, set[pset[j].nr].nurs, pset[j].col, pset[j].type[1], mode );
5719     }
5720   }
5721   /* draw the transparent objects */
5722   for (j=0; j<anzGeo->psets; j++ )
5723   {
5724     if(((pset[j].type[0]=='f')||(pset[j].type[0]=='e'))&&((pset[j].type[1]=='b')||(pset[j].type[2]=='b')))
5725     {
5726       if(pset[j].type[2]=='b') typ='x'; else typ=pset[j].type[1];
5727       glGetIntegerv( GL_CULL_FACE_MODE, ipuf );
5728       glDepthFunc(GL_LESS);
5729       glEnable (GL_BLEND);
5730       glDepthMask(GL_FALSE);
5731       glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
5732       glCullFace ( GL_FRONT );
5733       if(pset[j].type[0]=='f') drawFaces_plot( set[pset[j].nr].anz_f, set[pset[j].nr].face, node, colNr, face, pset[j].col, typ, pset[j].width, mode );
5734       else  drawElements_plot( set[pset[j].nr].anz_e, set[pset[j].nr].elem, node, colNr, e_enqire, pset[j].col, typ, pset[j].width, mode );
5735       glCullFace ( GL_BACK );
5736       if(pset[j].type[0]=='f') drawFaces_plot( set[pset[j].nr].anz_f, set[pset[j].nr].face, node, colNr, face, pset[j].col, typ, pset[j].width, mode );
5737       else  drawElements_plot( set[pset[j].nr].anz_e, set[pset[j].nr].elem, node, colNr, e_enqire, pset[j].col, typ, pset[j].width, mode );
5738       glDepthMask(GL_TRUE);
5739       glDisable (GL_BLEND);
5740       glDepthFunc(GL_LEQUAL);
5741       if ( ipuf[0] == GL_FRONT ) glCullFace ( GL_FRONT );
5742       else if ( ipuf[0] == GL_BACK ) glCullFace ( GL_BACK );
5743     }
5744   }
5745 }
5746 
5747 
5748 
DrawAxes()5749 void DrawAxes()
5750 {
5751   static char buffer[MAX_LINE_LENGTH];
5752 #if TEST
5753   printf(" in DrawAxes\n");
5754 #endif
5755 
5756   glClearColor ( backgrndcol_rgb[0], backgrndcol_rgb[1], backgrndcol_rgb[2], backgrndcol_rgb[3] );
5757   glClear(GL_COLOR_BUFFER_BIT );
5758 
5759   glLoadIdentity();
5760   glOrtho( -1., 1., -1., 1., -1., 1. ); /* nach glLoadIdentity() !! */
5761 
5762     v[0]= centerPnt[0] ;            /* nodes sind scaliert, sonst scalieren mit scalNodes() */
5763     v[1]= centerPnt[1] ;
5764     v[2]= centerPnt[2] ;
5765     v[3]=1.;
5766     m_sub( &dR[0][0], &R[0][0], &Rmem[0][0] );
5767     v_matmult( v, &dR[0][0] );
5768     glMultMatrixd( &R[0][0] );
5769 
5770     glColor3dv( foregrndcol_rgb );
5771     glBegin ( GL_LINE_STRIP );
5772      glVertex3d(0.,.5,0.);
5773      glVertex3d(0.,0.,0.);
5774      glVertex3d(.5,0.,0.);
5775     glEnd();
5776     glBegin ( GL_LINES );
5777      glVertex3d(0.,0.,0.);
5778      glVertex3d(0.,0.,.5);
5779     glEnd();
5780 
5781     text( .5, 0., 0., "X ", glut_font[legend_font] );
5782     text( 0., .5, 0., "Y ", glut_font[legend_font] );
5783     text( 0., 0., .5, "Z ", glut_font[legend_font] );
5784 
5785   if(drawMode!=4)
5786   {
5787     glLoadIdentity();
5788     if(surfFlag) sprintf (buffer,"s");
5789     else         sprintf (buffer,"v");
5790     glColor3dv( foregrndcol_rgb );
5791     text( -1, -1, 0.,buffer, glut_font[legend_font] );
5792   }
5793   glutSwapBuffers();
5794 }
5795 
5796 
updCommandLine()5797 void updCommandLine()
5798 {
5799   DrawCommandLine(0,0);
5800 }
5801 
5802 
DrawCommandLine(char * string,int curpos)5803 void DrawCommandLine(char *string, int curpos)
5804 {
5805   int i,pix=0;
5806 #if TEST
5807   printf(" in DrawCommandLine\n");
5808 #endif
5809   if(!commandLineFlag) return;
5810   glutSetWindow( w3);
5811 
5812   glClearColor ( backgrndcol_rgb[0], backgrndcol_rgb[1], backgrndcol_rgb[2], backgrndcol_rgb[3] );
5813   glClear(GL_COLOR_BUFFER_BIT );
5814 
5815   glLoadIdentity();
5816   glColor3dv( foregrndcol_rgb );
5817   glOrtho( -1., 1., -1., 1., -1., 1. ); /* nach glLoadIdentity() !! */
5818   glBegin ( GL_LINES );
5819     glVertex3d(-1, 1., 0. );
5820     glVertex3d(1, 1., 0. );
5821   glEnd();
5822   sprintf(buffer, ":");
5823   if(string) strcpy(&buffer[strlen(buffer)], string);
5824   text( -.99, -.5, 0., buffer, glut_font[menu_font] );
5825   // cursor position in pixel
5826   for(i=0; i<=curpos; i++) pix+=glutBitmapWidth(glut_font[menu_font],buffer[i]);
5827   //printf("pix:%d %f %f\n",pix, -1.+pix*2./width_w0, -1.+(pix+8.)*2./width_w0);
5828   glBegin ( GL_LINES );
5829     glVertex3d(-.99+pix*2./width_w0, -.7, 0. );
5830     glVertex3d(-.99+(pix+glutBitmapWidth(glut_font[menu_font],buffer[curpos]))*2./width_w0, -.7, 0. );
5831   glEnd();
5832   glutSwapBuffers();
5833 }
5834 
5835 
5836 
idleFunction(void)5837 void idleFunction(void)
5838 {
5839   int i,k,s,l,c;
5840   static int loop=0;
5841   FILE *inihandle;
5842 
5843 #if TEST
5844   printf(" in Idle\n");
5845 #endif
5846 
5847   /* read initial commands */
5848   if(loop==0)
5849   {
5850     sprintf(buffer,"%s/%s", homepath, initfile);
5851     inihandle = fopen (buffer, "r");
5852     if ( inihandle!= NULL )
5853     {
5854       fclose(inihandle);
5855       readfbd(buffer, 0);
5856     }
5857     if(backgrndcol) sprintf(buffer,"bg w"); else sprintf(buffer,"bg k");
5858     pre_view(buffer);
5859     if (cullFlag) sprintf(buffer,"back"); else sprintf(buffer,"front");
5860     pre_view(buffer);
5861   }
5862   if(loop<2) { glutPostRedisplay(); loop++; return; }
5863 
5864   if(iniActionsFlag)
5865   {
5866     glutSetWindow( w0);
5867     glutDisplayFunc ( DrawMenuSet );
5868     DrawMenuSet();
5869     glutSetWindow( w1);
5870     glutDisplayFunc ( DrawPickedItems );
5871     DrawPickedItems();
5872     glutSetWindow( w2);
5873     DrawAxes();
5874     DrawCommandLine(0,0);
5875 
5876     /* read the geometry of the model */
5877     gtol_buf=gtol;
5878     if(iniActionsFlag==1) { readfbd( datin, 0);  if(!animFlag) updateDispLists(); }
5879     if(iniActionsFlag==2)
5880     {
5881       i=readstep( datin, step_mode);
5882       sprintf(picture_text,"displayed shape: %s", set[i].name);
5883     }
5884     iniActionsFlag=0;
5885     if(gtol_buf==gtol)
5886     { gtol=calcGTOL(setall);  printf ("gtol calculated:%e\n", gtol); }
5887 
5888     /* if a cad file was read do some preparations */
5889     if(automode==1)
5890     {
5891       /* merge only points which are referenced by lines of a common body */
5892       for (i=0; i<anzGeo->b; i++) if( body[i].name != (char *)NULL )
5893       {
5894         printf(" merge points of body:%s which are referenced by lines\n", body[i].name);
5895         delSet(specialset->uori );
5896         k=pre_seta(specialset->uori, "i", 0 );
5897         for (s=0; s<body[i].ns; s++)
5898 	{
5899 	  for (l=0; l<surf[body[i].s[s]].nl; l++)
5900 	  {
5901             if(surf[body[i].s[s]].typ[l]=='l') seta(k,"l",surf[body[i].s[s]].l[l]);
5902             else
5903 	    {
5904               for (c=0; c<lcmb[surf[s].l[l]].nl; c++) seta(k,"l",lcmb[surf[s].l[l]].l[c]);
5905 	    }
5906           }
5907 	}
5908         completeSet( specialset->uori, "e") ;
5909         sprintf( buffer,"p %s %lf nolock", specialset->uori, gtol*GTOL_EDGES);
5910         pre_merge( buffer);
5911       }
5912 
5913       delSet(specialset->uori );
5914       k=pre_seta(specialset->uori, "i", 0 );
5915       for (i=0; i<anzGeo->l; i++) seta(k,"l",i);
5916 
5917       /* delete zero length lines */
5918       printf(" delete zero length lines\n");
5919       sprintf( buffer,"l0 %s", specialset->uori);
5920       pre_del( buffer);
5921 
5922       /* in case NURLs are read then calculate a suitable div for the related spline */
5923       if(autoDivFlag)
5924       {
5925         printf(" calcLineDiv with default parameters for elem_length:%f angle:%f elem_length_ratio:%f\n",gtol*GTOL_NODE_DIST, acos(GTOL_COS_A)*180./PI, ELEM_LENGTH_RATIO  );
5926         for (i=0; i<set[k].anz_l; i++)
5927         {
5928 	  if(line[set[k].line[i]].name!=NULL)
5929             calcLineDiv(line, set[k].line[i], GTOL_COS_A, gtol*GTOL_NODE_DIST/scale->w, gtol*GTOL_NODE_DIST/scale->w*ELEM_LENGTH_RATIO);
5930         }
5931         printf(" Optionally modify the line divisions with the 'div' command or with the interactive 'qdiv' command\n");
5932       }
5933       delSet(specialset->uori );
5934 
5935       /* delete unmeshable surfaces */
5936       printf("delete unmeshable surfaces\n");
5937       k=pre_seta(specialset->uori, "i", 0 );
5938       for (i=0; i<anzGeo->s; i++) if( surf[i].name != (char *)NULL )
5939       {
5940         if(surf[i].nl==1)
5941 	{
5942           if((surf[i].typ[0]=='l')&&(line[surf[i].l[0]].p1!=line[surf[i].l[0]].p2)) seta(k,"s",i);
5943 	}
5944         if(surf[i].nl==2)
5945 	{
5946           if((surf[i].typ[0]=='l')&&(surf[i].typ[1]=='l'))
5947 	  {
5948             if((line[surf[i].l[0]].typ==' ')&&(line[surf[i].l[1]].typ==' ')) seta(k,"s",i);
5949 	  }
5950 	}
5951       }
5952       zap(specialset->uori);
5953       delSet(specialset->uori );
5954 
5955       glutSetWindow( w1 ); /* has to be called before repSurf() to use the correct resolution */
5956       printf("orientSet\n");
5957       orientSet( "all" );  /* set "all" to avoid substitute surfs */
5958       for (i=0; i<set[setall].anz_l; i++) repLine(set[setall].line[i]);
5959       plot("lp all\n");
5960       printf("\n Optionally create separate bodies (body ! setname (ie. all)) but better start with surface meshing.\n");
5961       printf(" Change the element-type with 'elty' if needed, default is 'tr6u' for the surface mesh.\n");
5962       printf(" mesh with 'mesh all' and plot the elements with 'plot e all'.\n\n");
5963       printf(" Orient the elements (and surfaces) with 'qflp' in a way that all are illuminated (dark ones point inward) by choosing an illuminated element with 'a' and 'e'\n");
5964       printf(" Optionally use 'qmsh' for local modifications of the mesh density and finally create the volume mesh with 'mesh all tet'.\n\n");
5965 
5966       /* delete zero length lines */
5967       sprintf( buffer,"l0 all");
5968       pre_del( buffer);
5969       if(autoEltyFlag)
5970       {
5971         sprintf( buffer,"all tr6u");
5972         pre_elty(buffer);
5973       }
5974       updateDispLists();
5975 
5976       if(!anzGeo->b)
5977       {
5978         printf("\nWARNING: No body found:\n");
5979         printf("Manually merge points before meshing. If just one part exists type:\n  merg p all\nAssemblies need individual merging of endpoints referenced by lines of each single part:\n");
5980         printf("  seta b1 l <set>\n");
5981         printf("  comp b1 e\n");
5982         printf("  merg p b1\n\n");
5983         printf("  ori all\n");
5984       }
5985     }
5986     if(anzGeo->psets==0)
5987     {
5988       plot("p all    \n");
5989       plus("l all    \n");
5990       plus("s all    \n");
5991       plus("b all    \n");
5992     }
5993   }
5994   else
5995   {
5996     if(inpformat=='a') iniMeshData( datin, "ansl" );
5997     if(inpformat=='c') iniMeshData( datin, "ccx" );
5998     if(inpformat=='d') iniMeshData( datin, "duns2d" );
5999     if(inpformat=='D') iniMeshData( datin, "duns2dl" );
6000     if(inpformat=='i') iniMeshData( datin, "isaac2d" );
6001     if(inpformat=='j') iniMeshData( datin, "isaac3d" );
6002     if(inpformat=='e') iniMeshData( datin, "duns3d" );
6003     if(inpformat=='E') iniMeshData( datin, "duns3dl" );
6004     if(inpformat=='f') iniMeshData( datin, "foam" );
6005     if(inpformat=='m') iniMeshData( datin, "nas" );
6006     if(inpformat=='n') iniMeshData( datin, "ng" );
6007     if(inpformat=='t') iniMeshData( datin, "tg" );
6008     if(inpformat=='s') iniMeshData( datin, "stl" );
6009     if(inpformat=='v') iniMeshData( datin, "frd" );
6010 
6011     /* calc additional entities only if the block was not jumped during read */
6012     for (i=0; i<anz->olc; i++)  if (lcase[i].loaded)
6013       calcDatasets( i, anz, node, lcase );
6014 
6015     frame();
6016     ConfigureAndShowWindow_Light();
6017 
6018     gtol_buf=gtol;
6019     if(ccxfile[0]>0)
6020     {
6021       sprintf(buffer, "%s inp nom", ccxfile );
6022       pre_read(buffer);
6023     }
6024     if(gtol_buf==gtol)
6025     { gtol=calcGTOL(setall);  printf ("gtol calculated:%e\n", gtol); }
6026   }
6027 
6028   /* create the mainmenu */
6029   if((!sequenceFlag)&&(!vectorFlag)) createDatasetEntries();
6030 
6031   /* deactivate the idleFunction */
6032   glutIdleFunc (NULL);
6033 }
6034 
6035 
6036 
iniDrawMenu()6037 void iniDrawMenu()
6038 {
6039   char buffer[MAX_LINE_LENGTH];
6040   int i, maxchars;
6041   double x,y;
6042 #if TEST
6043   printf(" in iniDrawMenu\n");
6044 #endif
6045 
6046   glClearColor ( backgrndcol_rgb[0], backgrndcol_rgb[1], backgrndcol_rgb[2], backgrndcol_rgb[3] );
6047   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
6048 
6049   glLoadIdentity();
6050   glOrtho( -1., 1., -1., 1., -1., 1. ); /* nach glLoadIdentity() !! */
6051 
6052   glColor3dv( foregrndcol_rgb );
6053   if (frameFlag)
6054   {
6055     glBegin ( GL_LINE_LOOP );
6056      glVertex3d(-1+(width_menu*19/20-1)*2./width_w0, 1-(height_menu/10-1)*2./height_w0, 0. );
6057      glVertex3d(-1+(width_menu*19/20-1)*2./width_w0, 1-(height_menu/10+height_w1+1)*2./height_w0, 0. );
6058      glVertex3d(-1+(width_menu*19/20+width_w1+1)*2./width_w0,1-(height_menu/10+height_w1+1)*2./height_w0,0.);
6059      glVertex3d(-1+(width_menu*19/20+width_w1+1)*2./width_w0, 1-(height_menu/10-1)*2./height_w0, 0. );
6060     glEnd();
6061   }
6062   maxchars=(width_w0 /pixPerCharx[legend_font]);
6063   if (captionFlag)
6064   {
6065     i=strlen(picture_caption)-maxchars;
6066     if (i>0) strcpy(buffer, &picture_caption[i]);
6067     else strcpy(buffer, picture_caption);
6068     x=  -(double)(strlen( buffer )*pixPerCharx[legend_font]) / (double)(width_w0);
6069     y= 1-(height_menu/10+height_w1+4+pixPerChary[legend_font])*2./height_w0;
6070     text( x, y, 0., buffer, glut_font[legend_font] );
6071   }
6072   if (textFlag)
6073   {
6074     i=strlen(picture_text)-maxchars;
6075     if (i>0) strcpy(buffer, &picture_text[i]);
6076     else strcpy(buffer, picture_text);
6077     x=  -(double)(strlen( buffer )*pixPerCharx[legend_font]) / (double)(width_w0);
6078     y= 1-(height_menu/10+height_w1+6+pixPerChary[legend_font]*2)*2./height_w0;
6079     text( x, y, 0., buffer, glut_font[legend_font] );
6080   }
6081 }
6082 
6083 
6084 
DrawMenuLoad(void)6085 void DrawMenuLoad( void )
6086 {
6087   char buffer[MAX_LINE_LENGTH];
6088   double y;
6089   int flipflop=0;
6090 
6091   defineColTextur_load(1.);
6092  redraw:;
6093   flipflop=!flipflop;
6094 
6095   iniDrawMenu();
6096   if (scalaFlag)
6097   {
6098     sprintf (buffer,"%d/%d:%s", lcase[cur_lc].step_number,cur_lc+1,lcase[cur_lc].name);
6099     text( -0.99, 0.95, 0.,buffer, glut_font[legend_font]);
6100     if(lcase[cur_lc].analysis_type==2) sprintf (buffer,"Freq:%lf", lcase[cur_lc].value);
6101     else sprintf (buffer,"Time:%lf", lcase[cur_lc].value);
6102     text( -0.99, 0.9, 0.,buffer, glut_font[legend_font]);
6103     sprintf (buffer,"Entity:%s", lcase[cur_lc].compName[cur_entity]);
6104     text( -0.99, 0.85, 0., buffer, glut_font[legend_font] );
6105     if(addDispFlag)
6106     {
6107       sprintf (buffer,"+Dispf:%lf", anim_faktor);
6108       text( -0.99, 0.80, 0., buffer, glut_font[legend_font] );
6109     }
6110     if(scale->format=='f')
6111     {
6112       sprintf (buffer,"max: %-10f  ", lcase[cur_lc].max[cur_entity]);
6113       text( -0.99, 0.75, 0., buffer, glut_font[legend_font] );
6114       sprintf (buffer,"min: %-10f  ", lcase[cur_lc].min[cur_entity]);
6115       text( -0.99, 0.71, 0., buffer, glut_font[legend_font] );
6116     }
6117     else if(scale->format=='i')
6118     {
6119       sprintf (buffer,"max: %-10f  ", lcase[cur_lc].max[cur_entity]);
6120       text( -0.99, 0.75, 0., buffer, glut_font[legend_font] );
6121       sprintf (buffer,"min: %-10f  ", lcase[cur_lc].min[cur_entity]);
6122       text( -0.99, 0.71, 0., buffer, glut_font[legend_font] );
6123     }
6124     else
6125     {
6126       sprintf (buffer,"max: %5.2e  ", lcase[cur_lc].max[cur_entity]);
6127       text( -0.99, 0.75, 0., buffer, glut_font[legend_font] );
6128       sprintf (buffer,"min: %5.2e  ", lcase[cur_lc].min[cur_entity]);
6129       text( -0.99, 0.71, 0., buffer, glut_font[legend_font] );
6130     }
6131     y= 1-(height_menu/10+height_w1+1)*2./height_w0;
6132     if ((animFlag==0)||(halfperiod)) scala_tex((1-y)/2, -0.93, y, steps, scale->smin, scale->smax, (double)steps/(double)TEX_PIXELS, foregrndcol_rgb, glut_font[legend_font], scale->format, scale->sminr, scale->smaxr);
6133     else  scala_tex((1-y)/2, -0.93, y, steps, scale->smin-(scale->smax-scale->smin), scale->smax, (double)steps/(double)TEX_PIXELS, foregrndcol_rgb, glut_font[legend_font], scale->format, scale->sminr, scale->smaxr);
6134   }
6135   glutSwapBuffers();
6136   if((cur_commandFile>-1)&&(flipflop)) goto redraw;
6137 }
6138 
6139 
6140 
DrawMenuSequence(void)6141 void DrawMenuSequence( void )
6142 {
6143   char buffer[MAX_LINE_LENGTH];
6144   double y;
6145   int flipflop=0;
6146 
6147   defineColTextur_load(1.);
6148  redraw:;
6149   flipflop=!flipflop;
6150 
6151   iniDrawMenu();
6152   if (scalaFlag)
6153   {
6154     sprintf (buffer,"%d/%d:%s", lcase[lcase_animList].step_number, lcase_animList+1,lcase[lcase_animList].name);
6155     text( -0.99, 0.95, 0.,buffer, glut_font[legend_font]);
6156     sprintf (buffer,"Entity:%s", lcase[lcase_animList].compName[0]);
6157     text( -0.99, 0.85, 0., buffer, glut_font[legend_font] );
6158     if(addDispFlag)
6159     {
6160       sprintf (buffer,"+Dispf:%lf", anim_faktor);
6161       text( -0.99, 0.80, 0., buffer, glut_font[legend_font] );
6162     }
6163     if(scale->format=='f')
6164     {
6165       sprintf (buffer,"max: %-10f  ", lcase[cur_lc].max[0]);
6166       text( -0.99, 0.75, 0., buffer, glut_font[legend_font] );
6167       sprintf (buffer,"min: %-10f  ", lcase[cur_lc].min[0]);
6168       text( -0.99, 0.71, 0., buffer, glut_font[legend_font] );
6169     }
6170     else if(scale->format=='i')
6171     {
6172       sprintf (buffer,"max: %-10f  ", lcase[cur_lc].max[0]);
6173       text( -0.99, 0.75, 0., buffer, glut_font[legend_font] );
6174       sprintf (buffer,"min: %-10f  ", lcase[cur_lc].min[0]);
6175       text( -0.99, 0.71, 0., buffer, glut_font[legend_font] );
6176     }
6177     else
6178     {
6179       sprintf (buffer,"max: %5.2e  ", lcase[cur_lc].max[0]);
6180       text( -0.99, 0.75, 0., buffer, glut_font[legend_font] );
6181       sprintf (buffer,"min: %5.2e  ", lcase[cur_lc].min[0]);
6182       text( -0.99, 0.71, 0., buffer, glut_font[legend_font] );
6183     }
6184     y= 1-(height_menu/10+height_w1+1)*2./height_w0;
6185     scala_tex( (1-y)/2,-0.93, y, steps, scale->smin, scale->smax, (double)steps/(double)TEX_PIXELS, foregrndcol_rgb, glut_font[legend_font], scale->format, scale->sminr, scale->smaxr);
6186   }
6187   glutSwapBuffers();
6188   if((cur_commandFile>-1)&&(flipflop)) goto redraw;
6189 }
6190 
6191 
6192 
DrawMenuLight(void)6193 void DrawMenuLight( void )
6194 {
6195   int flipflop=0;
6196  redraw:;
6197   flipflop=!flipflop;
6198   iniDrawMenu();
6199     if(addDispFlag)
6200     {
6201       sprintf (buffer,"+Dispf:%lf", anim_faktor);
6202       text( -0.99, 0.80, 0., buffer, glut_font[legend_font] );
6203     }
6204   glutSwapBuffers();
6205   if((cur_commandFile>-1)&&(flipflop)) goto redraw;
6206 }
6207 
6208 
6209 
DrawMenuAnimate(void)6210 void DrawMenuAnimate( void )
6211 {
6212   char buffer[MAX_LINE_LENGTH];
6213   int flipflop=0;
6214 
6215  redraw:;
6216   flipflop=!flipflop;
6217   iniDrawMenu();
6218   if ((!sequenceFlag)&&(cur_lc > -1))
6219   {
6220     sprintf (buffer,"%d/%d:%s", lcase[cur_lc].step_number, cur_lc+1,lcase[cur_lc].name);
6221     text( -0.99, 0.95, 0.,buffer, glut_font[legend_font]);
6222     if(lcase[cur_lc].analysis_type==2) sprintf (buffer,"Freq:%lf", lcase[cur_lc].value);
6223     else sprintf (buffer,"Time:%lf", lcase[cur_lc].value);
6224     text( -0.99, 0.9, 0.,buffer, glut_font[legend_font]);
6225   }
6226   text( -0.99, 0.85, 0., "Animated", glut_font[legend_font] );
6227   if (halfperiod)
6228   {
6229     text( -0.99, 0.8, 0., "Tune-value:", glut_font[legend_font] );
6230     sprintf (buffer,"%3.1f", anim_faktor);
6231     text( -0.99, 0.76, 0., buffer, glut_font[legend_font] );
6232   }
6233   glutSwapBuffers();
6234   if((cur_commandFile>-1)&&(flipflop)) goto redraw;
6235 }
6236 
6237 
6238 
DrawMenuSet(void)6239 void DrawMenuSet( void )
6240 {
6241   int flipflop=0;
6242  redraw:;
6243   flipflop=!flipflop;
6244   iniDrawMenu();
6245   glutSwapBuffers();
6246   if((cur_commandFile>-1)&&(flipflop)) goto redraw;
6247 }
6248 
6249 
setWindowSize(char * string)6250 void setWindowSize(char *string)
6251 {
6252   int length,i,j;
6253   char format[MAX_LINE_LENGTH];
6254   if(!inpformat) return;
6255     length=sscanf( string, "%*s %s %d",format,&j);
6256     glutSetWindow( w0);
6257     if(format[0]=='f') { i=glutGet(GLUT_SCREEN_WIDTH); j=glutGet(GLUT_SCREEN_HEIGHT); }
6258     else if(length<1) { i=glutGet(GLUT_INIT_WINDOW_WIDTH); j=glutGet(GLUT_INIT_WINDOW_HEIGHT); }
6259     else i=atoi(format);
6260     if(i<width_menu) i=width_menu+1;
6261     if(j<height_menu) j=height_menu+1;
6262     glutReshapeWindow(i, j);               // call to reshape()
6263     glutSetWindow( activWindow);
6264     redraw();
6265 }
6266 
6267 
6268 
setWindowPos(char * string)6269 void setWindowPos(char *string)
6270 {
6271   int i,j;
6272   if(!inpformat) return;
6273     sscanf( string, "%*s %d %d",&i,&j);
6274     glutSetWindow( w0);
6275     glutPositionWindow(i, j);
6276     glutSetWindow( activWindow);
6277     redraw();
6278 }
6279 
6280 
6281 
reshape(int width,int height)6282 void reshape( int width, int height )
6283 {
6284   width_w0=width;
6285   height_w0=height;
6286   width_w1=width - width_menu;
6287   height_w1=height - height_menu;
6288   aspectRatio_w1=(double)width_w1/(double)height_w1;
6289 
6290   /* MAIN WINDOW */
6291   glutSetWindow( w0 );
6292     glViewport(0, 0, (GLint)width, (GLint)height );
6293   /* Drawing window */
6294   glutSetWindow( w1 );
6295     glutPositionWindow( width_menu*19/20, height_menu/10);
6296     glutReshapeWindow( width_w1, height_w1);
6297     glViewport( 0, 0, (GLint)width_w1, (GLint)height_w1);
6298   /* axis window */
6299   glutSetWindow( w2 );
6300     glutPositionWindow( 0, height_w1*0.9);
6301     glutReshapeWindow( height_w1/10, height_w1/10);
6302     glViewport( 0, 0, (GLint)height_w1/10, (GLint)height_w1/10);
6303   /* Command line window */
6304   if (commandLineFlag)
6305   {
6306     glutSetWindow( w3 );
6307        glutPositionWindow( 0, height_w0-pixPerChary[menu_font]);
6308        glutReshapeWindow( width_w0, pixPerChary[menu_font]);
6309       glViewport( 0, 0, (GLint)width_w0, (GLint)(pixPerChary[menu_font]));
6310     glutPostRedisplay();
6311   }
6312 }
6313 
6314 
6315 
initLight_rgb(void)6316 void initLight_rgb( void )
6317 {
6318     static GLfloat lmodel_ambient[] = { GAMB, GAMB, GAMB, 1.0 };
6319 
6320   /* lichtanteile rgba definieren  */
6321     static GLfloat ambient0[] = { AMB, AMB, AMB, 1.0 }; /* ungerichtet */
6322     static GLfloat diffuse0[] = { DIFF, DIFF, DIFF, 1.0 }; /* gerichtetes licht*/
6323 
6324   /* Position der Lichtquellen xyzw, mit w=0.0 entfernung unendlich def.*/
6325     static GLfloat position0[] = { 0., 0., -1., 0.0 };
6326 
6327     /*    glMatrixMode(GL_PROJECTION); fuert hier zu bildfehlern (Z-Buffer) */
6328     /* Definieren und Positionieren der Lampen */
6329     glLightfv(GL_LIGHT0, GL_AMBIENT, ambient0);          /* allseitiges Licht */
6330     glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse0);          /* gerichtetes Licht, ungerichtete reflexion */
6331     glLightfv(GL_LIGHT0, GL_SPECULAR, diffuse0);         /* gerichtetes Licht, gerichtete reflexion */
6332     glLightfv(GL_LIGHT0, GL_POSITION, position0);
6333 
6334     /* Beschreibung des Beleuchtungsmodells */
6335     glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); /* globales licht ohne quelle */
6336     glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, lmodel_oneside);
6337     glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE); /* GL_FALSE: infinite distance */
6338 
6339     glEnable(GL_LIGHT0);
6340     glDisable (GL_COLOR_MATERIAL);      /* improves performance (~2%) */
6341 }
6342 
6343 
6344 
addCommandToInitFile(char * string)6345 void addCommandToInitFile(char *string)
6346 {
6347   FILE *inihandle;
6348 
6349   sprintf(buffer,"%s/%s", homepath, initfile);
6350   inihandle = fopen (buffer, "a");
6351   fprintf(inihandle,"%s\n",string);
6352   fclose(inihandle);
6353 }
6354 
6355 
6356 
main(int argc,char ** argv)6357 int main( int argc, char **argv )
6358 {
6359   int i,j;
6360   char buffer[MAX_LINE_LENGTH];
6361   char command[MAX_LINE_LENGTH];
6362   FILE *inihandle;
6363   static char *string=NULL;
6364 
6365   lcase=NULL;
6366   node=NULL;
6367   e_enqire=NULL;
6368   anz->free=0;
6369   anz->threads=NTHREADS_MIN;
6370   anz->orign=0;
6371   anz->n=0;
6372   anz->e=0;
6373   anz->f=0;
6374   anz->g=0;
6375   anz->t=0;
6376   anz->l=0;
6377   anz->olc=0;
6378   anz->orignmax=0;
6379   anz->nmax=0;
6380   anz->nmin=MAX_INTEGER;
6381   anz->emax=0;
6382   anz->emin=MAX_INTEGER;
6383   anz->sets=0;
6384   anz->mats=0;
6385   anz->amps=0;
6386   anz->nnext=1;
6387   anz->enext=1;
6388 
6389   anzGeo->p=0;
6390   anzGeo->l=0;
6391   anzGeo->c=0;
6392   anzGeo->s=0;
6393   anzGeo->b=0;
6394   anzGeo->sh=0;
6395   anzGeo->nurl=0;
6396   anzGeo->nurs=0;
6397   anzGeo->psets=0;
6398 
6399   openSets->nr=0;
6400   openSets->set=NULL;
6401 
6402   copiedNodeSets->sets=0;
6403   copiedNodeSets->type=NULL;
6404   copiedNodeSets->anz_n=NULL;
6405   copiedNodeSets->axis=NULL;
6406   copiedNodeSets->mnod=NULL;
6407   copiedNodeSets->snod=NULL;
6408   copiedNodeSets->fi=NULL;
6409 
6410   dsSequence.nds=0;
6411   dsSequence.ds=NULL;
6412 
6413   strcpy(specialset->nsave,NSAVE);
6414   strcpy(specialset->njby,NJBY);
6415   strcpy(specialset->copy,COPY);
6416   strcpy(specialset->mesh,MESH);
6417   strcpy(specialset->nomesh,NOMESH);
6418   strcpy(specialset->zap,ZAP);
6419   strcpy(specialset->impc,IMPC);
6420   strcpy(specialset->mpc,DMPC);
6421   strcpy(specialset->nompc,NOMPC);
6422   strcpy(specialset->noel,NOEL);
6423   strcpy(specialset->glur,GLUR);
6424   strcpy(specialset->blr,BLR);
6425   strcpy(specialset->ori,ORI);
6426   strcpy(specialset->dep,DEP);
6427   strcpy(specialset->ind,IND);
6428   strcpy(specialset->tmp,TMP);
6429   strcpy(specialset->etmp,ETMP);
6430   strcpy(specialset->highl,HIGHLIGHT);
6431   strcpy(specialset->uori,UORI);
6432   strcpy(specialset->bnur,BNUR);
6433   strcpy(specialset->bsur,BSUR);
6434   strcpy(specialset->noprj,NOPRJ);
6435   strcpy(specialset->cf,CF);
6436   strcpy(specialset->plot2d,PLOT2D);
6437   strcpy(specialset->thrs,THRESHOLD);
6438 
6439   resetScaleValues( scale);
6440   scale->format='e';
6441   scale->lock='u';
6442 
6443   sumAsci->max_suma=0;
6444   sumAsci->anza=NULL;
6445   sumAsci->aindx=NULL;
6446   sumAsci->max_sump=0;
6447   sumAsci->anzp=NULL;
6448   sumAsci->pindx=NULL;
6449   sumAsci->max_suml=0;
6450   sumAsci->anzl=NULL;
6451   sumAsci->lindx=NULL;
6452   sumAsci->max_sumc=0;
6453   sumAsci->anzc=NULL;
6454   sumAsci->cindx=NULL;
6455   sumAsci->max_sums=0;
6456   sumAsci->anzs=NULL;
6457   sumAsci->sindx=NULL;
6458   sumAsci->max_sumb=0;
6459   sumAsci->anzb=NULL;
6460   sumAsci->bindx=NULL;
6461   sumAsci->max_sumS=0;
6462   sumAsci->anzS=NULL;
6463   sumAsci->Sindx=NULL;
6464   sumAsci->max_sumse=0;
6465   sumAsci->anzse=NULL;
6466   sumAsci->seindx=NULL;
6467   sumAsci->max_sumsh=0;
6468   sumAsci->anzsh=NULL;
6469   sumAsci->shindx=NULL;
6470   sumAsci->max_sumamp=0;
6471   sumAsci->anzamp=NULL;
6472   sumAsci->ampindx=NULL;
6473 
6474   setall=seto( "all" );
6475 
6476   if(sem_init(&sem_n, 0, 1) < 0) printf("Error in:sem_init\n");
6477   if(sem_init(&sem_g, 0, 1) < 0) printf("Error in:sem_init\n");
6478   if(sem_init(&sem_rep, 0, 1) < 0) printf("Error in:sem_init\n");
6479   if(sem_init(&sem_stn, 0, 1) < 0) printf("Error in:sem_init\n");
6480 
6481   if( (parameter= (char **)malloc( MAX_STACK_PARAMS*sizeof(char *))) == NULL )
6482     printf("\n\n ERROR: malloc failed\n\n") ;
6483   for(i=0; i<MAX_STACK_PARAMS; i++)
6484   {
6485     if( (parameter[i]= (char *)malloc( MAX_LINE_LENGTH*sizeof(char))) == NULL )
6486       printf("\n\n ERROR: malloc failed\n\n") ;
6487   }
6488 
6489   if( (entitycol= (Entitycol *)malloc( SET_COLS*sizeof(Entitycol))) == NULL )
6490     printf("\n\n ERROR: malloc failed\n\n") ;
6491   for(i=0; i<SET_COLS; i++)
6492   {
6493     entitycol[i].name[0]=entity_k[i]; entitycol[i].name[1]=0;
6494     entitycol[i].r=entity_r[i];
6495     entitycol[i].g=entity_g[i];
6496     entitycol[i].b=entity_b[i];
6497     //printf(" col %d n:%s %f %f %f\n", i, entitycol[i].name, entitycol[i].r, entitycol[i].g, entitycol[i].b  );
6498   }
6499   entitycols=SET_COLS;
6500 
6501   /* get the current system type  */
6502   uname (cursys);
6503   printf ("on a %s machine, ", cursys->sysname);
6504   printf ("nodename %s, ", cursys->nodename);
6505   printf ("release %s, ", cursys->release);
6506   printf ("version %s, ", cursys->version);
6507   printf ("machine %s \n", cursys->machine);
6508 
6509   if (getenv("CGXDOCS")!=NULL) {
6510   	sprintf(helpfile[0],"%s",getenv("CGXDOCS"));
6511   }
6512   if (getenv("CCXDOCS")!=NULL) {
6513   	sprintf(helpfile[1],"%s",getenv("CCXDOCS"));
6514   }
6515   if (getenv("BROWSER")!=NULL) {
6516   	sprintf(browser,"%s",getenv("BROWSER"));
6517   }
6518   if (getenv("CGXTERMVIEWER")!=NULL) {
6519   	sprintf(psviewer,"%s",getenv("CGXTERMVIEWER"));
6520   }
6521   if (getenv("CGXINITFILE")!=NULL) {
6522   	sprintf(initfile,"%s",getenv("CGXINITFILE"));
6523   }
6524 #ifdef WIN32
6525   if (getenv("HOMEDRIVE")!=NULL) {
6526   	sprintf(homepath,"%s%s",getenv("HOMEDRIVE"),getenv("HOMEPATH"));
6527     printf(" The win HOME was detected:%s\n",homepath);
6528   }
6529 #else
6530   if (getenv("HOME")!=NULL) {
6531   	sprintf(homepath,"%s",getenv("HOME"));
6532     printf(" The HOME was detected:%s\n",homepath);
6533   }
6534 #endif
6535   /* seach for ALLOW_SYS to enable the 'sys' command */
6536   sprintf(buffer,"%s/%s", homepath, initfile);
6537   inihandle = fopen (buffer, "r");
6538   if ( inihandle!= NULL )
6539   {
6540     do
6541     {
6542       i=getCommandLine(inihandle, &string);
6543       sscanf(string,"%s ", string);
6544       if(strcasecmp(string, "ALLOW_SYS")==0)
6545       {
6546         allowSysFlag=1;
6547       }
6548     } while( string[i]!= (char)EOF);
6549     fclose(inihandle);
6550   }
6551 
6552   width_w0  = width_ini  + width_menu;
6553   height_w0 = height_ini + height_menu;
6554 
6555   if (argc < 2)
6556   {
6557     generalinfo();
6558     exit (0);
6559   }
6560   else
6561   {
6562     /* initial sets */
6563     setall=pre_seta("all", "i", 0);
6564     pre_seta(specialset->nsave, "i", 0);
6565 
6566     inpformat=0;
6567     i=0;
6568     do{ i++;} while((i<argc)&&(argv[i][0]=='-'));
6569     printf("parameters:%d arguments:%d\n", argc, i);
6570     for (j=1; j<i; j++)
6571     {
6572       if( compare( argv[j], "-ansl", 4 ) == 4 )
6573       {
6574         inpformat='a';
6575         if(argc==i) { printf("ERROR: no ansysList file specified\n"); exit(-1); }
6576         else strcpy( datin, argv[i]);
6577       }
6578       else if( compare( argv[j], "-a", 2 ) == 2 )
6579       {
6580         inpformat='b';
6581         automode=1;
6582         anz->threads=NTHREADS_MAX;
6583         if(argc==i) strcpy( datin, "dummy.fbd");
6584         else strcpy( datin, argv[i]);
6585         if ( (lcase = (Datasets *)malloc( (anz->l+1) * sizeof(Datasets))) == NULL )
6586           printf("\n\n ERROR: malloc failed lcase\n\n") ;
6587         if ( (node = (Nodes *)malloc( (anz->n+1) * sizeof(Nodes))) == NULL )
6588           printf("\n\n ERROR: malloc failed node\n\n") ;
6589         if ( (e_enqire = (Elements *)malloc( (anz->e+1) * sizeof(Elements))) == NULL )
6590           printf("\n\n ERROR: malloc failed elem\n\n") ;
6591       }
6592       else if( compare( argv[j], "-bg", 3 ) == 3 )
6593       {
6594         inpformat=0;
6595         if(argc==i) strcpy( datin, "dummy.fbd");
6596         else strcpy( datin, argv[i]);
6597         if ( (lcase = (Datasets *)malloc( (anz->l+1) * sizeof(Datasets))) == NULL )
6598           printf("\n\n ERROR: malloc failed lcase\n\n") ;
6599         if ( (node = (Nodes *)malloc( (anz->n+1) * sizeof(Nodes))) == NULL )
6600           printf("\n\n ERROR: malloc failed node\n\n") ;
6601         if ( (e_enqire = (Elements *)malloc( (anz->e+1) * sizeof(Elements))) == NULL )
6602           printf("\n\n ERROR: malloc failed elem\n\n") ;
6603         readfbd( datin, 0);
6604         exit(0);
6605       }
6606       else if( compare( argv[j], "-b", 2 ) == 2 )
6607       {
6608         if(argc==i) strcpy( datin, "dummy.fbd");
6609         else strcpy( datin, argv[i]);
6610         if ( (lcase = (Datasets *)malloc( (anz->l+1) * sizeof(Datasets))) == NULL )
6611           printf("\n\n ERROR: malloc failed lcase\n\n") ;
6612         if ( (node = (Nodes *)malloc( (anz->n+1) * sizeof(Nodes))) == NULL )
6613           printf("\n\n ERROR: malloc failed node\n\n") ;
6614         if ( (e_enqire = (Elements *)malloc( (anz->e+1) * sizeof(Elements))) == NULL )
6615           printf("\n\n ERROR: malloc failed elem\n\n") ;
6616 
6617         /* evaluate the first record, seach for WSIZE and INIT (in initfile and in the inputfile) */
6618         for(i=0; i<2; i++)
6619         {
6620           if(i==0) {
6621             /* read initial commands (read again in idleFunction() )*/
6622             sprintf(buffer,"%s/%s", homepath, initfile);
6623             inihandle = fopen (buffer, "r"); }
6624           if(i==1) inihandle = fopen (datin, "r");
6625           if ( inihandle!= NULL )
6626           {
6627             frecord( inihandle, buffer);
6628             sscanf(buffer,"%s ", command);
6629             if(strcasecmp(command, "WSIZE")==0)
6630   	    {
6631               sscanf(buffer,"%*s %d %d", &width_w0, &height_w0);
6632   	    }
6633             if(strcasecmp(command, "INIT")==0)
6634   	    {
6635               fclose(inihandle);
6636               inihandle = fopen (datin, "r");
6637               if (inihandle==NULL)
6638               {
6639                 printf (" ERROR: The input file \"%s\" could not be opened.\n\n", datin);
6640                 exit(1);;
6641               }
6642               getCommandLine(inihandle, &string);
6643               initModel(string);
6644   	    }
6645             if(strcasecmp(command, "READ")==0)
6646   	    {
6647               fclose(inihandle);
6648               sscanf(buffer,"%*s %s", command);
6649               inihandle = fopen (command, "r");
6650              if (inihandle==NULL)
6651               {
6652                 printf (" ERROR: The input file \"%s\" could not be opened.\n\n", datin);
6653                 exit(1);;
6654               }
6655               getCommandLine(inihandle, &string);
6656               sscanf(string,"%s ", command);
6657               if(strcasecmp(command, "INIT")==0) initModel(string);
6658   	    }
6659             fclose(inihandle);
6660           }
6661 	}
6662        inpformat='b';
6663       }
6664       else if( compare( argv[j], "-c", 2 ) == 2 )
6665       {
6666         inpformat='c';
6667         if(argc==i) { printf("ERROR: no file specified\n"); exit(-1); }
6668         else strcpy( datin, argv[i]);
6669       }
6670       else if( compare( argv[j], "-duns2d", 7 ) == 7 )
6671       {
6672         inpformat='d';
6673         if( compare( argv[j], "-duns2dl", 8 ) == 8 ) inpformat='D';
6674         if(argc==i) { printf("ERROR: no duns-file specified\n"); exit(-1); }
6675         else strcpy( datin, argv[i]);
6676       }
6677       else if( compare( argv[j], "-duns3d", 7 ) == 7 )
6678       {
6679         inpformat='e';
6680         if( compare( argv[j], "-duns3dl", 8 ) == 8 ) inpformat='E';
6681         if(argc==i) { printf("ERROR: no duns-file specified\n"); exit(-1); }
6682         else strcpy( datin, argv[i]);
6683       }
6684       else if( compare( argv[j], "-foam", 5 ) == 5 )
6685       {
6686         inpformat='f';
6687         if(argc==i) { printf("ERROR: no foam-file specified\n"); exit(-1); }
6688         else strcpy( datin, argv[i]);
6689       }
6690       else if( compare( argv[j], "-isaac2d", 8 ) == 8 )
6691       {
6692         inpformat='i';
6693         strcpy( datin, argv[argc-1]);
6694       }
6695       else if( compare( argv[j], "-isaac3d", 8 ) == 8 )
6696       {
6697         inpformat='j';
6698         strcpy( datin, argv[argc-1]);
6699       }
6700       else if( compare( argv[j], "-f06", 4 ) == 4 )
6701       {
6702         inpformat='m';
6703         if(argc==i) { printf("ERROR: no f06-file specified\n"); exit(-1); }
6704         else strcpy( datin, argv[i]);
6705       }
6706       else if( compare( argv[j], "-ng", 3 ) == 3 )
6707       {
6708         inpformat='n';
6709         if(argc==i) { printf("ERROR: no ng-file specified\n"); exit(-1); }
6710         else strcpy( datin, argv[i]);
6711       }
6712       else if( compare( argv[j], "-tg", 3 ) == 3 )
6713       {
6714         inpformat='t';
6715         if(argc==i) { printf("ERROR: no Tetgen-file specified\n"); exit(-1); }
6716         else strcpy( datin, argv[i]);
6717       }
6718       else if( compare( argv[j], "-oldbias", 7 ) == 7 )  { OLD_BIAS_DEF=1; }
6719       else if( compare( argv[j], "-read", 5 ) == 5 )
6720       {
6721         read_mode=1;
6722       }
6723       else if( compare( argv[j], "-step", 5 ) == 5 )
6724       {
6725         inpformat='x';
6726         if(argc==i) { printf("ERROR: no step-file specified\n"); exit(-1); }
6727         else strcpy( datin, argv[i]);
6728 
6729         if( compare( argv[j], "-stepsplit", 10 ) == 10 ) step_mode=1;
6730 
6731         if ( (lcase = (Datasets *)malloc( (anz->l+1) * sizeof(Datasets))) == NULL )
6732           printf("\n\n ERROR: malloc failed lcase\n\n") ;
6733         if ( (node = (Nodes *)malloc( (anz->n+1) * sizeof(Nodes))) == NULL )
6734           printf("\n\n ERROR: malloc failed node\n\n") ;
6735         if ( (e_enqire = (Elements *)malloc( (anz->e+1) * sizeof(Elements))) == NULL )
6736           printf("\n\n ERROR: malloc failed elem\n\n") ;
6737       }
6738       else if( compare( argv[j], "-stl", 4 ) == 4 )
6739       {
6740         inpformat='s';
6741         if(argc==i) { printf("ERROR: no stl-file specified\n"); exit(-1); }
6742         else strcpy( datin, argv[i]);
6743       }
6744 
6745       if( compare( argv[j], "--v", 3 ) == 3 ) { printf("Version %s\n", VERSION);  exit (0); }
6746     }
6747     if (inpformat==0)
6748     {
6749       inpformat='v';
6750       if(argc==i) { printf("ERROR: no file specified\n"); exit(1); }
6751       else if(argc==i+2) strcpy( ccxfile, argv[i+1]);
6752       strcpy( datin, argv[i]);
6753     }
6754   }
6755   strcpy(picture_caption, datin);
6756 
6757   /* Trackballfunktion inizialisieren  */
6758   trackball( 0, trackbsize, lastquat, -0.2,-0.7, 0.2, 0.7 );
6759   build_rotmatrix( R, lastquat );
6760 
6761   width_w1=width_w0 - width_menu;
6762   height_w1=height_w0 - height_menu;
6763 
6764 
6765   /* Mutter-Fenster */
6766   glutInitWindowSize ( width_w0, height_w0 );
6767   /* problems with xwd on sgi without GLUT_DEPTH */
6768   glutInitDisplayMode ( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH );
6769   glutInit ( &argc, argv );
6770   sprintf (buffer, "CalculiX GraphiX");
6771   activWindow= w0 = glutCreateWindow ( buffer );
6772   glutDisplayFunc ( DrawMenuSet );
6773   glShadeModel ( GL_FLAT );
6774   glDisable ( GL_DEPTH_TEST );
6775   glMatrixMode ( GL_MODELVIEW );
6776   glutReshapeFunc ( reshape );
6777   glutMouseFunc ( MouseState );
6778   glutKeyboardFunc ( Keyboard );
6779   glutSpecialFunc ( specialKeyboard );
6780   glutVisibilityFunc ( WindowState );
6781   /* kein DITHERing (speed, Hoehenlinien)  */
6782   glDisable(GL_DITHER);
6783 
6784   subsubmenu_animTune = glutCreateMenu( tuneAnimation );
6785   glutAddMenuEntry(" RESET TO 1.", 0);
6786   glutAddMenuEntry(" tune * 10", 1);
6787   glutAddMenuEntry(" tune *  5", 2);
6788   glutAddMenuEntry(" tune *  2", 3);
6789   glutAddMenuEntry(" tune /  2", 4);
6790   glutAddMenuEntry(" tune /  5", 5);
6791   glutAddMenuEntry(" tune / 10", 6);
6792 
6793   subsubmenu_animSteps = glutCreateMenu( stepsAnimation );
6794   glutAddMenuEntry("  4 Steps", 4);
6795   glutAddMenuEntry("  8 Steps", 8);
6796   glutAddMenuEntry(" 12 Steps", 12);
6797   glutAddMenuEntry(" 24 Steps", 24);
6798   glutAddMenuEntry(" 36 Steps", 36);
6799   glutAddMenuEntry(" 72 Steps", 72);
6800 
6801   subsubmenu_animPeriod = glutCreateMenu( newTimePerPeriod );
6802   glutAddMenuEntry(" Fastest     ", 1);
6803   glutAddMenuEntry(" 1,0 seconds ", 2);
6804   glutAddMenuEntry(" 1,2 seconds ", 3);
6805   glutAddMenuEntry(" 1,5 seconds ", 4);
6806   glutAddMenuEntry(" 2,0 seconds ", 5);
6807   glutAddMenuEntry(" 5,0 seconds ", 6);
6808 
6809   subsubmenu_colormap = glutCreateMenu( changeColormap );
6810   for(i=0; i<cmaps; i++) glutAddMenuEntry(cmap_names[i], i+1);
6811 
6812   submenu_view = glutCreateMenu( selectView );
6813   glutAddMenuEntry("Show All Elements With Light", 1);
6814   glutAddMenuEntry("Show Bad Elements", 2);
6815   glutAddMenuEntry(" FILL  ", 3);
6816   glutAddMenuEntry(" LINES ", 4);
6817   glutAddMenuEntry(" DOTS ", 5);
6818   glutAddMenuEntry("Toggle Culling Back/Front", 6);
6819   glutAddMenuEntry("Toggle Illuminate Backface", 15);
6820   glutAddMenuEntry("Toggle Model Edges", 7);
6821   glutAddMenuEntry("Toggle Element Edges", 8);
6822   glutAddMenuEntry("Toggle Surfaces/Volumes", 9);
6823   glutAddMenuEntry("Toggle Move-Z/Zoom", 10);
6824   glutAddMenuEntry("Toggle Background Color", 11);
6825   glutAddMenuEntry("Toggle Vector-Plot", 12);
6826   glutAddMenuEntry("Toggle Add-Displacement", 13);
6827   glutAddMenuEntry("Toggle Shaded Results", 14);
6828   glutAddMenuEntry("Toggle Transparency", 16);
6829   glutAddMenuEntry("Toggle Ruler", 17);
6830   glutAddSubMenu  ("Colormap", subsubmenu_colormap );
6831 
6832   submenu_animate = glutCreateMenu( changeAnimation );
6833   glutAddMenuEntry("Start", 1);
6834   glutAddSubMenu  ("Tune-Value ", subsubmenu_animTune );
6835   glutAddSubMenu  ("Steps per Period", subsubmenu_animSteps );
6836   glutAddSubMenu  ("Time per Period ", subsubmenu_animPeriod );
6837   glutAddMenuEntry("Toggle Real Displacements", 2);
6838   glutAddMenuEntry("Toggle Static Model Edges", 3);
6839   glutAddMenuEntry("Toggle Static Element Edges", 4);
6840   glutAddMenuEntry("Toggle Dataset Sequence", 5);
6841 
6842   submenu_orientation = glutCreateMenu( orientModel );
6843   glutAddMenuEntry( "+x View     ", 1);
6844   glutAddMenuEntry( "-x View     ", 2);
6845   glutAddMenuEntry( "+y View     ", 3);
6846   glutAddMenuEntry( "-y View     ", 4);
6847   glutAddMenuEntry( "+z View     ", 5);
6848   glutAddMenuEntry( "-z View     ", 6);
6849 
6850   submenu_hardcopy = glutCreateMenu( markHardcopy );
6851   glutAddMenuEntry( "Tga-Hardcopy", 2);
6852   glutAddMenuEntry( "Ps-Hardcopy ", 1);
6853   glutAddMenuEntry( "Gif-Hardcopy", 4);
6854   glutAddMenuEntry( "Png-Hardcopy", 5);
6855   glutAddMenuEntry( "Start Recording Gif-Movie", 3);
6856 
6857   submenu_cut   = glutCreateMenu( selectCutNode   );
6858   glutAddMenuEntry( "Node 1 ", 1);
6859   glutAddMenuEntry( "Node 2 ", 2);
6860   glutAddMenuEntry( "Node 3 ", 3);
6861   glutAddMenuEntry( "Vector ", 5);
6862   glutAddMenuEntry( "Uncut   ", 4);
6863 
6864   submenu_graph = glutCreateMenu( selectGraphMode );
6865   glutAddMenuEntry( "Length ", 1);
6866   glutAddMenuEntry( "Datasets ", 2);
6867   glutAddMenuEntry( "Time ", 3);
6868 
6869   submenu_help = glutCreateMenu( showHelp );
6870   glutAddMenuEntry( "Quick Reference (cgx)", 1);
6871   glutAddMenuEntry( "Html Manual (cgx)", 2);
6872   glutAddMenuEntry( "Html Manual (ccx)", 3);
6873 #ifdef AFLIB
6874   glutAddMenuEntry( "Html Manual (aflib)", 4);
6875 #endif
6876 
6877   subsubmenu_parameter = glutCreateMenu( selectParameter );
6878   subsubmenu_entity = glutCreateMenu( selectEntityMenu );
6879   submenu_load = glutCreateMenu( selectDatasetMenu );
6880 
6881   /* Grafik-Fenster */
6882   glutInitDisplayMode ( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH );
6883   activWindow= w1 = glutCreateSubWindow ( w0, width_menu*19/20, height_menu/10, width_ini, height_ini );
6884   glutDisplayFunc ( DrawPickedItems );
6885   glEnable ( GL_DEPTH_TEST );
6886   glDepthFunc(GL_LEQUAL);
6887   glFrontFace ( GL_CCW );
6888   glShadeModel (GL_FLAT);
6889   /* Eventhandling Grafikfenster */
6890   glutMouseFunc ( MouseState );
6891   glutMotionFunc ( Mouse );
6892   glutKeyboardFunc ( Keyboard );
6893   glutSpecialFunc ( specialKeyboard );
6894   glutEntryFunc ( entryfunktion );
6895   glutPassiveMotionFunc ( Mouse );
6896   glDisable(GL_DITHER);
6897   glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, lmodel_oneside);
6898   glCullFace ( GL_BACK );
6899   initLight_rgb();
6900 
6901   /* Axenkreuz-Fenster-index im w1 fenster  */
6902   //glutInitDisplayMode ( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH  );
6903   glutInitDisplayMode ( GLUT_RGBA | GLUT_DOUBLE  );
6904   activWindow= w2 = glutCreateSubWindow ( w1, 0, height_ini*0.9, width_ini/10, height_ini/10 );
6905   glutDisplayFunc ( DrawAxes );
6906   glutIdleFunc ( idleFunction );
6907   glDisable(GL_DITHER);
6908   glShadeModel ( GL_FLAT );
6909 
6910   glGetIntegerv (GL_MAX_EVAL_ORDER, &gl_max_eval_order);
6911   printf("GL_MAX_EVAL_ORDER:%d, mesh threads:%d\n", gl_max_eval_order, anz->threads);
6912 
6913   /* Display listen */
6914   glutSetWindow(w1);
6915   list_elem_light = glGenLists((GLint)1);
6916   list_surf_light = glGenLists((GLint)1);
6917   list_elem_load = glGenLists((GLint)1);
6918   list_elem_elstress = glGenLists((GLint)1);
6919   list_surf_load = glGenLists((GLint)1);
6920   list_model_edges = glGenLists((GLint)1);
6921   list_surf_edges = glGenLists((GLint)1);
6922   list_elem_edges = glGenLists((GLint)1);
6923 
6924   if(inpformat=='b')
6925   {
6926     iniActionsFlag=1;
6927   }
6928   else if(inpformat=='x')
6929   {
6930     iniActionsFlag=2;
6931   }
6932   else
6933   {
6934     iniActionsFlag=0;
6935   }
6936 
6937 #if TEST
6938   printHash();
6939 #endif
6940 
6941   glutMainLoop ();
6942   return(1);
6943 }
6944 
6945 
6946 
printHash()6947 void printHash()
6948 {
6949   int i;
6950   FILE *handle[7];
6951 
6952   handle[0] = fopen ("hash.p", "w");
6953   if ( handle[0]== NULL )
6954   {
6955     printf ("\nThe file could not be opened.\n\n");
6956     return;
6957   }
6958   for (i=0; i<sumAsci->max_sump; i++)
6959   {
6960     fprintf(handle[0], " sumASCI: %d indexes: %d\n", i, sumAsci->anzp[i]);
6961   }
6962   handle[1] = fopen ("hash.l", "w");
6963   if ( handle[1]== NULL )
6964   {
6965     printf ("\nThe file could not be opened.\n\n");
6966     return;
6967   }
6968   for (i=0; i<sumAsci->max_suml; i++)
6969   {
6970     fprintf(handle[1], " sumASCI: %d indexes: %d\n", i, sumAsci->anzl[i]);
6971   }
6972   handle[2] = fopen ("hash.c", "w");
6973   if ( handle[2]== NULL )
6974   {
6975     printf ("\nThe file could not be opened.\n\n");
6976     return;
6977   }
6978   for (i=0; i<sumAsci->max_sumc; i++)
6979   {
6980     fprintf(handle[2], " sumASCI: %d indexes: %d\n", i, sumAsci->anzc[i]);
6981   }
6982   handle[3] = fopen ("hash.s", "w");
6983   if ( handle[3]== NULL )
6984   {
6985     printf ("\nThe file could not be opened.\n\n");
6986     return;
6987   }
6988   for (i=0; i<sumAsci->max_sums; i++)
6989   {
6990     fprintf(handle[3], " sumASCI: %d indexes: %d\n", i, sumAsci->anzs[i]);
6991   }
6992   handle[4] = fopen ("hash.b", "w");
6993   if ( handle[4]== NULL )
6994   {
6995     printf ("\nThe file could not be opened.\n\n");
6996     return;
6997   }
6998   for (i=0; i<sumAsci->max_sumb; i++)
6999   {
7000     fprintf(handle[4], " sumASCI: %d indexes: %d\n", i, sumAsci->anzb[i]);
7001   }
7002   handle[5] = fopen ("hash.a", "w");
7003   if ( handle[5]== NULL )
7004   {
7005     printf ("\nThe file could not be opened.\n\n");
7006     return;
7007   }
7008   for (i=0; i<sumAsci->max_suma; i++)
7009   {
7010     fprintf(handle[5], " sumASCI: %d indexes: %d\n", i, sumAsci->anza[i]);
7011   }
7012   handle[6] = fopen ("hash.S", "w");
7013   if ( handle[6]== NULL )
7014   {
7015     printf ("\nThe file could not be opened.\n\n");
7016     return;
7017   }
7018   for (i=0; i<sumAsci->max_sumS; i++)
7019   {
7020     fprintf(handle[6], " sumASCI: %d indexes: %d\n", i, sumAsci->anzS[i]);
7021   }
7022 }
7023