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 "eulerops.h"
00049 #include "hiegroup.h"
00050 #include "shpshape.h"
00051 #include "genfunc_.h"
00052 #include "mancommd.h"
00053
00054 void MSD_execNameCopyElement(void)
00055 {
00056 char name1[30], name2[30];
00057
00058 while (2 != sscanf(restbuf, "%s %s", name1, name2))
00059 {
00060 printf("copy: Nome1 Nome2");
00061 if (!lineins("? "))
00062 {
00063 return;
00064 }
00065 }
00066 MSD_highNameCopyElement(name1, name2);
00067 }
00068
00069 int MSD_highNameCopyElement(char *name1, char *name2)
00070 {
00071 switch (MSD_getTypeByName(name1))
00072 {
00073 case 'o':
00074 return(MSD_highNameCopySolid(name1, name2));
00075
00076 case 'g':
00077 return(MSD_highNameCopyGroup(name1, name2));
00078 }
00079 return(FALSE);
00080 }
00081
00082 #ifdef __Extended_Version
00083 void MSD_execNameCopySolid(void)
00084 {
00085 char oname1[30], oname2[30];
00086
00087 while (2 != sscanf(restbuf, "%s %s", oname1, oname2))
00088 {
00089 printf("CopySolid: old new\n");
00090 if (!lineins("? "))
00091 {
00092 return;
00093 }
00094 }
00095 MSD_highNameCopySolid(oname1, oname2);
00096 }
00097
00098 #endif
00099
00100 int MSD_highNameCopySolid(char *name1, char *name2)
00101 {
00102 SPTYPE sptr;
00103 Id sn1, sn2;
00104
00105 if ((sn1 = MSD_getSolidIdFromName(name1)) == -1)
00106 {
00107 fprintf(stderr, MEN_NaoEncontrouSolido, NAM_CopySolid, name1);
00108 return(ERROR);
00109 }
00110 if (MSD_getSolidIdFromName(name2) != -1)
00111 {
00112 fprintf(stderr, MEN_SolidoJaExiste, NAM_CopySolid, name2);
00113 return(ERROR);
00114 }
00115 if ((sn2 = MSD_highCopySolid(sn1)) != -1)
00116 {
00117 sptr = MSD_getSolid(sn2);
00118 strcpy(SolName(sptr), name2);
00119 sptr = MSD_getSolid(sn1);
00120 strcpy(SolName(sptr), name1);
00121 return(SUCCESS);
00122 }
00123 return(ERROR);
00124 }
00125
00126 #ifdef __Extended_Version
00127 void MSD_execCopySolid(void)
00128 {
00129 int sn;
00130
00131 while (1 != sscanf(restbuf, "%d", &sn))
00132 {
00133 printf("CopySolid: sn\n");
00134 if (!lineins("? "))
00135 {
00136 return;
00137 }
00138 }
00139 printf("Id = %d\n", MSD_highCopySolid(sn));
00140 }
00141
00142 #endif
00143
00144 int MSD_highCopySolid(int sn)
00145 {
00146 SPTYPE sptr;
00147 Id sn1;
00148
00149 sn1 = MSD_getMaxSolidId();
00150 if ((sptr = MSD_getSolid(sn)) == SNIL)
00151 {
00152 fprintf(stderr, MEN_NaoEncontrouSolido, NAM_CopySolid, sn);
00153 return(ERROR);
00154 }
00155 return(MSD_lowCopySolid(sptr, sn1) == SUCCESS ? sn1 : -1);
00156 }
00157
00158 int MSD_lowCopySolid(SPTYPE s, Id sn)
00159 {
00160 PEulerOp StartOp;
00161 PEulerOp op;
00162 int cont;
00163
00164 StartOp = OpHead;
00165 Gdoinversion = TRUE;
00166 MSD_lowSoftRemove(s);
00167 Gdoinversion = FALSE;
00168
00169 if ((s = MSD_lowApplyEulerOp(EULEROPS(OpHead), &cont)) != SNIL)
00170 {
00171 op = OpHead;
00172 for (EulerOpNext(op); op != StartOp; EulerOpNext(op))
00173 {
00174 MSD_lowApplyEulerOp(EULEROPS(op), &cont);
00175 while (cont != 1)
00176 {
00177 EulerOpNext(op);
00178 cont--;
00179 }
00180 }
00181 MSD_lowSetNormal(s, TRUE);
00182 MSD_lowSetEdgeAngle(s);
00183 MSD_lowSetInfo(s);
00184 }
00185
00186 EulerSolidNo(OpHead) = sn;
00187 if ((s = MSD_lowApplyEulerOp(EULEROPS(OpHead), &cont)) != SNIL)
00188 {
00189 op = OpHead;
00190 for (EulerOpNext(op); op != StartOp; EulerOpNext(op))
00191 {
00192 EulerSolidNo(op) = sn;
00193 MSD_lowApplyEulerOp(EULEROPS(op), &cont);
00194 while (cont != 1)
00195 {
00196 EulerOpNext(op);
00197 cont--;
00198 }
00199 }
00200 MSD_lowSetNormal(s, TRUE);
00201 MSD_lowSetEdgeAngle(s);
00202 MSD_lowSetInfo(s);
00203 }
00204
00205 MSD_lowFreeUndoLog(StartOp);
00206 return(SUCCESS);
00207 }