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 "mancommd.h"
00049 #include "shpshape.h"
00050 #include "disdispl.h"
00051
00052 void MSD_execNameMakeTorus(void)
00053 {
00054 char name[30];
00055 float r0, r1;
00056 int n;
00057
00058 while (4 != sscanf(restbuf, "%s %d %f %f", name, &n, &r0, &r1))
00059 {
00060 printf("Objeto N_div R_maior R_menor\n");
00061 if (!lineins("? "))
00062 {
00063 return;
00064 }
00065 }
00066 MSD_highNameMakeTorus(name, n, r0, r1);
00067 }
00068
00069 void MSD_highNameMakeTorus(char *name, int n, real r0, real r1)
00070 {
00071 Id sn;
00072
00073 if (MSD_getSolidIdFromName(name) != -1)
00074 {
00075 fprintf(stderr, MEN_SolidoJaExiste, NAM_MakeTorus, name);
00076 return;
00077 }
00078 if ((sn = MSD_highMakeTorus(n, r0, r1)) != -1)
00079 {
00080 MSD_highName(sn, name, SOLID);
00081 }
00082 }
00083
00084 #ifdef __Extended_Version
00085 void MSD_execMakeTorus(void)
00086 {
00087 float r0, r1;
00088 int n;
00089
00090 while (3 != sscanf(restbuf, "%d %f %f", &n, &r0, &r1))
00091 {
00092 printf("N_div R_maior R_menor\n");
00093 if (!lineins("? "))
00094 {
00095 return;
00096 }
00097 }
00098 printf("Id = %d\n", MSD_highMakeTorus(n, r0, r1));
00099 }
00100
00101 #endif
00102
00103 Id MSD_highMakeTorus(int n, real r0, real r1)
00104 {
00105 SPTYPE optr;
00106 Id sn;
00107
00108 sn = MSD_getMaxSolidId();
00109 if ((r1 < r0) && (r1 != 0.0) && (n > 2))
00110 {
00111 if ((optr = MSD_lowMakeTorus(sn, r0, r1, 2 * n, n)) != SNIL)
00112 {
00113 MSD_lowDisplayMonitor('o', optr, GNIL);
00114 return(sn);
00115 }
00116 }
00117 fprintf(stderr, MEN_ParametrosIncorretos, NAM_MakeTorus);
00118 return(-1);
00119 }
00120
00121 SPTYPE MSD_lowMakeTorus(Id sn, real r1, real r2, int nf1, int nf2)
00122 {
00123 SPTYPE s;
00124 int flag = 1, GOld;
00125 static vector vect = { 0.0, 1.0, 0.0, 0.0 };
00126
00127 GOld = Gdoinversion;
00128 Gdoinversion = FALSE;
00129 CommandCount++;
00130 if ((s = MSD_lowMakeCircle(sn, r1, 0.0, r2, 0.0, nf2)) == SNIL)
00131 {
00132 flag = 0;
00133 }
00134 if (MSD_lowMakeRotationalSweep(s, nf1, 2, 0, vect) == ERROR)
00135 {
00136 flag = 0;
00137 }
00138 if (flag == 1)
00139 {
00140 MSD_lowSetNormal(s, TRUE);
00141 MSD_lowSetEdgeAngle(s);
00142 MSD_lowSetInfo(s);
00143 }
00144 if (flag == 0)
00145 {
00146 MSD_lowHardRemove(s);
00147 }
00148 if (flag == 1)
00149 {
00150 MSD_lowAddEulerOp(s, HARDREM, 0, 0, 0, 0, 0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0);
00151 }
00152 Gdoinversion = GOld;
00153 return(flag == 0 ? SNIL : s);
00154 }