1 #include "MeshCut_Utils.hxx"
10 using namespace MESHCUT;
12 //string pathUsers = (string) "/var/www/XMeshLab/users/";
14 bool MESHCUT::estUnTypeMaille(std::string S)
16 if (S == (string) "POI1" || S == (string) "SEG2" || S == (string) "SEG3" || S == (string) "TRIA3" || S
17 == (string) "TRIA6" || S == (string) "QUAD4" || S == (string) "QUAD8" || S == (string) "QUAD9" || S
18 == (string) "TETRA4" || S == (string) "TETRA10" || S == (string) "PYRAM5" || S == (string) "PYRAM13" || S
19 == (string) "PENTA6" || S == (string) "PENTA15" || S == (string) "HEXA8" || S == (string) "HEXA20" || S
26 void MESHCUT::ERREUR(const char* msg)
28 cout << endl << "====== ERREUR ====== " << msg << endl << endl;
32 char* MESHCUT::string2char(std::string str)
34 // créer le buffer pour copier la chaîne
35 size_t size = str.size() + 1;
36 char* buffer = new char[size];
38 strncpy(buffer, str.c_str(), size);
46 std::string MESHCUT::int2string(int k)
48 std::stringstream oss;
50 return oss.str(); // oss.seekp (ios_base::beg);
53 float MESHCUT::char2float(const char* ch)
58 std::string MESHCUT::float2string(float f)
66 bool MESHCUT::appartient(std::string e, std::string tableau[], int taille)
68 for (int i = 0; i < taille; i++)
74 float MESHCUT::arrondi(float x)
76 if (x > 0 and x < 1.0e-5)
78 else if (x < 0 and x > -1.0e-5)
84 int MESHCUT::numNoeudPointe(std::string b1, std::string b2, std::string b3)
86 if (b1 == "1" && b2 == "1" && b3 == "2")
88 else if (b1 == "1" && b2 == "2" && b3 == "1")
90 else if (b1 == "1" && b2 == "2" && b3 == "2")
92 else if (b1 == "2" && b2 == "1" && b3 == "1")
94 else if (b1 == "2" && b2 == "1" && b3 == "2")
96 else if (b1 == "2" && b2 == "2" && b3 == "1")
102 std::string MESHCUT::strip(std::string S)
106 int startIndex = S.find_first_not_of(" ");
107 int endIndex = S.find_last_not_of(" ");
108 return S.substr(startIndex, (endIndex - startIndex + 1));
111 std::string MESHCUT::entierSur10_g(int i)
114 ERREUR("Tentative d'ecriture sur 10 caracteres d'un entier plus grand que 999999999");
116 return int2string(i) + (string) " ";
118 return int2string(i) + (string) " ";
120 return int2string(i) + (string) " ";
122 return int2string(i) + (string) " ";
124 return int2string(i) + (string) " ";
125 else if (i < 1000000)
126 return int2string(i) + (string) " ";
127 else if (i < 10000000)
128 return int2string(i) + (string) " ";
129 else if (i < 100000000)
130 return int2string(i) + (string) " ";
131 else if (i < 1000000000)
132 return int2string(i) + (string) " ";
134 return int2string(i);
137 std::string MESHCUT::entierSur10_d(int i)
140 ERREUR("Tentative d'ecriture sur 10 caracteres d'un entier plus grand que 999999999");
142 return (string) " " + int2string(i);
144 return (string) " " + int2string(i);
146 return (string) " " + int2string(i);
148 return (string) " " + int2string(i);
150 return (string) " " + int2string(i);
151 else if (i < 1000000)
152 return (string) " " + int2string(i);
153 else if (i < 10000000)
154 return (string) " " + int2string(i);
155 else if (i < 100000000)
156 return (string) " " + int2string(i);
157 else if (i < 1000000000)
158 return (string) " " + int2string(i);
160 return int2string(i);
163 std::string MESHCUT::typeEnsight(std::string type)
165 if (type == (string) "POI1")
166 return (string) "point";
167 else if (type == (string) "SEG2")
168 return (string) "bar2";
169 else if (type == (string) "SEG3")
170 return (string) "bar2";// ATTENTION, triche!
171 else if (type == (string) "TRIA3")
172 return (string) "tria3";
173 else if (type == (string) "TRIA6")
174 return (string) "tria3";// ATTENTION, triche!
175 else if (type == (string) "QUAD4")
176 return (string) "quad4";
177 else if (type == (string) "QUAD8")
178 return (string) "quad4"; // ATTENTION, triche!
179 else if (type == (string) "QUAD9")
180 ERREUR("Type QUAD9 non supporte par Ensight");
181 else if (type == (string) "TETRA4")
182 return (string) "tetra4";
183 else if (type == (string) "TETRA10")
184 return (string) "tetra4"; // ATTENTION, triche!
185 else if (type == (string) "PYRAM5")
186 return (string) "pyramid5";
187 else if (type == (string) "PYRAM13")
188 return (string) "pyramid5"; // ATTENTION, triche!
189 else if (type == (string) "PENTA6")
190 return (string) "penta6";
191 else if (type == (string) "PENTA15")
192 return (string) "penta6"; // ATTENTION, triche!
193 else if (type == (string) "HEXA8")
194 return (string) "hexa8";
195 else if (type == (string) "HEXA20")
196 return (string) "hexa8"; // ATTENTION, triche!
197 else if (type == (string) "HEXA27")
198 ERREUR("Type HEXA27 non supporte par Ensight");
200 ERREUR("Type maille non reconnu (routine \"typeEnsight\"");
204 int MESHCUT::Nnoeuds(TYPE_MAILLE type)
243 //case QUAD9: { return 9; break; }
284 //case HEXA27: { return 27; break; }
286 ERREUR("Type maille non reconnu (routine Nnoeuds)");
291 int MESHCUT::NnoeudsGeom(TYPE_MAILLE type)
330 //case QUAD9: { return 9; break; }
371 //case HEXA27: { return 27; break; }
373 ERREUR("Type maille non reconnu (routine NnoeudsGeom)");
378 int MESHCUT::codeGMSH(std::string type)
380 if (type == (string) "POI1")
381 ERREUR("POI1 non pris en charge par GMSH");
382 else if (type == (string) "SEG2")
384 else if (type == (string) "SEG3")
386 else if (type == (string) "TRIA3")
388 else if (type == (string) "TRIA6")
390 else if (type == (string) "QUAD4")
392 else if (type == (string) "QUAD8")
394 else if (type == (string) "QUAD9")
396 else if (type == (string) "TETRA4")
398 else if (type == (string) "TETRA10")
400 else if (type == (string) "PYRAM5")
402 else if (type == (string) "PENTA6")
404 else if (type == (string) "PENTA15")
406 else if (type == (string) "HEXA8")
408 else if (type == (string) "HEXA20")
410 else if (type == (string) "HEXA27")
413 ERREUR("Type maille non reconnu (routine codeGMSH)");
417 std::string MESHCUT::floatEnsight(float x)
422 sprintf(buf, "%1.5E", x);
424 sprintf(buf, " %1.5E", x);
430 bool MESHCUT::typeComplexe(std::string type)
432 if (type == (string) "SEG3")
434 else if (type == (string) "TRIA6")
436 else if (type == (string) "QUAD8")
438 else if (type == (string) "QUAD9")
440 else if (type == (string) "TETRA10")
442 else if (type == (string) "PYRAM13")
444 else if (type == (string) "PENTA15")
446 else if (type == (string) "HEXA20")
448 else if (type == (string) "HEXA27")
454 std::string MESHCUT::ASTER8(std::string s)
457 return (s + (string) " ");
458 else if (s.size() == 1)
459 return (s + (string) " ");
460 else if (s.size() == 2)
461 return (s + (string) " ");
462 else if (s.size() == 3)
463 return (s + (string) " ");
464 else if (s.size() == 4)
465 return (s + (string) " ");
466 else if (s.size() == 5)
467 return (s + (string) " ");
468 else if (s.size() == 6)
469 return (s + (string) " ");
470 else if (s.size() == 7)
471 return (s + (string) " ");
472 else if (s.size() == 8)
475 ERREUR("Depassement de la longueur max 8 pour une chaine ASTER");
480 * Distance à laquelle doit se tenir l'observateur sur un axe
481 * pour voir sous 90° un objet centré de dimensions a et b selon les deux autres axes.
482 * Si on ne tient pas compte de la dimension de l'objet selon l'axe choisi,
483 * la formule d_obs=max(a,b)/2 donne la cote
484 * qui permet de voir l'objet plat dans un angle de 90°.
485 * A cela il faut ajouter la dimension de l'objet selon l'axe d'observation = c.
487 * @param a dimensions de l'objet selon un des axes normal à l'axe d'observation
488 * @param b dimensions de l'objet selon l'autre axe normal à l'axe d'observation
489 * @param c est la dimension de l'objet selon l'axe d'observation
491 float MESHCUT::dObservateur(float a, float b, float c)
493 return (max(a, b) / 2.0 + c);
496 int MESHCUT::copieFichier(std::string source, std::string cible)
498 FILE *fsource, *fcible;
501 if ((fsource = fopen(string2char(source), "rb")) == NULL)
503 if ((fcible = fopen(string2char(cible), "wb")) == NULL)
508 while ((NbLu = fread(buffer, 1, 512, fsource)) != 0)
509 fwrite(buffer, 1, NbLu, fcible);
515 med_geometry_type MESHCUT::InstanceMGE(TYPE_MAILLE TYPE)
517 med_geometry_type typeBanaliseMED;
522 typeBanaliseMED = MED_POINT1;
523 break; // Attention, piège !
525 typeBanaliseMED = MED_SEG2;
528 typeBanaliseMED = MED_SEG3;
531 typeBanaliseMED = MED_TRIA3;
534 typeBanaliseMED = MED_TRIA6;
537 typeBanaliseMED = MED_QUAD4;
540 typeBanaliseMED = MED_QUAD8;
543 typeBanaliseMED = MED_TETRA4;
546 typeBanaliseMED = MED_TETRA10;
549 typeBanaliseMED = MED_PYRA5;
550 break; // Attention, piège !
552 typeBanaliseMED = MED_PYRA13;
553 break; // Attention, piège !
555 typeBanaliseMED = MED_PENTA6;
558 typeBanaliseMED = MED_PENTA15;
561 typeBanaliseMED = MED_HEXA8;
564 typeBanaliseMED = MED_HEXA20;
567 ERREUR("Routine InstanceMGE, type inconnu ");
569 return typeBanaliseMED;
572 int MESHCUT::chrono()
574 return clock() / CLOCKS_PER_SEC;
577 TYPE_MAILLE MESHCUT::typeMaille(std::string type)
579 if (type == (string) "POI1")
581 else if (type == (string) "SEG2")
583 else if (type == (string) "SEG3")
585 else if (type == (string) "TRIA3")
587 else if (type == (string) "TRIA6")
589 else if (type == (string) "QUAD4")
591 else if (type == (string) "QUAD8")
593 else if (type == (string) "TETRA4")
595 else if (type == (string) "TETRA10")
597 else if (type == (string) "PYRAM5")
599 else if (type == (string) "PYRAM13")
601 else if (type == (string) "PENTA6")
603 else if (type == (string) "PENTA15")
605 else if (type == (string) "HEXA8")
607 else if (type == (string) "HEXA20")
610 ERREUR("ERREUR procédure typeMaille, type non reconnu");
614 std::string MESHCUT::MGE2string(med_geometry_type MGE)
617 return (string) "NOEUD";
618 else if (MGE == MED_POINT1)
619 return (string) "POI1";
620 else if (MGE == MED_SEG2)
621 return (string) "SEG2";
622 else if (MGE == MED_SEG3)
623 return (string) "SEG3";
624 else if (MGE == MED_TRIA3)
625 return (string) "TRIA3";
626 else if (MGE == MED_TRIA6)
627 return (string) "TRIA6";
628 else if (MGE == MED_QUAD4)
629 return (string) "QUAD4";
630 else if (MGE == MED_QUAD8)
631 return (string) "QUAD8";
632 else if (MGE == MED_TETRA4)
633 return (string) "TETRA4";
634 else if (MGE == MED_TETRA10)
635 return (string) "TETRA10";
636 else if (MGE == MED_PYRA5)
637 return (string) "PYRAM5";
638 else if (MGE == MED_PYRA13)
639 return (string) "PYRAM13";
640 else if (MGE == MED_PENTA6)
641 return (string) "PENTA6";
642 else if (MGE == MED_PENTA15)
643 return (string) "PENTA15";
644 else if (MGE == MED_HEXA8)
645 return (string) "HEXA8";
646 else if (MGE == MED_HEXA20)
647 return (string) "HEXA20";
649 ERREUR("ERREUR procédure MGE2string, type non reconnu");
650 return (string) "NOEUD";
653 std::string MESHCUT::TM2string(TYPE_MAILLE MGE)
656 return (string) "POI1";
657 else if (MGE == SEG2)
658 return (string) "SEG2";
659 else if (MGE == SEG3)
660 return (string) "SEG3";
661 else if (MGE == TRIA3)
662 return (string) "TRIA3";
663 else if (MGE == TRIA6)
664 return (string) "TRIA6";
665 else if (MGE == QUAD4)
666 return (string) "QUAD4";
667 else if (MGE == QUAD8)
668 return (string) "QUAD8";
669 else if (MGE == TETRA4)
670 return (string) "TETRA4";
671 else if (MGE == TETRA10)
672 return (string) "TETRA10";
673 else if (MGE == PYRAM5)
674 return (string) "PYRAM5";
675 else if (MGE == PYRAM13)
676 return (string) "PYRAM13";
677 else if (MGE == PENTA6)
678 return (string) "PENTA6";
679 else if (MGE == PENTA15)
680 return (string) "PENTA15";
681 else if (MGE == HEXA8)
682 return (string) "HEXA8";
683 else if (MGE == HEXA20)
684 return (string) "HEXA20";
686 ERREUR("ERREUR procédure TM2string, type non reconnu");
687 return (string) "POI1";
690 TYPE_MAILLE MESHCUT::string2TM(std::string stm)
692 if (stm == (string) "POI1")
694 else if (stm == (string) "SEG2")
696 else if (stm == (string) "SEG3")
698 else if (stm == (string) "TRIA3")
700 else if (stm == (string) "TRIA6")
702 else if (stm == (string) "QUAD4")
704 else if (stm == (string) "QUAD8")
706 else if (stm == (string) "TETRA4")
708 else if (stm == (string) "TETRA10")
710 else if (stm == (string) "PYRAM5")
712 else if (stm == (string) "PYRAM13")
714 else if (stm == (string) "PENTA6")
716 else if (stm == (string) "PENTA15")
718 else if (stm == (string) "HEXA8")
720 else if (stm == (string) "HEXA20")
723 ERREUR("ERREUR procédure string2TM, type non reconnu");
727 std::string MESHCUT::coordIndex_ILS(TYPE_MAILLE tm)
730 return (string) " 0,1 ";
732 return (string) " 0,1 "; // Idem SEG2
733 else if (tm == TRIA3)
734 return (string) " 0,1,2,0 ";
735 else if (tm == TRIA6)
736 return (string) " 0,1,2,0 ";
737 else if (tm == QUAD4)
738 return (string) " 0,1,2,3,0 ";
739 else if (tm == QUAD8)
740 return (string) " 0,1,2,3,0 ";
741 else if (tm == TETRA4)
742 return (string) " 0,1,2,0,-1, 0,3,-1, 1,3,-1, 2,3,-1 ";
743 else if (tm == TETRA10)
744 return (string) " 0,1,2,0,-1, 0,3,-1, 1,3,-1, 2,3,-1 ";
745 else if (tm == PYRAM5)
746 return (string) " 0,1,2,3,0,-1, 0,4,-1, 1,4,-1, 2,4,-1, 3,4,-1 ";
747 else if (tm == PYRAM13)
748 return (string) " 0,1,2,3,0,-1, 0,4,-1, 1,4,-1, 2,4,-1, 3,4,-1 ";
749 else if (tm == PENTA6)
750 return (string) " 0,1,2,0,-1, 3,4,5,3,-1, 0,3,-1, 1,4,-1, 2,5,-1 ";
751 else if (tm == PENTA15)
752 return (string) " 0,1,2,0,-1, 3,4,5,3,-1, 0,3,-1, 1,4,-1, 2,5,-1 ";
753 else if (tm == HEXA8)
754 return (string) " 0,1,2,3,0,-1, 4,5,6,7,4,-1, 0,4,-1, 1,5,-1, 2,6,-1, 3,7,-1 ";
755 else if (tm == HEXA20)
756 return (string) " 0,1,2,3,0,-1, 4,5,6,7,4,-1, 0,4,-1, 1,5,-1, 2,6,-1, 3,7,-1 ";
761 std::string MESHCUT::coordIndex_IFS(TYPE_MAILLE tm)
766 return (string) " "; // Idem SEG2
767 else if (tm == TRIA3)
768 return (string) " 0,1,2,0,-1, 0,2,1,0,-1 ";
769 else if (tm == TRIA6)
770 return (string) " 0,1,2,0,-1, 0,2,1,0,-1 ";
771 else if (tm == QUAD4)
772 return (string) " 0,1,2,3,0,-1, 0,3,2,1,0,-1 ";
773 else if (tm == QUAD8)
774 return (string) " 0,1,2,3,0,-1, 0,3,2,1,0,-1 ";
775 else if (tm == TETRA4)
776 return (string) " 0,1,2,0,-1, 0,2,1,0,-1, 0,3,1,0,-1, 0,1,3,0,-1, 1,3,2,1,-1, 1,2,3,1,-1, 0,2,3,0,-1, 0,3,2,0,-1 ";
777 else if (tm == TETRA10)
778 return (string) " 0,1,2,0,-1, 0,2,1,0,-1, 0,3,1,0,-1, 0,1,3,0,-1, 1,3,2,1,-1, 1,2,3,1,-1, 0,2,3,0,-1, 0,3,2,0,-1 ";
779 else if (tm == PYRAM5)
780 return (string) " 0,1,2,3,0,-1, 0,3,2,1,0,-1, 0,1,4,0,-1, 0,4,1,0,-1, 1,2,4,1,-1, 1,4,2,1,-1, 2,4,3,2,-1, 2,3,4,2,-1, 3,4,0,3,-1, 3,0,4,3,-1 ";
781 else if (tm == PYRAM13)
782 return (string) " 0,1,2,3,0,-1, 0,3,2,1,0,-1, 0,1,4,0,-1, 0,4,1,0,-1, 1,2,4,1,-1, 1,4,2,1,-1, 2,4,3,2,-1, 2,3,4,2,-1, 3,4,0,3,-1, 3,0,4,3,-1 ";
783 else if (tm == PENTA6)
784 return (string) " 0,1,2,0,-1, 0,2,1,0,-1, 3,4,5,3,-1, 3,5,4,3,-1, 0,1,4,3,0,-1, 0,3,4,1,0,-1, 1,4,5,2,1,-1, 1,2,5,4,1,-1, 0,3,5,2,0,-1, 0,2,5,3,0,-1 ";
785 else if (tm == PENTA15)
786 return (string) " 0,1,2,0,-1, 0,2,1,0,-1, 3,4,5,3,-1, 3,5,4,3,-1, 0,1,4,3,0,-1, 0,3,4,1,0,-1, 1,4,5,2,1,-1, 1,2,5,4,1,-1, 0,3,5,2,0,-1, 0,2,5,3,0,-1 ";
787 else if (tm == HEXA8)
788 return (string) " 0,1,2,3,0,-1, 0,3,2,1,0,-1, 1,5,6,2,1,-1, 1,2,6,5,1,-1, 5,4,7,6,5,-1, 5,6,7,4,5,-1, 4,0,3,7,4,-1, 4,7,3,0,4,-1, 0,4,5,1,0,-1, 0,1,5,4,0,-1, 3,7,6,2,3,-1, 3,2,6,7,3,-1 ";
789 else if (tm == HEXA20)
790 return (string) " 0,1,2,3,0,-1, 0,3,2,1,0,-1, 1,5,6,2,1,-1, 1,2,6,5,1,-1, 5,4,7,6,5,-1, 5,6,7,4,5,-1, 4,0,3,7,4,-1, 4,7,3,0,4,-1, 0,4,5,1,0,-1, 0,1,5,4,0,-1, 3,7,6,2,3,-1, 3,2,6,7,3,-1 ";
795 std::string MESHCUT::SIGNE(double x)
805 void MESHCUT::champType(std::string type, med_entity_type MEM, med_geometry_type MGE, med_idt fid, med_idt fidout,
806 char *maa, char *nomChamp, char *nomChampMoy, med_field_type typeChamp, char *compChamp,
807 char *unitChamp, med_int nCompChamp, std::map<std::string, int> REFGAUSS, int ichamp)
811 int ipt, nmailles, ngauss, imaille, igauss, icomp;
813 med_int nval, numdt, numo, nPasTemps;
814 char dtunit[MED_SNAME_SIZE + 1] = "";
815 char locname[MED_NAME_SIZE + 1] = "";
816 char nomprofil[MED_NAME_SIZE + 1] = "";
818 med_float *valr = NULL;
819 med_float *valr2 = NULL;
822 med_field_type fieldType;
824 if (MEDfieldInfo(fid, ichamp, nomChamp, maa, &local, &fieldType, compChamp, unitChamp, dtunit, &nPasTemps) < 0)
825 ERREUR("Erreur MEDfieldInfo");
826 cout << type << " : " << (int) nPasTemps << " pas de temps " << endl;
828 for (ipt = 1; ipt <= nPasTemps; ipt++)
830 //for (ipt=1; ipt<=min(nPasTemps,1); ipt++) {
834 cout << "************************************************************" << endl;
836 cout << " CHAMP " << ichamp << endl;
838 cout << " " << nomChamp << endl;
840 cout << " " << type << " --- Pas de temps " << ipt << endl;
842 cout << "************************************************************" << endl;
846 if (MEDfieldComputingStepInfo(fid, nomChamp, ipt, &numdt, &numo, &dt) < 0)
849 cout << endl << "####################################################################" << endl;
850 cout << " ERREUR MEDpasdetempsInfo " << endl;
851 cout << endl << "####################################################################" << endl;
852 cout << " Champ: " << (string) nomChamp << endl;
853 cout << " Géométrie: " << MGE2string(MGE) << endl;
854 cout << " Pas de temps " << ipt << " ignoré" << endl;
859 med_int profilesize, nintegrationpoint;
860 nval = MEDfieldnValueWithProfile(fid, nomChamp, numdt, numo, MEM, MGE, ipt, MED_COMPACT_PFLMODE, nomprofil,
861 &profilesize, locname, &nintegrationpoint);
863 cout << " Nombre de valeurs dans ce pas de temps : " << (int) nval << endl;
865 if (typeChamp == MED_FLOAT64)
866 valr = (med_float*) calloc(nCompChamp * nval, sizeof(med_float));
868 ERREUR("Type de champ non pris en compte");
870 if (MEDfieldValueWithProfileRd(fid, maa, numdt, numo, MEM, MGE, MED_COMPACT_PFLMODE, nomprofil,
871 MED_FULL_INTERLACE, MED_ALL_CONSTITUENT, (unsigned char*) valr) < 0)
874 cout << endl << "####################################################################" << endl;
875 cout << " ERREUR MEDchampLire " << endl;
876 cout << endl << "####################################################################" << endl;
878 cout << " Champ: " << (string) nomChamp << endl;
879 cout << " Géométrie: " << MGE2string(MGE) << endl;
880 cout << " Pas de temps " << ipt << " ignoré" << endl;
881 cout << endl << endl;
886 cout << " profil = " << (string) nomprofil << endl;
887 // Localisation du champ aux points de Gauss
889 cout << " locname = " << (string) locname << endl;
891 if (REFGAUSS[(string) locname])
893 ngauss = REFGAUSS[(string) locname];
895 cout << " " << ngauss << " points de Gauss par élément)" << endl;
900 nmailles = nval / ngauss;
902 cout << " Nbre de mailles: " << nmailles << endl;
906 cout << endl << " Liste des valeurs du champ brut aux 3 premiers éléments:" << endl;
907 for (imaille = 0; imaille < min(nmailles, 3); imaille++)
909 cout << " Maille " << imaille << endl;
910 for (igauss = 0; igauss < ngauss; igauss++)
912 cout << " PG " << igauss << " : ";
913 for (icomp = 0; icomp < nCompChamp; icomp++)
914 cout << " " << *(valr + imaille * ngauss * nCompChamp + igauss * nCompChamp + icomp);
925 valr2 = (med_float*) calloc(nCompChamp * nmailles, sizeof(med_float));
928 cout << endl << " Moyenne sur les PG des mailles" << endl;
929 for (imaille = 0; imaille < nmailles; imaille++)
931 for (icomp = 0; icomp < nCompChamp; icomp++)
933 float valCompMaille = 0.0;
934 for (igauss = 0; igauss < ngauss; igauss++)
935 valCompMaille += *(valr + imaille * ngauss * nCompChamp + igauss * nCompChamp + icomp);
936 *(valr2 + imaille * nCompChamp + icomp) = valCompMaille / ngauss;
941 //cout << endl << "Nom champ moy = " << (string)nomChampMoy << endl;
942 //cout << endl << "Type champ = " << typeChamp << endl;
943 //cout << endl << "Comp champ = " << (string)compChamp << endl;
944 //cout << endl << "Unit champ = " << (string)unitChamp << endl;
945 //cout << endl << "N comp champ = " << nCompChamp << endl;
947 if (MEDfieldValueWithProfileWr(fidout, nomChampMoy, numdt, numo, dt, MEM, MGE, MED_COMPACT_PFLMODE,
948 nomprofil, MED_NO_LOCALIZATION, MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,
949 (med_int) nmailles, (unsigned char*) valr2) < 0)
952 cout << endl << "********************************************************************" << endl;
953 cout << "******************** ***********************" << endl;
954 cout << "******************** ERREUR MEDchampEcr ***********************" << endl;
955 cout << "******************** ***********************" << endl;
956 cout << "********************************************************************" << endl;
958 cout << " Champ: " << (string) nomChampMoy << endl;
959 cout << " Géométrie: " << MGE2string(MGE) << endl;
960 cout << " Pas de temps " << ipt << " ignoré" << endl;
961 cout << endl << endl;
966 cout << " Ecriture des valeurs moyennées dans le nouveau champ: OK " << endl;
968 // Restitution du champ moyenné
971 cout << endl << " Liste des valeurs du champ moyenné aux 3 premiers éléments:" << endl;
972 for (imaille = 0; imaille < min(nmailles, 3); imaille++)
974 cout << " Maille " << imaille << endl;
975 for (icomp = 0; icomp < nCompChamp; icomp++)
976 cout << " " << *(valr2 + imaille * nCompChamp + icomp);
987 } // boucle sur les pas de temps
992 std::string MESHCUT::nomMaille(TYPE_MAILLE tm, int nl)
994 return (TM2string(tm) + (string) "_" + int2string(nl));
997 bool MESHCUT::appartientVN(int n, std::vector<int> V)
1000 for (unsigned int i = 0; i < V.size(); i++)
1009 float MESHCUT::distance2(float x1, float y1, float z1, float x2, float y2, float z2)
1011 return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + (z2 - z1) * (z2 - z1);
1015 * Conversion HL-MED d'une table de connectivités
1017 void MESHCUT::conversionCNX(int *CNXtm, TYPE_MAILLE tm, int N)
1020 int n = Nnoeuds(tm);
1024 for (int i = 0; i < N; i++)
1026 int i1 = CNXtm[i * n + 1];
1027 int i2 = CNXtm[i * n + 2];
1028 CNXtm[i * n + 1] = i2;
1029 CNXtm[i * n + 2] = i1;
1032 else if (tm == PYRAM5)
1034 for (int i = 0; i < N; i++)
1036 int i1 = CNXtm[i * n + 1];
1037 int i3 = CNXtm[i * n + 3];
1038 CNXtm[i * n + 1] = i3;
1039 CNXtm[i * n + 3] = i1;
1042 else if (tm == PENTA6)
1044 for (int i = 0; i < N; i++)
1046 int i0 = CNXtm[i * n + 0];
1047 int i1 = CNXtm[i * n + 1];
1048 int i2 = CNXtm[i * n + 2];
1049 int i3 = CNXtm[i * n + 3];
1050 int i4 = CNXtm[i * n + 4];
1051 int i5 = CNXtm[i * n + 5];
1052 CNXtm[i * n + 0] = i3;
1053 CNXtm[i * n + 1] = i4;
1054 CNXtm[i * n + 2] = i5;
1055 CNXtm[i * n + 3] = i0;
1056 CNXtm[i * n + 4] = i1;
1057 CNXtm[i * n + 5] = i2;
1061 else if (tm == HEXA8)
1063 for (int i = 0; i < N; i++)
1065 int i0 = CNXtm[i * n + 0];
1066 int i1 = CNXtm[i * n + 1];
1067 int i2 = CNXtm[i * n + 2];
1068 int i3 = CNXtm[i * n + 3];
1069 int i4 = CNXtm[i * n + 4];
1070 int i5 = CNXtm[i * n + 5];
1071 int i6 = CNXtm[i * n + 6];
1072 int i7 = CNXtm[i * n + 7];
1073 CNXtm[i * n + 0] = i4;
1074 CNXtm[i * n + 1] = i5;
1075 CNXtm[i * n + 2] = i6;
1076 CNXtm[i * n + 3] = i7;
1077 CNXtm[i * n + 4] = i0;
1078 CNXtm[i * n + 5] = i1;
1079 CNXtm[i * n + 6] = i2;
1080 CNXtm[i * n + 7] = i3;