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
descalPoints(int anz_p,Points * point,Scale * scale)25 void descalPoints ( int anz_p, Points *point, Scale *scale )
26 {
27 int i;
28 for (i=0; i<anz_p; i++ )
29 {
30 /* descalieren */
31 point[i].px = (point[i].px* scale->w+scale->x);
32 point[i].py = (point[i].py* scale->w+scale->y);
33 point[i].pz = (point[i].pz* scale->w+scale->z);
34 }
35 }
36
37
scalPoints(int anz_p,Points * point,Scale * scale)38 void scalPoints ( int anz_p, Points *point, Scale *scale )
39 {
40 int i;
41 for (i=0; i<anz_p; i++ )
42 {
43 /* scalieren */
44 point[i].px = (point[i].px-scale->x)/scale->w;
45 point[i].py = (point[i].py-scale->y)/scale->w;
46 point[i].pz = (point[i].pz-scale->z)/scale->w;
47 }
48 }
49
descalSurfs(int anz_s,Gsur * surf,Scale * scale)50 void descalSurfs ( int anz_s, Gsur *surf, Scale *scale )
51 {
52 int i,j,n,k;
53 for (i=0; i<anz_s; i++ )
54 {
55 n=0;
56 while((surf[i].npgn-n))
57 {
58 n++; /* jump over the polygon token (ie.GL_POLYGON_TOKEN) */
59 j=surf[i].pgn[n++];
60 n+=3;
61 for(k=0; k<j; k++)
62 {
63 surf[i].pgn[n]=(surf[i].pgn[n]*scale->w)+scale->x;
64 surf[i].pgn[n+1]=(surf[i].pgn[n+1]*scale->w)+scale->y;
65 surf[i].pgn[n+2]=(surf[i].pgn[n+2]*scale->w)+scale->z;
66 n+=3;
67 }
68 }
69 }
70 }
71
scalSurfs(int anz_s,Gsur * surf,Scale * scale)72 void scalSurfs ( int anz_s, Gsur *surf, Scale *scale )
73 {
74 int i,j,n,k;
75 for (i=0; i<anz_s; i++ )
76 {
77 /* printf("surf:%s w:%lf xyz: %lf %lf %lf\n",surf[i].name,scale->w,scale->x,scale->y,scale->z); */
78 n=0;
79 while((surf[i].npgn-n))
80 {
81 n++; /* jump over the polygon token (ie.GL_POLYGON_TOKEN) */
82 j=surf[i].pgn[n++];
83 n+=3;
84 for(k=0; k<j; k++)
85 {
86 /* printf(" %lf %lf %lf -> ", surf[i].pgn[n],surf[i].pgn[n+1],surf[i].pgn[n+2]); */
87 surf[i].pgn[n]=(surf[i].pgn[n]-scale->x)/scale->w;
88 surf[i].pgn[n+1]=(surf[i].pgn[n+1]-scale->y)/scale->w;
89 surf[i].pgn[n+2]=(surf[i].pgn[n+2]-scale->z)/scale->w;
90 n+=3;
91 /* printf(" %lf %lf %lf\n", surf[i].pgn[n-3],surf[i].pgn[n-2],surf[i].pgn[n-1]); */
92 }
93 }
94 }
95 }
96