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 "lowsolid.h"
00047 #include "eulerops.h"
00048 #include "vectorop.h"
00049 #include "mancommd.h"
00050 #include "shpshape.h"
00051 #include "disdispl.h"
00052
00053 void MSD_execNameMakeCube(void)
00054 {
00055 char name[30];
00056 float a, b, c;
00057
00058 while (4 != sscanf(restbuf, "%s %f %f %f", name, &a, &b, &c))
00059 {
00060 printf("Objeto A B C\n");
00061 if (!lineins("? "))
00062 {
00063 return;
00064 }
00065 }
00066 MSD_highNameMakeCube(name, a, b, c);
00067 }
00068
00069 void MSD_highNameMakeCube(char *name, real a, real b, real c)
00070 {
00071 Id sn;
00072
00073 if (MSD_getSolidIdFromName(name) != -1)
00074 {
00075 fprintf(stderr, MEN_SolidoJaExiste, NAM_MakeCube, name);
00076 return;
00077 }
00078 if ((sn = MSD_highMakeCube(a, b, c)) != -1)
00079 {
00080 MSD_highName(sn, name, SOLID);
00081 }
00082 }
00083
00084 #ifdef __Extended_Version
00085 void MSD_execMakeCube(void)
00086 {
00087 float a, b, c;
00088 int sn;
00089
00090 while (4 != sscanf(restbuf, "%d %f %f %f", &sn, &a, &b, &c))
00091 {
00092 printf("A B C\n");
00093 if (!lineins("? "))
00094 {
00095 return;
00096 }
00097 }
00098 maxs = sn;
00099 printf("Id = %d\n", MSD_highMakeCube(a, b, c));
00100 }
00101
00102 #endif
00103
00104 Id MSD_highMakeCube(real a, real b, real c)
00105 {
00106 SPTYPE optr;
00107 Id sn;
00108
00109 sn = MSD_getMaxSolidId();
00110 if ((a > 0.0) && (b > 0.0) && (c > 0.0))
00111 {
00112 if ((optr = MSD_lowMakeCube(sn, a, b, c)) != SNIL)
00113 {
00114 MSD_lowDisplayMonitor('o', optr, GNIL);
00115 return(sn);
00116 }
00117 }
00118
00119 if ((a > 0.0) && (b > 0.0) && (c <= 0.0))
00120 {
00121 if ((optr = MSD_lowMakeCube0(sn, a, b)) != SNIL)
00122 {
00123 MSD_lowDisplayMonitor('o', optr, GNIL);
00124 return(sn);
00125 }
00126 }
00127 if ((b > 0.0) && (c > 0.0) && (a <= 0.0))
00128 {
00129 if ((optr = MSD_lowMakeCube0(sn, b, c)) != SNIL)
00130 {
00131 MSD_lowDisplayMonitor('o', optr, GNIL);
00132 return(sn);
00133 }
00134 }
00135 if ((a > 0.0) && (c > 0.0) && (b <= 0.0))
00136 {
00137 if ((optr = MSD_lowMakeCube0(sn, a, c)) != SNIL)
00138 {
00139 MSD_lowDisplayMonitor('o', optr, GNIL);
00140 return(sn);
00141 }
00142 }
00143 fprintf(stderr, MEN_ParametrosIncorretos, NAM_MakeCube);
00144 return(-1);
00145 }
00146
00147 SPTYPE MSD_lowMakeCube(Id sn, real dx, real dy, real dz)
00148 {
00149 SPTYPE s;
00150 Id face;
00151 int flag = 1, GOld;
00152 vector normal;
00153 static vector vec = { 0.0, 0.0, 1.0, 0.0 };
00154
00155 GOld = Gdoinversion;
00156 Gdoinversion = FALSE;
00157 CommandCount++;
00158 if ((s = MSD_lowMVSF(sn, maxf++, maxv++, maxd++, 0.0, 0.0, 0.0)) == SNIL)
00159 {
00160 flag = 0;
00161 }
00162 if (MSD_highMEV(sn, maxf - 1, maxv - 1, maxv, dx, 0.0, 0.0) == ERROR)
00163 {
00164 flag = 0;
00165 }
00166 maxv++;
00167 if (MSD_highMEV(sn, maxf - 1, maxv - 1, maxv, dx, dy, 0.0) == ERROR)
00168 {
00169 flag = 0;
00170 }
00171 maxv++;
00172 if (MSD_highMEV(sn, maxf - 1, maxv - 1, maxv, 0.0, dy, 0.0) == ERROR)
00173 {
00174 flag = 0;
00175 }
00176 maxv++;
00177 if (MSD_highMEF(sn, maxv - 4, maxv - 1, maxf - 1, maxf) == ERROR)
00178 {
00179 flag = 0;
00180 }
00181 maxf++;
00182 if (flag == 1)
00183 {
00184 MSD_lowFaceEq(FacFLOut(MSD_getFace(s, maxf - 2)), normal);
00185 face = dot(normal, vec) > 0.0 ? maxf - 2 : maxf - 1;
00186 if (MSD_lowMakeSweep(MSD_getFace(s, face), 0.0, 0.0, dz) == ERROR)
00187 {
00188 flag = 0;
00189 }
00190 if (flag == 1)
00191 {
00192 MSD_lowSetNormal(s, TRUE);
00193 MSD_lowSetEdgeAngle(s);
00194 MSD_lowSetInfo(s);
00195 }
00196 }
00197 if (flag == 0)
00198 {
00199 MSD_lowHardRemove(s);
00200 }
00201 if (flag == 1)
00202 {
00203 MSD_lowAddEulerOp(s, HARDREM, 0, 0, 0, 0, 0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0);
00204 }
00205 Gdoinversion = GOld;
00206 return((flag == 0) ? SNIL : s);
00207 }
00208
00209 SPTYPE MSD_lowMakeCube0(Id sn, real dx, real dy)
00210 {
00211 SPTYPE s;
00212 int flag = 1, GOld;
00213
00214 GOld = Gdoinversion;
00215 Gdoinversion = FALSE;
00216 CommandCount++;
00217 if ((s = MSD_lowMVSF(sn, maxf++, maxv++, maxd++, 0.0, 0.0, 0.0)) == SNIL)
00218 {
00219 flag = 0;
00220 }
00221 if (MSD_highMEV(sn, maxf - 1, maxv - 1, maxv, dx, 0.0, 0.0) == ERROR)
00222 {
00223 flag = 0;
00224 }
00225 maxv++;
00226 if (MSD_highMEV(sn, maxf - 1, maxv - 1, maxv, dx, dy, 0.0) == ERROR)
00227 {
00228 flag = 0;
00229 }
00230 maxv++;
00231 if (MSD_highMEV(sn, maxf - 1, maxv - 1, maxv, 0.0, dy, 0.0) == ERROR)
00232 {
00233 flag = 0;
00234 }
00235 maxv++;
00236 if (MSD_highMEF(sn, maxv - 4, maxv - 1, maxf - 1, maxf) == ERROR)
00237 {
00238 flag = 0;
00239 }
00240 maxf++;
00241 if (flag == 1)
00242 {
00243 MSD_lowSetNormal(s, TRUE);
00244 MSD_lowSetEdgeAngle(s);
00245 MSD_lowSetInfo(s);
00246 }
00247 if (flag == 0)
00248 {
00249 MSD_lowHardRemove(s);
00250 }
00251 if (flag == 1)
00252 {
00253 MSD_lowAddEulerOp(s, HARDREM, 0, 0, 0, 0, 0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0);
00254 }
00255 Gdoinversion = GOld;
00256 return((flag == 0) ? SNIL : s);
00257 }