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 <string.h>
00043 #include "mensagem.h"
00044 #include "memvirtu.h"
00045 #include "lowparam.h"
00046 #include "lowmacro.h"
00047 #include "lowsolid.h"
00048 #include "vectorop.h"
00049 #include "eulerops.h"
00050 #include "mancommd.h"
00051 #include "hiegroup.h"
00052
00053 #ifdef __Extended_Version
00054 void MSD_execNameCreateAxisRotation(void)
00055 {
00056 char name[30];
00057 float x1, y1, z1, x2, y2, z2;
00058
00059 while (7 != sscanf(restbuf, "%s %f %f %f %f %f %f", name, &x1, &y1, &z1,
00060 &x2, &y2, &z2))
00061 {
00062 printf("crtaxsrot: nome x1 y1 z1 x2 y2 z2\n");
00063 if (!lineins("? "))
00064 {
00065 return;
00066 }
00067 }
00068 MSD_highNameCreateAxisRotation(name, x1, y1, z1, x2, y2, z2);
00069 }
00070
00071 #endif
00072
00073 int MSD_highNameCreateAxisRotation(char *name, real x1, real y1, real z1,
00074 real x2, real y2, real z2)
00075 {
00076 APTYPE aptr;
00077 int an;
00078
00079 if (MSD_getAxisIdFromName(name) != -1)
00080 {
00081 fprintf(stderr, MEN_AxisJaExiste, NAM_CreateAxisOfRotation, name);
00082 return(ERROR);
00083 }
00084 if ((an = MSD_highCreateAxisRotation(x1, y1, z1, x2, y2, z2)) != -1)
00085 {
00086 aptr = MSD_getAxis(an);
00087 strcpy(AxsName(aptr), name);
00088 return(SUCCESS);
00089 }
00090 return(ERROR);
00091 }
00092
00093 #ifdef __Extended_Version
00094 void MSD_execCreateAxisRotation(void)
00095 {
00096 float x1, y1, z1, x2, y2, z2;
00097
00098 while (6 != sscanf(restbuf, "%f %f %f %f %f %f", &x1, &y1, &z1, &x2, &y2, &z2))
00099 {
00100 printf("crtaxsrot: an x y z\n");
00101 if (!lineins("? "))
00102 {
00103 return;
00104 }
00105 }
00106 printf("Id = %d\n", MSD_highCreateAxisRotation(x1, y1, z1, x2, y2, z2));
00107 }
00108
00109 #endif
00110
00111 int MSD_highCreateAxisRotation(real x1, real y1, real z1,
00112 real x2, real y2, real z2)
00113 {
00114 vector vec1, vec2;
00115
00116 makevec(vec1, x1, y1, z1, 1.0);
00117 makevec(vec2, x2, y2, z2, 1.0);
00118 return(MSD_lowCreateAxisRotation(MSD_getMaxAxisId(), vec1, vec2));
00119 }
00120
00121 int MSD_middleCreateAxisRotation(int an, real x1, real y1, real z1,
00122 real x2, real y2, real z2)
00123 {
00124 vector vec1, vec2;
00125
00126 makevec(vec1, x1, y1, z1, 1.0);
00127 makevec(vec2, x2, y2, z2, 1.0);
00128 return(MSD_lowCreateAxisRotation(an, vec1, vec2));
00129 }
00130
00131 int MSD_lowCreateAxisRotation(Id an, vector pos, vector vec)
00132 {
00133 APTYPE aptr;
00134
00135 if ((aptr = (APTYPE)MSD_lowNewElement(AXIS, NNIL)) == ANIL)
00136 {
00137 fprintf(stderr, MEN_NaoPossuiMemoria, NAM_CreateAxisOfRotation);
00138 return(ERROR);
00139 }
00140 AxsAxisNo(aptr) = an;
00141 AxsMode(aptr) = AxisOfRotation;
00142 veccopy(AxsCenter(aptr), pos);
00143 veccopy(AxsVector(aptr), vec);
00144 if (Gdoinversion)
00145 {
00146 MSD_lowAddEulerOp(SNIL, REMAXS, an, 0, 0, 0, 0, 0, 0, 0,
00147 0.0, 0.0, 0.0, 0.0);
00148 }
00149 return(an);
00150 }
00151
00152 int MSD_execStructCrtAxsRotation(EulerOp *op)
00153 {
00154 EulerOp *op1;
00155 Id an;
00156 real fd1, fd2, fd3, fd4, fd5, fd6;
00157
00158 an = op->ip1;
00159 fd1 = op->fp1;
00160 fd2 = op->fp2;
00161 fd3 = op->fp3;
00162
00163 #ifndef __VIRTUAL_MEM
00164 op1 = op->opnext;
00165 #else
00166 op1 = EULEROPS(op->pp - 1);
00167 #endif
00168
00169 fd4 = op1->fp1;
00170 fd5 = op1->fp2;
00171 fd6 = op1->fp3;
00172 return(MSD_middleCreateAxisRotation(an, fd1, fd2, fd3, fd4, fd5, fd6));
00173 }
00174
00175 void MSD_printStructCrtAxsRotation(FILE *f, EulerOp *op)
00176 {
00177 Id sid, ip1;
00178 real fd1, fd2, fd3, fd4;
00179
00180 sid = op->solidno;
00181 ip1 = op->ip1;
00182 fd1 = op->fp1;
00183 fd2 = op->fp2;
00184 fd3 = op->fp3;
00185 fd4 = op->fp4;
00186 fprintf(f, "crtaxsrot %d %d %f %f %f %f\n", sid, ip1, fd1, fd2, fd3, fd4);
00187 }
00188
00189 int MSD_readStructCrtAxsRotation(FILE *f, EulerOp *op)
00190 {
00191 int solidno, ip1;
00192 real fd1, fd2, fd3, fd4;
00193
00194 if (fscanf(f, "%d %d %f %f %f\n", &solidno, &ip1,
00195 &fd1, &fd2, &fd3, &fd4) != 6)
00196 {
00197 return(ERROR);
00198 }
00199 op->solidno = solidno;
00200 op->ip1 = ip1;
00201 op->ip2 = 0;
00202 op->ip3 = 0;
00203 op->ip4 = 0;
00204 op->ip5 = 0;
00205 op->ip6 = 0;
00206 op->ip7 = 0;
00207 op->ip8 = 0;
00208 op->fp1 = fd1;
00209 op->fp2 = fd2;
00210 op->fp3 = fd3;
00211 op->fp4 = fd4;
00212 return(SUCCESS);
00213 }
00214
00215 int MSD_modifyStructCrtAxsRotation(EulerOp *op)
00216 {
00217 int axisno;
00218
00219 axisno = MSD_lowCheckTranslatorTable(op->ip1, AXIS);
00220 op->ip1 = axisno;
00221 return(SUCCESS);
00222 }