1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : ghs3dprl_mesh_wrap.cxx
22 // Author : Christian VAN WAMBEKE (CEA)
25 #include "ghs3dprl_mesh_wrap.h"
35 #include <libxml/tree.h>
36 #include <libxml/parser.h>
37 #include <libxml/xpath.h>
38 #include <libxml/xpathInternals.h>
54 //#include <med_config.h>
55 //#include <med_utils.h>
56 //#include <med_misc.h>
61 //************************************
62 std::string i2a(const int &v)
64 std::ostringstream ss;
69 //************************************
70 QString endspace(QString deb,int lg)
71 //better fill by spaces for char unicoo[3*MED_TAILLE_PNOM+1]; etc...
77 fin=deb.leftJustified(lg,' ',true);
81 //************************************
82 void charendnull(char *p, QString deb, int lg)
87 strcpy(p,fin.toLatin1().constData()); // 0 at end
88 for (int i=fin.length();i<lg-1;i++){
94 //************************************
95 void familles::newfam(QString nom){
96 //std::cout<<"newfam "<<nom<<std::endl;
97 if (fam.find(nom)!=fam.end()){
98 std::cout<<"***newfam*** "<<nom.toLatin1().constData()<<" deja present\n";
105 //************************************
106 void familles::newgro(QString nom){
107 //std::cout<<"newgro "<<nom<<std::endl;
108 if (gro.find(nom)!=gro.end()){
109 std::cout<<"***newgro*** "<<nom.toLatin1().constData()<<" deja present\n";
116 //************************************
117 void familles::write(){
122 for (it1=fam.begin(); it1!=fam.end(); ++it1){
124 std::cout<<"Family=<"<<(*it1).first.toLatin1().constData()<<">\tGroups=";
126 for (it2=gb.begin(); it2!=gb.end(); ++it2){
127 std::cout<<"<"<<(*it2).first.toLatin1().constData()<<"> ";
129 std::cout<<std::endl;
131 if (nbf==0) std::cout<<"no families"<<std::endl;
132 for (it1=gro.begin(); it1!=gro.end(); ++it1){
134 std::cout<<"Group=<"<<(*it1).first.toLatin1().constData()<<">\tFamilies=";
136 for (it2=gb.begin(); it2!=gb.end(); ++it2){
137 std::cout<<"<"<<(*it2).first.toLatin1().constData()<<"> ";
139 std::cout<<std::endl;
141 if (nbg==0) std::cout<<"no groups"<<std::endl;
144 //************************************
145 xmlNodePtr familles::xml_groups(){
152 res=xmlNewNode(NULL, BAD_CAST "groups");
153 for (it1=gro.begin(); it1!=gro.end(); ++it1){
154 node = xmlNewChild(res, 0, BAD_CAST "group",0);
155 ss=(*it1).first.toLatin1().constData();
156 xmlNewProp(node, BAD_CAST "name", BAD_CAST ss.c_str());
160 for (it2=gb.begin(); it2!=gb.end(); ++it2){
161 ss=ss+" "+(*it2).first.toLatin1().constData();
164 xmlNewProp(node, BAD_CAST "families_number", BAD_CAST i2a(nbf).c_str());
165 xmlNewProp(node, BAD_CAST "families", BAD_CAST ss.substr(1).c_str());
166 //std::cout<<std::endl;
168 xmlNewProp(res, BAD_CAST "number", BAD_CAST i2a(nb).c_str());
172 //************************************
173 void familles::add(QString nomfam, QString nomgro)
175 //std::cout<<"add family <"<<nomfam<<">\t<"<<nomgro<<">\n";
179 //std::cout<<"add new family <"<<nomfam<<">\t<"<<nomgro<<">\n";
183 if (nomgro=="") return; //no group
184 (*it).second[nomgro]=0;
187 //std::cout<<"***new*** "<<nomgro<<" non present\n";
191 (*it).second[nomfam]=0;
196 //************************************
197 bool familles::get_number_of_new_family(int sign, med_int *ires, QString *tmp)
198 //if sign < 0 families faces or tria3 etc...
199 //if sign >= 0 family zero and family nodes
200 //outputs in *ires and *tmp
205 if (sign>=0) pas=1; else pas=-1;
208 for (i=0;i<10000;i++) { //mefiance
209 nomfam=nomfam.sprintf("%d",ii);
212 *tmp=nomfam; *ires=ii;
213 //std::cout<<"NewFamily Found<"<<*ires<<"><"<<*tmp<<">\n";
218 std::cerr<<"***get_number_of_new_family*** Problem new family not found"<<std::endl;
222 //************************************
223 med_int familles::find_family_on_groups(med_int fam1, med_int fam2)
226 if (fam1==fam2) {ires=fam1; return ires;}
227 //find one family whith groups of fam1 and groups of fam2
228 fend gb=fuse_goups(fam1,fam2);
229 //find if one family have theses groups
232 for (it1=fam.begin(); it1!=fam.end(); ++it1){
233 if (gb==(*it1).second){
234 ires=(*it1).first.toLong();
235 //std::cout<<"find_family_on_groups old <"<<ires<<"> from <"<<
236 // fam1<<"><"<<fam2<<">\n";
240 //std::cout<<"no family found!!! - groups of "<<fam1<<" and "<<fam2<<std::endl;
242 //fam1 positive for nodes negative faces & mailles
243 bool oktmp=get_number_of_new_family(fam1,&ires,&tmp);
245 for (it=gb.begin(); it!=gb.end(); ++it){
246 this->add(tmp,(*it).first);
248 //std::cout<<"new family <"<<ires<<"> intersection of <"<<fam1<<"><"<<fam2<<">\n";
252 //************************************
253 fend familles::fuse_goups(med_int fam1, med_int fam2)
254 //concatenation/fusion deux map groupes
257 fagr::iterator it1,it2;
258 nom1=nom1.sprintf("%d",fam1);
260 nom2=nom2.sprintf("%d",fam2);
262 if ( (it1==fam.end())||(it2==fam.end()) ) {
263 std::cerr<<"***fuse_goups*** non existing family "<<fam1<<" or "<<fam2<<std::endl;
267 fend gb=(*it1).second; //firt groups
268 gb.insert((*it2).second.begin(),(*it2).second.end()); //other groups
271 std::cout<<"fuse_goups "<<fam1<<" "<<fam2<<" ";
273 for (it=gb.begin(); it!=gb.end(); ++it){
274 std::cout<<"<"<<(*it).first.toLatin1().constData()<<"> ";
276 std::cout<<std::endl;
280 long CVWtab::memoryuse=0; //static
281 long CVWtab::memorymax=1000*1000000; //static
283 //************************************
284 CVWtab::CVWtab(long nb, med_int *pmint)
285 //constructor with pmint allocated yet with new
287 //std::cout"***constructor med_int CVWtab***\n";
289 type=1; //only tmint valide
292 memoryuse=memoryuse+sizeof(med_int)*nb;
293 //std::cout<<"memoryuse int "<<sizeof(med_int)<<" "<<nb<<" "<<memoryuse<<" "<<memorymax<<std::endl;
294 if (memoryuse>memorymax) {
295 std::cout<<"***WARNING*** memory max reached "<<memorymax<<std::endl;
296 //std::cout<<"memoryuse int "<<sizeof(med_int)<<" "<<nb<<" "<<memoryuse<<std::endl;
300 //************************************
301 CVWtab::CVWtab(long nb, med_float *pmflo)
302 //constructor with pmflo allocated yet with new
304 //std::cout<<"***constructor med_float CVWtab***\n";
306 type=2; //only tmflo valide
309 memoryuse=memoryuse+sizeof(med_float)*nb;
310 //std::cout<<"memoryuse float "<<sizeof(med_float)<<" "<<nb<<" "<<memoryuse<<" "<<memorymax<<std::endl;
311 if (memoryuse>memorymax) {
312 std::cout<<"***WARNING*** memory max reached "<<memorymax<<std::endl;
313 //std::cout<<"memoryuse float "<<sizeof(med_float)<<" "<<nb<<" "<<memoryuse<<std::endl;
317 //************************************
321 //std::cout<<" destructor CVWtab *** "<<this->filename<<std::endl;
322 ok=this->CVWtab_deallocate();
323 //remove temporary file
324 if (this->filename!="_NO_FILE")
326 remove(this->filename.toLatin1().constData()); //#include <stdio.h>
327 //std::cout<<this->filename<<" successfully deleted\n";
332 //************************************
333 bool CVWtab::CVWtab_deallocate()
335 //std::cout<<" deallocate CVWtab*** "<<size<<std::endl;
336 if (size <= 0) return false;
340 memoryuse=memoryuse-sizeof(med_int)*size;
341 size=-size; //precaution
346 memoryuse=memoryuse-sizeof(med_float)*size;
347 size=-size; //precaution
349 if (memoryuse<0) std::cout<<"***WARNING*** memoryuse <0 "<<memoryuse<<std::endl;
350 if (memoryuse==0) std::cout<<"***CVWtab_deallocate*** memoryuse=0 "<<std::endl;
354 //************************************
355 bool CVWtab::is_equal(CVWtab *tab2)
357 //std::cout<<"is_equal tab1 tab2 type="<<this->type<<" size="<<this->size<<" "<<tab2->size<<std::endl;
358 //if (this->type==1) std::cout<<"med_int tab1[0]="<<this->tmint[0]<<std::endl;
359 //if (this->type==2) std::cout<<"med_float tab1[0]="<<this->tmflo[0]<<std::endl;
360 if (this->size!=tab2->size) return false;
361 if (this->type!=tab2->type) return false;
365 { std::cout<<"***is_equal*** pb pointer NULL with tmint size="<<this->size<<std::endl;
368 for (long i=0; i < this->size; i++)
369 if (this->tmint[i]!=tab2->tmint[i]) return false;
374 { std::cout<<"***is_equal*** pb pointer NULL with tmflo size="<<this->size<<std::endl;
377 for (long i=0; i < this->size; i++)
378 if (this->tmflo[i]!=tab2->tmflo[i]) return false;
383 //************************************
384 bool CVW_is_equal_vertices(CVWtab *tab1, long i1,
385 CVWtab *tab2, long i2, int verbose)
386 //verbose 0 for no prints
387 //verbose 1 for print vertices not equals
388 //verbose 2 for print also vertices equals (debug)
390 //std::cout<<"is_equal_vertice size="<<tab1->size<<" "<<tab2->size<<std::endl;
393 //vertices indices from 1 not 0!
394 long di1=(i1-1)*3, di2=(i2-1)*3;
395 if (di1<0 || di1>=tab1->size)
397 std::cerr<<"BadIndice tab1 in is_equal_vertices "<<
398 di1<<" not in "<<tab1->size<<std::endl;
401 if (di2<0 || di2>=tab2->size)
403 std::cerr<<"BadIndice tab2 in is_equal_vertices "<<
404 di2<<" not in "<<tab2->size<<std::endl;
407 p1=(tab1->tmflo+di1);
408 p2=(tab2->tmflo+di2);
409 if (p1[0]==p2[0] && p1[1]==p2[1] && p1[2]==p2[2]) ok=true ;
410 if (!ok && verbose>0) printf(
411 "Vertices differents (%.16g %.16g %.16g) (%.16g %.16g %.16g)\n",
412 p1[0],p1[1],p1[2],p2[0],p2[1],p2[2]);
414 if (verbose>1) printf(
415 "Vertices equals (%.16g %.16g %.16g)\n",
420 //************************************
421 bool CVW_FindString(const std::string &str,std::fstream &Ff, long &count)
422 //find in file first line with string str in first position of line
423 //converts count value expected after "='" in line found
429 if (getline(Ff,line))
431 if (line[0]==str[0]) //faster
433 if (line.find(str)==0)
437 count=tmp.section('\'',1,1).toLong(&ok);
444 std::cerr<<"Problem line '"<<str<<"' not found in file\n"<<std::endl;
451 //************************************
452 bool CVW_FindStringInFirstLines(const std::string &str,std::fstream &Ff, long &maxline)
453 //find in file maximum maxline first lines with string str in first position of line
454 //converts count value expected after " " in line found
460 if (getline(Ff,line))
463 if (line[0]==str[0]) //faster
465 if (line.find(str)==0)
472 std::cerr<<"Problem line '"<<str<<"' not found in first "<<maxline<<" lines of file\n"<<std::endl;
478 std::cerr<<"Problem line '"<<str<<"' not found in all file\n"<<std::endl;
485 //************************************
486 bool ghs3dprl_mesh_wrap::ReadFileMSGnew(const QString FileName)
487 //read file .glo with no parser xml because big file (volume)
488 //no read of <receive> for speed (and so no test)
491 std::fstream Ff(FileName.toLatin1().constData(),std::ios_base::in);
493 long i,count,nbneighbour,ineighbour;
498 std::cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
503 if (!CVW_FindString("<neighbours count=",Ff,nbneighbour)) return false;
504 if (verbose>2) std::cout<<"NeighboursCountDomain_"<<this->nofile<<"="<<nbneighbour<<std::endl;
505 for (i=1; i<=nbneighbour; i++)
507 if (!CVW_FindString("<neighbour indice=",Ff,ineighbour)) return false;
508 if (!CVW_FindString("<vertices count=",Ff,count)) return false;
510 med_int *tmint=new med_int[count];
511 for (int i=0; i<count; i++) Ff>>tmint[i];
512 if (verbose>4) std::cout<<"Vertices "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
514 CVWtab *montab=new CVWtab(count,tmint);
515 tmp=tmp.sprintf("MS%ld NE%ld VE SE",this->nofile,ineighbour);
516 ok=this->insert_key(tmp,montab);
518 if (!CVW_FindString("<edges count=",Ff,count)) return false;
520 med_int *tmint=new med_int[count];
521 for (int i=0; i<count; i++) Ff>>tmint[i];
522 if (verbose>4) std::cout<<"Edges "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
524 CVWtab *montab=new CVWtab(count,tmint);
525 tmp=tmp.sprintf("MS%ld NE%ld ED SE",this->nofile,ineighbour);
526 ok=this->insert_key(tmp,montab);
528 if (!CVW_FindString("<faces count=",Ff,count)) return false;
530 med_int *tmint=new med_int[count];
531 for (int i=0; i<count; i++) Ff>>tmint[i];
532 if (verbose>4) std::cout<<"Faces "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
534 CVWtab *montab=new CVWtab(count,tmint);
535 tmp=tmp.sprintf("MS%ld NE%ld FA SE",this->nofile,ineighbour);
536 ok=this->insert_key(tmp,montab);
538 if (!CVW_FindString("<elements count=",Ff,count)) return false;
540 med_int *tmint=new med_int[count];
541 for (int i=0; i<count; i++) Ff>>tmint[i];
542 if (verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
544 CVWtab *montab=new CVWtab(count,tmint);
545 tmp=tmp.sprintf("MS%ld NE%ld EL SE",this->nofile,ineighbour);
546 ok=this->insert_key(tmp,montab);
556 //************************************
557 bool ghs3dprl_mesh_wrap::TestExistingFileMESHnew(const QString FileName)
558 //read file .glo with no parser xml because big file (volume)
559 //no read of <receive> for speed (and so no test)
562 std::fstream Ff(FileName.toLatin1().constData(),std::ios_base::in);
564 long i,count,meshversion,maxline;
569 std::cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
573 //Lit les donn�s au debut du fichier, 1 lignes maxi:
575 if (!CVW_FindStringInFirstLines("MeshVersionFormatted",Ff,maxline)) return false;
576 if (verbose>2) std::cout<<"MeshVersionFormatted_"<<this->nofile<<" ok"<<std::endl;
584 ///************************************
585 bool ghs3dprl_mesh_wrap::ReadFileGLO(const QString FileName)
586 //read file .glo with no parser xml because big file (volume)
589 std::fstream Ff(FileName.toLatin1().constData(),std::ios_base::in);
596 std::cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
601 if (!CVW_FindString("<vertices count=",Ff,count)) return false;
602 if (verbose>3) std::cout<<"GloVerticesCount="<<count<<std::endl;
605 med_int *tmint=new med_int[count];
606 for (int i=0; i<count; i++) Ff>>tmint[i];
607 if (verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
609 CVWtab *montab=new CVWtab(count,tmint);
610 tmp=tmp.sprintf("GL%ld VE",this->nofile);
611 ok=this->insert_key(tmp,montab);
614 if (!CVW_FindString("<edges count=",Ff,count)) return false;
615 if (verbose>3) std::cout<<"GloEdgesCount="<<count<<std::endl;
618 med_int *tmint=new med_int[count];
619 for (int i=0; i<count; i++) Ff>>tmint[i];
620 if (verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
622 CVWtab *montab=new CVWtab(count,tmint);
623 tmp=tmp.sprintf("GL%ld ED",this->nofile);
624 ok=this->insert_key(tmp,montab);
627 if (!CVW_FindString("<faces count=",Ff,count)) return false;
628 if (verbose>3) std::cout<<"GloFacesCount="<<count<<std::endl;
631 med_int *tmint=new med_int[count];
632 for (int i=0; i<count; i++) Ff>>tmint[i];
633 if (verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
635 CVWtab *montab=new CVWtab(count,tmint);
636 tmp=tmp.sprintf("GL%ld FA",this->nofile);
637 ok=this->insert_key(tmp,montab);
640 if (!CVW_FindString("<elements count=",Ff,count)) return false;
641 if (verbose>3) std::cout<<"GloElementsCount="<<count<<std::endl;
644 med_int *tmint=new med_int[count];
645 for (int i=0; i<count; i++) Ff>>tmint[i];
646 if (verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
648 CVWtab *montab=new CVWtab(count,tmint);
649 tmp=tmp.sprintf("GL%ld EL",this->nofile);
650 ok=this->insert_key(tmp,montab);
658 //************************************
659 bool ghs3dprl_mesh_wrap::ReadFileFACES(const QString FileName)
660 //read file .faces (wrap)
663 std::fstream Ff(FileName.toLatin1().constData(),std::ios_base::in);
670 std::cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
675 //Replace le pointeur de fichier au d�ut :f.seekg(0);
676 if (getline(Ff,line))
679 nbelem=tmp.section(' ',0,0).toLong(&ok);
683 std::cerr<<"Problem on first line of file"<<std::endl;
686 if (verbose>3) std::cout<<"FacesNumberOfElements="<<nbelem<<std::endl;
687 med_int *tmint=new med_int[nbelem*7];
688 for (int i=0; i<nbelem*7; i=i+7)
691 if (ntype!=3) //only triangles
693 std::cerr<<"Problem on ntype != 3"<<std::endl;
696 for (int j=0; j<7; j++) Ff>>tmint[i+j];
697 //for (int j=0; j<7; j++) std::cout<<tmint[i+j]<<' '; std::cout<<std::endl;
699 if (verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[nbelem*7-1]<<std::endl;
701 CVWtab *montab=new CVWtab(nbelem*7,tmint);
702 tmp=tmp.sprintf("FC%ld",this->nofile);
703 ok=this->insert_key(tmp,montab);
710 //************************************
711 bool ghs3dprl_mesh_wrap::ReadFileMESH(const QString FileName)
712 //read file .mesh from tetra_hpc (with volume)
714 std::string line(" ");
716 std::fstream Ff(FileName.toLatin1().constData(),std::ios_base::in);
717 long Mversion=0,Mdim=0,Mvert=0,Mtria=0,Mtetra=0;
719 //long ne,np,npfixe,subnumber,reste;
721 if (verbose>=6)std::cout<<"Read File '"<<FileName.toLatin1().constData()<<std::endl;
723 std::cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
728 if (getline(Ff,line) && (line.find("MeshVersionFormatted")==0))
731 Mversion=tmp.section(' ',1,1).toLong(&ok);
735 std::cerr<<"Problem on line 1 of file: 'MeshVersionFormatted' expected"<<std::endl;
741 if (getline(Ff,line) && (line.find("Dimension 3")==0))
744 Mdim=tmp.section(' ',1,1).toLong(&ok);
748 std::cerr<<"Problem on line 3 of file: Dimension 3 expected"<<std::endl;
754 if (!(getline(Ff,line) && (line.find("Vertices")==0)))
756 std::cerr<<"Problem on line 5 of file: 'Vertices' expected"<<std::endl;
759 if (getline(Ff,line))
762 Mvert=tmp.toLong(&ok);
766 std::cerr<<"Problem on line 6 of file: a positive integer is expected"<<std::endl;
771 std::cerr<<"Problem on line 6 of file: a positive integer is expected"<<std::endl;
775 med_float *tmflo=new med_float[Mvert*3];
776 for (int i=0; i<Mvert*3; i=i+3) Ff>>tmflo[i]>>tmflo[i+1]>>tmflo[i+2]>>garbage;
777 if (verbose>4) std::cout<<"Vertices "<<tmflo[0]<<" "<<tmflo[1]<<"... "<<tmflo[Mvert*3-1]<<std::endl;
779 CVWtab *montab=new CVWtab(Mvert*3,tmflo);
780 tmp=tmp.sprintf("NB%ld VC",this->nofile);
781 ok=this->insert_key(tmp,montab);
786 if (!(getline(Ff,line) && (line.find("Triangles")==0)))
788 std::cerr<<"Problem on line 'Triangles' of file: not found"<<line<<std::endl;
791 if (getline(Ff,line))
794 Mtria=tmp.toLong(&ok);
798 std::cerr<<"Problem on line 'Triangles' of file: a positive integer is expected"<<std::endl;
803 std::cerr<<"Problem on line 'Triangles' of file: a positive integer is expected"<<std::endl;
807 med_int *tmint=new med_int[Mtria*7]; //*7 as older files .faces
808 for (int i=0; i<Mtria*7; i=i+7) {
809 Ff>>tmint[i]>>tmint[i+1]>>tmint[i+2]>>garbage;
815 if (verbose>4) std::cout<<"Triangles "<<tmint[0]<<" "<<tmint[1]<<"... "<<
816 tmint[Mtria*7-5]<<" "<<tmint[Mtria*7-4]<<" "<<tmint[Mtria*7-3]<<" "<<
817 tmint[Mtria*7-2]<<" "<<tmint[Mtria*7-1]<<std::endl;
819 montab=new CVWtab(Mtria*7,tmint);
820 tmp=tmp.sprintf("FC%ld",this->nofile);
821 ok=this->insert_key(tmp,montab);
826 if (!(getline(Ff,line) && (line.find("Tetrahedra")==0)))
828 std::cerr<<"Problem on line 'Tetrahedra' of file: not found"<<std::endl;
831 if (getline(Ff,line))
834 Mtetra=tmp.toLong(&ok);
838 std::cerr<<"Problem on line 'Tetrahedra' of file: a positive integer is expected"<<std::endl;
843 std::cerr<<"Problem on line 'Tetrahedra' of file: a positive integer is expected"<<std::endl;
849 std::cout<<"MeshVersionFormatted="<<Mversion<<std::endl;
850 std::cout<<"MeshDimension="<<Mdim<<std::endl;
851 std::cout<<"MeshNumberOfVertices="<<Mvert<<std::endl;
852 std::cout<<"MeshNumberOfTriangles="<<Mtria<<std::endl;
853 std::cout<<"MeshNumberOfTetrahedra="<<Mtetra<<std::endl;
856 tmint=new med_int[Mtetra*4];
857 for (int i=0; i<Mtetra*4; i=i+4) Ff>>tmint[i]>>tmint[i+1]>>tmint[i+2]>>tmint[i+3]>>garbage;
858 if (verbose>4) std::cout<<"Tetrahedra "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[Mtetra*4-1]<<std::endl;
860 montab=new CVWtab(Mtetra*4,tmint);
861 tmp=tmp.sprintf("NB%ld EV",this->nofile);
862 ok=this->insert_key(tmp,montab);
864 //swap on file if too big for memory in one cpu
865 //default 1GOctet/8(for double)/10(for arrays in memory at the same time)
866 if (Mvert*3>this->nbelem_limit_swap)
867 this->SwapOutOfMemory_key_mesh_wrap(QRegExp("NB",Qt::CaseSensitive,QRegExp::RegExp));
868 //beware record 6 lenght 1
875 //************************************
876 bool ghs3dprl_mesh_wrap::ReadFileNOBOITE(const QString FileName)
877 //read file .noboite (volume)
878 //for huge files it could be better use ReadFileNOBOITEB (B=binary format)
879 //(parameter option of ghs3d but NOT tepal)
882 std::fstream Ff(FileName.toLatin1().constData(),std::ios_base::in);
883 long ne,np,npfixe,subnumber,reste;
887 std::cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
894 std::cout<<"NoboiteNumberOfElements="<<ne<<std::endl;
895 std::cout<<"NoboiteNumberOfVertices="<<np<<std::endl;
896 std::cout<<"NoboiteNumberOfSpecifiedPoints="<<npfixe<<std::endl;
899 for (int i=1; i<=17-3; i++) Ff>>reste;
900 //printf("reste %ld\n",reste);
901 med_int *tmint=new med_int[ne*4];
902 for (int i=0; i<ne*4; i++) Ff>>tmint[i];
903 if (verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[ne*4-1]<<std::endl;
905 CVWtab *montab=new CVWtab(ne*4,tmint);
906 tmp=tmp.sprintf("NB%ld EV",this->nofile);
907 ok=this->insert_key(tmp,montab);
909 med_float *tmflo=new med_float[np*3];
910 for (int i=0; i<np*3; i++) Ff>>tmflo[i];
911 if (verbose>4) std::cout<<"Vertices "<<tmflo[0]<<" "<<tmflo[1]<<"... "<<tmflo[np*3-1]<<std::endl;
913 montab=new CVWtab(np*3,tmflo);
914 tmp=tmp.sprintf("NB%ld VC",this->nofile);
915 ok=this->insert_key(tmp,montab);
918 if (verbose>2) std::cout<<"NumberOfSubdomains="<<subnumber<<std::endl;
919 //tmint=new med_int[subnumber*3];
920 tmint=new med_int[subnumber*3];
922 maxint=std::numeric_limits<int>::max();
925 for (int i=0; i<subnumber*3; i++) {
929 if (isproblem && verbose>1) std::cout<<"There is one or more negative med_int value in NumberOfSubdomains "<<onelong<<std::endl;
933 if (onelong>maxint) {
934 if (isproblem && verbose>1) std::cout<<"There is one or more truncated med_int value in NumberOfSubdomains "<<onelong<<std::endl;
938 tmint[i]=(int)onelong;
940 if (verbose>4) std::cout<<"Subdomains "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[subnumber*3-1]<<std::endl;
942 montab=new CVWtab(subnumber*3,tmint);
943 tmp=tmp.sprintf("NB%ld SN",this->nofile);
944 ok=this->insert_key(tmp,montab);
946 //swap on file if too big for memory in one cpu
947 //default 1GOctet/8(for double)/10(for arrays in memory at the same time)
948 if (np*3>this->nbelem_limit_swap)
949 this->SwapOutOfMemory_key_mesh_wrap(QRegExp("NB",Qt::CaseSensitive,QRegExp::RegExp));
950 //beware record 6 lenght 1
957 //************************************
958 bool ghs3dprl_mesh_wrap::ReadFileNOBOITEB(const QString FileName)
959 //read file .noboiteb (volume)
960 //for huge files it could be better use ReadFileNOBOITEB (B=binary format)
961 //but NOT parameter option of tepal
962 //idem ReadFileNOBOITE with read unformatted
966 std::cerr<<"Problem function ReadFileNOBOITEB\n"
967 <<"(no FORTRAN binary format files in tepal)\n\n";
969 FILE *Ff=fopen(FileName.toLatin1().constData(),"rb");
970 long ne,np,npfixe,reste,subnumber;
972 //http://www.math.utah.edu/software/c-with-fortran.html
973 //record 1 from format FORTRAN begins and ends with lengh of record
974 //=> 2*long(68) (68=17*4octets)
977 std::cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
981 fread(&r1,sizeof(long),17+2,Ff);
982 for (long i=1; i<18; i++) std::cout<<"R1("<<i<<")="<<r1[i]<<std::endl;
985 std::cerr<<"First FORTRAN record of File '"<<FileName.toLatin1().constData()<<"' not length 17*long"<<std::endl;
992 std::cout<<"NoboitebNumberOfElements="<<ne<<std::endl;
993 std::cout<<"NoboitebNumberOfVertices="<<np<<std::endl;
994 std::cout<<"NoboitebNumberOfSpecifiedPoints="<<npfixe<<std::endl;
996 //etc...could be done if necessary not debugged
997 fread(&reste,sizeof(long),1,Ff);
998 long *tlong=new long[ne*4];
999 med_int *tmint=new med_int[ne*4];
1000 fread(tlong,sizeof(long),ne*4,Ff);
1001 fread(&reste,sizeof(long),1,Ff);
1002 for (long i=0; i<ne*4; i++) tmint[i]=tlong[i];
1004 if (verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[ne*4-1]<<std::endl;
1006 CVWtab *montab=new CVWtab(ne*4,tmint);
1007 tmp=tmp.sprintf("NB%ld EV",this->nofile);
1008 ok=this->insert_key(tmp,montab);
1010 fread(&reste,sizeof(long),1,Ff);
1011 //std::cout<<"info "<<reste<<" "<<np*3<<" "<<sizeof(med_float)<<std::endl;
1012 float *tfloat=new float[np*3];
1013 med_float *tmflo=new med_float[np*3];
1014 fread(tfloat,sizeof(float),np*3,Ff);
1015 fread(&reste,sizeof(long),1,Ff);
1016 for (long i=0; i<np*3; i++) tmflo[i]=tfloat[i];
1018 if (verbose>4) printf("Vertices %g %g ... %g \n",tmflo[0],tmflo[1],tmflo[np*3-1]);
1020 montab=new CVWtab(np*3,tmflo);
1021 tmp=tmp.sprintf("NB%ld VC",this->nofile);
1022 ok=this->insert_key(tmp,montab);
1024 fread(&reste,sizeof(long),1,Ff);
1025 fread(&subnumber,sizeof(long),1,Ff);
1026 fread(&reste,sizeof(long),1,Ff);
1027 if (verbose>2) std::cout<<"NumberOfSubdomains="<<subnumber<<std::endl;
1028 fread(&reste,sizeof(long),1,Ff);
1029 tlong=new long[subnumber*3];
1030 fread(tlong,sizeof(long),subnumber*3,Ff);
1031 fread(&reste,sizeof(long),1,Ff);
1032 if (verbose>4) printf("Subdomains %ld %ld ... %ld \n",tlong[0],tlong[1],tlong[subnumber*3-1]);
1034 tmint=new med_int[subnumber*3];
1035 for (long i=0; i<subnumber*3; i++) tmint[i]=tlong[i];
1037 montab=new CVWtab(subnumber*3,tmint);
1038 tmp=tmp.sprintf("NB%ld SN",this->nofile);
1039 ok=this->insert_key(tmp,montab);
1041 //swap on file if too big for memory in one cpu
1042 //default 1GOctet/8(for double)/10(for arrays in memory at the same time)
1043 if (np*3>this->nbelem_limit_swap)
1044 this->SwapOutOfMemory_key_mesh_wrap(QRegExp("NB",Qt::CaseSensitive,QRegExp::RegExp));
1046 //beware record 6 lenght 1
1047 //ferme le fichier :
1053 //************************************
1054 bool ghs3dprl_mesh_wrap::ReadFilePOINTS(const QString FileName)
1055 //read file .points (wrap)
1064 //NOT Raw because Raw=non-buffered file access
1065 //qt3 ok=Ff.open(IO_ReadOnly|IO_Translate);
1066 ok=Ff.open(QIODevice::ReadOnly|QIODevice::Text);
1068 std::cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
1071 tmp=Ff.readLine(maxlen);
1072 tmp=tmp.simplified();
1075 std::cerr<<"Problem conversion File '"<<FileName.toLatin1().constData()<<"\n"<<std::endl;
1078 if (verbose>2) std::cout<<"NumberOfVertices="<<nb<<std::endl;
1079 med_float *tmflo=new med_float[3*nb]; //coordinates
1080 med_int *tmint=new med_int[nb]; //nrs (attribute of point)
1082 for ( long il=0; il<nb; il++ ){
1083 tmp=Ff.readLine(maxlen);
1084 tmp=tmp.simplified();
1085 for ( int j=0; j<3; j++ ){
1086 tmflo[il3]=tmp.section(' ',j,j).toDouble(&ok);
1087 //std::cout<<"cv '"<<tmflo[il3]<<"' "<<il3<<std::endl;
1090 std::cerr<<"Problem conversion File '"<<FileName.toLatin1().constData()<<"\n"<<std::endl;
1094 //nrs is vertex attribute
1095 tmint[il]=tmp.section(' ',3,3).toLong(&ok);
1097 std::cerr<<"Problem conversion File '"<<FileName.toLatin1().constData()<<"\n"<<std::endl;
1101 //beware no examples with each specified points (if any) here
1102 CVWtab *montab=new CVWtab(nb,tmint); //init montab->tmint nrs
1103 tmp=tmp.sprintf("PO%ld NRS",this->nofile);
1104 ok=this->insert_key(tmp,montab);
1106 montab=new CVWtab(nb,tmflo); //init montab->tmflo xyz
1107 tmp=tmp.sprintf("PO%ld XYZ",this->nofile);
1108 ok=this->insert_key(tmp,montab);
1110 //Ferme le fichier :
1116 //************************************
1117 bool ghs3dprl_mesh_wrap::list_keys_mesh_wrap()
1119 QHashIterator<QString,CVWtab*> it( this->mestab);
1120 while ( it.hasNext() ) {
1122 QString nom = it.key().leftJustified(32,' ');
1123 std::cout<<nom.toLatin1().constData()<<"-> size="<<it.value()->size<<std::endl;
1128 //************************************
1129 long ghs3dprl_mesh_wrap::remove_all_keys_mesh_wrap()
1131 long nb=this->remove_key_mesh_wrap(QRegExp(".",Qt::CaseSensitive,QRegExp::RegExp));
1135 //************************************
1136 long ghs3dprl_mesh_wrap::remove_key_mesh_wrap(const QRegExp &rxp)
1139 QMutableHashIterator<QString,CVWtab*> it(this->mestab);
1140 while ( it.hasNext() ){
1142 if (it.key().contains(rxp)) {
1144 if (this->verbose>6) std::cout<<"remove key "<<it.key().toLatin1().constData()<<std::endl;
1152 //************************************
1153 long ghs3dprl_mesh_wrap::nb_key_mesh_wrap(const QRegExp &rxp)
1156 //std::cout<<"nb_key_mesh_wrap on "<<std::endl;
1157 QMutableHashIterator<QString,CVWtab*> it(this->mestab);
1158 while ( it.hasNext() ){
1160 if (it.key().contains(rxp)) nbremove++;
1162 //std::cout<<"nb_key_mesh_wrap found "<<nbremove<<std::endl;
1166 //************************************
1167 bool SwapOnFile(const QString &key,const QString &path,CVWtab *tab,int verbose)
1171 if (tab->filename=="_NO_FILE"){
1172 tab->filename=path+key+".tmp";
1173 tab->filename.replace(" ","_"); //replace " " by "_"
1175 //swap disque binaire
1176 //montab->tmint=new long[10]; //for test
1177 //for (int i=0; i<10; i++) montab->tmint[i]=i*2;
1178 FILE *fichier=fopen(tab->filename.toLatin1().constData(),"wb");
1181 fwrite(&taille,sizeof(taille),1,fichier);
1184 std::cout<<"SwapOnFile_binary "<<tab->filename.toLatin1().constData()<<
1185 " NbElements "<<taille<<
1186 " SizeElement_med_int "<<sizeof(med_int)<<
1187 " TotalSizeBinary " <<taille*sizeof(med_int)<<std::endl;
1188 fwrite(tab->tmint,sizeof(med_int),taille,fichier);
1189 //fread(&gagnants,sizeof(gagnants),1,fichier);
1193 std::cout<<"SwapOnFile_binary "<<tab->filename.toLatin1().constData()<<
1194 " NbElements "<<taille<<
1195 " SizeElement_med_float "<<sizeof(med_float)<<
1196 " TotalSizeBinary " <<taille*sizeof(med_float)<<std::endl;
1197 fwrite(tab->tmflo,sizeof(med_float),taille,fichier);
1202 if (verbose>3) std::cout<<"SwapOnFile in binary file done yet "<<
1203 tab->filename.toLatin1().constData()<<std::endl;
1205 //deallocate because swap disk binary mode
1206 tab->CVWtab_deallocate(); //free memory
1210 //************************************
1211 long ghs3dprl_mesh_wrap::SwapOutOfMemory_key_mesh_wrap(const QRegExp &rxp,
1213 //swap on file if not yet and if size greater than ifgreaterthan
1217 QHashIterator<QString,CVWtab*> it(this->mestab);
1218 while ( it.hasNext() ) {
1220 if (it.key().contains(rxp)) {
1222 if ((it.value()->size>0)&&(it.value()->size>ifgreaterthan)){
1224 std::cout<<"SwapOutOfMemory_key_mesh_wrap on demand "<<
1225 it.key().toLatin1().constData()<<
1226 " size "<<it.value()->size<<">"<<ifgreaterthan<<std::endl;
1228 ok=SwapOnFile(it.key(),this->path,it.value(),this->verbose);
1234 //************************************
1235 bool ghs3dprl_mesh_wrap::list_onekey_mesh_wrap(const QString &key)
1237 CVWtab *montab=this->mestab[key];
1239 //std::cout<<"key "<<key<<"trouvee -> size="<<montab->size<<std::endl;
1240 if (montab->type==1)
1241 for ( long i=0; i<montab->size; i++ )
1242 std::cout<<montab->tmint[i]<<" ";
1243 if (montab->type==2)
1244 for ( long i=0; i<montab->size; i++ )
1245 std::cout<<montab->tmflo[i]<<" ";
1246 std::cout<<std::endl;
1249 std::cout<<"key "<<key.toLatin1().constData()<<" not found"<<std::endl;
1253 //************************************
1254 bool ghs3dprl_mesh_wrap::insert_key(const QString &key,CVWtab *tab)
1255 //insertion conditionn� par limite this->nbelem_limit_swap
1256 //si tableaux contenus on dimension superieure
1257 //alors swap disque dans getenv(tmp) fichier temporaire binaire
1261 std::cout<<"insert key "<<key.toLatin1().constData()<<
1262 " size="<<tab->size<<std::endl;
1263 tab->filename="_NO_FILE";
1264 if (this->nbelem_limit_swap<tab->size) {
1265 if (verbose>3) std::cout<<"insert key automatic SwapOnFile "<<
1266 key.toLatin1().constData()<<std::endl;
1267 ok=SwapOnFile(key,this->path,tab,this->verbose);
1269 this->mestab.insert(key,tab);
1272 //************************************
1273 CVWtab* ghs3dprl_mesh_wrap::restore_key(const QString &key)
1274 //retauration conditionn� par limite nbelem
1275 //si tableaux contenus on dimension superieure a nbelem
1276 //alors swap disque dans getenv(tmp) fichier temporaire
1277 //alors lecture du fichier (et reallocate memory)
1280 tab=this->mestab[key];
1281 /*if (tab) std::cout<<" -> size in proc "<<tab->size<<std::endl;
1282 else std::cout<<" -> tab NULL\n";*/
1283 if (!tab) //it is NOT a problem
1285 if (verbose>6) std::cout<<"restore key not found "<<key.toLatin1().constData()<<std::endl;
1289 if (verbose>5) std::cout<<"restore key direct from memory "<<key.toLatin1().constData()<<" size="<<tab->size<<std::endl;
1292 //restore from binary file
1293 if ((tab->type<1)||(tab->type>2)){
1294 std::cerr<<"Problem restore key from binary file "<<tab->filename.toLatin1().constData()<<
1295 " type unexpexted "<<tab->type<<std::endl;
1298 //std::cout<<"restore_key from binary file "<<tab->filename<<std::endl;
1300 //swap disque binaire
1301 FILE *fichier=fopen(tab->filename.toLatin1().constData(),"rb");
1303 fread(&taille,sizeof(long),1,fichier);
1304 if (taille!=-tab->size){
1305 std::cerr<<"Problem restore_key from binary file "<<tab->filename.toLatin1().constData()<<
1306 " size unexpexted "<<taille<<" expected "<<-tab->size<<std::endl;
1312 std::cout<<"restore key from binary file "<<tab->filename.toLatin1().constData()<<
1313 " number of elements "<<taille<<
1314 " size_element med_float "<<sizeof(med_float)<<
1315 " total_size_binary " <<taille*sizeof(med_float)<<std::endl;
1317 //allocate because swap disque binaire
1318 tab->tmint=new med_int[taille]; //allocate memory
1319 fread(tab->tmint,sizeof(med_int),taille,fichier);
1323 std::cout<<"restore key from binary file "<<tab->filename.toLatin1().constData()<<
1324 " number of elements "<<taille<<
1325 " size_element med_float "<<sizeof(med_float)<<
1326 " total_size_binary " <<taille*sizeof(med_float)<<std::endl;
1327 //allocate because swap disque binaire
1328 tab->tmflo=new med_float[taille]; //allocate memory
1329 for (int i=0; i<taille ; i++) tab->tmflo[i]=-1e0;
1330 fread(tab->tmflo,sizeof(med_float),taille,fichier);
1331 /*for (int i=0; i<taille ; i++) std::cout<<tab->tmflo[i]<<"/";
1332 std::cout<<std::endl;*/
1335 tab->size=-tab->size;
1339 //************************************
1340 bool ghs3dprl_mesh_wrap::test_msg_wrap()
1341 //tests sur resultats fichiers msg
1343 QString key1,key2,typ="FA VE ED EL"; //pour faces vertice edges elements
1347 //numerotations locales sont identiques
1348 long nb=typ.count(' ',Qt::CaseSensitive) + 1; //nb chiffres detectes
1349 for (long i=0; i < nb; i++)
1350 for (long ifile=1; ifile <= this->nbfiles; ifile++)
1351 for (long ineig=1; ineig <= this->nbfiles; ineig++)
1353 if (ifile==ineig) continue; //impossible
1354 key1=key1.sprintf("MS%ld NE%ld ",ifile,ineig)+typ.section(' ',i,i)+" SE";
1355 key2=key2.sprintf("MS%ld NE%ld ",ifile,ineig)+typ.section(' ',i,i)+" RE";
1356 //std::cout<<"key "<<key1<<" et key "<<key2<<std::endl;
1357 tab1=this->restore_key(key1);
1358 //tab1=this->mestab[key1];
1359 tab2=this->restore_key(key2);
1360 //tab2=this->mestab[key2];
1361 //std::cout<<"sortie key "<<key1<<" et key "<<key2<<std::endl;
1362 if (!tab1 && !tab2) continue; //case not neighbours
1364 { std::cout<<"key "<<key1.toLatin1().constData()<<" inexistante avec key "<<key2.toLatin1().constData()<<" existante"<<std::endl;
1370 { std::cout<<"key "<<key2.toLatin1().constData()<<" inexistante avec key "<<key1.toLatin1().constData()<<" existante"<<std::endl;
1374 if (!tab1->is_equal(tab2))
1375 { std::cout<<"key "<<key1.toLatin1().constData()<<" et key "<<key2.toLatin1().constData()<<" de contenu differents"<<std::endl;
1380 printf("key '%s' et key '%s' identiques \n",
1381 (const char *)key2,(const char *)key1);*/
1384 //test size neighbourg=ifile
1385 //numerotations locales sont differentes mais de tailles identiques
1386 //pas besoin de verifier " RE " car deja fait au dessus
1387 for (long i=0; i < nb; i++)
1388 for (long ifile=1; ifile <= this->nbfiles; ifile++)
1389 for (long ineig=ifile+1; ineig <= this->nbfiles; ineig++)
1391 if (ifile==ineig) continue; //cas impossible
1392 key1=key1.sprintf("MS%ld NE%ld ",ifile,ineig)+typ.section(' ',i,i)+" SE";
1393 tab1=this->restore_key(key1); //tab1=this->mestab[key1];
1394 key2=key2.sprintf("MS%ld NE%ld ",ineig,ifile)+typ.section(' ',i,i)+" SE";
1395 tab2=this->restore_key(key2); //tab2=this->mestab[key2];
1396 if (!tab1 && !tab2) continue; //case not neighbours
1398 { std::cout<<"key "<<key1.toLatin1().constData()<<" inexistante avec key "<<key2.toLatin1().constData()<<" existante"<<std::endl;
1404 { std::cout<<"key "<<key2.toLatin1().constData()<<" inexistante avec key "<<key1.toLatin1().constData()<<" existante"<<std::endl;
1408 if ((tab1->type!=tab2->type)||(tab1->size!=tab2->size))
1409 { std::cout<<"key "<<key1.toLatin1().constData()<<" et key "<<key2.toLatin1().constData()<<" de type ou tailles differents"<<std::endl;
1417 //************************************
1418 bool ghs3dprl_mesh_wrap::test_vertices_wrap()
1419 //tests sur vertices
1421 QString key1,key2,key11,key22,key11old,key22old;
1422 CVWtab *tab1,*tab2,*tab11,*tab22;
1424 key11old="_NO_KEY";key22old="_NO_KEY";
1425 //test size neighbourg=ifile
1426 //numerotations locales sont differentes mais de tailles identiques
1427 //pas besoin de verifier " RE " car deja fait au dessus
1428 //for (int ifile=1; ifile <= this->nbfiles; ifile++)
1429 //for (int ineig=ifile+1; ineig <= this->nbfiles; ineig++)
1431 for (int ifile=this->nbfiles; ifile >= 1; ifile--)
1432 for (int ineig=this->nbfiles; ineig >= ifile+1; ineig--)
1434 if (ifile==ineig) continue; //cas impossible
1435 key1=key1.sprintf("MS%d NE%d VE SE",ifile,ineig);
1436 key11=key11.sprintf("NB%d VC",ifile);
1437 tab1=this->restore_key(key1); //tab1=this->mestab[key1];
1438 key2=key2.sprintf("MS%d NE%d VE SE",ineig,ifile);
1439 key22=key22.sprintf("NB%d VC",ineig);
1440 tab2=this->restore_key(key2); //tab2=this->mestab[key2];
1441 if (!tab1 && !tab2) continue; //cas non voisins
1444 std::cerr<<"TestEqualityCoordinates key "<<key1.toLatin1().constData()<<
1445 " NOT existing but key "<<key2.toLatin1().constData()<<" existing"<<std::endl;
1450 std::cerr<<"TestEqualityCoordinates key "<<key2.toLatin1().constData()<<
1451 " NOT existing but key "<<key1.toLatin1().constData()<<" existing"<<std::endl;
1454 if (tab1->size!=tab2->size)
1456 std::cerr<<"TestEqualityCoordinates key "<<key1.toLatin1().constData()<<
1457 " and key "<<key2.toLatin1().constData()<<" NOT same size"<<std::endl;
1463 //Swap out of memory if no use
1464 if ((key11old!=key11)&&(key11old!=key22))
1465 this->SwapOutOfMemory_key_mesh_wrap(QRegExp(key11old,Qt::CaseSensitive,QRegExp::RegExp));
1466 if ((key22old!=key11)&&(key22old!=key22))
1467 this->SwapOutOfMemory_key_mesh_wrap(QRegExp(key22old,Qt::CaseSensitive,QRegExp::RegExp));
1469 tab11=this->restore_key(key11); //tab11=this->mestab[key11];
1470 tab22=this->restore_key(key22); //tab22=this->mestab[key22];
1471 if (tab11->size>this->nbelem_limit_swap ||
1472 tab22->size>this->nbelem_limit_swap) swap=true ;
1475 //test on equality of xyz_coordinates of commons vertices
1476 for (long j=0; j < tab1->size-1; j++)
1480 //1 for print vertices not equals
1481 if (!CVW_is_equal_vertices(tab11,i1,tab22,i2,1))
1483 std::cerr<<j<<" Vertice "<<i1<<" != Vertice "<<i2<<"\n"<<std::endl;
1484 ok=false; ok1=false;
1487 if ((verbose>2)&&(ok1))
1488 std::cout<<"TestEqualityCoordinates "<<tab1->size<<
1489 " Vertices "<<key1.toLatin1().constData()<<" and "<<key2.toLatin1().constData()<<" ok"<<std::endl;
1491 std::cerr<<"TestEqualityCoordinates "<<tab1->size<<
1492 " Vertices "<<key1.toLatin1().constData()<<" and "<<key2.toLatin1().constData()<<" NO_OK"<<std::endl;
1493 key11old=key11; key22old=key22;
1496 //Swap out of memory (supposed no use?)
1497 //NO because NB1&NB2 VC supposed future use
1500 this->SwapOutOfMemory_key_mesh_wrap(QRegExp(key11old,Qt::CaseSensitive,QRegExp::RegExp));
1501 this->SwapOutOfMemory_key_mesh_wrap(QRegExp(key22old,Qt::CaseSensitive,QRegExp::RegExp));
1506 //************************************
1507 bool ghs3dprl_mesh_wrap::Find_VerticesDomainToVerticesSkin()
1508 //initialise correspondances vertice skin et vertices locaux pour chaque domaine
1509 //calcule un med_int new tab[nb_vertices_of_domain]
1510 //avec nieme vertice of skin=tab[ieme vertice de domain]
1511 //apres verification tepal garde bien dans la global numbering "GLi VE"
1512 //les indices initiaux des noeuds (attention: de 1 a nbNodes)
1514 QString key1,key2,tmp;
1515 CVWtab *cooskin,*coodom,*glodom,*montab;
1520 cooskin=this->restore_key(QString("SKIN_VERTICES_COORDINATES"));
1521 if (!cooskin) return false;
1522 if (verbose>4)std::cout<<"NumberVerticesSKIN="<<cooskin->size/3<<std::endl;
1523 //ici pourrait creer BBtree sur skin
1524 for (int ifile=1; ifile<=this->nbfiles; ifile++)
1526 key1=key1.sprintf("NB%ld VC",ifile);
1527 coodom=this->restore_key(key1);
1528 if (!coodom) continue; //Problem
1529 key2=key2.sprintf("GL%ld VE",ifile);
1530 glodom=this->restore_key(key2);
1532 std::cout<<"NumberVerticesDOMAIN_"<<ifile<<"="<<glodom->size<<std::endl;
1533 if (coodom->size!=glodom->size*3)
1535 std::cerr<<"Find_VerticesDomainToVerticesSkin key "<<key1.toLatin1().constData()<<
1536 " and key "<<key2.toLatin1().constData()<<" NOT coherent sizes"<<std::endl;
1539 //test on equality of xyz_coordinates of commons vertices
1540 med_int *tab=new med_int[glodom->size];
1542 nb=0; //nb equals vertices
1544 std::cout<<"\nglobal numbering nodes: no iglo\n";
1545 for (jd=0; jd < glodom->size; jd++)
1546 std::cout<<"\t"<<jd<<"\t"<<glodom->tmint[jd]<<std::endl;
1547 std::cout<<"\nresults: no i js iglo\n";
1548 for (jd=0; jd < coodom->size; jd=jd+3)
1550 p2=(coodom->tmflo+jd);
1552 //ici pourrait utiliser BBtree
1553 for (js=0; js < cooskin->size; js=js+3)
1555 p1=(cooskin->tmflo+js);
1556 if (p1[0]==p2[0] && p1[1]==p2[1] && p1[2]==p2[2])
1558 std::cout<<"\t"<<nb<<"\t"<<i<<"\t"<<js/3<<"\t"<<glodom->tmint[i]-1<<
1559 key2.sprintf("\t%13.5e%13.5e%13.5e",p1[0],p1[1],p1[2]).toLatin1().constData()<<std::endl;
1560 tab[i]=js/3; nb++; continue;
1565 montab=new CVWtab(glodom->size,tab);
1566 tmp=tmp.sprintf("NB%ld GL_SKIN",ifile);
1567 ok=this->insert_key(tmp,montab);
1569 std::cout<<"NumberOfEqualsVerticesDOMAIN_"<<ifile<<"="<<nb<<std::endl;
1576 //fin utils procedures
1578 //************************************
1579 bool ghs3dprl_mesh_wrap::Write_masterxmlMEDfile()
1583 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!first call
1586 //define master file (.xml) in memory
1587 tmp=path+medname+".xml";
1588 filemaster=tmp.toLatin1().constData();
1589 domainname=medname.toLatin1().constData();
1592 //Creating the XML document
1593 master_doc = xmlNewDoc(BAD_CAST "1.0");
1594 root_node = xmlNewNode(0, BAD_CAST "root");
1595 xmlDocSetRootElement(master_doc,root_node);
1597 //Creating child nodes
1599 med_int majeur,mineur,release;
1600 //Quelle version de MED est utilisee
1601 MEDlibraryNumVersion(&majeur,&mineur,&release);
1602 if (verbose>0) fprintf(stdout,"Files write with MED V%d.%d.%d\n",majeur,mineur,release);
1603 node = xmlNewChild(root_node, 0, BAD_CAST "version",0);
1604 //xmlNewProp(node, BAD_CAST "maj", BAD_CAST int2string2(majeur).c_str());
1605 xmlNewProp(node, BAD_CAST "maj", BAD_CAST i2a(majeur).c_str());
1606 xmlNewProp(node, BAD_CAST "min", BAD_CAST i2a(mineur).c_str());
1607 xmlNewProp(node, BAD_CAST "ver", BAD_CAST i2a(release).c_str());
1610 node = xmlNewChild(root_node,0, BAD_CAST "description",0);
1611 xmlNewProp(node, BAD_CAST "what", BAD_CAST "tetrahedral mesh by MeshGems-Tetra-hpc (formerly tepal)");
1614 GetLocalTime ( &present );
1615 sprintf(buff,"%04d/%02d/%02d %02dh%02dm",
1616 present.wYear,present.wMonth,present.wDay,
1617 present.wHour,present.wMinute);
1621 struct tm *time_asc = localtime(&present);
1622 sprintf(buff,"%04d/%02d/%02d %02dh%02dm",
1623 time_asc->tm_year+1900,time_asc->tm_mon+1,time_asc->tm_mday,
1624 time_asc->tm_hour,time_asc->tm_min);
1626 xmlNewProp(node, BAD_CAST "when", BAD_CAST buff);
1627 xmlNewProp(node, BAD_CAST "from", BAD_CAST "tepal2med");
1630 node =xmlNewChild(root_node,0, BAD_CAST "content",0);
1631 node2 = xmlNewChild(node, 0, BAD_CAST "mesh",0);
1632 xmlNewProp(node2, BAD_CAST "name", BAD_CAST domainname.c_str());
1633 info_node = xmlNewChild(node, 0, BAD_CAST "tepal2med_info",0);
1636 node=xmlNewChild(root_node,0,BAD_CAST "splitting",0);
1637 node2=xmlNewChild(node,0,BAD_CAST "subdomain",0);
1638 xmlNewProp(node2, BAD_CAST "number", BAD_CAST i2a(nbfilestot).c_str());
1639 node2=xmlNewChild(node,0,BAD_CAST "global_numbering",0);
1640 xmlNewProp(node2, BAD_CAST "present", BAD_CAST "yes");
1643 files_node=xmlNewChild(root_node,0,BAD_CAST "files",0);
1646 node = xmlNewChild(root_node,0,BAD_CAST "mapping",0);
1647 mesh_node = xmlNewChild(node, 0, BAD_CAST "mesh",0);
1648 xmlNewProp(mesh_node, BAD_CAST "name", BAD_CAST domainname.c_str());
1651 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!all calls
1653 char *hostname = getenv("HOSTNAME");
1654 node = xmlNewChild(files_node,0,BAD_CAST "subfile",0);
1655 xmlNewProp(node, BAD_CAST "id", BAD_CAST i2a(idom).c_str());
1656 node2 = xmlNewChild(node, 0, BAD_CAST "name", BAD_CAST distfilename);
1657 if (hostname == NULL)
1658 node2 = xmlNewChild(node, 0, BAD_CAST "machine",BAD_CAST "localhost");
1660 node2 = xmlNewChild(node, 0, BAD_CAST "machine",BAD_CAST hostname);
1662 node = xmlNewChild(mesh_node,0,BAD_CAST "chunk",0);
1663 xmlNewProp(node, BAD_CAST "subdomain", BAD_CAST i2a(idom).c_str());
1664 node2 = xmlNewChild(node, 0, BAD_CAST "name", BAD_CAST nomfinal);
1667 node = xmlNewChild(info_node, 0, BAD_CAST "chunk",0);
1668 xmlNewProp(node, BAD_CAST "subdomain", BAD_CAST i2a(idom).c_str());
1669 xmlNewProp(node, BAD_CAST "nodes_number", BAD_CAST i2a(nbnodes).c_str());
1670 xmlNewProp(node, BAD_CAST "faces_number", BAD_CAST i2a(nbtria3).c_str());
1671 xmlNewProp(node, BAD_CAST "tetrahedra_number", BAD_CAST i2a(nbtetra4).c_str());
1672 //node2 = xmlNewChild(node, 0, BAD_CAST "name", BAD_CAST nomfinal);
1674 //node2 = xmlNewChild(node, 0, BAD_CAST "nodes", 0);
1675 //xmlNewProp(node2, BAD_CAST "number", BAD_CAST i2a(nbnodes).c_str());
1676 //node2 = xmlNewChild(node, 0, BAD_CAST "faces", 0);
1677 //xmlNewProp(node2, BAD_CAST "number", BAD_CAST i2a(nbtria3).c_str());
1678 //node2 = xmlNewChild(node, 0, BAD_CAST "tetrahedra", 0);
1679 //xmlNewProp(node2, BAD_CAST "number", BAD_CAST i2a(nbtetra4).c_str());
1681 //tepal2med_info about joints of one subdomain
1682 xmlAddChild(node,joints_node);
1683 //tepal2med_info about groups and families of one subdomain
1684 xmlAddChild(node,families.xml_groups());
1687 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!last call
1688 if (idom==nbfilestot)
1690 node2 = xmlNewChild(info_node, 0, BAD_CAST "global",0);
1691 xmlNewProp(node2, BAD_CAST "tetrahedra_number", BAD_CAST i2a(nbtetrastotal).c_str());
1693 xmlSaveFormatFileEnc(filemaster.c_str(), master_doc, "UTF-8", 1);
1694 xmlFreeDoc(master_doc);
1701 //************************************
1702 bool ghs3dprl_mesh_wrap::Write_MEDfiles_v2(bool deletekeys)
1703 //deletekeys=true to delete non utils keys and arrays "au fur et a mesure"
1707 char description[MED_COMMENT_SIZE];
1708 char dtunit[MED_SNAME_SIZE+1]="_NO_UNIT";
1709 char axisname[MED_SNAME_SIZE*3+1]="x y z ";
1710 char axisunit[MED_SNAME_SIZE*3+1]="_NO_UNIT _NO_UNIT _NO_UNIT ";
1714 //precaution because casename->med_nomfinal no more 32 character
1715 //if path, in this->path.
1716 //20 preserve for add postfixes "_idom" etc...
1717 if (verbose>0)std::cout<<"\nWrite_MEDfiles_v2\n";
1718 if (verbose>6){std::cout<<"\nInitialFamilies\n"; families.write();}
1720 medname=medname.section('/',-1);
1721 if (medname.length()>20) {
1722 std::cerr<<"CaseNameMed truncated (no more 20 characters)"<<std::endl;
1723 medname.truncate(20);
1726 //create file resume DOMAIN.joints.med of all joints for quick display (...may be...)
1727 tmp=path+medname+tmp.sprintf("_joints.med",idom);
1728 charendnull(distfilename,tmp,MED_COMMENT_SIZE);
1729 fidjoint=MEDfileOpen(distfilename,MED_ACC_CREAT);
1730 if (fidjoint<0) std::cerr<<"Problem MEDfileOpen "<<distfilename<<std::endl;
1731 if (verbose>0) std::cout<<"CreateMEDFile for all joints <"<<distfilename<<">\n";
1733 //copy file source/GHS3DPRL_skin.med as destination/DOMAIN.skin.med
1734 tmp=path+medname+"_skin.med";
1735 cmd=pathini+casename+"_skin.med";
1736 int ret = access(cmd.toLatin1().constData(),F_OK); //on regarde si le fichier existe
1743 cmd = cmd+pathini+casename+"_skin.med "+tmp;
1744 //std::cout<<"Copy skin.med Command = "<<cmd<<std::endl;
1745 system(cmd.toLatin1().constData());
1746 if (verbose>0) std::cout<<"CreateMEDFile for initial skin <"<<tmp.toLatin1().constData()<<">\n"; }
1748 if (verbose>0) std::cout<<"No CreateMEDFile <"<<tmp.toLatin1().constData()<<"> for initial skin because <"<<
1749 cmd.toLatin1().constData()<<"> does not exist\n"; }
1751 //define family 0 if not existing, no groups
1752 //La famille FAMILLE_ZERO n'a pas été trouvée, elle est obligatoire
1753 families.add("0","FAMILLE_ZERO");
1754 //define family Group_of_New_Nodes (which not exists before tetrahedra)
1756 if (QString("All_Nodes").contains(deletegroups)==0){
1757 oktmp=families.get_number_of_new_family(1,&famallnodes,&tmp);
1758 families.add(tmp,"All_Nodes");
1760 else if (verbose>3) std::cout<<"--deletegroups matches \"All_Nodes\"\n";
1763 if (QString("All_Faces").contains(deletegroups)==0){
1764 oktmp=families.get_number_of_new_family(-1,&famalltria3,&tmp);
1765 families.add(tmp,"All_Faces");
1767 else if (verbose>3) std::cout<<"--deletegroups matches \"All_Faces\"\n";
1770 if (QString("All_Tetrahedra").contains(deletegroups)==0){
1771 oktmp=families.get_number_of_new_family(-1,&famalltetra4,&tmp);
1772 families.add(tmp,"All_Tetrahedra");
1774 else if (verbose>3) std::cout<<"--deletegroups matches \"All_Tetrahedra\"\n";
1777 if (QString("New_Nodes").contains(deletegroups)==0){
1778 oktmp=families.get_number_of_new_family(1,&famnewnodes,&tmp);
1779 families.add(tmp,"New_Nodes");
1781 else if (verbose>3) std::cout<<"--deletegroups matches \"New_Nodes\"\n";
1784 if (QString("New_Faces").contains(deletegroups)==0){
1785 oktmp=families.get_number_of_new_family(-1,&famnewtria3,&tmp);
1786 families.add(tmp,"New_Faces");
1788 else if (verbose>3) std::cout<<"--deletegroups matches \"New_Faces\"\n";
1791 if (QString("New_Tetrahedra").contains(deletegroups)==0){
1792 oktmp=families.get_number_of_new_family(-1,&famnewtetra4,&tmp);
1793 families.add(tmp,"New_Tetrahedra");
1795 else if (verbose>3) std::cout<<"--deletegroups matches \"New_Tetrahedra\"\n";
1797 if (verbose>6){std::cout<<"\nIntermediatesFamilies\n"; families.write();}
1798 if (verbose>6) std::cout<<"\nNumber0fFiles="<<nbfilestot<<std::endl;
1799 familles intermediatesfamilies=families;
1800 //initialisations on all domains
1803 //loop on the domains
1804 //for (idom=1; idom<=nbfilestot; idom++) {
1805 for (idom=1; idom<=nbfilestot; idom++) {
1808 //restore initial context of families
1809 if (idom>1) families=intermediatesfamilies;
1810 //if (idom>1) continue;
1811 tmp=path+medname+tmp.sprintf("_%d.med",idom);
1812 charendnull(distfilename,tmp,MED_COMMENT_SIZE);
1814 //std::cout<<"<"<<distfilename<<">"<<std::endl;
1815 fid=MEDfileOpen(distfilename,MED_ACC_CREAT);
1816 if (fid<0) {std::cerr<<"Problem MEDfileOpen "<<distfilename<<std::endl; goto erreur;}
1818 if (verbose>2) std::cout<<std::endl;
1819 std::cout<<"CreateMEDFile "<<idom<<" <"<<distfilename<<">\n";
1823 tmp=medname+tmp.sprintf("_%d",idom);
1824 charendnull(nomfinal,tmp,MED_NAME_SIZE);
1825 tmp=tmp.sprintf("domain %d among %d",idom,nbfilestot);
1826 charendnull(description,tmp,MED_COMMENT_SIZE);
1828 if (verbose>4) std::cout<<"Description : "<<description<<std::endl;
1829 err=MEDmeshCr(fid,nomfinal,3,3,MED_UNSTRUCTURED_MESH,description,dtunit,MED_SORT_DTIT,MED_CARTESIAN,axisname,axisunit);
1830 if (err<0) {std::cerr<<"Problem MEDmeshCr"<<nomfinal<<std::endl; goto erreur;}
1832 if (!idom_nodes()) {std::cerr<<"Problem on Nodes"<<std::endl; goto erreur;}
1833 if (!idom_edges()) {std::cerr<<"Problem on Edges"<<std::endl; goto erreur;}
1834 if (!idom_faces()) {std::cerr<<"Problem on Faces"<<std::endl; goto erreur;}
1835 if (!idom_tetras()) {std::cerr<<"Problem on tetrahedra"<<std::endl; goto erreur;}
1836 if (!idom_joints()) {std::cerr<<"Problem on Joints"<<std::endl; goto erreur;}
1838 if (verbose>6){std::cout<<"\nFinalsFamilies\n"; families.write();}
1839 //for nodes families
1840 nb=create_families(fid,1);
1841 if (verbose>5)std::cout<<"NumberOfFamiliesNodes="<<nb<<std::endl;
1843 err=MEDmeshEntityFamilyNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_NODE,MED_UNDEF_GEOMETRY_TYPE,nbnodes,famnodes);
1845 std::cout<<"MEDmeshEntityFamilyNumberWr nodes "<<nbnodes<<":"<<
1846 famnodes[0]<<"..."<<famnodes[nbnodes-1]<<" "<<std::endl;
1848 if (err<0) std::cerr<<"Problem MEDmeshEntityFamilyNumberWr nodes"<<std::endl;
1850 //for others families
1851 nb=create_families(fid,-1);
1852 if (verbose>5)std::cout<<"NumberOfFamiliesFacesAndEdgesEtc="<<nb<<std::endl;
1854 err=MEDmeshEntityFamilyNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TRIA3,nbtria3,famtria3);
1856 std::cout<<"MEDmeshEntityFamilyNumberWr tria3 "<<nbtria3<<":"<<
1857 famtria3[0]<<"..."<<famtria3[nbtria3-1]<<" "<<std::endl;
1859 if (err<0) std::cerr<<"Problem MEDmeshEntityFamilyNumberWr tria3"<<std::endl;
1861 err=MEDmeshEntityFamilyNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TETRA4,nbtetra4,famtetra4);
1863 std::cout<<"MEDmeshEntityFamilyNumberWr tetra4 "<<nbtetra4<<":"<<
1864 famtetra4[0]<<"..."<<famtetra4[nbtria3-1]<<" "<<std::endl;
1866 if (err<0) std::cerr<<"Problem MEDmeshEntityFamilyNumberWr tria3"<<std::endl;
1868 MEDfileClose(fid); //no error
1869 //master.xml writings
1870 oktmp=Write_masterxmlMEDfile();
1871 continue; //and loop on others domains
1875 MEDfileClose(fid); //but loop on others domains
1879 MEDfileClose(fidjoint); //no error
1880 if (verbose>0)std::cout<<"\nTotalNumberOftetrahedra="<<nbtetrastotal<<std::endl;
1885 //************************************
1886 bool ghs3dprl_mesh_wrap::idom_nodes()
1889 QString tmp,key,key1,key2,key3;
1890 CVWtab *tab,*tab1,*tab2,*tab3;
1891 med_int i,j,*arrayi;
1894 //writing node(vertices) coordinates
1895 //NBx VC=files.NoBoite Vertex Coordinates
1896 key=key.sprintf("NB%d VC",idom); //files.NoBoite Vertex Coordinates
1897 tab=this->restore_key(key); //tab1=this->mestab[key1];
1899 if (!for_tetrahpc) {
1900 tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".noboite";
1901 ok=this->ReadFileNOBOITE(tmp);
1904 tmp=pathini+casename+tmp.sprintf(format_tetra.toLatin1().constData(),idom)+".mesh";
1905 ok=this->ReadFileMESH(tmp);
1907 tab=this->restore_key(key); //tab1=this->mestab[key1];
1908 if (!tab) return false;
1910 tmp=tmp.sprintf("NB%d SN",idom);
1911 //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
1912 xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
1913 nbnodes=tab->size/3;
1914 err=MEDmeshNodeCoordinateWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,0.,MED_FULL_INTERLACE,nbnodes,tab->tmflo);
1915 if (err<0) {std::cerr<<"Problem MEDmeshNodeCoordinateWr"<<std::endl; return false;}
1916 if (verbose>4)std::cout<<"NumberOfNodes="<<nbnodes<<std::endl;
1918 //writing indices of nodes
1919 arrayi=new med_int[nbnodes];
1920 for (i=0; i<nbnodes ; i++) arrayi[i]=i+1;
1921 err=MEDmeshEntityNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_NODE,MED_UNDEF_GEOMETRY_TYPE,nbnodes,arrayi);
1923 if (err<0) {std::cerr<<"Problem MEDmeshEntityNumberWr of nodes"<<std::endl; return false;}
1925 key1=key1.sprintf("GL%d VE",idom); //global numerotation
1926 tab1=this->restore_key(key1); //tab1=this->mestab[key1];
1928 if (!for_tetrahpc) {
1929 tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".glo";
1930 ok=this->ReadFileGLO(tmp);
1933 tmp=pathini+casename+tmp.sprintf(format_tetra.toLatin1().constData(),idom)+".glo";
1934 ok=this->ReadFileGLO(tmp);
1936 if (!ok) {std::cerr<<"Problem file "<<tmp.toLatin1().constData()<<std::endl; return false;}
1937 tab1=this->restore_key(key1); //tab1=this->mestab[key1];
1938 if (!tab1) return false;
1940 if (nbnodes!=tab1->size){std::cerr<<"Problem size GLi VE!=nbnodes!"<<std::endl; return false;}
1942 key2=key2.sprintf("SKIN_VERTICES_FAMILIES",idom); //on global numerotation
1943 tab2=this->restore_key(key2); //tab1=this->mestab[key1];
1945 if (tab2) med_int nbskin=tab2->size;
1946 //for (i=0; i<nbskin; i++) std::cout<<i<<" "<<tab2->tmint[i]<<std::endl;
1948 //set families of nodes existing in GHS3DPRL_skin.med
1950 famnodes=new med_int[nb];
1951 for (i=0; i<nb ; i++) famnodes[i]=famallnodes;
1952 med_int * fammore=new med_int[nb];
1953 for (i=0; i<nb ; i++) fammore[i]=famnewnodes;
1955 //set families of nodes of skin
1956 for (i=0; i<nb ; i++){
1957 j=tab1->tmint[i]-1; //
1959 fammore[i]=tab2->tmint[j];
1962 ok=set_one_more_family(famnodes,fammore,nb);
1965 //std::cout<<"nodes loc "<<i<<" = gl "<<j<<"\t << "<<tab2->tmint[j]<<
1966 // tmp.sprintf("\t%23.15e%23.15e%23.15e",tab3->tmflo[i*3],
1967 // tab3->tmflo[i*3+1],tab3->tmflo[i*3+2])<<std::endl;
1969 //writing nodes(vertices) global numbering
1970 err=MEDmeshGlobalNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_NODE,MED_UNDEF_GEOMETRY_TYPE,nbnodes,tab1->tmint);
1971 if (err<0){std::cerr<<"Problem MEDmeshGlobalNumberWr nodes"<<std::endl; return false;}
1977 //************************************
1978 bool ghs3dprl_mesh_wrap::set_one_more_family_old(med_int *fami, med_int *more, med_int nb)
1979 //fuse array of med_int families more et fami as kind of groups
1980 //because there are possibilities of intersections
1983 med_int i,newfam,morfam,oldfam;
1984 for (i=0; i<nb ; i++) {
1985 if (more[i]==0) continue;
1988 //std::cout<<"sur "<<i<<" en plus "<<more[i]<<std::endl;
1990 else { //intersection
1991 if (fami[i]==more[i]) continue; //same families
1994 //create new family intersection if needed
1995 newfam=families.find_family_on_groups(oldfam,morfam);
1996 //std::cout<<"oldfam "<<oldfam<<" morfam "<<morfam<<" -> newfam "<<newfam<<std::endl;
2003 //************************************
2004 bool ghs3dprl_mesh_wrap::set_one_more_family(med_int *fami, med_int *more, med_int nb)
2005 //fuse array of med_int families more et fami as kind of groups
2006 //because there are possibilities of intersections
2009 med_int i,ii,j,newfam,morfam,oldfam,morfami,oldfami,i_zero,nb_fam,nb_max,nb_tot,nb_mess;
2012 nb_fam=families.fam.size(); //on families negative and positive
2013 //std::cout<<"size families "<<nb_fam<<std::endl;
2014 if (nb_fam<=0) nb_fam=5; //precaution
2015 i_zero=nb_fam*2; //offset for negative indices of families
2017 if (nb_fam>300) std::cout<<
2018 "***set_one_more_family*** warning many initial families could decrease speed "<<nb_fam<<std::endl;
2019 nb_tot=nb_max*nb_max; //max oversizing *2 on families
2020 //newfami is for speed (avoid calls find_family_on_groups)
2021 //it is an array[nb_fam*4][nb_fam*4] implemented on vector[nb_max]
2022 //to memorize newfam in array[oldfam][morfam]
2023 newfami=new med_int[nb_tot];
2024 for (i=0; i<nb_tot ; i++) newfami[i]=0; //not yet met!
2027 for (i=0; i<nb ; i++) {
2028 if (more[i]==0) continue;
2031 //std::cout<<"sur "<<i<<" en plus "<<more[i]<<std::endl;
2033 else { //intersection
2034 if (fami[i]==more[i]) continue; //same families
2035 oldfam=fami[i]; oldfami=oldfam+i_zero;
2036 morfam=more[i]; morfami=morfam+i_zero;
2038 ii=oldfami+morfami*nb_max; //array 2d on vector
2039 if ((ii>=0)&&(ii<nb_tot)) {
2045 std::cout<<"***set_one_more_family*** warning many new families decrease speed "<<nb_fam<<std::endl;
2051 //create new family intersection if needed
2052 newfam=families.find_family_on_groups(oldfam,morfam);
2053 //std::cout<<"new oldfam "<<oldfam<<" morfam "<<morfam<<" -> newfam "<<newfam<<std::endl;
2054 if (ii>=0) newfami[ii]=newfam;
2057 std::cout<<"!!! oldfam "<<oldfam<<" morfam "<<morfam<<" -> newfam "<<newfam<<std::endl;
2066 //************************************
2067 bool ghs3dprl_mesh_wrap::idom_edges()
2075 //************************************
2076 bool ghs3dprl_mesh_wrap::idom_faces()
2079 QString tmp,key,key1,key2,key3;
2080 CVWtab *tab,*tab1,*tab2,*tab3;
2081 med_int ii,i,j,*arrayi;
2084 //writing connectivity of faces triangles of wrap by nodes
2085 key1=key1.sprintf("FC%d",idom); //files.FaCes faces (wrap and triangles only)
2086 tab1=this->restore_key(key1); //tab1=this->mestab[key1];
2088 tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".faces";
2089 ok=this->ReadFileFACES(tmp);
2090 tab1=this->restore_key(key1);
2091 if (!tab1) return false;
2093 nbtria3=tab1->size/7;
2094 if (verbose>4) std::cout<<"NumberOfTriangles="<<nbtria3<<std::endl;
2095 arrayi=new med_int[nbtria3*3];
2097 for (j=0; j<nbtria3 ; j++){
2098 arrayi[ii]=tab1->tmint[i]; ii++;
2099 arrayi[ii]=tab1->tmint[i+1]; ii++;
2100 arrayi[ii]=tab1->tmint[i+2]; ii++;
2103 err=MEDmeshElementConnectivityWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,0.,MED_CELL,MED_TRIA3,MED_NODAL,MED_FULL_INTERLACE,nbtria3,arrayi);
2104 delete[] arrayi; //need immediately more little array
2105 if (err<0){std::cerr<<"Problem MEDmeshElementConnectivityWr for triangles connectivity"<<std::endl; return false;}
2107 //writing indices of faces triangles of wrap
2109 //generate "overlapping of numbers of elements" in "import med file" in salome
2110 //if not in "//writing indices of tetrahedra" -> arrayi[i]=!NBFACES!+i+1
2111 arrayi=new med_int[nbtria3];
2112 for (i=0; i<nbtria3 ; i++) arrayi[i]=nbseg2+i+1;
2113 err=MEDmeshEntityNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TRIA3,nbtria3,arrayi);
2115 if (err<0){std::cerr<<"Problem MEDmeshEntityNumberWr of triangles"<<std::endl; return false;}
2117 //GLx FA=files.GLo FAces
2118 key1=key1.sprintf("GL%d FA",idom);
2119 tab1=this->restore_key(key1); //tab1=this->mestab[key1];
2120 if (nbtria3!=tab1->size){std::cerr<<"Problem size GLi FA!=nbtria3!"<<std::endl; return false;}
2122 key2=key2.sprintf("SKIN_TRIA3_FAMILIES",idom); //on global numerotation
2123 tab2=this->restore_key(key2); //tab1=this->mestab[key1];
2125 if (tab2) nbskin=tab2->size;
2127 //set families of faces existing in GHS3DPRL_skin.med
2129 famtria3=new med_int[nb];
2130 for (i=0; i<nb ; i++) famtria3[i]=famalltria3;
2131 med_int * fammore=new med_int[nb];
2132 for (i=0; i<nb ; i++) fammore[i]=famnewtria3;
2134 //set families of faces of skin
2135 for (i=0; i<nb ; i++){
2136 j=tab1->tmint[i]-1; //
2138 fammore[i]=tab2->tmint[j];
2141 ok=set_one_more_family(famtria3,fammore,nb);
2144 //writing faces(triangles) global numbering
2146 std::cout<<"CreateMEDglobalNumerotation_Faces "<<key1.toLatin1().constData()<<" "<<tab1->size<<std::endl;
2147 err=MEDmeshGlobalNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TRIA3,tab1->size,tab1->tmint);
2148 if (err<0){std::cerr<<"Problem MEDmeshGlobalNumberWr faces"<<std::endl; return false;}
2150 //xx=this->remove_key_mesh_wrap(QRegExp("FC*",true,true));
2151 tmp=tmp.sprintf("GL%d FA",idom);
2152 //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
2153 xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
2154 tmp=tmp.sprintf("GL%d VE",idom);
2155 //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
2156 xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
2161 //************************************
2162 bool ghs3dprl_mesh_wrap::idom_joints()
2165 QString tmp,namejoint,key,key1,key2;
2166 CVWtab *tab,*tab1,*tab2;
2167 med_int ineig,ii,jj,i,j,k,*arrayi,nb,famjoint,*fammore,*inodes,*arrayfaces;
2168 med_float *arraynodes;
2169 char namejnt[MED_NAME_SIZE+1]; //no more 32
2170 char namedist[MED_NAME_SIZE+1];
2171 char descjnt[MED_COMMENT_SIZE+1];
2172 med_int numfam_ini_wrap=100;
2173 joints_node=xmlNewNode(NULL, BAD_CAST "joints"); //masterfile.xml
2174 med_int nbjoints=0,nbnodesneig,nbtria3neig;
2175 std::string sjoints=""; //which domains are neighbourg
2177 char dtunit[MED_SNAME_SIZE+1]="_NO_UNIT";
2178 char axisname[MED_SNAME_SIZE*3+1]="x y z ";
2179 char axisunit[MED_SNAME_SIZE*3+1]="_NO_UNIT _NO_UNIT _NO_UNIT ";
2181 tmp=tmp.sprintf("MS%d *",idom);
2182 //read file .msg if not done
2183 //qt3 if (this->nb_key_mesh_wrap(QRegExp(tmp,true,true))<=0) {
2184 if (this->nb_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp))<=0) {
2187 if (!for_tetrahpc) {
2188 tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".msg";
2191 tmp=pathini+casename+tmp.sprintf(format_tetra.toLatin1().constData(),idom)+".msg";
2194 ok=this->ReadFileMSGnew(tmp);
2196 std::cerr<<"Problem in file "<<tmp.toLatin1().constData()<<std::endl;
2202 for (ineig=1; ineig <= nbfilestot; ineig++) {
2203 if (idom==ineig) continue; //impossible
2205 //!*************nodes
2206 //std::cout<<"\n nodes joints\n";
2207 key1=key1.sprintf("MS%d NE%d VE SE",idom,ineig); //SE or RE identicals
2208 tab1=restore_key(key1);
2209 if (!tab1) continue; //case (ifile,ineig) are not neighbours=>no joints
2210 key1=key1.sprintf("MS%d NE%d VE SE",ineig,idom); //SE or RE identicals
2211 tab2=this->restore_key(key1);
2212 //if not yet loaded (first time) try to load necessary file msg of neighbourg
2215 if (!for_tetrahpc) {
2216 tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,ineig)+".msg";
2219 tmp=pathini+casename+tmp.sprintf(format_tetra.toLatin1().constData(),ineig)+".msg";
2222 this->nofile=ineig; //neighbourg file
2223 ok=this->ReadFileMSGnew(tmp);
2224 this->nofile=idom; //restaure initial domain
2226 std::cerr<<"Problem in file "<<tmp.toLatin1().constData()<<std::endl;
2229 tab2=this->restore_key(key1);
2231 if (!tab2) std::cerr<<"Problem existing nodes joint in domain "<<idom<<
2232 " with none in neighbourg "<<ineig<<" files .msg"<<std::endl;
2233 nb=tab1->size; nbnodesneig=tab2->size;
2234 if (nb!=nbnodesneig) {
2235 std::cerr<<"Problem in file "<<tmp.toLatin1().constData()<<
2236 " number of nodes of joint "<<idom<<"<->"<<ineig<<" not equals"<<std::endl;
2240 nbjoints++; //one more joint for this domain
2241 sjoints=sjoints+" "+i2a(ineig);
2243 std::cout<<"NumberOfNodesOfJoint_"<<idom<<"_"<<ineig<<"="<<nb<<std::endl;
2244 namejoint=namejoint.sprintf("JOINT_%d_%d_Nodes",idom,ineig);
2245 strcpy(namejnt,namejoint.toLatin1().constData());
2246 tmp=tmp.sprintf("JOINT_%d_%d among %d domains of ",idom,ineig,nbfilestot)+nomfinal;
2247 strcpy(descjnt,tmp.toLatin1().constData());
2248 tmp=medname+tmp.sprintf("_%d",ineig);
2249 strcpy(namedist,tmp.toLatin1().constData());
2250 err=MEDsubdomainJointCr(fid,nomfinal,namejnt,descjnt,ineig,namedist);
2251 if (err<0) std::cerr<<"Problem MEDsubdomainJointCr"<<std::endl;
2254 if (namejoint.contains(deletegroups)==0){
2255 ok=families.get_number_of_new_family(1,&famjoint,&tmp);
2256 families.add(tmp,namejoint);
2259 key=key.sprintf("NB%d VC",idom); //files.NoBoite Vertex Coordinates
2260 tab=this->restore_key(key); //tab1=this->mestab[key1];
2261 //nbnodes=tab->size/3;
2263 //writing correspondence nodes-nodes
2264 //two indices for one correspondence
2265 arrayi=new med_int[nb*2];
2266 arraynodes=new med_float[nbnodesneig*3]; //for file DOMAIN_join.med
2267 inodes=new med_int[nbnodes]; //for file DOMAIN_join.med
2268 med_int * fammore=new med_int[nbnodes];
2269 for (i=0; i<nbnodes ; i++) {fammore[i]=0; inodes[i]=-2;} //precautions
2271 for (i=0; i<nb ; i++){
2272 //no need because <send> equals <receive> tab1->tmint[i]==tab2->tmint[i]
2273 j=tab1->tmint[i]-1; //contents of tab1 1->nb, j 0->nb-1
2274 inodes[j]=k; k++; //contents of inodes 1->n ,nodes of joint from nodes of domain
2275 arraynodes[jj]=tab->tmflo[j*3]; jj++;
2276 arraynodes[jj]=tab->tmflo[j*3+1]; jj++;
2277 arraynodes[jj]=tab->tmflo[j*3+2]; jj++;
2279 fammore[j]=famjoint;
2280 arrayi[ii]=tab1->tmint[i]; ii++;
2281 arrayi[ii]=tab2->tmint[i]; ii++;
2283 if (namejoint.contains(deletegroups)==0){
2284 ok=set_one_more_family(famnodes,fammore,nbnodes);
2288 err=MEDsubdomainCorrespondenceWr(fid,nomfinal,namejnt,MED_NO_DT,MED_NO_IT,
2289 MED_NODE,MED_UNDEF_GEOMETRY_TYPE,MED_NODE,MED_UNDEF_GEOMETRY_TYPE,nb,arrayi);
2290 if (err<0) std::cerr<<"Problem MEDsubdomainCorrespondenceWr nodes"<<std::endl;
2293 //!*************TRIA3
2294 //writing correspondence triangles-triangles
2295 //std::cout<<"\n faces joints\n";
2297 key1=key1.sprintf("MS%d NE%d FA SE",idom,ineig); //SE or RE identicals
2298 tab1=this->restore_key(key1); //tab1=this->mestab[key1];
2301 std::cout<<"NumberOfTrianglesOfJoint_"<<idom<<"_"<<ineig<<"=0"<<std::endl;
2302 //continue; //case (ifile,ineig) are not neighbours=>no joints
2304 else //have to set xml may be no faces but nodes in a joint!
2306 key1=key1.sprintf("MS%d NE%d FA SE",ineig,idom); //SE or RE identicals
2307 tab2=this->restore_key(key1);
2308 if (!tab2) std::cerr<<"Problem existing triangles of joint in domain "<<idom<<
2309 " with none in neighbourg "<<ineig<<" files .msg"<<std::endl;
2310 nb=tab1->size; nbtria3neig=tab2->size;
2311 if (nb!=nbtria3neig) {
2312 std::cerr<<"Problem in file "<<tmp.toLatin1().constData()<<
2313 " number of triangles of joint "<<idom<<"<->"<<ineig<<" not equals"<<std::endl;
2316 namejoint=namejoint.sprintf("JOINT_%d_%d_Faces",idom,ineig);
2319 if (namejoint.contains(deletegroups)==0){
2320 ok=families.get_number_of_new_family(-1,&famjoint,&tmp);
2321 families.add(tmp,namejoint);
2324 key=key.sprintf("FC%d",idom); //files.FaCes faces (wrap and triangles only)
2325 tab=this->restore_key(key); //tab1=this->mestab[key1];
2327 med_int nb=tab1->size; nbtria3neig=nb;
2328 //if (verbose>=0) std::cout<<"NumberOfTrianglesOfJoint_"<<idom<<"_"<<ineig<<"="<<nb<<std::endl;
2329 arrayi=new med_int[nb*2]; //correspondance indices triangles in 2 domains
2330 arrayfaces=new med_int[nbtria3neig*3]; //for file DOMAIN_join.med
2331 for (i=0; i<nbtria3neig*3 ; i++) arrayfaces[i]=-1; //precaution
2332 fammore=new med_int[nbtria3];
2333 for (i=0; i<nbtria3 ; i++) fammore[i]=0;
2335 for (i=0; i<nb ; i++){
2336 arrayi[ii]=tab1->tmint[i]; ii++;
2337 arrayi[ii]=tab2->tmint[i]; ii++; //correspondance indices triangles in 2 domains
2339 fammore[tab1->tmint[i]-1]=famjoint;
2340 //famtria3[tab1->tmint[i]-1]=famjoint;
2342 k=tab1->tmint[i]-1; //indice of node connectivity
2343 //std::cout<<"k="<<k<<std::endl;
2344 k=k*7; //indice of node connectivity in tab of triangles
2346 arrayfaces[jj]=inodes[tab->tmint[k]-1]; jj++;
2347 arrayfaces[jj]=inodes[tab->tmint[k+1]-1]; jj++;
2348 arrayfaces[jj]=inodes[tab->tmint[k+2]-1]; jj++;
2351 for (i=0; i<nbtria3neig*3 ; i++) {
2352 if (arrayfaces[i]<=0) {
2353 std::cerr<<"Problem file X_joints.med unknown node in joint "<<idom<<"_"<<ineig<<" face "<<i/3+1<<std::endl; //precaution
2357 /*TODO DEBUG may be bug distene?
2359 std::cout<<"\nNumberOfTrianglesOfJoint_"<<idom<<"_"<<ineig<<"="<<nb<<std::endl;
2360 for (i=0; i<nbnodes ; i++) std::cout<<"inode i "<<i+1<<" "<<inodes[i]<<std::endl;
2361 for (i=0; i<tab1->size ; i++) std::cout<<"triangle i "<<i+1<<" "<<tab1->tmint[i]<<std::endl;
2362 for (i=0; i<tab->size ; i=i+7) std::cout<<"conn i "<<i/7+1<<" : "<<tab->tmint[i]<<" "<<tab->tmint[i+1]<<" "<<tab->tmint[i+2]<<std::endl;
2365 if (namejoint.contains(deletegroups)==0){
2366 ok=set_one_more_family(famtria3,fammore,nbtria3);
2370 err=MEDsubdomainCorrespondenceWr(fid,nomfinal,namejnt,MED_NO_DT,MED_NO_IT,
2371 MED_CELL,MED_TRIA3,MED_CELL,MED_TRIA3,nb,arrayi);
2372 if (err<0) std::cerr<<"Problem MEDsubdomainCorrespondenceWr triangles"<<std::endl;
2376 //!write in file resume DOMAIN.joints.med of all joints for quick display (...may be...)
2377 if (idom<=ineig) { //no duplicate joint_1_2 and joint_2_1
2379 namejoint=namejoint.sprintf("JOINT_%d_%d",idom,ineig);
2380 charendnull(namejnt,namejoint,MED_NAME_SIZE);
2381 tmp=tmp.sprintf("joint between %d and %d",idom,ineig);
2382 charendnull(descjnt,tmp,MED_COMMENT_SIZE);
2383 err=MEDmeshCr(fidjoint,namejnt,3,3,MED_UNSTRUCTURED_MESH,descjnt,dtunit,MED_SORT_DTIT,MED_CARTESIAN,axisname,axisunit);
2384 if (err<0) std::cerr<<"Problem MEDmeshCr "<<namejnt<<std::endl;
2386 err=MEDmeshNodeCoordinateWr(fidjoint,namejnt,MED_NO_DT,MED_NO_IT,0.,MED_FULL_INTERLACE,nbnodesneig,arraynodes);
2387 if (err<0) std::cerr<<"Problem MEDmeshNodeCoordinateWr "<<namejnt<<std::endl;
2388 arrayi=new med_int[nbnodesneig];
2389 for (i=0; i<nbnodesneig ; i++) arrayi[i]=i+1;
2390 err=MEDmeshEntityNumberWr(fidjoint,namejnt,MED_NO_DT,MED_NO_IT,MED_NODE,MED_UNDEF_GEOMETRY_TYPE,nbnodesneig,arrayi);
2392 if (err<0) std::cerr<<"Problem MEDmeshEntityNumberWr of nodes "<<namejnt<<std::endl;
2393 //families zero in file fidjoint ???
2394 //La famille FAMILLE_ZERO n'a pas été trouvée, elle est obligatoire
2395 nb=create_family_zero(fidjoint,namejnt);
2398 if (nbtria3neig>0) {
2399 //for (i=0; i<nbtria3neig ; i++) std::cout<<i+1<<" "<<
2400 // arrayfaces[i*3]<<" "<<arrayfaces[i*3+1]<<" "<<arrayfaces[i*3+2]<<std::endl;
2401 err=MEDmeshElementConnectivityWr(fidjoint,namejnt,MED_NO_DT,MED_NO_IT,0.,
2402 MED_CELL,MED_TRIA3,MED_NODAL,MED_FULL_INTERLACE,nbtria3neig,arrayfaces);
2403 if (err<0) std::cerr<<"Problem MEDmeshElementConnectivityWr for triangles connectivity "<<namejnt<<std::endl;
2404 //writing indices of faces triangles of joint
2405 arrayi=new med_int[nbtria3neig];
2406 for (i=0; i<nbtria3neig ; i++) arrayi[i]=i+1;
2407 err=MEDmeshEntityNumberWr(fidjoint,namejnt,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TRIA3,nbtria3neig,arrayi);
2409 if (err<0) std::cerr<<"Problem MEDmeshEntityNumberWr of triangles "<<namejnt<<std::endl;
2413 delete[] arraynodes;
2414 if (nbtria3neig>0) delete[] arrayfaces;
2418 node=xmlNewChild(joints_node, 0, BAD_CAST "joint", 0);
2419 xmlNewProp(node, BAD_CAST "id", BAD_CAST i2a(ineig).c_str());
2420 xmlNewProp(node, BAD_CAST "nodes_number", BAD_CAST i2a(nbnodesneig).c_str());
2421 xmlNewProp(node, BAD_CAST "faces_number", BAD_CAST i2a(nbtria3neig).c_str());
2422 //node2 = xmlNewChild(node, 0, BAD_CAST "nodes", 0);
2423 //xmlNewProp(node2, BAD_CAST "number", BAD_CAST i2a(nbnodesneig).c_str());
2424 //node2 = xmlNewChild(node, 0, BAD_CAST "faces", 0);
2425 //xmlNewProp(node2, BAD_CAST "number", BAD_CAST i2a(nbtria3neig).c_str());
2429 xmlNewProp(joints_node, BAD_CAST "number", BAD_CAST i2a(nbjoints).c_str());
2430 xmlNewChild(joints_node, 0, BAD_CAST "id_neighbours", BAD_CAST sjoints.substr(1).c_str());
2432 tmp=tmp.sprintf("NB%d VC",idom);
2433 //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
2434 xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
2435 //tmp=tmp.sprintf("MS%d NE*",idom);
2436 //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
2437 //xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
2438 tmp=tmp.sprintf("FC%d",idom);
2439 //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
2440 xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
2441 tmp=tmp.sprintf("GL%d *",idom);
2442 //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
2443 xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
2447 //************************************
2448 bool ghs3dprl_mesh_wrap::idom_tetras()
2456 //writing connectivity of tetrahedra by nodes
2457 key1=key1.sprintf("NB%d EV",idom); //files.NoBoite Elements Vertices (tetra only)
2458 tab1=this->restore_key(key1); //tab1=this->mestab[key1];
2459 nbtetra4=tab1->size/4;
2460 nbtetrastotal=nbtetrastotal + nbtetra4;
2461 if (verbose>5)std::cout<<"NumberOftetrahedra="<<nbtetra4<<std::endl;
2462 err=MEDmeshElementConnectivityWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,0.,MED_CELL,MED_TETRA4,MED_NODAL,MED_FULL_INTERLACE,nbtetra4,tab1->tmint);
2463 if (err<0){std::cerr<<"Problem MEDmeshElementConnectivityWr for tetra connectivity"<<std::endl; return false;}
2465 //writing indices of tetrahedra
2466 arrayi=new med_int[nbtetra4];
2467 for (i=0; i<nbtetra4 ; i++) arrayi[i]=nbseg2+nbtria3+i+1;
2468 //for (i=0; i<nbtria3 ; i++) std::cout<<i<<" "<<arrayi[i]<<std::endl;
2469 err=MEDmeshEntityNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TETRA4,nbtetra4,arrayi);
2471 if (err<0){std::cerr<<"Problem MEDmeshEntityNumberWr of tetrahedra"<<std::endl; return false;}
2473 famtetra4=new med_int[nbtetra4];
2474 for (i=0; i<nbtetra4 ; i++) famtetra4[i]=famnewtetra4;
2476 //writing tetrahedra global numbering
2477 //GLx EL=files.GLo ELements
2478 key1=key1.sprintf("GL%d EL",idom);
2479 tab1=this->restore_key(key1); //tab1=this->mestab[key1];
2481 tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".glo";
2482 ok=this->ReadFileGLO(tmp);
2483 tab1=this->restore_key(key1);
2484 if (!tab1) return false;
2487 if (tab1->size!=nbtetra4){
2488 std::cerr<<"Problem incorrect size of tetrahedra global numbering"<<std::endl; return false;}
2490 std::cout<<"CreateMEDglobalNumerotation_tetrahedra "<<key1.toLatin1().constData()<<" "<<tab1->size<<std::endl;
2491 err=MEDmeshGlobalNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TETRA4,tab1->size,tab1->tmint);
2492 if (err<0){std::cerr<<"Problem MEDmeshGlobalNumberWr tetrahedra"<<std::endl; return false;}
2494 tmp=tmp.sprintf("NB%d EV",idom);
2495 //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
2496 xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
2500 //************************************
2501 med_int ghs3dprl_mesh_wrap::create_families(med_idt fid, int sign)
2502 //if sign < 0 families faces or tria3 etc...
2503 //if sign >= 0 family zero and family nodes
2506 char nomfam[MED_NAME_SIZE+1]; //it.current()->name;
2507 char attdes[MED_COMMENT_SIZE+1]="_NO_DESCRIPTION";
2509 med_int i,attide=1,attval=1,natt=1,num,ngro;
2511 if (sign>=0) pas=1; else pas=-1;
2516 for (it1=families.fam.begin(); it1!=families.fam.end(); ++it1){
2517 num=(*it1).first.toLong();
2518 if ((pas==-1) && (num>=0)) continue; //not good families
2519 if ((pas== 1) && (num< 0)) continue; //not good families
2520 charendnull(nomfam,(*it1).first,MED_NAME_SIZE);
2523 ngro=(*it1).second.size();
2525 std::cout<<"CreateFamilyInMEDFile <"<<nomfam<<">\tNbGroups="<<ngro;
2526 gro=new char[MED_LNAME_SIZE*ngro+2];
2529 for (it2=gb.begin(); it2!=gb.end(); ++it2){
2530 charendnull(&gro[i*MED_LNAME_SIZE],(*it2).first,MED_LNAME_SIZE);
2531 if (verbose>5)std::cout<<" <"<<&gro[i*MED_LNAME_SIZE]<<"> ";
2534 if (verbose>5)std::cout<<std::endl;
2535 err=MEDfamilyCr(fid,nomfinal,nomfam,num,ngro,gro);
2537 if (err<0) std::cerr<<"Problem MEDfamilyCr of "<<nomfam<<std::endl;
2542 med_int ghs3dprl_mesh_wrap::create_family_zero(med_idt fid, QString nameMesh)
2546 char nomfam[MED_NAME_SIZE+1]="FAMILLE_ZERO"; //it.current()->name;
2547 char attdes[MED_COMMENT_SIZE+1]="_NO_DESCRIPTION";
2550 med_int i,attide=1,attval=1,natt=1,num=0,ngro=0;
2552 gro=new char[MED_LNAME_SIZE*ngro+2];
2553 if (verbose>3)std::cout<<"\ncreate_family_ZERO "<<nameMesh.toLatin1().constData()<<std::endl;
2554 err=MEDfamilyCr(fid,nameMesh.toLatin1().constData(),nomfam,num,ngro,gro);
2555 if (err<0) std::cerr<<"Problem MEDfamilyCr FAMILLE_ZERO of "<<nameMesh.toLatin1().constData()<<std::endl;