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 #ifdef __Extended_Version
00053 void MSD_execNameTranslate(void)
00054 {
00055 char name[30];
00056 float tx, ty, tz;
00057
00058 while (4 != sscanf(restbuf, "%s %f %f %f", name, &tx, &ty, &tz))
00059 {
00060 printf("trans: name rx ry rz\n");
00061 if (!lineins("? "))
00062 {
00063 return;
00064 }
00065 }
00066 MSD_highNameTranslate(name, tx, ty, tz);
00067 }
00068
00069 #endif
00070
00071 int MSD_highNameTranslate(char *name, real tx, real ty, real tz)
00072 {
00073 int sn;
00074
00075 if ((sn = MSD_getSolidIdFromName(name)) == -1)
00076 {
00077 fprintf(stderr, MEN_NaoEncontrouSolidNome, NAM_TranslateSolid, name);
00078 return(ERROR);
00079 }
00080 return(MSD_highTranslate(sn, tx, ty, tz));
00081 }
00082
00083 #ifdef __Extended_Version
00084 void MSD_execTranslate(void)
00085 {
00086 int s, op;
00087 float tx, ty, tz;
00088
00089 while (5 != sscanf(restbuf, "%d %d %f %f %f", &s, &op, &tx, &ty, &tz))
00090 {
00091 printf("trans: Sid rx ry rz\n");
00092 if (!lineins("? "))
00093 {
00094 return;
00095 }
00096 }
00097 MSD_highTranslate(s, tx, ty, tz);
00098 }
00099
00100 #endif
00101
00102 int MSD_highTranslate(Id sn, real tx, real ty, real tz)
00103 {
00104 SPTYPE s;
00105
00106 if ((s = MSD_getSolid(sn)) == SNIL)
00107 {
00108
00109 return(ERROR);
00110 }
00111 CommandCount++;
00112 MSD_lowTranslate(s, tx, ty, tz);
00113 return(SUCCESS);
00114 }
00115
00116 void MSD_lowTranslate(SPTYPE s, real tx, real ty, real tz)
00117 {
00118 DPTYPE d;
00119 FPTYPE f;
00120 HPTYPE he;
00121 HPTYPE efim;
00122 VPTYPE v;
00123 vector pc;
00124 int length;
00125
00126 #ifdef __curved_env__
00127 matrix m;
00128 #endif
00129
00130
00131 if (Gdoinversion)
00132 {
00133 MSD_lowAddEulerOp(s, TRANS, 0, 0, 0, 0, 0, 0, 0, 0, -tx, -ty, -tz, 0.0);
00134 }
00135 if (Gdodirect)
00136 {
00137 MSD_lowAddEulerOpRedo(s, TRANS, 0, 0, 0, 0, 0, 0, 0, 0, tx, ty, tz, 0.0);
00138 }
00139
00140 for (AllShellsSolid(s, d))
00141 {
00142 for (AllVerticesShell(d, v))
00143 {
00144 VerVCoord(v)[0] += tx;
00145 VerVCoord(v)[1] += ty;
00146 VerVCoord(v)[2] += tz;
00147 }
00148 }
00149
00150
00151 MSD_lowSetNormal(s, TRUE);
00152 for (AllShellsSolid(s, d))
00153 {
00154 for (AllFacesShell(d, f))
00155 {
00156 veczer(pc);
00157 length = 0;
00158 he = efim = LooLEdg(FacFLOut(f));
00159 do
00160 {
00161 vecplus(pc, pc, VerVCoord(HalVtx(he)));
00162 length++;
00163 } while ((he = HalNxt(he)) != efim);
00164 FacFeq(f)[3] = length != 0 ? -dot(pc, FacFeq(f)) / length : 0.0;
00165 }
00166 }
00167
00168 #ifdef __curved_env__
00169 matident(m);
00170 mattrans(m, tx, ty, tz);
00171
00172 #endif
00173 }
00174
00175 int MSD_execStructTranslate(EulerOp *op)
00176 {
00177 Id sid;
00178 real fd1, fd2, fd3;
00179
00180 sid = op->solidno;
00181 fd1 = op->fp1;
00182 fd2 = op->fp2;
00183 fd3 = op->fp3;
00184 MSD_highTranslate(sid, fd1, fd2, fd3);
00185 return(SUCCESS);
00186 }
00187
00188 void MSD_printStructTranslate(FILE *f, EulerOp *op)
00189 {
00190 Id sid;
00191 real fd1, fd2, fd3;
00192 int com;
00193
00194 sid = op->solidno;
00195 fd1 = op->fp1;
00196 fd2 = op->fp2;
00197 fd3 = op->fp3;
00198 com = op->CommandCount;
00199 fprintf(f, "trans %d %d %f %f %f \n", sid, com, fd1, fd2, fd3);
00200 }
00201
00202 int MSD_readStructTranslate(FILE *f, EulerOp *op)
00203 {
00204 int solidno, com;
00205 float fp1, fp2, fp3;
00206
00207 if (fscanf(f, "%d %d %f %f %f\n", &solidno, &com, &fp1, &fp2, &fp3) != 5)
00208 {
00209 return(ERROR);
00210 }
00211 op->solidno = solidno;
00212 op->CommandCount = com;
00213 op->ip1 = 0;
00214 op->ip2 = 0;
00215 op->ip3 = 0;
00216 op->ip4 = 0;
00217 op->ip5 = 0;
00218 op->ip6 = 0;
00219 op->ip7 = 0;
00220 op->ip8 = 0;
00221 op->fp1 = fp1;
00222 op->fp2 = fp2;
00223 op->fp3 = fp3;
00224 op->fp4 = 0.0;
00225 return(SUCCESS);
00226 }
00227
00228 int MSD_modifyStructTranslate(EulerOp *op)
00229 {
00230 int solidno;
00231
00232 solidno = MSD_lowCheckTranslatorTable(op->solidno, SOLID);
00233 op->solidno = solidno;
00234 return(SUCCESS);
00235 }