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 #ifndef __UNIX_
00044 #include <malloc.h>
00045 #endif
00046 #include "mensagem.h"
00047 #include "memvirtu.h"
00048 #include "lowparam.h"
00049 #include "lowsolid.h"
00050 #include "curvgeom.h"
00051 #include "eulerops.h"
00052 #include "mancommd.h"
00053
00054 typedef struct eulercod EuCode;
00055
00056 struct eulercod
00057 {
00058 OpCode ecode;
00059 char *eop;
00060 int (*xeop)(EulerOp *op);
00061 void (*peop)(FILE *f, EulerOp *op);
00062 int (*reop)(FILE *f, EulerOp *op);
00063 int (*meop)(EulerOp *op);
00064 int num;
00065 };
00066
00067 extern EuCode ematrix[];
00068
00069
00070 void MSD_execUndoOp(void)
00071 {
00072 MSD_highUndoOp();
00073 }
00074
00075 void MSD_highUndoOp(void)
00076 {
00077 MSD_lowUndoOp();
00078 }
00079
00080 SPTYPE MSD_lowUndoOp(void)
00081 {
00082 SPTYPE s;
00083 EulerOp *op;
00084 int Gsave, cont, i, com;
00085
00086 Gsave = Gdoinversion;
00087 Gdoinversion = 0;
00088 s = SNIL;
00089 if (OpHead != EuNIL)
00090 {
00091 #ifndef __VIRTUAL_MEM
00092 op = OpHead;
00093 #else
00094 op = EULEROPS(OpHead);
00095 #endif
00096 com = op->CommandCount;
00097 while (com == op->CommandCount)
00098 {
00099 s = MSD_lowApplyEulerOp(op, &cont);
00100 for (i = 0; i < cont; i++)
00101 {
00102 EulerOpNext(OpHead);
00103 OpCount--;
00104
00105 #ifndef __VIRTUAL_MEM
00106 free((char *)op);
00107 op = OpHead;
00108 #else
00109 op = EULEROPS(OpHead);
00110 #endif
00111 }
00112 }
00113 }
00114 Gdoinversion = Gsave;
00115 return(s);
00116 }
00117
00118
00119 SPTYPE MSD_lowApplyEulerOp(EulerOp *op, int *cont)
00120 {
00121 EuCode *p;
00122
00123 for (p = ematrix; *p->eop; ++p)
00124 {
00125 if (p->ecode == op->opcode)
00126 {
00127 break;
00128 }
00129 }
00130 if ((*p->xeop)(op) == ERROR)
00131 {
00132 fprintf(stderr, MEN_ParametrosIncorretos, NAM_ApplyEulerOp);
00133 return(SNIL);
00134 }
00135 *cont = p->num;
00136 return(MSD_getSolid(op->solidno));
00137 }
00138
00139 int MSD_execStructError(EulerOp *op)
00140 {
00141 MSD_lowNaoUtilizado(op);
00142
00143 fprintf(stderr, MEN_ParametrosIncorretos, NAM_ApplyEulerOp);
00144 return(ERROR);
00145 }
00146
00147 void MSD_lowFreeUndoLog(PEulerOp EndOp)
00148 {
00149 #ifndef __VIRTUAL_MEM
00150 EulerOp *op;
00151
00152 while (OpHead != EndOp)
00153 {
00154 if ((op = OpHead) != (EulerOp *)NIL)
00155 {
00156 OpHead = op->opnext;
00157 OpCount--;
00158 free((char *)op);
00159 }
00160 }
00161 #else
00162 OpHead = EndOp;
00163 #endif
00164 }
00165
00166
00167 void MSD_lowGetMatrix(EulerOp *op, matrix m)
00168 {
00169 PEulerOp eop;
00170
00171 #ifndef __VIRTUAL_MEM
00172 eop = op;
00173 #else
00174 eop = op->pp;
00175 #endif
00176
00177 EulerOpNext(eop);
00178 m[0][0] = EulerFp1(eop);
00179 m[0][1] = EulerFp2(eop);
00180 m[0][2] = EulerFp3(eop);
00181 m[0][3] = EulerFp4(eop);
00182
00183 EulerOpNext(eop);
00184 m[1][0] = EulerFp1(eop);
00185 m[1][1] = EulerFp2(eop);
00186 m[1][2] = EulerFp3(eop);
00187 m[1][3] = EulerFp4(eop);
00188
00189 EulerOpNext(eop);
00190 m[2][0] = EulerFp1(eop);
00191 m[2][1] = EulerFp2(eop);
00192 m[2][2] = EulerFp3(eop);
00193 m[2][3] = EulerFp4(eop);
00194
00195 EulerOpNext(eop);
00196 m[3][0] = EulerFp1(eop);
00197 m[3][1] = EulerFp2(eop);
00198 m[3][2] = EulerFp3(eop);
00199 m[3][3] = EulerFp4(eop);
00200 }