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 "vectorop.h"
00048 #include "eulerops.h"
00049 #include "mancommd.h"
00050 #include "disdispl.h"
00051 #include "hiegroup.h"
00052
00053 #ifdef __Extended_Version
00054 void MSD_execNameTransformUsingAxis(void)
00055 {
00056 char aname[30];
00057 float desl;
00058
00059 while (2 != sscanf(restbuf, "%s %f", aname, &desl))
00060 {
00061 printf("TransformUsingAxis: axis desl\n");
00062 if (!lineins("? "))
00063 {
00064 return;
00065 }
00066 }
00067 MSD_highNameTransformUsingAxis(aname, desl);
00068 }
00069
00070 #endif
00071
00072 int MSD_highNameTransformUsingAxis(char *name, real desl)
00073 {
00074 int an;
00075
00076 if ((an = MSD_getAxisIdFromName(name)) == -1)
00077 {
00078 fprintf(stderr, MEN_NaoEncontrouAxisNome,
00079 NAM_TransformUsingAxis, name);
00080 return(ERROR);
00081 }
00082 return(MSD_highTransformUsingAxis(an, desl));
00083 }
00084
00085 #ifdef __Extended_Version
00086 void MSD_execTransformUsingAxis(void)
00087 {
00088 float desl;
00089 int an;
00090
00091 while (2 != sscanf(restbuf, "%d %f", &an, &desl))
00092 {
00093 printf("TransformUsingAxis: an desl\n");
00094 if (!lineins("? "))
00095 {
00096 return;
00097 }
00098 }
00099 MSD_highTransformUsingAxis(an, desl);
00100 }
00101
00102 #endif
00103
00104 int MSD_highTransformUsingAxis(int an, real desl)
00105 {
00106 APTYPE aptr;
00107
00108 if ((aptr = MSD_getAxis(an)) == ANIL)
00109 {
00110 fprintf(stderr, MEN_NaoEncontrouAxisId,
00111 NAM_TransformUsingAxis, an);
00112 return(ERROR);
00113 }
00114 return(MSD_lowTransformUsingAxis(aptr, desl));
00115 }
00116
00117 int MSD_lowTransformUsingAxis(APTYPE aptr, real desl)
00118 {
00119 vector disp;
00120
00121 switch (AxsMode(aptr))
00122 {
00123 case AxisOfRotation:
00124 MSD_lowRotateUsingAxis(aptr, AxsCenter(aptr), AxsVector(aptr), desl);
00125 break;
00126
00127 case AxisOfTranslation:
00128 vecesc(disp, AxsVector(aptr), desl);
00129 MSD_lowTranslateUsingAxis(aptr, disp);
00130 break;
00131 }
00132 return(SUCCESS);
00133 }
00134
00135 void MSD_lowTranslateUsingAxis(APTYPE aptr, vector disp)
00136 {
00137 SPTYPE optr;
00138 GPTYPE gptr;
00139 APTYPE aptt;
00140
00141 if (AxsType(aptr) == SOLID)
00142 {
00143 for (AllSolids(optr))
00144 {
00145 if (SolOAxs(optr) == aptr)
00146 {
00147 MSD_lowTranslate(optr, disp[0], disp[1], disp[2]);
00148 }
00149 }
00150 }
00151
00152 if (AxsType(aptr) == GROUP)
00153 {
00154 for (AllGroup(gptr))
00155 {
00156 if (GrpGAxs(gptr) == aptr)
00157 {
00158 for (AllSolids(optr))
00159 {
00160 if (MSD_lowIsAncestorGroup(gptr, SolGroup(optr)))
00161 {
00162 MSD_lowTranslate(optr, disp[0], disp[1], disp[2]);
00163 }
00164 }
00165 }
00166 }
00167 }
00168
00169 for (AllAxis(aptt))
00170 {
00171 if (MSD_lowIsAncestorAxis(aptr, aptt))
00172 {
00173 MSD_lowMoveAxis(aptt, disp);
00174 }
00175 }
00176 }
00177
00178 void MSD_lowRotateUsingAxis(APTYPE aptr, vector center, vector vec, real th)
00179 {
00180 SPTYPE optr;
00181 GPTYPE gptr;
00182 APTYPE aptt;
00183 matrix rot;
00184
00185 th *= PI / 180.0;
00186 if (AxsType(aptr) == SOLID)
00187 {
00188 for (AllSolids(optr))
00189 {
00190 if (SolOAxs(optr) == aptr)
00191 {
00192 MSD_lowTranslate(optr, -center[0], -center[1], -center[2]);
00193 matident(rot);
00194 rotmat(vec, th, rot);
00195 MSD_lowTransformation(optr, rot);
00196 MSD_lowTranslate(optr, center[0], center[1], center[2]);
00197 }
00198 }
00199 }
00200
00201 if (AxsType(aptr) == GROUP)
00202 {
00203 for (AllGroup(gptr))
00204 {
00205 if (GrpGAxs(gptr) == aptr)
00206 {
00207 for (AllSolids(optr))
00208 {
00209 if (MSD_lowIsAncestorGroup(gptr, SolGroup(optr)))
00210 {
00211 MSD_lowTranslate(optr, -center[0], -center[1], -center[2]);
00212 matident(rot);
00213 rotmat(vec, th, rot);
00214 MSD_lowTransformation(optr, rot);
00215 MSD_lowTranslate(optr, center[0], center[1], center[2]);
00216 }
00217 }
00218 }
00219 }
00220 }
00221
00222 for (AllAxis(aptt))
00223 {
00224 if (MSD_lowIsAncestorAxis(aptr, aptt))
00225 {
00226 MSD_lowRotateAxis(aptt, center, vec, th);
00227 }
00228 }
00229 }