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 <math.h>
00043 #include <string.h>
00044 #include "mensagem.h"
00045 #include "memvirtu.h"
00046 #include "lowparam.h"
00047 #include "lowmacro.h"
00048 #include "lowsolid.h"
00049 #include "eulerops.h"
00050 #include "vectorop.h"
00051 #include "mancommd.h"
00052 #include "shpshape.h"
00053 #include "disdispl.h"
00054
00055 void MSD_execNameMakeCylinder(void)
00056 {
00057 char name1[15];
00058 int n;
00059 float r, h;
00060
00061 while (4 != sscanf(restbuf, "%s %d %f %f", name1, &n, &r, &h))
00062 {
00063 printf("Objeto N_div Raio Altura\n");
00064 if (!lineins("? "))
00065 {
00066 return;
00067 }
00068 }
00069 MSD_highNameMakeCylinder(name1, n, r, h);
00070 }
00071
00072 void MSD_highNameMakeCylinder(char *name, int n, real r, real h)
00073 {
00074 Id sn;
00075
00076 if (MSD_getSolidIdFromName(name) != -1)
00077 {
00078 fprintf(stderr, MEN_SolidoJaExiste, NAM_MakeCylinder, name);
00079 return;
00080 }
00081 if ((sn = MSD_highMakeCylinder(n, r, h)) != -1)
00082 {
00083 MSD_highName(sn, name, SOLID);
00084 }
00085 }
00086
00087 #ifdef __Extended_Version
00088 void MSD_execMakeCylinder(void)
00089 {
00090 int n, sn;
00091 float r, h;
00092
00093 while (4 != sscanf(restbuf, "%d %d %f %f", &sn, &n, &r, &h))
00094 {
00095 printf("N_div Raio Altura\n");
00096 if (!lineins("? "))
00097 {
00098 return;
00099 }
00100 }
00101 maxs = sn;
00102 printf("Id = %d\n", MSD_highMakeCylinder(n, r, h));
00103 }
00104
00105 #endif
00106
00107 Id MSD_highMakeCylinder(int n, real r, real h)
00108 {
00109 SPTYPE optr;
00110 Id sn;
00111
00112 sn = MSD_getMaxSolidId();
00113 if ((r != 0.0) && (h != 0.0) && (n > 2))
00114 {
00115 if ((optr = MSD_lowMakeCylinder(sn, r, h, n)) != SNIL)
00116 {
00117 MSD_lowDisplayMonitor('o', optr, GNIL);
00118 return(sn);
00119 }
00120 }
00121 if ((r != 0.0) && (n > 2))
00122 {
00123 if ((optr = MSD_lowMakeCylinder0(sn, r, n)) != SNIL)
00124 {
00125 MSD_lowDisplayMonitor('o', optr, GNIL);
00126 return(sn);
00127 }
00128 }
00129 fprintf(stderr, MEN_ParametrosIncorretos, NAM_MakeCylinder);
00130 return(-1);
00131 }
00132
00133 void MSD_execNameMakeCone(void)
00134 {
00135 char name1[15];
00136 int n;
00137 float r, h;
00138
00139 while (4 != sscanf(restbuf, "%s %d %f %f", name1, &n, &r, &h))
00140 {
00141 printf("Objeto N_div Raio Altura\n");
00142 if (!lineins("? "))
00143 {
00144 return;
00145 }
00146 }
00147 MSD_highNameMakeCone(name1, n, r, h);
00148 }
00149
00150 void MSD_highNameMakeCone(char *name, int n, real r, real h)
00151 {
00152 Id sn;
00153
00154 if (MSD_getSolidIdFromName(name) != -1)
00155 {
00156 fprintf(stderr, MEN_SolidoJaExiste, NAM_MakeCone, name);
00157 return;
00158 }
00159 if ((sn = MSD_highMakeCone(n, r, h)) != -1)
00160 {
00161 MSD_highName(sn, name, SOLID);
00162 }
00163 }
00164
00165 #ifdef __Extended_Version
00166 void MSD_execMakeCone(void)
00167 {
00168 int n, sn;
00169 float r, h;
00170
00171 while (4 != sscanf(restbuf, "%d %d %f %f", &sn, &n, &r, &h))
00172 {
00173 printf("N_div Raio Altura\n");
00174 if (!lineins("? "))
00175 {
00176 return;
00177 }
00178 }
00179 maxs = sn;
00180 printf("Id = %d\n", MSD_highMakeCone(n, r, h));
00181 }
00182
00183 #endif
00184
00185 Id MSD_highMakeCone(int n, real r, real h)
00186 {
00187 SPTYPE optr;
00188 Id sn;
00189
00190 sn = MSD_getMaxSolidId();
00191 if ((r != 0.0) && (h != 0.0) && (n > 2))
00192 {
00193 if ((optr = MSD_lowMakeCone(sn, r, h, n)) != SNIL)
00194 {
00195 MSD_lowDisplayMonitor('o', optr, GNIL);
00196 return(sn);
00197 }
00198 }
00199 if ((r != 0.0) && (n > 2))
00200 {
00201 if ((optr = MSD_lowMakeCylinder0(sn, r, n)) != SNIL)
00202 {
00203 MSD_lowDisplayMonitor('o', optr, GNIL);
00204 return(sn);
00205 }
00206 }
00207 fprintf(stderr, MEN_ParametrosIncorretos, NAM_MakeCone);
00208 return(-1);
00209 }
00210
00211 SPTYPE MSD_lowMakeCylinder(Id sn, real rad, real h, int n)
00212 {
00213 SPTYPE s;
00214 Id face;
00215 int flag = 1, GOld;
00216 static vector vec = { 0.0, 1.0, 0.0, 0.0 };
00217
00218 GOld = Gdoinversion;
00219 Gdoinversion = FALSE;
00220 CommandCount++;
00221 if ((s = MSD_lowMakeCircle(sn, 0.0, 0.0, rad, 0.0, n)) == SNIL)
00222 {
00223 flag = 0;
00224 }
00225 if (flag == 1)
00226 {
00227 face = dot(FacFeq(MSD_getFace(s, maxf - 2)), vec) > 0.0 ? maxf - 2 : maxf - 1;
00228 if (MSD_lowMakeSweep(MSD_getFace(s, face), 0.0, h, 0.0) == ERROR)
00229 {
00230 flag = 0;
00231 }
00232 if (flag == 1)
00233 {
00234 MSD_lowRot90Dg(s);
00235 MSD_lowSetNormal(s, TRUE);
00236 MSD_lowSetEdgeAngle(s);
00237 MSD_lowSetInfo(s);
00238 }
00239 if (flag == 0)
00240 {
00241 MSD_lowHardRemove(s);
00242 }
00243 }
00244 if (flag == 1)
00245 {
00246 MSD_lowAddEulerOp(s, HARDREM, 0, 0, 0, 0, 0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0);
00247 }
00248 Gdoinversion = GOld;
00249 return(flag == 0 ? SNIL : s);
00250 }
00251
00252 SPTYPE MSD_lowMakeCylinder0(Id sn, real rad, int n)
00253 {
00254 SPTYPE s;
00255 int GOld;
00256
00257 GOld = Gdoinversion;
00258 Gdoinversion = FALSE;
00259 CommandCount++;
00260 if ((s = MSD_lowMakeCircle(sn, 0.0, 0.0, rad, 0.0, n)) != SNIL)
00261 {
00262 MSD_lowRot90Dg(s);
00263 MSD_lowSetNormal(s, TRUE);
00264 MSD_lowSetEdgeAngle(s);
00265 MSD_lowSetInfo(s);
00266 MSD_lowAddEulerOp(s, HARDREM, 0, 0, 0, 0, 0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0);
00267 }
00268 Gdoinversion = GOld;
00269 return(s);
00270 }
00271
00272 SPTYPE MSD_lowMakeCone(Id sn, real rad, real h, int n)
00273 {
00274 SPTYPE s;
00275 Id face;
00276 int flag = 1, GOld;
00277 static vector vec = { 0.0, 1.0, 0.0, 0.0 };
00278
00279 GOld = Gdoinversion;
00280 Gdoinversion = FALSE;
00281 CommandCount++;
00282 if ((s = MSD_lowMakeCircle(sn, 0.0, 0.0, rad, 0.0, n)) == SNIL)
00283 {
00284 flag = 0;
00285 }
00286 face = dot(FacFeq(MSD_getFace(s, maxf - 2)), vec) > 0.0 ? maxf - 2 : maxf - 1;
00287 if (MSD_lowMakeSweep(MSD_getFace(s, face), 0.0, h, 0.0) == ERROR)
00288 {
00289 flag = 0;
00290 }
00291 if (flag == 1)
00292 {
00293 MSD_lowSetFaceToPoint(MSD_getFace(s, face), 0.0, h, 0.0);
00294 MSD_lowMakeFaceToPoint(MSD_getFace(s, face));
00295 MSD_lowRot90Dg(s);
00296 MSD_lowSetNormal(s, TRUE);
00297 MSD_lowSetEdgeAngle(s);
00298 MSD_lowSetInfo(s);
00299 }
00300 if (flag == 0)
00301 {
00302 MSD_lowHardRemove(s);
00303 }
00304 if (flag == 1)
00305 {
00306 MSD_lowAddEulerOp(s, HARDREM, 0, 0, 0, 0, 0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0);
00307 }
00308 Gdoinversion = GOld;
00309 return((flag == 0) ? SNIL : s);
00310 }
00311
00312 void MSD_lowRot90Dg(SPTYPE s)
00313 {
00314 matrix m;
00315 DPTYPE d;
00316 VPTYPE vptr;
00317
00318 matident(m);
00319 matrotat(m, 90.0, 0.0, 0.0);
00320 for (AllShellsSolid(s, d))
00321 {
00322 for (AllVerticesShell(d, vptr))
00323 {
00324 vecmult(VerVCoord(vptr), VerVCoord(vptr), m);
00325 }
00326 }
00327 }