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 "mensagem.h"
00043 #include "memvirtu.h"
00044 #include "lowparam.h"
00045 #include "lowmacro.h"
00046 #include "lowsolid.h"
00047 #include "eulerops.h"
00048 #include "shpshape.h"
00049 #include "vectorop.h"
00050 #include "mancommd.h"
00051
00052
00053 #ifdef __Extended_Version
00054 void MSD_execNameRotate(void)
00055 {
00056 char name[30];
00057 float tx, ty, tz;
00058
00059 while (4 != sscanf(restbuf, "%s %f %f %f", name, &tx, &ty, &tz))
00060 {
00061 printf("rotate: name rx ry rz\n");
00062 if (!lineins("? "))
00063 {
00064 return;
00065 }
00066 }
00067 MSD_highNameRotate(name, tx, ty, tz);
00068 }
00069
00070 #endif
00071
00072 int MSD_highNameRotate(char *name, real tx, real ty, real tz)
00073 {
00074 int sn;
00075
00076 if ((sn = MSD_getSolidIdFromName(name)) == -1)
00077 {
00078 fprintf(stderr, MEN_NaoEncontrouSolidNome, NAM_RotateSolid, name);
00079 return(ERROR);
00080 }
00081 return(MSD_highRotate(sn, tx, ty, tz));
00082 }
00083
00084 #ifdef __Extended_Version
00085 void MSD_execRotate(void)
00086 {
00087 int s;
00088 float rx, ry, rz;
00089
00090 while (4 != sscanf(restbuf, "%d %f %f %f", &s, &rx, &ry, &rz))
00091 {
00092 printf("rotate: Sid rx ry rz\n");
00093 if (!lineins("? "))
00094 {
00095 return;
00096 }
00097 }
00098 MSD_highRotate(s, rx, ry, rz);
00099 }
00100
00101 #endif
00102
00103 int MSD_highRotate(Id sn, real rx, real ry, real rz)
00104 {
00105 SPTYPE s;
00106
00107 if ((s = MSD_getSolid(sn)) == SNIL)
00108 {
00109 fprintf(stderr, MEN_NaoEncontrouSolido, NAM_RotateSolid, sn);
00110 return(ERROR);
00111 }
00112 CommandCount++;
00113 MSD_lowRotate(s, rx, ry, rz);
00114 return(SUCCESS);
00115 }
00116
00117 void MSD_lowRotate(SPTYPE s, real rx, real ry, real rz)
00118 {
00119 DPTYPE d;
00120 VPTYPE v;
00121 matrix m;
00122 int GdoinversionOld;
00123
00124 if (Gdoinversion)
00125 {
00126 MSD_lowAddEulerOp(s, ROTAT, 0, 0, 0, 0, 0, 0, 0, 0, -rx, -ry, -rz, 0.0);
00127 }
00128 if (Gdodirect)
00129 {
00130 MSD_lowAddEulerOpRedo(s, ROTAT, 0, 0, 0, 0, 0, 0, 0, 0, rx, ry, rz, 0.0);
00131 }
00132
00133 matident(m);
00134 matrotat(m, rx, ry, rz);
00135 for (AllShellsSolid(s, d))
00136 {
00137 for (AllVerticesShell(d, v))
00138 {
00139 vecmult(VerVCoord(v), VerVCoord(v), m);
00140 }
00141 }
00142 MSD_lowSetNormal(s, TRUE);
00143
00144 #ifdef __curved_env__
00145
00146 #endif
00147
00148 if (determ(m, 3) < 0.0)
00149 {
00150 GdoinversionOld = Gdoinversion;
00151 Gdoinversion = 0;
00152 for (AllShellsSolid(s, d))
00153 {
00154 MSD_lowRevert(d);
00155 }
00156 Gdoinversion = GdoinversionOld;
00157 }
00158 }
00159
00160 int MSD_execStructRotate(EulerOp *op)
00161 {
00162 Id sid;
00163 real fd1, fd2, fd3;
00164
00165 sid = op->solidno;
00166 fd1 = op->fp1;
00167 fd2 = op->fp2;
00168 fd3 = op->fp3;
00169 MSD_highRotate(sid, fd1, fd2, fd3);
00170 return(SUCCESS);
00171 }
00172
00173 void MSD_printStructRotate(FILE *f, EulerOp *op)
00174 {
00175 Id sid;
00176 real fd1, fd2, fd3;
00177 int com;
00178
00179 sid = op->solidno;
00180 fd1 = op->fp1;
00181 fd2 = op->fp2;
00182 fd3 = op->fp3;
00183 com = op->CommandCount;
00184 fprintf(f, "rotat %d %d %f %f %f \n", sid, com, fd1, fd2, fd3);
00185 }
00186
00187 int MSD_readStructRotate(FILE *f, EulerOp *op)
00188 {
00189 int solidno, com;
00190 float fp1, fp2, fp3;
00191
00192 if (fscanf(f, "%d %d %f %f %f\n", &solidno, &com, &fp1, &fp2, &fp3) != 5)
00193 {
00194 return(ERROR);
00195 }
00196 op->solidno = solidno;
00197 op->CommandCount = com;
00198 op->ip1 = 0;
00199 op->ip2 = 0;
00200 op->ip3 = 0;
00201 op->ip4 = 0;
00202 op->ip5 = 0;
00203 op->ip6 = 0;
00204 op->ip7 = 0;
00205 op->ip8 = 0;
00206 op->fp1 = fp1;
00207 op->fp2 = fp2;
00208 op->fp3 = fp3;
00209 op->fp4 = 0.0;
00210 return(SUCCESS);
00211 }
00212
00213 int MSD_modifyStructRotate(EulerOp *op)
00214 {
00215 int solidno;
00216
00217 solidno = MSD_lowCheckTranslatorTable(op->solidno, SOLID);
00218 op->solidno = solidno;
00219 return(SUCCESS);
00220 }