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 #ifndef __UNIX_
00044 #include <malloc.h>
00045 #endif
00046 #include <math.h>
00047 #include <stdlib.h>
00048 #include "lowmacro.h"
00049 #include "mensagem.h"
00050 #include "memvirtu.h"
00051 #include "lowparam.h"
00052 #include "lowsolid.h"
00053 #include "eulerops.h"
00054 #include "vectorop.h"
00055 #include "genfunc_.h"
00056 #include "sethmain.h"
00057 #include "mancommd.h"
00058 #include "analise_.h"
00059 #include "basrov__.h"
00060 #include "gphgraph.h"
00061 #include "disdispl.h"
00062
00063 char MSD_formatImpressao[] =
00064 "(%s %s %.2f %.2f MSD %s %s %s %s %s %s %s %s %.2f %.2f)\n";
00065 int MSD_lowOrdena(char *nome, real raio, real dx, real dy, real dz);
00066 int MSD_lowAreaProjetadaTotal(real dx, real dy, real dz, real *area, real *dim);
00067 double MSD_lowSolidAreaProjetada(SPTYPE s);
00068
00069
00070 void MSD_execProjetadaTotal(void)
00071 {
00072 float dx, dy, dz;
00073 real area, dim;
00074
00075 while (3 != sscanf(restbuf, "%f %f %f ", &dx, &dy, &dz))
00076 {
00077 printf("ROV.projetada total dx dy dz\n");
00078 if (!lineins("? "))
00079 {
00080 return;
00081 }
00082 }
00083 MSD_lowAreaProjetadaTotal(dx, dy, dz, &area, &dim);
00084 printf(" area = %f dim = %f\n", area, dim);
00085 }
00086
00087 void MSD_execOrdena(void)
00088 {
00089 float dx, dy, dz, raio;
00090 char nome[15];
00091 int i;
00092
00093 while (5 != sscanf(restbuf, "%s %f %f %f %f", nome, &raio, &dx, &dy, &dz))
00094 {
00095 printf("ROV.ordena nomearq raio dx dy dz\n");
00096 if (!lineins("? "))
00097 {
00098 return;
00099 }
00100 }
00101 MSD_lowOrdena(nome, raio, dx, dy, dz);
00102 for (i = 0; i < NumListaEscoamento; i++)
00103 {
00104 printf("..Solido %2d = %s\n", i, SolName(ListaEscoamento[i].optr));
00105 printf("..Solido Id = %2d dist = %10.4f\n",
00106 SolSolidNo(ListaEscoamento[i].optr),
00107 ListaEscoamento[i].param);
00108 }
00109 }
00110
00111 int MSD_lowOrdenaListaEstudo(void)
00112 {
00113 SPTYPE optr;
00114 vector vec;
00115 real temp;
00116 int sorted = FALSE, j;
00117
00118 while (!sorted)
00119 {
00120 sorted = TRUE;
00121 for (j = 0; j < NumListaEscoamento - 1; j++)
00122 {
00123 if (ListaEscoamento[j].param < ListaEscoamento[j + 1].param)
00124 {
00125 optr = ListaEscoamento[j].optr;
00126 ListaEscoamento[j].optr = ListaEscoamento[j + 1].optr;
00127 ListaEscoamento[j + 1].optr = optr;
00128 temp = ListaEscoamento[j].param;
00129 ListaEscoamento[j].param = ListaEscoamento[j + 1].param;
00130 ListaEscoamento[j + 1].param = temp;
00131 veccopy(vec, ListaEscoamento[j].cg);
00132 veccopy(ListaEscoamento[j].cg, ListaEscoamento[j + 1].cg);
00133 veccopy(ListaEscoamento[j + 1].cg, vec);
00134 sorted = FALSE;
00135 }
00136 }
00137 }
00138 return(TRUE);
00139 }
00140
00141 int MSD_lowCriaListaEstudo(real dx, real dy, real dz)
00142 {
00143 SPTYPE optr;
00144 vector dir, cg, ref;
00145 int cont;
00146
00147 cont = 0;
00148 for (AllSolids(optr))
00149 {
00150 if ((SolPerfil(optr) != -1) || (SolType(optr) == SOLIDO_TIPO_SOLID))
00151 {
00152 cont++;
00153 }
00154 }
00155
00156 if (NumListaEscoamento != 0)
00157 {
00158 free((char *)ListaEscoamento);
00159 }
00160 if ((ListaEscoamento = (LOPType *)malloc(cont * sizeof(LOPType))) ==
00161 (LOPType *)NIL)
00162 {
00163 fprintf(stderr, MEN_NaoPossuiMemoria, NAM_RovOrdena);
00164 return(ERROR);
00165 }
00166 NumListaEscoamento = cont;
00167 makevec(dir, dx, dy, dz, 1.0);
00168 makevec(ref, 0.0, 0.0, 0.0, 1.0);
00169
00170 cont = 0;
00171 for (AllSolids(optr))
00172 {
00173 if ((SolPerfil(optr) == -1) && (SolType(optr) != SOLIDO_TIPO_SOLID))
00174 {
00175 continue;
00176 }
00177 MSD_lowCentroDeGravidade(optr, cg);
00178 veccopy(ListaEscoamento[cont].cg, cg);
00179 ListaEscoamento[cont].optr = optr;
00180 ListaEscoamento[cont++].param =
00181 MSD_determinaDistanciaParametrica(ref, dir, cg);
00182 }
00183 return(TRUE);
00184 }
00185
00186 int MSD_lowSetVariaveisImpressao(int i, int j, char *TSolido, char *TFronteira,
00187 char *TGeometria, char *TAtitude,
00188 real dx, real dy, real dz, int flag)
00189 {
00190 vector dir, dirp1, dirp2;
00191
00192 switch (SolType(ListaEscoamento[i].optr))
00193 {
00194 case SOLIDO_TIPO_BARRA:
00195 strcpy(TSolido, "BARRA");
00196 strcat(TSolido, flag == 1 ? "-V" : "-R");
00197
00198 makevec(dir, dx, dy, dz, 1.0);
00199
00200 veccopy(dirp1, SolPrincDir(ListaEscoamento[i].optr));
00201 MSD_lowRebatePontoNoPlano(dirp1, dirp1, dir);
00202 veccopy(dirp2, SolPrincDir(ListaEscoamento[j].optr));
00203 MSD_lowRebatePontoNoPlano(dirp2, dirp2, dir);
00204 cross(dir, dirp2, dirp1);
00205 if (vecnull(dir, EPS))
00206 {
00207 strcpy(TAtitude, "NORMAL");
00208 strcat(TAtitude, flag == 1 ? "-V" : "-R");
00209 }
00210 else
00211 {
00212 strcpy(TAtitude, "OBLIQUA");
00213 strcat(TAtitude, flag == 1 ? "-V" : "-R");
00214 }
00215
00216 switch (SolGeometria(ListaEscoamento[i].optr))
00217 {
00218 case BARRA_GEOM_CIRCULO:
00219 strcpy(TGeometria, "CIRCULO");
00220 strcat(TGeometria, flag == 1 ? "-V" : "-R");
00221 strcpy(TFronteira, "ARREDONDADO");
00222 strcat(TFronteira, flag == 1 ? "-V" : "-R");
00223 break;
00224
00225 case BARRA_GEOM_QUADRADO:
00226 strcpy(TGeometria, "QUADRADO");
00227 strcat(TGeometria, flag == 1 ? "-V" : "-R");
00228 strcpy(TFronteira, "CANTOS-VIVOS");
00229 strcat(TFronteira, flag == 1 ? "-V" : "-R");
00230 break;
00231
00232 case BARRA_GEOM_TRIANGULO:
00233 strcpy(TGeometria, "TRIANGULO");
00234 strcat(TGeometria, flag == 1 ? "-V" : "-R");
00235 strcpy(TFronteira, "CANTOS-VIVOS");
00236 strcat(TFronteira, flag == 1 ? "-V" : "-R");
00237 break;
00238
00239 case BARRA_GEOM_RETANGULO:
00240 strcpy(TGeometria, "RETANGULO");
00241 strcat(TGeometria, flag == 1 ? "-V" : "-R");
00242 strcpy(TFronteira, "CANTOS-VIVOS");
00243 strcat(TFronteira, flag == 1 ? "-V" : "-R");
00244 break;
00245
00246 case BARRA_GEOM_ELIPSE:
00247 strcpy(TGeometria, "ELIPSE");
00248 strcat(TGeometria, flag == 1 ? "-V" : "-R");
00249 strcpy(TFronteira, "ARREDONDADO");
00250 strcat(TFronteira, flag == 1 ? "-V" : "-R");
00251 break;
00252
00253 case BARRA_GEOM_PERFIL_L:
00254 strcpy(TGeometria, "PERFIL-L");
00255 strcat(TGeometria, flag == 1 ? "-V" : "-R");
00256 strcpy(TFronteira, "CANTOS-VIVOS");
00257 strcat(TFronteira, flag == 1 ? "-V" : "-R");
00258 break;
00259
00260 case BARRA_GEOM_PERFIL_T:
00261 strcpy(TGeometria, "PERFIL-T");
00262 strcat(TGeometria, flag == 1 ? "-V" : "-R");
00263 strcpy(TFronteira, "CANTOS-VIVOS");
00264 strcat(TFronteira, flag == 1 ? "-V" : "-R");
00265 break;
00266
00267 case BARRA_GEOM_PERFIL_I:
00268 strcpy(TGeometria, "PERFIL-I");
00269 strcat(TGeometria, flag == 1 ? "-V" : "-R");
00270 strcpy(TFronteira, "CANTOS-VIVOS");
00271 strcat(TFronteira, flag == 1 ? "-V" : "-R");
00272 break;
00273
00274 default:
00275 return(ERROR);
00276 }
00277 break;
00278
00279 case SOLIDO_TIPO_SOLID:
00280 strcpy(TSolido, "SOLIDO");
00281 strcat(TSolido, flag == 1 ? "-V" : "-R");
00282 strcpy(TAtitude, "");
00283
00284 switch (SolGeometria(ListaEscoamento[i].optr))
00285 {
00286 case SOLIDO_GEOM_CUBO:
00287 strcpy(TGeometria, "CUBO");
00288 strcat(TGeometria, flag == 1 ? "-V" : "-R");
00289 strcpy(TFronteira, "CANTOS-VIVOS");
00290 strcat(TFronteira, flag == 1 ? "-V" : "-R");
00291 break;
00292
00293 case SOLIDO_GEOM_CONE:
00294 strcpy(TGeometria, "CONE");
00295 strcat(TGeometria, flag == 1 ? "-V" : "-R");
00296 makevec(dir, dx, dy, dz, 1.0);
00297 cross(dir, dir, SolPrincDir(ListaEscoamento[i].optr));
00298 if (comp(dot(dir, dir), 0.0, 0.01) == 0)
00299 {
00300 strcpy(TFronteira, "CANTOS-VIVOS");
00301 strcat(TFronteira, flag == 1 ? "-V" : "-R");
00302 }
00303 else
00304 {
00305 strcpy(TFronteira, "ARREDONDADO");
00306 strcat(TFronteira, flag == 1 ? "-V" : "-R");
00307 }
00308 break;
00309
00310 case SOLIDO_GEOM_ESFERA:
00311 strcpy(TGeometria, "ESFERA");
00312 strcat(TGeometria, flag == 1 ? "-V" : "-R");
00313 strcpy(TFronteira, "ARREDONDADO");
00314 strcat(TFronteira, flag == 1 ? "-V" : "-R");
00315 break;
00316
00317 case SOLIDO_GEOM_PRISMA:
00318 strcpy(TGeometria, "PRISMA");
00319 strcat(TGeometria, flag == 1 ? "-V" : "-R");
00320 strcpy(TFronteira, "CANTOS-VIVOS");
00321 strcat(TFronteira, flag == 1 ? "-V" : "-R");
00322 break;
00323
00324 case SOLIDO_GEOM_PIRAMIDE:
00325 strcpy(TGeometria, "PIRAMIDE");
00326 strcat(TGeometria, flag == 1 ? "-V" : "-R");
00327 strcpy(TFronteira, "CANTOS-VIVOS");
00328 strcat(TFronteira, flag == 1 ? "-V" : "-R");
00329 break;
00330
00331 default:
00332 break;
00333 }
00334 break;
00335
00336 case SOLIDO_TIPO_PLACA:
00337 strcpy(TSolido, "PLACA");
00338 strcat(TSolido, flag == 1 ? "-V" : "-R");
00339
00340 makevec(dir, dx, dy, dz, 1.0);
00341 if (comp(dot(dir, SolPrincDir(ListaEscoamento[i].optr)), 0.0, 0.01) == 0)
00342 {
00343 strcpy(TAtitude, "TANGENTE");
00344 strcat(TAtitude, flag == 1 ? "-V" : "-R");
00345 }
00346 else
00347 {
00348 strcpy(TAtitude, "NORMAL");
00349 strcat(TAtitude, flag == 1 ? "-V" : "-R");
00350 }
00351 strcpy(TGeometria, "");
00352 strcpy(TFronteira, "CANTOS-VIVOS");
00353 strcat(TFronteira, flag == 1 ? "-V" : "-R");
00354 break;
00355
00356 default:
00357 return(ERROR);
00358 }
00359 return(TRUE);
00360 }
00361
00362 int MSD_lowCalculaDimensoesRelativas(int i, int j, real *LD, real *TD,
00363 real dx, real dy, real dz)
00364 {
00365 real L, T, D, param;
00366 vector dir, dir_L;
00367
00368 makevec(dir, dx, dy, dz, 1.0);
00369 param = MSD_determinaDistanciaParametrica(ListaEscoamento[j].cg, dir,
00370 ListaEscoamento[i].cg);
00371 vecesc(dir_L, dir, param);
00372 L = sqrt(dot(dir_L, dir_L));
00373
00374 vecplus(dir_L, dir_L, ListaEscoamento[j].cg);
00375 vecminus(dir_L, dir_L, ListaEscoamento[i].cg);
00376 T = sqrt(dot(dir_L, dir_L));
00377
00378 D = (ListaEscoamento[i].D + ListaEscoamento[j].D) * 0.5;
00379 *LD = L / D;
00380 *TD = T / D;
00381 return(TRUE);
00382 }
00383
00384 int MSD_lowImprimeListaEstudo(char *nome, real raio, real dx, real dy, real dz)
00385 {
00386 SPTYPE sp;
00387 char nome1[20], nome2[20];
00388 char TSolidoInterfere[20];
00389 char TSolidoEstudo[20];
00390 char TFronteiraInterfere[20];
00391 char TFronteiraEstudo[20];
00392 char TGeometriaInterfere[20];
00393 char TGeometriaEstudo[20];
00394 char TAtitudeInterfere[20];
00395 char TAtitudeEstudo[20];
00396 real LD, TD, area, dim, alfa, beta, gama;
00397 FILE *fp, *fpin;
00398 vector dir, axs;
00399 int i, j, flag, linecount = 0;
00400
00401 if ((fp = fopen("lista.tmp", "w")) == (FILE *)NIL)
00402 {
00403 fprintf(stderr, "Nao conseguiu abrir arquivo lista.tmp!\n");
00404 return(ERROR);
00405 }
00406
00407 for (i = 0; i < NumListaEscoamento; i++)
00408 {
00409 flag = 0;
00410 if (SolType(ListaEscoamento[i].optr) == SOLIDO_TIPO_BARRA)
00411 {
00412 makevec(dir, dx, dy, dz, 1.0);
00413 if ((sp = MSD_getSolid(SolPerfil(ListaEscoamento[i].optr))) == SNIL)
00414 {
00415 fprintf(stderr, "Nao encontrou o perfil\n");
00416 exit(1);
00417 }
00418 cross(dir, FacFeq(MSD_getFace(sp, 1)), dir);
00419 if (vecnull(dir, EPS))
00420 {
00421 flag = 1;
00422 }
00423 }
00424 if (flag == 1)
00425 {
00426 continue;
00427 }
00428
00429 for (flag = j = 0; j < NumListaEscoamento; j++)
00430 {
00431
00432
00433
00434 if (i == j)
00435 {
00436 continue;
00437 }
00438 if (comp(ListaEscoamento[i].param, ListaEscoamento[j].param, 0.01) == -1)
00439 {
00440 continue;
00441 }
00442 if (vecd(ListaEscoamento[i].cg, ListaEscoamento[j].cg) >
00443 raio * ListaEscoamento[i].D)
00444 {
00445 continue;
00446 }
00447
00448 MSD_lowSetVariaveisImpressao(i, j, TSolidoEstudo, TFronteiraEstudo,
00449 TGeometriaEstudo, TAtitudeEstudo, dx, dy, dz, 0);
00450
00451 MSD_lowCalculaDimensoesRelativas(i, j, &LD, &TD, dx, dy, dz);
00452 MSD_lowSetVariaveisImpressao(j, i, TSolidoInterfere, TFronteiraInterfere,
00453 TGeometriaInterfere, TAtitudeInterfere,
00454 dx, dy, dz, 1);
00455 strcpy(nome1, SolName(ListaEscoamento[i].optr));
00456 strcpy(nome2, SolName(ListaEscoamento[j].optr));
00457 fprintf(fp, MSD_formatImpressao, nome1, nome2,
00458 ListaEscoamento[i].area,
00459 ListaEscoamento[i].H_D,
00460 TSolidoInterfere, TFronteiraInterfere,
00461 TGeometriaInterfere, TAtitudeInterfere,
00462 TSolidoEstudo, TFronteiraEstudo,
00463 TGeometriaEstudo, TAtitudeEstudo,
00464 LD, TD);
00465 linecount++;
00466 flag = 1;
00467 }
00468 if (flag == 0)
00469 {
00470 MSD_lowSetVariaveisImpressao(i, i, TSolidoEstudo, TFronteiraEstudo,
00471 TGeometriaEstudo, TAtitudeEstudo, dx, dy, dz, 0);
00472
00473 fprintf(fp, "(%s %s %.2f %.2f MSD SOZINHO %s %s %s %s)\n",
00474 SolName(ListaEscoamento[i].optr),
00475 SolName(ListaEscoamento[i].optr),
00476 ListaEscoamento[i].area,
00477 ListaEscoamento[i].H_D,
00478 TSolidoEstudo, TFronteiraEstudo,
00479 TGeometriaEstudo, TAtitudeEstudo);
00480 linecount++;
00481 }
00482 }
00483 fclose(fp);
00484
00485 area = 0;
00486 dim = 0;
00487
00488 if ((fp = fopen(nome, "w")) == (FILE *)NIL)
00489 {
00490 fprintf(stderr, "Nao conseguiu abrir arquivo %s!\n", nome);
00491 return(ERROR);
00492 }
00493 if ((fpin = fopen("lista.tmp", "r")) == (FILE *)NIL)
00494 {
00495 fprintf(stderr, "Nao conseguiu abrir arquivo lista.tmp!\n");
00496 return(ERROR);
00497 }
00498 fprintf(fp, "%d\n", linecount);
00499
00500 makevec(dir, dx, dy, 0.0, 1.0);
00501 normalize(dir);
00502 makevec(axs, 1.0, 0.0, 0.0, 1.0);
00503 alfa = acos(dot(dir, axs)) * 180.0 / 3.1416;
00504 makevec(dir, 0.0, dy, dz, 1.0);
00505 normalize(dir);
00506 makevec(axs, 0.0, 1.0, 0.0, 1.0);
00507 beta = acos(dot(dir, axs)) * 180.0 / 3.1416;
00508 makevec(dir, dx, 0.0, dz, 1.0);
00509 normalize(dir);
00510 makevec(axs, 0.0, 0.0, 1.0, 1.0);
00511 gama = acos(dot(dir, axs)) * 180.0 / 3.1416;
00512
00513 fprintf(fp, "%.2f %.2f %.2f\n", alfa, beta, gama);
00514 fprintf(fp, "%.2f %.2f\n", area, dim);
00515
00516 while (!feof(fpin))
00517 {
00518 fputc(fgetc(fpin), fp);
00519 }
00520
00521 fclose(fpin);
00522 fclose(fp);
00523 remove("lista.tmp");
00524
00525 return(TRUE);
00526 }
00527
00528 int MSD_CalculaParametrosInterferencia(real dx, real dy, real dz)
00529 {
00530 int i;
00531 real H, D, area, dim;
00532 vector dir;
00533
00534 for (i = 0; i < NumListaEscoamento; i++)
00535 {
00536
00537 MSD_lowAreaProjetada(ListaEscoamento[i].optr, dx, dy, dz, &area, &dim, 1);
00538 ListaEscoamento[i].area = area;
00539
00540
00541 makevec(dir, dx, dy, dz, 1.0);
00542 D = MSD_determinaDimensaoPrincipal(ListaEscoamento[i].optr, dir, dim);
00543 H = MSD_determinaMaiorDimensao(ListaEscoamento[i].optr);
00544 ListaEscoamento[i].D = D;
00545 ListaEscoamento[i].H_D = H / D;
00546 }
00547 return(TRUE);
00548 }
00549
00550 int MSD_lowAreaProjetadaTotal(real dx, real dy, real dz, real *area, real *dim)
00551 {
00552 SPTYPE optr;
00553 SPTYPE sp;
00554 real sa, sd;
00555 vector normal;
00556 char aa[5] = "st";
00557 char bb[5] = "er";
00558
00559 makevec(normal, 0.0, 0.0, 1.0, 0.0);
00560 for (AllSolids(optr))
00561 {
00562 if ((SolPerfil(optr) != -1) || (SolType(optr) == SOLIDO_TIPO_SOLID))
00563 {
00564 MSD_lowAreaProjetada(optr, dx, dy, dz, &sa, &sd, 0);
00565
00566 MSD_highNameDisplay("cam", aa);
00567 fprintf(stderr, "--> solid %s\n", SolName(optr));
00568 if (MSD_getSolidIdFromName("er") == -1)
00569 {
00570 MSD_highNameRenameSolid("st", "er");
00571 }
00572 else
00573 {
00574 MSD_highNameUnion("st", "er", "un");
00575 MSD_highNameRenameSolid("un", "er");
00576 }
00577 g_clear();
00578 MSD_highNameDisplay("cam", bb);
00579 }
00580 }
00581
00582 sp = MSD_lowFindSolidByName("er");
00583 *area = MSD_lowSolidAreaProjetada(sp);
00584 *dim = MSD_lowSolidDimensaoPrincipal(sp, normal);
00585 MSD_highNameSoftRemove("er");
00586 return(TRUE);
00587 }
00588
00589 int MSD_lowOrdena(char *nome, real raio, real dx, real dy, real dz)
00590 {
00591 if (MSD_lowCriaListaEstudo(dx, dy, dz) == ERROR)
00592 {
00593 return(ERROR);
00594 }
00595 MSD_lowOrdenaListaEstudo();
00596 MSD_CalculaParametrosInterferencia(dx, dy, dz);
00597 MSD_lowImprimeListaEstudo(nome, raio, dx, dy, dz);
00598 return(TRUE);
00599 }