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 "mancommd.h"
00048 #include "shpshape.h"
00049 #include "disdispl.h"
00050 #include "eulerops.h"
00051
00052 void MSD_execNameMakePrism(void)
00053 {
00054 XY *listvtx;
00055 char name1[15];
00056 int n;
00057 float h;
00058
00059 while (3 != sscanf(restbuf, "%s %d %f", name1, &n, &h))
00060 {
00061 printf("Objeto N_div Altura\n");
00062 if (!lineins("? "))
00063 {
00064 return;
00065 }
00066 }
00067 if ((n > 2) && setvtpi(&listvtx, n))
00068 {
00069 MSD_highNameMakePrism(name1, n, h, listvtx);
00070 }
00071 }
00072
00073 void MSD_highNameMakePrism(char *name, int n, real h, XY *listvtx)
00074 {
00075 Id sn;
00076
00077 if (MSD_getSolidIdFromName(name) != -1)
00078 {
00079 fprintf(stderr, MEN_SolidoJaExiste, NAM_MakePrism, name);
00080 return;
00081 }
00082 if ((sn = MSD_highMakePrism(n, h, listvtx)) != -1)
00083 {
00084 MSD_highName(sn, name, SOLID);
00085 }
00086 }
00087
00088 #ifdef __Extended_Version
00089 void MSD_execMakePrism(void)
00090 {
00091 XY *listvtx;
00092 int n;
00093 float h;
00094
00095 while (2 != sscanf(restbuf, "%d %f", &n, &h))
00096 {
00097 printf("N_div Altura\n");
00098 if (!lineins("? "))
00099 {
00100 return;
00101 }
00102 }
00103 if ((n > 2) && setvtpi(&listvtx, n))
00104 {
00105 printf("Id = %d\n", MSD_highMakePrism(n, h, listvtx));
00106 }
00107 }
00108
00109 #endif
00110
00111 Id MSD_highMakePrism(int n, real h, XY *listvtx)
00112 {
00113 SPTYPE optr;
00114 Id sn;
00115
00116 sn = MSD_getMaxSolidId();
00117 if (h != 0.0)
00118 {
00119 if ((optr = MSD_lowMakePrism(sn, listvtx, h, n)) != SNIL)
00120 {
00121 MSD_lowDisplayMonitor('o', optr, GNIL);
00122 return(sn);
00123 }
00124 }
00125 if (h == 0.0)
00126 {
00127 if ((optr = MSD_lowMakePrism0(sn, listvtx, n, 1)) != SNIL)
00128 {
00129 MSD_lowDisplayMonitor('o', optr, GNIL);
00130 return(sn);
00131 }
00132 }
00133 fprintf(stderr, MEN_ParametrosIncorretos, NAM_MakePrism);
00134 return(-1);
00135 }
00136
00137 void MSD_execNameMakePyramid(void)
00138 {
00139 XY *listvtx;
00140 char name1[15];
00141 int n;
00142 float h;
00143
00144 while (3 != sscanf(restbuf, "%s %d %f", name1, &n, &h))
00145 {
00146 printf("Objeto N_div Altura\n");
00147 if (!lineins("? "))
00148 {
00149 return;
00150 }
00151 }
00152 if ((n > 2) && setvtpi(&listvtx, n))
00153 {
00154 MSD_highNameMakePyramid(name1, n, h, listvtx);
00155 }
00156 }
00157
00158 void MSD_highNameMakePyramid(char *name, int n, real h, XY *listvtx)
00159 {
00160 Id sn;
00161
00162 if (MSD_getSolidIdFromName(name) != -1)
00163 {
00164 fprintf(stderr, MEN_SolidoJaExiste, NAM_MakePyramid, name);
00165 return;
00166 }
00167 if ((sn = MSD_highMakePyramid(n, h, listvtx)) != -1)
00168 {
00169 MSD_highName(sn, name, SOLID);
00170 }
00171 }
00172
00173 #ifdef __Extended_Version
00174 void MSD_execMakePyramid(void)
00175 {
00176 XY *listvtx;
00177 int n;
00178 float h;
00179
00180 while (2 != sscanf(restbuf, "%d %f", &n, &h))
00181 {
00182 printf("N_div Altura\n");
00183 if (!lineins("? "))
00184 {
00185 return;
00186 }
00187 }
00188 if ((n > 2) && setvtpi(&listvtx, n))
00189 {
00190 printf("Id = %d\n", MSD_highMakePyramid(n, h, listvtx));
00191 }
00192 }
00193
00194 #endif
00195
00196 Id MSD_highMakePyramid(int n, real h, XY *listvtx)
00197 {
00198 SPTYPE optr;
00199 Id sn;
00200
00201 sn = MSD_getMaxSolidId();
00202 if (h != 0.0)
00203 {
00204 if ((optr = MSD_lowMakePyramid(sn, listvtx, h, n)) != SNIL)
00205 {
00206 MSD_lowDisplayMonitor('o', optr, GNIL);
00207 return(sn);
00208 }
00209 }
00210 if (h == 0.0)
00211 {
00212 if ((optr = MSD_lowMakePrism0(sn, listvtx, n, 1)) != SNIL)
00213 {
00214 MSD_lowDisplayMonitor('o', optr, GNIL);
00215 return(sn);
00216 }
00217 }
00218 fprintf(stderr, MEN_ParametrosIncorretos, NAM_MakePyramid);
00219 return(-1);
00220 }
00221
00222 char setvtpi(XY **listxy, int n)
00223 {
00224 char prompt[16];
00225 float x, y;
00226 int i;
00227
00228 if (n > 100)
00229 {
00230 return(FALSE);
00231 }
00232 *listxy = (XY *)workbuf;
00233 for (i = 0; i < n; i++)
00234 {
00235 sprintf(prompt, "X%d Y%d ? ", i, i);
00236 do
00237 {
00238 if (!lineins(prompt))
00239 {
00240 return(FALSE);
00241 }
00242 } while (2 != sscanf(restbuf, "%f %f", &x, &y));
00243
00244 ((*listxy) + i)->x = x;
00245 ((*listxy) + i)->y = y;
00246 }
00247 return(TRUE);
00248 }