00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include <stdio.h>
00042 #include <stdlib.h>
00043 #include "mensagem.h"
00044 #include "memvirtu.h"
00045 #include "lowparam.h"
00046 #include "lowmacro.h"
00047 #include "lowsolid.h"
00048 #include "genfunc_.h"
00049 #include "eulerops.h"
00050 #include "shpshape.h"
00051 #include "vectorop.h"
00052 #include "mancommd.h"
00053
00054
00055 #ifdef __Extended_Version
00056 void MSD_execNameTransformation(void)
00057 {
00058 int i, ip, ap, bp, op;
00059 float x, y, z, w;
00060 char name[14];
00061 matrix mat;
00062
00063 for (ip = ap = 0; ip == 0;)
00064 {
00065 if ((bp = sscanf(restbuf, "%s &op", name, &op)) == 2)
00066 {
00067 for (i = 0; i < 4; ++i)
00068 {
00069 if (!lineins("? "))
00070 {
00071 return;
00072 }
00073 ap = sscanf(restbuf, " %f %f %f %f", &x, &y, &z, &w);
00074 mat[i][0] = x;
00075 mat[i][1] = y;
00076 mat[i][2] = z;
00077 mat[i][3] = w;
00078 if (ap != 4)
00079 {
00080 break;
00081 }
00082 }
00083 }
00084 if ((bp == 1) && (ap == 4))
00085 {
00086 ip = 1;
00087 }
00088 if (ip == 0)
00089 {
00090 printf("transf: name \nTransformation Matrix\n");
00091 if (!lineins("? "))
00092 {
00093 return;
00094 }
00095 }
00096 }
00097 MSD_highNameTransformation(name, mat);
00098 }
00099
00100 #endif
00101
00102 int MSD_highNameTransformation(char *name, matrix m)
00103 {
00104 int sn;
00105
00106 if ((sn = MSD_getSolidIdFromName(name)) == -1)
00107 {
00108 fprintf(stderr, MEN_NaoEncontrouSolidNome, NAM_TransformSolid, name);
00109 return(ERROR);
00110 }
00111 return(MSD_highTransformation(sn, m));
00112 }
00113
00114 #ifdef __Extended_Version
00115 void MSD_execTransformation(void)
00116 {
00117 int i, ip, ap, bp, sn, op;
00118 float x, y, z, w;
00119 matrix mat;
00120 char name[15];
00121
00122 for (ip = ap = 0; ip == 0;)
00123 {
00124 if ((bp = sscanf(restbuf, "%d %d", &sn, &op)) == 2)
00125 {
00126 for (i = 0; i < 4; ++i)
00127 {
00128 if (!lineins("? "))
00129 {
00130 return;
00131 }
00132 ap = sscanf(restbuf, "%s %d %d %d %f %f %f %f", name, &op, &op, &op, &x, &y, &z, &w);
00133 mat[i][0] = x;
00134 mat[i][1] = y;
00135 mat[i][2] = z;
00136 mat[i][3] = w;
00137 if (ap != 8)
00138 {
00139 break;
00140 }
00141 }
00142 }
00143 if ((bp == 2) && (ap == 8))
00144 {
00145 ip = 1;
00146 }
00147 if (ip == 0)
00148 {
00149 printf("transf: sid \nTransformation Matrix\n");
00150 if (!lineins("? "))
00151 {
00152 return;
00153 }
00154 }
00155 }
00156 MSD_highTransformation(sn, mat);
00157 }
00158
00159 #endif
00160
00161 int MSD_highTransformation(int sn, matrix m)
00162 {
00163 SPTYPE s;
00164
00165 if ((s = MSD_getSolid(sn)) == SNIL)
00166 {
00167 fprintf(stderr, MEN_NaoEncontrouSolido, NAM_TransformSolid, sn);
00168 return(ERROR);
00169 }
00170 CommandCount++;
00171 MSD_lowTransformation(s, m);
00172 return(SUCCESS);
00173 }
00174
00175 void MSD_lowTransformation(SPTYPE s, matrix m)
00176 {
00177 DPTYPE d;
00178 VPTYPE v;
00179 matrix minv;
00180 int GdoinversionOld;
00181
00182 if (Gdoinversion)
00183 {
00184 invmat(m, minv, 4);
00185 MSD_lowAddMatrix(s, TRANSFORM, -1, -1, 0, 0, 0, 0, minv);
00186 MSD_lowAddEulerOp(s, TRANSFORM, 1, 1, 0, 0, 0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0);
00187 }
00188 if (Gdodirect)
00189 {
00190 MSD_lowAddEulerOpRedo(s, TRANSFORM, 1, 1, 0, 0, 0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0);
00191 MSD_lowAddMatrixRedo(s, TRANSFORM, -1, -1, 0, 0, 0, 0, m);
00192 }
00193
00194 for (AllShellsSolid(s, d))
00195 {
00196 for (AllVerticesShell(d, v))
00197 {
00198 vecmult(VerVCoord(v), VerVCoord(v), m);
00199 }
00200 }
00201 MSD_lowSetNormal(s, TRUE);
00202
00203 #ifdef __curved_env__
00204
00205 #endif
00206
00207 if (determ(m, 3) < 0.0)
00208 {
00209 GdoinversionOld = Gdoinversion;
00210 Gdoinversion = 0;
00211 for (AllShellsSolid(s, d))
00212 {
00213 MSD_lowRevert(d);
00214 }
00215 MSD_lowSetNormal(s, TRUE);
00216 MSD_lowSetEdgeAngle(s);
00217 Gdoinversion = GdoinversionOld;
00218 }
00219 }
00220
00221 int MSD_execStructTransformation(EulerOp *op)
00222 {
00223 Id sn;
00224 matrix m;
00225
00226 sn = op->solidno;
00227 matident(m);
00228 MSD_lowGetMatrix(op, m);
00229 MSD_highTransformation(sn, m);
00230 return(SUCCESS);
00231 }
00232
00233 void MSD_printStructTransformation(FILE *f, EulerOp *op)
00234 {
00235 Id sid, ip1;
00236 real fd1, fd2, fd3, fd4;
00237 int com;
00238
00239 sid = op->solidno;
00240 ip1 = op->ip1;
00241 com = op->CommandCount;
00242 if (ip1 == 1)
00243 {
00244 fprintf(f, "transform %d %d %d 0.0 0.0 0.0 0.0\n", sid, com, ip1);
00245 }
00246 else
00247 {
00248 fd1 = op->fp1;
00249 fd2 = op->fp2;
00250 fd3 = op->fp3;
00251 fd4 = op->fp4;
00252 fprintf(f, "transform %d %d %d %f %f %f %f\n", sid, com, ip1,
00253 fd1, fd2, fd3, fd4);
00254 }
00255 }
00256
00257 int MSD_readStructTransformation(FILE *f, EulerOp *op)
00258 {
00259 int solidno, ip1, com;
00260 float fd1, fd2, fd3, fd4;
00261
00262 if (fscanf(f, "%d %d %d %f %f %f %f\n", &solidno, &com, &ip1, &fd1, &fd2,
00263 &fd3, &fd4) != 7)
00264 {
00265 return(ERROR);
00266 }
00267 op->solidno = solidno;
00268 op->CommandCount = com;
00269 op->ip1 = ip1;
00270 op->ip2 = 0;
00271 op->ip3 = 0;
00272 op->ip4 = 0;
00273 op->ip5 = 0;
00274 op->ip6 = 0;
00275 op->ip7 = 0;
00276 op->ip8 = 0;
00277 op->fp1 = fd1;
00278 op->fp2 = fd2;
00279 op->fp3 = fd3;
00280 op->fp4 = fd4;
00281 return(SUCCESS);
00282 }
00283
00284 int MSD_modifyStructTransformation(EulerOp *op)
00285 {
00286 int solidno;
00287
00288 solidno = MSD_lowCheckTranslatorTable(op->solidno, SOLID);
00289 op->solidno = solidno;
00290 return(SUCCESS);
00291 }