1 // Copyright (C) 2007-2016 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>
53 //#include <med_config.h>
54 //#include <med_utils.h>
55 //#include <med_misc.h>
59 //************************************
60 std::string i2a(const int &v)
62 std::ostringstream ss;
67 //************************************
68 QString endspace(QString deb,int lg)
69 //better fill by spaces for char unicoo[3*MED_TAILLE_PNOM+1]; etc...
75 fin=deb.leftJustified(lg,' ',true);
79 //************************************
80 void charendnull(char *p, QString deb, int lg)
85 strcpy(p,fin.toLatin1().constData()); // 0 at end
86 for (int i=fin.length();i<lg-1;i++){
92 //************************************
93 void familles::newfam(QString nom){
94 //std::cout<<"newfam "<<nom<<std::endl;
95 if (fam.find(nom)!=fam.end()){
96 std::cout<<"***newfam*** "<<nom.toLatin1().constData()<<" deja present\n";
103 //************************************
104 void familles::newgro(QString nom){
105 //std::cout<<"newgro "<<nom<<std::endl;
106 if (gro.find(nom)!=gro.end()){
107 std::cout<<"***newgro*** "<<nom.toLatin1().constData()<<" deja present\n";
114 //************************************
115 void familles::write(){
120 for (it1=fam.begin(); it1!=fam.end(); ++it1){
122 std::cout<<"Family=<"<<(*it1).first.toLatin1().constData()<<">\tGroups=";
124 for (it2=gb.begin(); it2!=gb.end(); ++it2){
125 std::cout<<"<"<<(*it2).first.toLatin1().constData()<<"> ";
127 std::cout<<std::endl;
129 if (nbf==0) std::cout<<"no families"<<std::endl;
130 for (it1=gro.begin(); it1!=gro.end(); ++it1){
132 std::cout<<"Group=<"<<(*it1).first.toLatin1().constData()<<">\tFamilies=";
134 for (it2=gb.begin(); it2!=gb.end(); ++it2){
135 std::cout<<"<"<<(*it2).first.toLatin1().constData()<<"> ";
137 std::cout<<std::endl;
139 if (nbg==0) std::cout<<"no groups"<<std::endl;
142 //************************************
143 xmlNodePtr familles::xml_groups(){
150 res=xmlNewNode(NULL, BAD_CAST "groups");
151 for (it1=gro.begin(); it1!=gro.end(); ++it1){
152 node = xmlNewChild(res, 0, BAD_CAST "group",0);
153 ss=(*it1).first.toLatin1().constData();
154 xmlNewProp(node, BAD_CAST "name", BAD_CAST ss.c_str());
158 for (it2=gb.begin(); it2!=gb.end(); ++it2){
159 ss=ss+" "+(*it2).first.toLatin1().constData();
162 xmlNewProp(node, BAD_CAST "families_number", BAD_CAST i2a(nbf).c_str());
163 xmlNewProp(node, BAD_CAST "families", BAD_CAST ss.substr(1).c_str());
164 //std::cout<<std::endl;
166 xmlNewProp(res, BAD_CAST "number", BAD_CAST i2a(nb).c_str());
170 //************************************
171 void familles::add(QString nomfam, QString nomgro)
173 //std::cout<<"add family <"<<nomfam<<">\t<"<<nomgro<<">\n";
177 //std::cout<<"add new family <"<<nomfam<<">\t<"<<nomgro<<">\n";
181 if (nomgro=="") return; //no group
182 (*it).second[nomgro]=0;
185 //std::cout<<"***new*** "<<nomgro<<" non present\n";
189 (*it).second[nomfam]=0;
194 //************************************
195 bool familles::get_number_of_new_family(int sign, med_int *ires, QString *tmp)
196 //if sign < 0 families faces or tria3 etc...
197 //if sign >= 0 family zero and family nodes
198 //outputs in *ires and *tmp
203 if (sign>=0) pas=1; else pas=-1;
206 for (i=0;i<10000;i++) { //mefiance
207 nomfam=nomfam.sprintf("%d",ii);
210 *tmp=nomfam; *ires=ii;
211 //std::cout<<"NewFamily Found<"<<*ires<<"><"<<*tmp<<">\n";
216 std::cerr<<"***get_number_of_new_family*** Problem new family not found"<<std::endl;
220 //************************************
221 med_int familles::find_family_on_groups(med_int fam1, med_int fam2)
224 if (fam1==fam2) {ires=fam1; return ires;}
225 //find one family whith groups of fam1 and groups of fam2
226 fend gb=fuse_goups(fam1,fam2);
227 //find if one family have theses groups
230 for (it1=fam.begin(); it1!=fam.end(); ++it1){
231 if (gb==(*it1).second){
232 ires=(*it1).first.toLong();
233 //std::cout<<"find_family_on_groups old <"<<ires<<"> from <"<<
234 // fam1<<"><"<<fam2<<">\n";
238 //std::cout<<"no family found!!! - groups of "<<fam1<<" and "<<fam2<<std::endl;
240 //fam1 positive for nodes negative faces & mailles
241 bool oktmp=get_number_of_new_family(fam1,&ires,&tmp);
243 for (it=gb.begin(); it!=gb.end(); ++it){
244 this->add(tmp,(*it).first);
246 //std::cout<<"new family <"<<ires<<"> intersection of <"<<fam1<<"><"<<fam2<<">\n";
250 //************************************
251 fend familles::fuse_goups(med_int fam1, med_int fam2)
252 //concatenation/fusion deux map groupes
255 fagr::iterator it1,it2;
256 nom1=nom1.sprintf("%d",fam1);
258 nom2=nom2.sprintf("%d",fam2);
260 if ( (it1==fam.end())||(it2==fam.end()) ) {
261 std::cerr<<"***fuse_goups*** non existing family "<<fam1<<" or "<<fam2<<std::endl;
265 fend gb=(*it1).second; //firt groups
266 gb.insert((*it2).second.begin(),(*it2).second.end()); //other groups
269 std::cout<<"fuse_goups "<<fam1<<" "<<fam2<<" ";
271 for (it=gb.begin(); it!=gb.end(); ++it){
272 std::cout<<"<"<<(*it).first.toLatin1().constData()<<"> ";
274 std::cout<<std::endl;
278 long CVWtab::memoryuse=0; //static
279 long CVWtab::memorymax=1000*1000000; //static
281 //************************************
282 CVWtab::CVWtab(long nb, med_int *pmint)
283 //constructor with pmint allocated yet with new
285 //std::cout"***constructor med_int CVWtab***\n";
287 type=1; //only tmint valide
290 memoryuse=memoryuse+sizeof(med_int)*nb;
291 //std::cout<<"memoryuse int "<<sizeof(med_int)<<" "<<nb<<" "<<memoryuse<<" "<<memorymax<<std::endl;
292 if (memoryuse>memorymax) {
293 std::cout<<"***WARNING*** memory max reached "<<memorymax<<std::endl;
294 //std::cout<<"memoryuse int "<<sizeof(med_int)<<" "<<nb<<" "<<memoryuse<<std::endl;
298 //************************************
299 CVWtab::CVWtab(long nb, med_float *pmflo)
300 //constructor with pmflo allocated yet with new
302 //std::cout<<"***constructor med_float CVWtab***\n";
304 type=2; //only tmflo valide
307 memoryuse=memoryuse+sizeof(med_float)*nb;
308 //std::cout<<"memoryuse float "<<sizeof(med_float)<<" "<<nb<<" "<<memoryuse<<" "<<memorymax<<std::endl;
309 if (memoryuse>memorymax) {
310 std::cout<<"***WARNING*** memory max reached "<<memorymax<<std::endl;
311 //std::cout<<"memoryuse float "<<sizeof(med_float)<<" "<<nb<<" "<<memoryuse<<std::endl;
315 //************************************
319 //std::cout<<" destructor CVWtab *** "<<this->filename<<std::endl;
320 ok=this->CVWtab_deallocate();
321 //remove temporary file
322 if (this->filename!="_NO_FILE")
324 remove(this->filename.toLatin1().constData()); //#include <stdio.h>
325 //std::cout<<this->filename<<" successfully deleted\n";
330 //************************************
331 bool CVWtab::CVWtab_deallocate()
333 //std::cout<<" deallocate CVWtab*** "<<size<<std::endl;
334 if (size <= 0) return false;
338 memoryuse=memoryuse-sizeof(med_int)*size;
339 size=-size; //precaution
344 memoryuse=memoryuse-sizeof(med_float)*size;
345 size=-size; //precaution
347 if (memoryuse<0) std::cout<<"***WARNING*** memoryuse <0 "<<memoryuse<<std::endl;
348 if (memoryuse==0) std::cout<<"***CVWtab_deallocate*** memoryuse=0 "<<std::endl;
352 //************************************
353 bool CVWtab::is_equal(CVWtab *tab2)
355 //std::cout<<"is_equal tab1 tab2 type="<<this->type<<" size="<<this->size<<" "<<tab2->size<<std::endl;
356 //if (this->type==1) std::cout<<"med_int tab1[0]="<<this->tmint[0]<<std::endl;
357 //if (this->type==2) std::cout<<"med_float tab1[0]="<<this->tmflo[0]<<std::endl;
358 if (this->size!=tab2->size) return false;
359 if (this->type!=tab2->type) return false;
363 { std::cout<<"***is_equal*** pb pointer NULL with tmint size="<<this->size<<std::endl;
366 for (long i=0; i < this->size; i++)
367 if (this->tmint[i]!=tab2->tmint[i]) return false;
372 { std::cout<<"***is_equal*** pb pointer NULL with tmflo size="<<this->size<<std::endl;
375 for (long i=0; i < this->size; i++)
376 if (this->tmflo[i]!=tab2->tmflo[i]) return false;
381 //************************************
382 bool CVW_is_equal_vertices(CVWtab *tab1, long i1,
383 CVWtab *tab2, long i2, int verbose)
384 //verbose 0 for no prints
385 //verbose 1 for print vertices not equals
386 //verbose 2 for print also vertices equals (debug)
388 //std::cout<<"is_equal_vertice size="<<tab1->size<<" "<<tab2->size<<std::endl;
391 //vertices indices from 1 not 0!
392 long di1=(i1-1)*3, di2=(i2-1)*3;
393 if (di1<0 || di1>=tab1->size)
395 std::cerr<<"BadIndice tab1 in is_equal_vertices "<<
396 di1<<" not in "<<tab1->size<<std::endl;
399 if (di2<0 || di2>=tab2->size)
401 std::cerr<<"BadIndice tab2 in is_equal_vertices "<<
402 di2<<" not in "<<tab2->size<<std::endl;
405 p1=(tab1->tmflo+di1);
406 p2=(tab2->tmflo+di2);
407 if (p1[0]==p2[0] && p1[1]==p2[1] && p1[2]==p2[2]) ok=true ;
408 if (!ok && verbose>0) printf(
409 "Vertices differents (%.16g %.16g %.16g) (%.16g %.16g %.16g)\n",
410 p1[0],p1[1],p1[2],p2[0],p2[1],p2[2]);
412 if (verbose>1) printf(
413 "Vertices equals (%.16g %.16g %.16g)\n",
418 //************************************
419 bool CVW_FindString(const std::string &str,std::fstream &Ff, long &count)
420 //find in file first line with string str in first position of line
421 //converts count value expected after "='" in line found
427 if (getline(Ff,line))
429 if (line[0]==str[0]) //faster
431 if (line.find(str)==0)
435 count=tmp.section('\'',1,1).toLong(&ok);
442 std::cerr<<"Problem line '"<<str<<"' not found in file\n"<<std::endl;
449 //************************************
450 bool CVW_FindStringInFirstLines(const std::string &str,std::fstream &Ff, long &maxline)
451 //find in file maximum maxline first lines with string str in first position of line
452 //converts count value expected after " " in line found
458 if (getline(Ff,line))
461 if (line[0]==str[0]) //faster
463 if (line.find(str)==0)
470 std::cerr<<"Problem line '"<<str<<"' not found in first "<<maxline<<" lines of file\n"<<std::endl;
476 std::cerr<<"Problem line '"<<str<<"' not found in all file\n"<<std::endl;
483 //************************************
484 bool ghs3dprl_mesh_wrap::ReadFileMSGnew(const QString FileName)
485 //read file .glo with no parser xml because big file (volume)
486 //no read of <receive> for speed (and so no test)
489 std::fstream Ff(FileName.toLatin1().constData(),std::ios_base::in);
491 long i,count,nbneighbour,ineighbour;
496 std::cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
501 if (!CVW_FindString("<neighbours count=",Ff,nbneighbour)) return false;
502 if (verbose>2) std::cout<<"NeighboursCountDomain_"<<this->nofile<<"="<<nbneighbour<<std::endl;
503 for (i=1; i<=nbneighbour; i++)
505 if (!CVW_FindString("<neighbour indice=",Ff,ineighbour)) return false;
506 if (!CVW_FindString("<vertices count=",Ff,count)) return false;
508 med_int *tmint=new med_int[count];
509 for (int i=0; i<count; i++) Ff>>tmint[i];
510 if (verbose>4) std::cout<<"Vertices "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
512 CVWtab *montab=new CVWtab(count,tmint);
513 tmp=tmp.sprintf("MS%ld NE%ld VE SE",this->nofile,ineighbour);
514 ok=this->insert_key(tmp,montab);
516 if (!CVW_FindString("<edges count=",Ff,count)) return false;
518 med_int *tmint=new med_int[count];
519 for (int i=0; i<count; i++) Ff>>tmint[i];
520 if (verbose>4) std::cout<<"Edges "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
522 CVWtab *montab=new CVWtab(count,tmint);
523 tmp=tmp.sprintf("MS%ld NE%ld ED SE",this->nofile,ineighbour);
524 ok=this->insert_key(tmp,montab);
526 if (!CVW_FindString("<faces count=",Ff,count)) return false;
528 med_int *tmint=new med_int[count];
529 for (int i=0; i<count; i++) Ff>>tmint[i];
530 if (verbose>4) std::cout<<"Faces "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
532 CVWtab *montab=new CVWtab(count,tmint);
533 tmp=tmp.sprintf("MS%ld NE%ld FA SE",this->nofile,ineighbour);
534 ok=this->insert_key(tmp,montab);
536 if (!CVW_FindString("<elements count=",Ff,count)) return false;
538 med_int *tmint=new med_int[count];
539 for (int i=0; i<count; i++) Ff>>tmint[i];
540 if (verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
542 CVWtab *montab=new CVWtab(count,tmint);
543 tmp=tmp.sprintf("MS%ld NE%ld EL SE",this->nofile,ineighbour);
544 ok=this->insert_key(tmp,montab);
554 //************************************
555 bool ghs3dprl_mesh_wrap::TestExistingFileMESHnew(const QString FileName)
556 //read file .glo with no parser xml because big file (volume)
557 //no read of <receive> for speed (and so no test)
560 std::fstream Ff(FileName.toLatin1().constData(),std::ios_base::in);
562 long i,count,meshversion,maxline;
567 std::cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
571 //Lit les donn�s au debut du fichier, 1 lignes maxi:
573 if (!CVW_FindStringInFirstLines("MeshVersionFormatted",Ff,maxline)) return false;
574 if (verbose>2) std::cout<<"MeshVersionFormatted_"<<this->nofile<<" ok"<<std::endl;
582 ///************************************
583 bool ghs3dprl_mesh_wrap::ReadFileGLO(const QString FileName)
584 //read file .glo with no parser xml because big file (volume)
587 std::fstream Ff(FileName.toLatin1().constData(),std::ios_base::in);
594 std::cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
599 if (!CVW_FindString("<vertices count=",Ff,count)) return false;
600 if (verbose>3) std::cout<<"GloVerticesCount="<<count<<std::endl;
603 med_int *tmint=new med_int[count];
604 for (int i=0; i<count; i++) Ff>>tmint[i];
605 if (verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
607 CVWtab *montab=new CVWtab(count,tmint);
608 tmp=tmp.sprintf("GL%ld VE",this->nofile);
609 ok=this->insert_key(tmp,montab);
612 if (!CVW_FindString("<edges count=",Ff,count)) return false;
613 if (verbose>3) std::cout<<"GloEdgesCount="<<count<<std::endl;
616 med_int *tmint=new med_int[count];
617 for (int i=0; i<count; i++) Ff>>tmint[i];
618 if (verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
620 CVWtab *montab=new CVWtab(count,tmint);
621 tmp=tmp.sprintf("GL%ld ED",this->nofile);
622 ok=this->insert_key(tmp,montab);
625 if (!CVW_FindString("<faces count=",Ff,count)) return false;
626 if (verbose>3) std::cout<<"GloFacesCount="<<count<<std::endl;
629 med_int *tmint=new med_int[count];
630 for (int i=0; i<count; i++) Ff>>tmint[i];
631 if (verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
633 CVWtab *montab=new CVWtab(count,tmint);
634 tmp=tmp.sprintf("GL%ld FA",this->nofile);
635 ok=this->insert_key(tmp,montab);
638 if (!CVW_FindString("<elements count=",Ff,count)) return false;
639 if (verbose>3) std::cout<<"GloElementsCount="<<count<<std::endl;
642 med_int *tmint=new med_int[count];
643 for (int i=0; i<count; i++) Ff>>tmint[i];
644 if (verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
646 CVWtab *montab=new CVWtab(count,tmint);
647 tmp=tmp.sprintf("GL%ld EL",this->nofile);
648 ok=this->insert_key(tmp,montab);
656 //************************************
657 bool ghs3dprl_mesh_wrap::ReadFileFACES(const QString FileName)
658 //read file .faces (wrap)
661 std::fstream Ff(FileName.toLatin1().constData(),std::ios_base::in);
668 std::cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
673 //Replace le pointeur de fichier au d�ut :f.seekg(0);
674 if (getline(Ff,line))
677 nbelem=tmp.section(' ',0,0).toLong(&ok);
681 std::cerr<<"Problem on first line of file"<<std::endl;
684 if (verbose>3) std::cout<<"FacesNumberOfElements="<<nbelem<<std::endl;
685 med_int *tmint=new med_int[nbelem*7];
686 for (int i=0; i<nbelem*7; i=i+7)
689 if (ntype!=3) //only triangles
691 std::cerr<<"Problem on ntype != 3"<<std::endl;
694 for (int j=0; j<7; j++) Ff>>tmint[i+j];
695 //for (int j=0; j<7; j++) std::cout<<tmint[i+j]<<' '; std::cout<<std::endl;
697 if (verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[nbelem*7-1]<<std::endl;
699 CVWtab *montab=new CVWtab(nbelem*7,tmint);
700 tmp=tmp.sprintf("FC%ld",this->nofile);
701 ok=this->insert_key(tmp,montab);
708 //************************************
709 bool ghs3dprl_mesh_wrap::ReadFileMESH(const QString FileName)
710 //read file .mesh from tetra_hpc (with volume)
712 std::string line(" ");
714 std::fstream Ff(FileName.toLatin1().constData(),std::ios_base::in);
715 long Mversion=0,Mdim=0,Mvert=0,Mtria=0,Mtetra=0;
717 //long ne,np,npfixe,subnumber,reste;
719 if (verbose>=6)std::cout<<"Read File '"<<FileName.toLatin1().constData()<<std::endl;
721 std::cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
726 if (getline(Ff,line) && (line.find("MeshVersionFormatted")==0))
729 Mversion=tmp.section(' ',1,1).toLong(&ok);
733 std::cerr<<"Problem on line 1 of file: 'MeshVersionFormatted' expected"<<std::endl;
739 if (getline(Ff,line) && (line.find("Dimension 3")==0))
742 Mdim=tmp.section(' ',1,1).toLong(&ok);
746 std::cerr<<"Problem on line 3 of file: Dimension 3 expected"<<std::endl;
752 if (!(getline(Ff,line) && (line.find("Vertices")==0)))
754 std::cerr<<"Problem on line 5 of file: 'Vertices' expected"<<std::endl;
757 if (getline(Ff,line))
760 Mvert=tmp.toLong(&ok);
764 std::cerr<<"Problem on line 6 of file: a positive integer is expected"<<std::endl;
769 std::cerr<<"Problem on line 6 of file: a positive integer is expected"<<std::endl;
773 med_float *tmflo=new med_float[Mvert*3];
774 for (int i=0; i<Mvert*3; i=i+3) Ff>>tmflo[i]>>tmflo[i+1]>>tmflo[i+2]>>garbage;
775 if (verbose>4) std::cout<<"Vertices "<<tmflo[0]<<" "<<tmflo[1]<<"... "<<tmflo[Mvert*3-1]<<std::endl;
777 CVWtab *montab=new CVWtab(Mvert*3,tmflo);
778 tmp=tmp.sprintf("NB%ld VC",this->nofile);
779 ok=this->insert_key(tmp,montab);
784 if (!(getline(Ff,line) && (line.find("Triangles")==0)))
786 std::cerr<<"Problem on line 'Triangles' of file: not found"<<line<<std::endl;
789 if (getline(Ff,line))
792 Mtria=tmp.toLong(&ok);
796 std::cerr<<"Problem on line 'Triangles' of file: a positive integer is expected"<<std::endl;
801 std::cerr<<"Problem on line 'Triangles' of file: a positive integer is expected"<<std::endl;
805 med_int *tmint=new med_int[Mtria*7]; //*7 as older files .faces
806 for (int i=0; i<Mtria*7; i=i+7) {
807 Ff>>tmint[i]>>tmint[i+1]>>tmint[i+2]>>garbage;
813 if (verbose>4) std::cout<<"Triangles "<<tmint[0]<<" "<<tmint[1]<<"... "<<
814 tmint[Mtria*7-5]<<" "<<tmint[Mtria*7-4]<<" "<<tmint[Mtria*7-3]<<" "<<
815 tmint[Mtria*7-2]<<" "<<tmint[Mtria*7-1]<<std::endl;
817 montab=new CVWtab(Mtria*7,tmint);
818 tmp=tmp.sprintf("FC%ld",this->nofile);
819 ok=this->insert_key(tmp,montab);
824 if (!(getline(Ff,line) && (line.find("Tetrahedra")==0)))
826 std::cerr<<"Problem on line 'Tetrahedra' of file: not found"<<std::endl;
829 if (getline(Ff,line))
832 Mtetra=tmp.toLong(&ok);
836 std::cerr<<"Problem on line 'Tetrahedra' of file: a positive integer is expected"<<std::endl;
841 std::cerr<<"Problem on line 'Tetrahedra' of file: a positive integer is expected"<<std::endl;
847 std::cout<<"MeshVersionFormatted="<<Mversion<<std::endl;
848 std::cout<<"MeshDimension="<<Mdim<<std::endl;
849 std::cout<<"MeshNumberOfVertices="<<Mvert<<std::endl;
850 std::cout<<"MeshNumberOfTriangles="<<Mtria<<std::endl;
851 std::cout<<"MeshNumberOfTetrahedra="<<Mtetra<<std::endl;
854 tmint=new med_int[Mtetra*4];
855 for (int i=0; i<Mtetra*4; i=i+4) Ff>>tmint[i]>>tmint[i+1]>>tmint[i+2]>>tmint[i+3]>>garbage;
856 if (verbose>4) std::cout<<"Tetrahedra "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[Mtetra*4-1]<<std::endl;
858 montab=new CVWtab(Mtetra*4,tmint);
859 tmp=tmp.sprintf("NB%ld EV",this->nofile);
860 ok=this->insert_key(tmp,montab);
862 //swap on file if too big for memory in one cpu
863 //default 1GOctet/8(for double)/10(for arrays in memory at the same time)
864 if (Mvert*3>this->nbelem_limit_swap)
865 this->SwapOutOfMemory_key_mesh_wrap(QRegExp("NB",Qt::CaseSensitive,QRegExp::RegExp));
866 //beware record 6 lenght 1
873 //************************************
874 bool ghs3dprl_mesh_wrap::ReadFileNOBOITE(const QString FileName)
875 //read file .noboite (volume)
876 //for huge files it could be better use ReadFileNOBOITEB (B=binary format)
877 //(parameter option of ghs3d but NOT tepal)
880 std::fstream Ff(FileName.toLatin1().constData(),std::ios_base::in);
881 long ne,np,npfixe,subnumber,reste;
885 std::cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
892 std::cout<<"NoboiteNumberOfElements="<<ne<<std::endl;
893 std::cout<<"NoboiteNumberOfVertices="<<np<<std::endl;
894 std::cout<<"NoboiteNumberOfSpecifiedPoints="<<npfixe<<std::endl;
897 for (int i=1; i<=17-3; i++) Ff>>reste;
898 //printf("reste %ld\n",reste);
899 med_int *tmint=new med_int[ne*4];
900 for (int i=0; i<ne*4; i++) Ff>>tmint[i];
901 if (verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[ne*4-1]<<std::endl;
903 CVWtab *montab=new CVWtab(ne*4,tmint);
904 tmp=tmp.sprintf("NB%ld EV",this->nofile);
905 ok=this->insert_key(tmp,montab);
907 med_float *tmflo=new med_float[np*3];
908 for (int i=0; i<np*3; i++) Ff>>tmflo[i];
909 if (verbose>4) std::cout<<"Vertices "<<tmflo[0]<<" "<<tmflo[1]<<"... "<<tmflo[np*3-1]<<std::endl;
911 montab=new CVWtab(np*3,tmflo);
912 tmp=tmp.sprintf("NB%ld VC",this->nofile);
913 ok=this->insert_key(tmp,montab);
916 if (verbose>2) std::cout<<"NumberOfSubdomains="<<subnumber<<std::endl;
917 //tmint=new med_int[subnumber*3];
918 tmint=new med_int[subnumber*3];
920 maxint=std::numeric_limits<int>::max();
923 for (int i=0; i<subnumber*3; i++) {
927 if (isproblem && verbose>1) std::cout<<"There is one or more negative med_int value in NumberOfSubdomains "<<onelong<<std::endl;
931 if (onelong>maxint) {
932 if (isproblem && verbose>1) std::cout<<"There is one or more truncated med_int value in NumberOfSubdomains "<<onelong<<std::endl;
936 tmint[i]=(int)onelong;
938 if (verbose>4) std::cout<<"Subdomains "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[subnumber*3-1]<<std::endl;
940 montab=new CVWtab(subnumber*3,tmint);
941 tmp=tmp.sprintf("NB%ld SN",this->nofile);
942 ok=this->insert_key(tmp,montab);
944 //swap on file if too big for memory in one cpu
945 //default 1GOctet/8(for double)/10(for arrays in memory at the same time)
946 if (np*3>this->nbelem_limit_swap)
947 this->SwapOutOfMemory_key_mesh_wrap(QRegExp("NB",Qt::CaseSensitive,QRegExp::RegExp));
948 //beware record 6 lenght 1
955 //************************************
956 bool ghs3dprl_mesh_wrap::ReadFileNOBOITEB(const QString FileName)
957 //read file .noboiteb (volume)
958 //for huge files it could be better use ReadFileNOBOITEB (B=binary format)
959 //but NOT parameter option of tepal
960 //idem ReadFileNOBOITE with read unformatted
964 std::cerr<<"Problem function ReadFileNOBOITEB\n"
965 <<"(no FORTRAN binary format files in tepal)\n\n";
967 FILE *Ff=fopen(FileName.toLatin1().constData(),"rb");
968 long ne,np,npfixe,reste,subnumber;
970 //http://www.math.utah.edu/software/c-with-fortran.html
971 //record 1 from format FORTRAN begins and ends with lengh of record
972 //=> 2*long(68) (68=17*4octets)
975 std::cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
979 fread(&r1,sizeof(long),17+2,Ff);
980 for (long i=1; i<18; i++) std::cout<<"R1("<<i<<")="<<r1[i]<<std::endl;
983 std::cerr<<"First FORTRAN record of File '"<<FileName.toLatin1().constData()<<"' not length 17*long"<<std::endl;
990 std::cout<<"NoboitebNumberOfElements="<<ne<<std::endl;
991 std::cout<<"NoboitebNumberOfVertices="<<np<<std::endl;
992 std::cout<<"NoboitebNumberOfSpecifiedPoints="<<npfixe<<std::endl;
994 //etc...could be done if necessary not debugged
995 fread(&reste,sizeof(long),1,Ff);
996 long *tlong=new long[ne*4];
997 med_int *tmint=new med_int[ne*4];
998 fread(tlong,sizeof(long),ne*4,Ff);
999 fread(&reste,sizeof(long),1,Ff);
1000 for (long i=0; i<ne*4; i++) tmint[i]=tlong[i];
1002 if (verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[ne*4-1]<<std::endl;
1004 CVWtab *montab=new CVWtab(ne*4,tmint);
1005 tmp=tmp.sprintf("NB%ld EV",this->nofile);
1006 ok=this->insert_key(tmp,montab);
1008 fread(&reste,sizeof(long),1,Ff);
1009 //std::cout<<"info "<<reste<<" "<<np*3<<" "<<sizeof(med_float)<<std::endl;
1010 float *tfloat=new float[np*3];
1011 med_float *tmflo=new med_float[np*3];
1012 fread(tfloat,sizeof(float),np*3,Ff);
1013 fread(&reste,sizeof(long),1,Ff);
1014 for (long i=0; i<np*3; i++) tmflo[i]=tfloat[i];
1016 if (verbose>4) printf("Vertices %g %g ... %g \n",tmflo[0],tmflo[1],tmflo[np*3-1]);
1018 montab=new CVWtab(np*3,tmflo);
1019 tmp=tmp.sprintf("NB%ld VC",this->nofile);
1020 ok=this->insert_key(tmp,montab);
1022 fread(&reste,sizeof(long),1,Ff);
1023 fread(&subnumber,sizeof(long),1,Ff);
1024 fread(&reste,sizeof(long),1,Ff);
1025 if (verbose>2) std::cout<<"NumberOfSubdomains="<<subnumber<<std::endl;
1026 fread(&reste,sizeof(long),1,Ff);
1027 tlong=new long[subnumber*3];
1028 fread(tlong,sizeof(long),subnumber*3,Ff);
1029 fread(&reste,sizeof(long),1,Ff);
1030 if (verbose>4) printf("Subdomains %ld %ld ... %ld \n",tlong[0],tlong[1],tlong[subnumber*3-1]);
1032 tmint=new med_int[subnumber*3];
1033 for (long i=0; i<subnumber*3; i++) tmint[i]=tlong[i];
1035 montab=new CVWtab(subnumber*3,tmint);
1036 tmp=tmp.sprintf("NB%ld SN",this->nofile);
1037 ok=this->insert_key(tmp,montab);
1039 //swap on file if too big for memory in one cpu
1040 //default 1GOctet/8(for double)/10(for arrays in memory at the same time)
1041 if (np*3>this->nbelem_limit_swap)
1042 this->SwapOutOfMemory_key_mesh_wrap(QRegExp("NB",Qt::CaseSensitive,QRegExp::RegExp));
1044 //beware record 6 lenght 1
1045 //ferme le fichier :
1051 //************************************
1052 bool ghs3dprl_mesh_wrap::ReadFilePOINTS(const QString FileName)
1053 //read file .points (wrap)
1062 //NOT Raw because Raw=non-buffered file access
1063 //qt3 ok=Ff.open(IO_ReadOnly|IO_Translate);
1064 ok=Ff.open(QIODevice::ReadOnly|QIODevice::Text);
1066 std::cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
1069 tmp=Ff.readLine(maxlen);
1070 tmp=tmp.simplified();
1073 std::cerr<<"Problem conversion File '"<<FileName.toLatin1().constData()<<"\n"<<std::endl;
1076 if (verbose>2) std::cout<<"NumberOfVertices="<<nb<<std::endl;
1077 med_float *tmflo=new med_float[3*nb]; //coordinates
1078 med_int *tmint=new med_int[nb]; //nrs (attribute of point)
1080 for ( long il=0; il<nb; il++ ){
1081 tmp=Ff.readLine(maxlen);
1082 tmp=tmp.simplified();
1083 for ( int j=0; j<3; j++ ){
1084 tmflo[il3]=tmp.section(' ',j,j).toDouble(&ok);
1085 //std::cout<<"cv '"<<tmflo[il3]<<"' "<<il3<<std::endl;
1088 std::cerr<<"Problem conversion File '"<<FileName.toLatin1().constData()<<"\n"<<std::endl;
1092 //nrs is vertex attribute
1093 tmint[il]=tmp.section(' ',3,3).toLong(&ok);
1095 std::cerr<<"Problem conversion File '"<<FileName.toLatin1().constData()<<"\n"<<std::endl;
1099 //beware no examples with each specified points (if any) here
1100 CVWtab *montab=new CVWtab(nb,tmint); //init montab->tmint nrs
1101 tmp=tmp.sprintf("PO%ld NRS",this->nofile);
1102 ok=this->insert_key(tmp,montab);
1104 montab=new CVWtab(nb,tmflo); //init montab->tmflo xyz
1105 tmp=tmp.sprintf("PO%ld XYZ",this->nofile);
1106 ok=this->insert_key(tmp,montab);
1108 //Ferme le fichier :
1114 //************************************
1115 bool ghs3dprl_mesh_wrap::list_keys_mesh_wrap()
1117 QHashIterator<QString,CVWtab*> it( this->mestab);
1118 while ( it.hasNext() ) {
1120 QString nom = it.key().leftJustified(32,' ');
1121 std::cout<<nom.toLatin1().constData()<<"-> size="<<it.value()->size<<std::endl;
1126 //************************************
1127 long ghs3dprl_mesh_wrap::remove_all_keys_mesh_wrap()
1129 long nb=this->remove_key_mesh_wrap(QRegExp(".",Qt::CaseSensitive,QRegExp::RegExp));
1133 //************************************
1134 long ghs3dprl_mesh_wrap::remove_key_mesh_wrap(const QRegExp &rxp)
1137 QMutableHashIterator<QString,CVWtab*> it(this->mestab);
1138 while ( it.hasNext() ){
1140 if (it.key().contains(rxp)) {
1142 if (this->verbose>6) std::cout<<"remove key "<<it.key().toLatin1().constData()<<std::endl;
1150 //************************************
1151 long ghs3dprl_mesh_wrap::nb_key_mesh_wrap(const QRegExp &rxp)
1154 //std::cout<<"nb_key_mesh_wrap on "<<std::endl;
1155 QMutableHashIterator<QString,CVWtab*> it(this->mestab);
1156 while ( it.hasNext() ){
1158 if (it.key().contains(rxp)) nbremove++;
1160 //std::cout<<"nb_key_mesh_wrap found "<<nbremove<<std::endl;
1164 //************************************
1165 bool SwapOnFile(const QString &key,const QString &path,CVWtab *tab,int verbose)
1169 if (tab->filename=="_NO_FILE"){
1170 tab->filename=path+key+".tmp";
1171 tab->filename.replace(" ","_"); //replace " " by "_"
1173 //swap disque binaire
1174 //montab->tmint=new long[10]; //for test
1175 //for (int i=0; i<10; i++) montab->tmint[i]=i*2;
1176 FILE *fichier=fopen(tab->filename.toLatin1().constData(),"wb");
1179 fwrite(&taille,sizeof(taille),1,fichier);
1182 std::cout<<"SwapOnFile_binary "<<tab->filename.toLatin1().constData()<<
1183 " NbElements "<<taille<<
1184 " SizeElement_med_int "<<sizeof(med_int)<<
1185 " TotalSizeBinary " <<taille*sizeof(med_int)<<std::endl;
1186 fwrite(tab->tmint,sizeof(med_int),taille,fichier);
1187 //fread(&gagnants,sizeof(gagnants),1,fichier);
1191 std::cout<<"SwapOnFile_binary "<<tab->filename.toLatin1().constData()<<
1192 " NbElements "<<taille<<
1193 " SizeElement_med_float "<<sizeof(med_float)<<
1194 " TotalSizeBinary " <<taille*sizeof(med_float)<<std::endl;
1195 fwrite(tab->tmflo,sizeof(med_float),taille,fichier);
1200 if (verbose>3) std::cout<<"SwapOnFile in binary file done yet "<<
1201 tab->filename.toLatin1().constData()<<std::endl;
1203 //deallocate because swap disk binary mode
1204 tab->CVWtab_deallocate(); //free memory
1208 //************************************
1209 long ghs3dprl_mesh_wrap::SwapOutOfMemory_key_mesh_wrap(const QRegExp &rxp,
1211 //swap on file if not yet and if size greater than ifgreaterthan
1215 QHashIterator<QString,CVWtab*> it(this->mestab);
1216 while ( it.hasNext() ) {
1218 if (it.key().contains(rxp)) {
1220 if ((it.value()->size>0)&&(it.value()->size>ifgreaterthan)){
1222 std::cout<<"SwapOutOfMemory_key_mesh_wrap on demand "<<
1223 it.key().toLatin1().constData()<<
1224 " size "<<it.value()->size<<">"<<ifgreaterthan<<std::endl;
1226 ok=SwapOnFile(it.key(),this->path,it.value(),this->verbose);
1232 //************************************
1233 bool ghs3dprl_mesh_wrap::list_onekey_mesh_wrap(const QString &key)
1235 CVWtab *montab=this->mestab[key];
1237 //std::cout<<"key "<<key<<"trouvee -> size="<<montab->size<<std::endl;
1238 if (montab->type==1)
1239 for ( long i=0; i<montab->size; i++ )
1240 std::cout<<montab->tmint[i]<<" ";
1241 if (montab->type==2)
1242 for ( long i=0; i<montab->size; i++ )
1243 std::cout<<montab->tmflo[i]<<" ";
1244 std::cout<<std::endl;
1247 std::cout<<"key "<<key.toLatin1().constData()<<" not found"<<std::endl;
1251 //************************************
1252 bool ghs3dprl_mesh_wrap::insert_key(const QString &key,CVWtab *tab)
1253 //insertion conditionn� par limite this->nbelem_limit_swap
1254 //si tableaux contenus on dimension superieure
1255 //alors swap disque dans getenv(tmp) fichier temporaire binaire
1259 std::cout<<"insert key "<<key.toLatin1().constData()<<
1260 " size="<<tab->size<<std::endl;
1261 tab->filename="_NO_FILE";
1262 if (this->nbelem_limit_swap<tab->size) {
1263 if (verbose>3) std::cout<<"insert key automatic SwapOnFile "<<
1264 key.toLatin1().constData()<<std::endl;
1265 ok=SwapOnFile(key,this->path,tab,this->verbose);
1267 this->mestab.insert(key,tab);
1270 //************************************
1271 CVWtab* ghs3dprl_mesh_wrap::restore_key(const QString &key)
1272 //retauration conditionn� par limite nbelem
1273 //si tableaux contenus on dimension superieure a nbelem
1274 //alors swap disque dans getenv(tmp) fichier temporaire
1275 //alors lecture du fichier (et reallocate memory)
1278 tab=this->mestab[key];
1279 /*if (tab) std::cout<<" -> size in proc "<<tab->size<<std::endl;
1280 else std::cout<<" -> tab NULL\n";*/
1281 if (!tab) //it is NOT a problem
1283 if (verbose>6) std::cout<<"restore key not found "<<key.toLatin1().constData()<<std::endl;
1287 if (verbose>5) std::cout<<"restore key direct from memory "<<key.toLatin1().constData()<<" size="<<tab->size<<std::endl;
1290 //restore from binary file
1291 if ((tab->type<1)||(tab->type>2)){
1292 std::cerr<<"Problem restore key from binary file "<<tab->filename.toLatin1().constData()<<
1293 " type unexpexted "<<tab->type<<std::endl;
1296 //std::cout<<"restore_key from binary file "<<tab->filename<<std::endl;
1298 //swap disque binaire
1299 FILE *fichier=fopen(tab->filename.toLatin1().constData(),"rb");
1301 fread(&taille,sizeof(long),1,fichier);
1302 if (taille!=-tab->size){
1303 std::cerr<<"Problem restore_key from binary file "<<tab->filename.toLatin1().constData()<<
1304 " size unexpexted "<<taille<<" expected "<<-tab->size<<std::endl;
1310 std::cout<<"restore key from binary file "<<tab->filename.toLatin1().constData()<<
1311 " number of elements "<<taille<<
1312 " size_element med_float "<<sizeof(med_float)<<
1313 " total_size_binary " <<taille*sizeof(med_float)<<std::endl;
1315 //allocate because swap disque binaire
1316 tab->tmint=new med_int[taille]; //allocate memory
1317 fread(tab->tmint,sizeof(med_int),taille,fichier);
1321 std::cout<<"restore key from binary file "<<tab->filename.toLatin1().constData()<<
1322 " number of elements "<<taille<<
1323 " size_element med_float "<<sizeof(med_float)<<
1324 " total_size_binary " <<taille*sizeof(med_float)<<std::endl;
1325 //allocate because swap disque binaire
1326 tab->tmflo=new med_float[taille]; //allocate memory
1327 for (int i=0; i<taille ; i++) tab->tmflo[i]=-1e0;
1328 fread(tab->tmflo,sizeof(med_float),taille,fichier);
1329 /*for (int i=0; i<taille ; i++) std::cout<<tab->tmflo[i]<<"/";
1330 std::cout<<std::endl;*/
1333 tab->size=-tab->size;
1337 //************************************
1338 bool ghs3dprl_mesh_wrap::test_msg_wrap()
1339 //tests sur resultats fichiers msg
1341 QString key1,key2,typ="FA VE ED EL"; //pour faces vertice edges elements
1345 //numerotations locales sont identiques
1346 long nb=typ.count(' ',Qt::CaseSensitive) + 1; //nb chiffres detectes
1347 for (long i=0; i < nb; i++)
1348 for (long ifile=1; ifile <= this->nbfiles; ifile++)
1349 for (long ineig=1; ineig <= this->nbfiles; ineig++)
1351 if (ifile==ineig) continue; //impossible
1352 key1=key1.sprintf("MS%ld NE%ld ",ifile,ineig)+typ.section(' ',i,i)+" SE";
1353 key2=key2.sprintf("MS%ld NE%ld ",ifile,ineig)+typ.section(' ',i,i)+" RE";
1354 //std::cout<<"key "<<key1<<" et key "<<key2<<std::endl;
1355 tab1=this->restore_key(key1);
1356 //tab1=this->mestab[key1];
1357 tab2=this->restore_key(key2);
1358 //tab2=this->mestab[key2];
1359 //std::cout<<"sortie key "<<key1<<" et key "<<key2<<std::endl;
1360 if (!tab1 && !tab2) continue; //case not neighbours
1362 { std::cout<<"key "<<key1.toLatin1().constData()<<" inexistante avec key "<<key2.toLatin1().constData()<<" existante"<<std::endl;
1368 { std::cout<<"key "<<key2.toLatin1().constData()<<" inexistante avec key "<<key1.toLatin1().constData()<<" existante"<<std::endl;
1372 if (!tab1->is_equal(tab2))
1373 { std::cout<<"key "<<key1.toLatin1().constData()<<" et key "<<key2.toLatin1().constData()<<" de contenu differents"<<std::endl;
1378 printf("key '%s' et key '%s' identiques \n",
1379 (const char *)key2,(const char *)key1);*/
1382 //test size neighbourg=ifile
1383 //numerotations locales sont differentes mais de tailles identiques
1384 //pas besoin de verifier " RE " car deja fait au dessus
1385 for (long i=0; i < nb; i++)
1386 for (long ifile=1; ifile <= this->nbfiles; ifile++)
1387 for (long ineig=ifile+1; ineig <= this->nbfiles; ineig++)
1389 if (ifile==ineig) continue; //cas impossible
1390 key1=key1.sprintf("MS%ld NE%ld ",ifile,ineig)+typ.section(' ',i,i)+" SE";
1391 tab1=this->restore_key(key1); //tab1=this->mestab[key1];
1392 key2=key2.sprintf("MS%ld NE%ld ",ineig,ifile)+typ.section(' ',i,i)+" SE";
1393 tab2=this->restore_key(key2); //tab2=this->mestab[key2];
1394 if (!tab1 && !tab2) continue; //case not neighbours
1396 { std::cout<<"key "<<key1.toLatin1().constData()<<" inexistante avec key "<<key2.toLatin1().constData()<<" existante"<<std::endl;
1402 { std::cout<<"key "<<key2.toLatin1().constData()<<" inexistante avec key "<<key1.toLatin1().constData()<<" existante"<<std::endl;
1406 if ((tab1->type!=tab2->type)||(tab1->size!=tab2->size))
1407 { std::cout<<"key "<<key1.toLatin1().constData()<<" et key "<<key2.toLatin1().constData()<<" de type ou tailles differents"<<std::endl;
1415 //************************************
1416 bool ghs3dprl_mesh_wrap::test_vertices_wrap()
1417 //tests sur vertices
1419 QString key1,key2,key11,key22,key11old,key22old;
1420 CVWtab *tab1,*tab2,*tab11,*tab22;
1422 key11old="_NO_KEY";key22old="_NO_KEY";
1423 //test size neighbourg=ifile
1424 //numerotations locales sont differentes mais de tailles identiques
1425 //pas besoin de verifier " RE " car deja fait au dessus
1426 //for (int ifile=1; ifile <= this->nbfiles; ifile++)
1427 //for (int ineig=ifile+1; ineig <= this->nbfiles; ineig++)
1429 for (int ifile=this->nbfiles; ifile >= 1; ifile--)
1430 for (int ineig=this->nbfiles; ineig >= ifile+1; ineig--)
1432 if (ifile==ineig) continue; //cas impossible
1433 key1=key1.sprintf("MS%d NE%d VE SE",ifile,ineig);
1434 key11=key11.sprintf("NB%d VC",ifile);
1435 tab1=this->restore_key(key1); //tab1=this->mestab[key1];
1436 key2=key2.sprintf("MS%d NE%d VE SE",ineig,ifile);
1437 key22=key22.sprintf("NB%d VC",ineig);
1438 tab2=this->restore_key(key2); //tab2=this->mestab[key2];
1439 if (!tab1 && !tab2) continue; //cas non voisins
1442 std::cerr<<"TestEqualityCoordinates key "<<key1.toLatin1().constData()<<
1443 " NOT existing but key "<<key2.toLatin1().constData()<<" existing"<<std::endl;
1448 std::cerr<<"TestEqualityCoordinates key "<<key2.toLatin1().constData()<<
1449 " NOT existing but key "<<key1.toLatin1().constData()<<" existing"<<std::endl;
1452 if (tab1->size!=tab2->size)
1454 std::cerr<<"TestEqualityCoordinates key "<<key1.toLatin1().constData()<<
1455 " and key "<<key2.toLatin1().constData()<<" NOT same size"<<std::endl;
1461 //Swap out of memory if no use
1462 if ((key11old!=key11)&&(key11old!=key22))
1463 this->SwapOutOfMemory_key_mesh_wrap(QRegExp(key11old,Qt::CaseSensitive,QRegExp::RegExp));
1464 if ((key22old!=key11)&&(key22old!=key22))
1465 this->SwapOutOfMemory_key_mesh_wrap(QRegExp(key22old,Qt::CaseSensitive,QRegExp::RegExp));
1467 tab11=this->restore_key(key11); //tab11=this->mestab[key11];
1468 tab22=this->restore_key(key22); //tab22=this->mestab[key22];
1469 if (tab11->size>this->nbelem_limit_swap ||
1470 tab22->size>this->nbelem_limit_swap) swap=true ;
1473 //test on equality of xyz_coordinates of commons vertices
1474 for (long j=0; j < tab1->size-1; j++)
1478 //1 for print vertices not equals
1479 if (!CVW_is_equal_vertices(tab11,i1,tab22,i2,1))
1481 std::cerr<<j<<" Vertice "<<i1<<" != Vertice "<<i2<<"\n"<<std::endl;
1482 ok=false; ok1=false;
1485 if ((verbose>2)&&(ok1))
1486 std::cout<<"TestEqualityCoordinates "<<tab1->size<<
1487 " Vertices "<<key1.toLatin1().constData()<<" and "<<key2.toLatin1().constData()<<" ok"<<std::endl;
1489 std::cerr<<"TestEqualityCoordinates "<<tab1->size<<
1490 " Vertices "<<key1.toLatin1().constData()<<" and "<<key2.toLatin1().constData()<<" NO_OK"<<std::endl;
1491 key11old=key11; key22old=key22;
1494 //Swap out of memory (supposed no use?)
1495 //NO because NB1&NB2 VC supposed future use
1498 this->SwapOutOfMemory_key_mesh_wrap(QRegExp(key11old,Qt::CaseSensitive,QRegExp::RegExp));
1499 this->SwapOutOfMemory_key_mesh_wrap(QRegExp(key22old,Qt::CaseSensitive,QRegExp::RegExp));
1504 //************************************
1505 bool ghs3dprl_mesh_wrap::Find_VerticesDomainToVerticesSkin()
1506 //initialise correspondances vertice skin et vertices locaux pour chaque domaine
1507 //calcule un med_int new tab[nb_vertices_of_domain]
1508 //avec nieme vertice of skin=tab[ieme vertice de domain]
1509 //apres verification tepal garde bien dans la global numbering "GLi VE"
1510 //les indices initiaux des noeuds (attention: de 1 a nbNodes)
1512 QString key1,key2,tmp;
1513 CVWtab *cooskin,*coodom,*glodom,*montab;
1518 cooskin=this->restore_key(QString("SKIN_VERTICES_COORDINATES"));
1519 if (!cooskin) return false;
1520 if (verbose>4)std::cout<<"NumberVerticesSKIN="<<cooskin->size/3<<std::endl;
1521 //ici pourrait creer BBtree sur skin
1522 for (int ifile=1; ifile<=this->nbfiles; ifile++)
1524 key1=key1.sprintf("NB%ld VC",ifile);
1525 coodom=this->restore_key(key1);
1526 if (!coodom) continue; //Problem
1527 key2=key2.sprintf("GL%ld VE",ifile);
1528 glodom=this->restore_key(key2);
1530 std::cout<<"NumberVerticesDOMAIN_"<<ifile<<"="<<glodom->size<<std::endl;
1531 if (coodom->size!=glodom->size*3)
1533 std::cerr<<"Find_VerticesDomainToVerticesSkin key "<<key1.toLatin1().constData()<<
1534 " and key "<<key2.toLatin1().constData()<<" NOT coherent sizes"<<std::endl;
1537 //test on equality of xyz_coordinates of commons vertices
1538 med_int *tab=new med_int[glodom->size];
1540 nb=0; //nb equals vertices
1542 std::cout<<"\nglobal numbering nodes: no iglo\n";
1543 for (jd=0; jd < glodom->size; jd++)
1544 std::cout<<"\t"<<jd<<"\t"<<glodom->tmint[jd]<<std::endl;
1545 std::cout<<"\nresults: no i js iglo\n";
1546 for (jd=0; jd < coodom->size; jd=jd+3)
1548 p2=(coodom->tmflo+jd);
1550 //ici pourrait utiliser BBtree
1551 for (js=0; js < cooskin->size; js=js+3)
1553 p1=(cooskin->tmflo+js);
1554 if (p1[0]==p2[0] && p1[1]==p2[1] && p1[2]==p2[2])
1556 std::cout<<"\t"<<nb<<"\t"<<i<<"\t"<<js/3<<"\t"<<glodom->tmint[i]-1<<
1557 key2.sprintf("\t%13.5e%13.5e%13.5e",p1[0],p1[1],p1[2]).toLatin1().constData()<<std::endl;
1558 tab[i]=js/3; nb++; continue;
1563 montab=new CVWtab(glodom->size,tab);
1564 tmp=tmp.sprintf("NB%ld GL_SKIN",ifile);
1565 ok=this->insert_key(tmp,montab);
1567 std::cout<<"NumberOfEqualsVerticesDOMAIN_"<<ifile<<"="<<nb<<std::endl;
1574 //fin utils procedures
1576 //************************************
1577 bool ghs3dprl_mesh_wrap::Write_masterxmlMEDfile()
1581 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!first call
1584 //define master file (.xml) in memory
1585 tmp=path+medname+".xml";
1586 filemaster=tmp.toLatin1().constData();
1587 domainname=medname.toLatin1().constData();
1590 //Creating the XML document
1591 master_doc = xmlNewDoc(BAD_CAST "1.0");
1592 root_node = xmlNewNode(0, BAD_CAST "root");
1593 xmlDocSetRootElement(master_doc,root_node);
1595 //Creating child nodes
1597 med_int majeur,mineur,release;
1598 //Quelle version de MED est utilisee
1599 MEDlibraryNumVersion(&majeur,&mineur,&release);
1600 if (verbose>0) fprintf(stdout,"Files write with MED V%d.%d.%d\n",majeur,mineur,release);
1601 node = xmlNewChild(root_node, 0, BAD_CAST "version",0);
1602 //xmlNewProp(node, BAD_CAST "maj", BAD_CAST int2string2(majeur).c_str());
1603 xmlNewProp(node, BAD_CAST "maj", BAD_CAST i2a(majeur).c_str());
1604 xmlNewProp(node, BAD_CAST "min", BAD_CAST i2a(mineur).c_str());
1605 xmlNewProp(node, BAD_CAST "ver", BAD_CAST i2a(release).c_str());
1608 node = xmlNewChild(root_node,0, BAD_CAST "description",0);
1609 xmlNewProp(node, BAD_CAST "what", BAD_CAST "tetrahedral mesh by MeshGems-Tetra-hpc (formerly tepal)");
1612 GetLocalTime ( &present );
1613 sprintf(buff,"%04d/%02d/%02d %02dh%02dm",
1614 present.wYear,present.wMonth,present.wDay,
1615 present.wHour,present.wMinute);
1619 struct tm *time_asc = localtime(&present);
1620 sprintf(buff,"%04d/%02d/%02d %02dh%02dm",
1621 time_asc->tm_year+1900,time_asc->tm_mon+1,time_asc->tm_mday,
1622 time_asc->tm_hour,time_asc->tm_min);
1624 xmlNewProp(node, BAD_CAST "when", BAD_CAST buff);
1625 xmlNewProp(node, BAD_CAST "from", BAD_CAST "tepal2med");
1628 node =xmlNewChild(root_node,0, BAD_CAST "content",0);
1629 node2 = xmlNewChild(node, 0, BAD_CAST "mesh",0);
1630 xmlNewProp(node2, BAD_CAST "name", BAD_CAST domainname.c_str());
1631 info_node = xmlNewChild(node, 0, BAD_CAST "tepal2med_info",0);
1634 node=xmlNewChild(root_node,0,BAD_CAST "splitting",0);
1635 node2=xmlNewChild(node,0,BAD_CAST "subdomain",0);
1636 xmlNewProp(node2, BAD_CAST "number", BAD_CAST i2a(nbfilestot).c_str());
1637 node2=xmlNewChild(node,0,BAD_CAST "global_numbering",0);
1638 xmlNewProp(node2, BAD_CAST "present", BAD_CAST "yes");
1641 files_node=xmlNewChild(root_node,0,BAD_CAST "files",0);
1644 node = xmlNewChild(root_node,0,BAD_CAST "mapping",0);
1645 mesh_node = xmlNewChild(node, 0, BAD_CAST "mesh",0);
1646 xmlNewProp(mesh_node, BAD_CAST "name", BAD_CAST domainname.c_str());
1649 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!all calls
1651 char *hostname = getenv("HOSTNAME");
1652 node = xmlNewChild(files_node,0,BAD_CAST "subfile",0);
1653 xmlNewProp(node, BAD_CAST "id", BAD_CAST i2a(idom).c_str());
1654 node2 = xmlNewChild(node, 0, BAD_CAST "name", BAD_CAST distfilename);
1655 if (hostname == NULL)
1656 node2 = xmlNewChild(node, 0, BAD_CAST "machine",BAD_CAST "localhost");
1658 node2 = xmlNewChild(node, 0, BAD_CAST "machine",BAD_CAST hostname);
1660 node = xmlNewChild(mesh_node,0,BAD_CAST "chunk",0);
1661 xmlNewProp(node, BAD_CAST "subdomain", BAD_CAST i2a(idom).c_str());
1662 node2 = xmlNewChild(node, 0, BAD_CAST "name", BAD_CAST nomfinal);
1665 node = xmlNewChild(info_node, 0, BAD_CAST "chunk",0);
1666 xmlNewProp(node, BAD_CAST "subdomain", BAD_CAST i2a(idom).c_str());
1667 xmlNewProp(node, BAD_CAST "nodes_number", BAD_CAST i2a(nbnodes).c_str());
1668 xmlNewProp(node, BAD_CAST "faces_number", BAD_CAST i2a(nbtria3).c_str());
1669 xmlNewProp(node, BAD_CAST "tetrahedra_number", BAD_CAST i2a(nbtetra4).c_str());
1670 //node2 = xmlNewChild(node, 0, BAD_CAST "name", BAD_CAST nomfinal);
1672 //node2 = xmlNewChild(node, 0, BAD_CAST "nodes", 0);
1673 //xmlNewProp(node2, BAD_CAST "number", BAD_CAST i2a(nbnodes).c_str());
1674 //node2 = xmlNewChild(node, 0, BAD_CAST "faces", 0);
1675 //xmlNewProp(node2, BAD_CAST "number", BAD_CAST i2a(nbtria3).c_str());
1676 //node2 = xmlNewChild(node, 0, BAD_CAST "tetrahedra", 0);
1677 //xmlNewProp(node2, BAD_CAST "number", BAD_CAST i2a(nbtetra4).c_str());
1679 //tepal2med_info about joints of one subdomain
1680 xmlAddChild(node,joints_node);
1681 //tepal2med_info about groups and families of one subdomain
1682 xmlAddChild(node,families.xml_groups());
1685 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!last call
1686 if (idom==nbfilestot)
1688 node2 = xmlNewChild(info_node, 0, BAD_CAST "global",0);
1689 xmlNewProp(node2, BAD_CAST "tetrahedra_number", BAD_CAST i2a(nbtetrastotal).c_str());
1691 xmlSaveFormatFileEnc(filemaster.c_str(), master_doc, "UTF-8", 1);
1692 xmlFreeDoc(master_doc);
1699 //************************************
1700 bool ghs3dprl_mesh_wrap::Write_MEDfiles_v2(bool deletekeys)
1701 //deletekeys=true to delete non utils keys and arrays "au fur et a mesure"
1705 char description[MED_COMMENT_SIZE];
1706 char dtunit[MED_SNAME_SIZE+1]="_NO_UNIT";
1707 char axisname[MED_SNAME_SIZE*3+1]="x y z ";
1708 char axisunit[MED_SNAME_SIZE*3+1]="_NO_UNIT _NO_UNIT _NO_UNIT ";
1712 //precaution because casename->med_nomfinal no more 32 character
1713 //if path, in this->path.
1714 //20 preserve for add postfixes "_idom" etc...
1715 if (verbose>0)std::cout<<"\nWrite_MEDfiles_v2\n";
1716 if (verbose>6){std::cout<<"\nInitialFamilies\n"; families.write();}
1718 medname=medname.section('/',-1);
1719 if (medname.length()>20) {
1720 std::cerr<<"CaseNameMed truncated (no more 20 characters)"<<std::endl;
1721 medname.truncate(20);
1724 //create file resume DOMAIN.joints.med of all joints for quick display (...may be...)
1725 tmp=path+medname+tmp.sprintf("_joints.med",idom);
1726 charendnull(distfilename,tmp,MED_COMMENT_SIZE);
1727 fidjoint=MEDfileOpen(distfilename,MED_ACC_CREAT);
1728 if (fidjoint<0) std::cerr<<"Problem MEDfileOpen "<<distfilename<<std::endl;
1729 if (verbose>0) std::cout<<"CreateMEDFile for all joints <"<<distfilename<<">\n";
1731 //copy file source/GHS3DPRL_skin.med as destination/DOMAIN.skin.med
1732 tmp=path+medname+"_skin.med";
1733 cmd=pathini+casename+"_skin.med";
1734 int ret = access(cmd.toLatin1().constData(),F_OK); //on regarde si le fichier existe
1741 cmd = cmd+pathini+casename+"_skin.med "+tmp;
1742 //std::cout<<"Copy skin.med Command = "<<cmd<<std::endl;
1743 system(cmd.toLatin1().constData());
1744 if (verbose>0) std::cout<<"CreateMEDFile for initial skin <"<<tmp.toLatin1().constData()<<">\n"; }
1746 if (verbose>0) std::cout<<"No CreateMEDFile <"<<tmp.toLatin1().constData()<<"> for initial skin because <"<<
1747 cmd.toLatin1().constData()<<"> does not exist\n"; }
1749 //define family 0 if not existing, no groups
1750 //La famille FAMILLE_ZERO n'a pas été trouvée, elle est obligatoire
1751 families.add("0","FAMILLE_ZERO");
1752 //define family Group_of_New_Nodes (which not exists before tetrahedra)
1754 if (QString("All_Nodes").contains(deletegroups)==0){
1755 oktmp=families.get_number_of_new_family(1,&famallnodes,&tmp);
1756 families.add(tmp,"All_Nodes");
1758 else if (verbose>3) std::cout<<"--deletegroups matches \"All_Nodes\"\n";
1761 if (QString("All_Faces").contains(deletegroups)==0){
1762 oktmp=families.get_number_of_new_family(-1,&famalltria3,&tmp);
1763 families.add(tmp,"All_Faces");
1765 else if (verbose>3) std::cout<<"--deletegroups matches \"All_Faces\"\n";
1768 if (QString("All_Tetrahedra").contains(deletegroups)==0){
1769 oktmp=families.get_number_of_new_family(-1,&famalltetra4,&tmp);
1770 families.add(tmp,"All_Tetrahedra");
1772 else if (verbose>3) std::cout<<"--deletegroups matches \"All_Tetrahedra\"\n";
1775 if (QString("New_Nodes").contains(deletegroups)==0){
1776 oktmp=families.get_number_of_new_family(1,&famnewnodes,&tmp);
1777 families.add(tmp,"New_Nodes");
1779 else if (verbose>3) std::cout<<"--deletegroups matches \"New_Nodes\"\n";
1782 if (QString("New_Faces").contains(deletegroups)==0){
1783 oktmp=families.get_number_of_new_family(-1,&famnewtria3,&tmp);
1784 families.add(tmp,"New_Faces");
1786 else if (verbose>3) std::cout<<"--deletegroups matches \"New_Faces\"\n";
1789 if (QString("New_Tetrahedra").contains(deletegroups)==0){
1790 oktmp=families.get_number_of_new_family(-1,&famnewtetra4,&tmp);
1791 families.add(tmp,"New_Tetrahedra");
1793 else if (verbose>3) std::cout<<"--deletegroups matches \"New_Tetrahedra\"\n";
1795 if (verbose>6){std::cout<<"\nIntermediatesFamilies\n"; families.write();}
1796 if (verbose>6) std::cout<<"\nNumber0fFiles="<<nbfilestot<<std::endl;
1797 familles intermediatesfamilies=families;
1798 //initialisations on all domains
1801 //loop on the domains
1802 //for (idom=1; idom<=nbfilestot; idom++) {
1803 for (idom=1; idom<=nbfilestot; idom++) {
1806 //restore initial context of families
1807 if (idom>1) families=intermediatesfamilies;
1808 //if (idom>1) continue;
1809 tmp=path+medname+tmp.sprintf("_%d.med",idom);
1810 charendnull(distfilename,tmp,MED_COMMENT_SIZE);
1812 //std::cout<<"<"<<distfilename<<">"<<std::endl;
1813 fid=MEDfileOpen(distfilename,MED_ACC_CREAT);
1814 if (fid<0) {std::cerr<<"Problem MEDfileOpen "<<distfilename<<std::endl; goto erreur;}
1816 if (verbose>2) std::cout<<std::endl;
1817 std::cout<<"CreateMEDFile "<<idom<<" <"<<distfilename<<">\n";
1821 tmp=medname+tmp.sprintf("_%d",idom);
1822 charendnull(nomfinal,tmp,MED_NAME_SIZE);
1823 tmp=tmp.sprintf("domain %d among %d",idom,nbfilestot);
1824 charendnull(description,tmp,MED_COMMENT_SIZE);
1826 if (verbose>4) std::cout<<"Description : "<<description<<std::endl;
1827 err=MEDmeshCr(fid,nomfinal,3,3,MED_UNSTRUCTURED_MESH,description,dtunit,MED_SORT_DTIT,MED_CARTESIAN,axisname,axisunit);
1828 if (err<0) {std::cerr<<"Problem MEDmeshCr"<<nomfinal<<std::endl; goto erreur;}
1830 if (!idom_nodes()) {std::cerr<<"Problem on Nodes"<<std::endl; goto erreur;}
1831 if (!idom_edges()) {std::cerr<<"Problem on Edges"<<std::endl; goto erreur;}
1832 if (!idom_faces()) {std::cerr<<"Problem on Faces"<<std::endl; goto erreur;}
1833 if (!idom_tetras()) {std::cerr<<"Problem on tetrahedra"<<std::endl; goto erreur;}
1834 if (!idom_joints()) {std::cerr<<"Problem on Joints"<<std::endl; goto erreur;}
1836 if (verbose>6){std::cout<<"\nFinalsFamilies\n"; families.write();}
1837 //for nodes families
1838 nb=create_families(fid,1);
1839 if (verbose>5)std::cout<<"NumberOfFamiliesNodes="<<nb<<std::endl;
1841 err=MEDmeshEntityFamilyNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_NODE,MED_UNDEF_GEOMETRY_TYPE,nbnodes,famnodes);
1843 std::cout<<"MEDmeshEntityFamilyNumberWr nodes "<<nbnodes<<":"<<
1844 famnodes[0]<<"..."<<famnodes[nbnodes-1]<<" "<<std::endl;
1846 if (err<0) std::cerr<<"Problem MEDmeshEntityFamilyNumberWr nodes"<<std::endl;
1848 //for others families
1849 nb=create_families(fid,-1);
1850 if (verbose>5)std::cout<<"NumberOfFamiliesFacesAndEdgesEtc="<<nb<<std::endl;
1852 err=MEDmeshEntityFamilyNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TRIA3,nbtria3,famtria3);
1854 std::cout<<"MEDmeshEntityFamilyNumberWr tria3 "<<nbtria3<<":"<<
1855 famtria3[0]<<"..."<<famtria3[nbtria3-1]<<" "<<std::endl;
1857 if (err<0) std::cerr<<"Problem MEDmeshEntityFamilyNumberWr tria3"<<std::endl;
1859 err=MEDmeshEntityFamilyNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TETRA4,nbtetra4,famtetra4);
1861 std::cout<<"MEDmeshEntityFamilyNumberWr tetra4 "<<nbtetra4<<":"<<
1862 famtetra4[0]<<"..."<<famtetra4[nbtria3-1]<<" "<<std::endl;
1864 if (err<0) std::cerr<<"Problem MEDmeshEntityFamilyNumberWr tria3"<<std::endl;
1866 MEDfileClose(fid); //no error
1867 //master.xml writings
1868 oktmp=Write_masterxmlMEDfile();
1869 continue; //and loop on others domains
1873 MEDfileClose(fid); //but loop on others domains
1877 MEDfileClose(fidjoint); //no error
1878 if (verbose>0)std::cout<<"\nTotalNumberOftetrahedra="<<nbtetrastotal<<std::endl;
1883 //************************************
1884 bool ghs3dprl_mesh_wrap::idom_nodes()
1887 QString tmp,key,key1,key2,key3;
1888 CVWtab *tab,*tab1,*tab2,*tab3;
1889 med_int i,j,*arrayi;
1892 //writing node(vertices) coordinates
1893 //NBx VC=files.NoBoite Vertex Coordinates
1894 key=key.sprintf("NB%d VC",idom); //files.NoBoite Vertex Coordinates
1895 tab=this->restore_key(key); //tab1=this->mestab[key1];
1897 if (!for_tetrahpc) {
1898 tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".noboite";
1899 ok=this->ReadFileNOBOITE(tmp);
1902 tmp=pathini+casename+tmp.sprintf(format_tetra.toLatin1().constData(),idom)+".mesh";
1903 ok=this->ReadFileMESH(tmp);
1905 tab=this->restore_key(key); //tab1=this->mestab[key1];
1906 if (!tab) return false;
1908 tmp=tmp.sprintf("NB%d SN",idom);
1909 //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
1910 xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
1911 nbnodes=tab->size/3;
1912 err=MEDmeshNodeCoordinateWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,0.,MED_FULL_INTERLACE,nbnodes,tab->tmflo);
1913 if (err<0) {std::cerr<<"Problem MEDmeshNodeCoordinateWr"<<std::endl; return false;}
1914 if (verbose>4)std::cout<<"NumberOfNodes="<<nbnodes<<std::endl;
1916 //writing indices of nodes
1917 arrayi=new med_int[nbnodes];
1918 for (i=0; i<nbnodes ; i++) arrayi[i]=i+1;
1919 err=MEDmeshEntityNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_NODE,MED_UNDEF_GEOMETRY_TYPE,nbnodes,arrayi);
1921 if (err<0) {std::cerr<<"Problem MEDmeshEntityNumberWr of nodes"<<std::endl; return false;}
1923 key1=key1.sprintf("GL%d VE",idom); //global numerotation
1924 tab1=this->restore_key(key1); //tab1=this->mestab[key1];
1926 if (!for_tetrahpc) {
1927 tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".glo";
1928 ok=this->ReadFileGLO(tmp);
1931 tmp=pathini+casename+tmp.sprintf(format_tetra.toLatin1().constData(),idom)+".glo";
1932 ok=this->ReadFileGLO(tmp);
1934 if (!ok) {std::cerr<<"Problem file "<<tmp.toLatin1().constData()<<std::endl; return false;}
1935 tab1=this->restore_key(key1); //tab1=this->mestab[key1];
1936 if (!tab1) return false;
1938 if (nbnodes!=tab1->size){std::cerr<<"Problem size GLi VE!=nbnodes!"<<std::endl; return false;}
1940 key2=key2.sprintf("SKIN_VERTICES_FAMILIES",idom); //on global numerotation
1941 tab2=this->restore_key(key2); //tab1=this->mestab[key1];
1943 if (tab2) med_int nbskin=tab2->size;
1944 //for (i=0; i<nbskin; i++) std::cout<<i<<" "<<tab2->tmint[i]<<std::endl;
1946 //set families of nodes existing in GHS3DPRL_skin.med
1948 famnodes=new med_int[nb];
1949 for (i=0; i<nb ; i++) famnodes[i]=famallnodes;
1950 med_int * fammore=new med_int[nb];
1951 for (i=0; i<nb ; i++) fammore[i]=famnewnodes;
1953 //set families of nodes of skin
1954 for (i=0; i<nb ; i++){
1955 j=tab1->tmint[i]-1; //
1957 fammore[i]=tab2->tmint[j];
1960 ok=set_one_more_family(famnodes,fammore,nb);
1963 //std::cout<<"nodes loc "<<i<<" = gl "<<j<<"\t << "<<tab2->tmint[j]<<
1964 // tmp.sprintf("\t%23.15e%23.15e%23.15e",tab3->tmflo[i*3],
1965 // tab3->tmflo[i*3+1],tab3->tmflo[i*3+2])<<std::endl;
1967 //writing nodes(vertices) global numbering
1968 err=MEDmeshGlobalNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_NODE,MED_UNDEF_GEOMETRY_TYPE,nbnodes,tab1->tmint);
1969 if (err<0){std::cerr<<"Problem MEDmeshGlobalNumberWr nodes"<<std::endl; return false;}
1975 //************************************
1976 bool ghs3dprl_mesh_wrap::set_one_more_family_old(med_int *fami, med_int *more, med_int nb)
1977 //fuse array of med_int families more et fami as kind of groups
1978 //because there are possibilities of intersections
1981 med_int i,newfam,morfam,oldfam;
1982 for (i=0; i<nb ; i++) {
1983 if (more[i]==0) continue;
1986 //std::cout<<"sur "<<i<<" en plus "<<more[i]<<std::endl;
1988 else { //intersection
1989 if (fami[i]==more[i]) continue; //same families
1992 //create new family intersection if needed
1993 newfam=families.find_family_on_groups(oldfam,morfam);
1994 //std::cout<<"oldfam "<<oldfam<<" morfam "<<morfam<<" -> newfam "<<newfam<<std::endl;
2001 //************************************
2002 bool ghs3dprl_mesh_wrap::set_one_more_family(med_int *fami, med_int *more, med_int nb)
2003 //fuse array of med_int families more et fami as kind of groups
2004 //because there are possibilities of intersections
2007 med_int i,ii,j,newfam,morfam,oldfam,morfami,oldfami,i_zero,nb_fam,nb_max,nb_tot,nb_mess;
2010 nb_fam=families.fam.size(); //on families negative and positive
2011 //std::cout<<"size families "<<nb_fam<<std::endl;
2012 if (nb_fam<=0) nb_fam=5; //precaution
2013 i_zero=nb_fam*2; //offset for negative indices of families
2015 if (nb_fam>300) std::cout<<
2016 "***set_one_more_family*** warning many initial families could decrease speed "<<nb_fam<<std::endl;
2017 nb_tot=nb_max*nb_max; //max oversizing *2 on families
2018 //newfami is for speed (avoid calls find_family_on_groups)
2019 //it is an array[nb_fam*4][nb_fam*4] implemented on vector[nb_max]
2020 //to memorize newfam in array[oldfam][morfam]
2021 newfami=new med_int[nb_tot];
2022 for (i=0; i<nb_tot ; i++) newfami[i]=0; //not yet met!
2025 for (i=0; i<nb ; i++) {
2026 if (more[i]==0) continue;
2029 //std::cout<<"sur "<<i<<" en plus "<<more[i]<<std::endl;
2031 else { //intersection
2032 if (fami[i]==more[i]) continue; //same families
2033 oldfam=fami[i]; oldfami=oldfam+i_zero;
2034 morfam=more[i]; morfami=morfam+i_zero;
2036 ii=oldfami+morfami*nb_max; //array 2d on vector
2037 if ((ii>=0)&&(ii<nb_tot)) {
2043 std::cout<<"***set_one_more_family*** warning many new families decrease speed "<<nb_fam<<std::endl;
2049 //create new family intersection if needed
2050 newfam=families.find_family_on_groups(oldfam,morfam);
2051 //std::cout<<"new oldfam "<<oldfam<<" morfam "<<morfam<<" -> newfam "<<newfam<<std::endl;
2052 if (ii>=0) newfami[ii]=newfam;
2055 std::cout<<"!!! oldfam "<<oldfam<<" morfam "<<morfam<<" -> newfam "<<newfam<<std::endl;
2064 //************************************
2065 bool ghs3dprl_mesh_wrap::idom_edges()
2073 //************************************
2074 bool ghs3dprl_mesh_wrap::idom_faces()
2077 QString tmp,key,key1,key2,key3;
2078 CVWtab *tab,*tab1,*tab2,*tab3;
2079 med_int ii,i,j,*arrayi;
2082 //writing connectivity of faces triangles of wrap by nodes
2083 key1=key1.sprintf("FC%d",idom); //files.FaCes faces (wrap and triangles only)
2084 tab1=this->restore_key(key1); //tab1=this->mestab[key1];
2086 tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".faces";
2087 ok=this->ReadFileFACES(tmp);
2088 tab1=this->restore_key(key1);
2089 if (!tab1) return false;
2091 nbtria3=tab1->size/7;
2092 if (verbose>4) std::cout<<"NumberOfTriangles="<<nbtria3<<std::endl;
2093 arrayi=new med_int[nbtria3*3];
2095 for (j=0; j<nbtria3 ; j++){
2096 arrayi[ii]=tab1->tmint[i]; ii++;
2097 arrayi[ii]=tab1->tmint[i+1]; ii++;
2098 arrayi[ii]=tab1->tmint[i+2]; ii++;
2101 err=MEDmeshElementConnectivityWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,0.,MED_CELL,MED_TRIA3,MED_NODAL,MED_FULL_INTERLACE,nbtria3,arrayi);
2102 delete[] arrayi; //need immediately more little array
2103 if (err<0){std::cerr<<"Problem MEDmeshElementConnectivityWr for triangles connectivity"<<std::endl; return false;}
2105 //writing indices of faces triangles of wrap
2107 //generate "overlapping of numbers of elements" in "import med file" in salome
2108 //if not in "//writing indices of tetrahedra" -> arrayi[i]=!NBFACES!+i+1
2109 arrayi=new med_int[nbtria3];
2110 for (i=0; i<nbtria3 ; i++) arrayi[i]=nbseg2+i+1;
2111 err=MEDmeshEntityNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TRIA3,nbtria3,arrayi);
2113 if (err<0){std::cerr<<"Problem MEDmeshEntityNumberWr of triangles"<<std::endl; return false;}
2115 //GLx FA=files.GLo FAces
2116 key1=key1.sprintf("GL%d FA",idom);
2117 tab1=this->restore_key(key1); //tab1=this->mestab[key1];
2118 if (nbtria3!=tab1->size){std::cerr<<"Problem size GLi FA!=nbtria3!"<<std::endl; return false;}
2120 key2=key2.sprintf("SKIN_TRIA3_FAMILIES",idom); //on global numerotation
2121 tab2=this->restore_key(key2); //tab1=this->mestab[key1];
2123 if (tab2) nbskin=tab2->size;
2125 //set families of faces existing in GHS3DPRL_skin.med
2127 famtria3=new med_int[nb];
2128 for (i=0; i<nb ; i++) famtria3[i]=famalltria3;
2129 med_int * fammore=new med_int[nb];
2130 for (i=0; i<nb ; i++) fammore[i]=famnewtria3;
2132 //set families of faces of skin
2133 for (i=0; i<nb ; i++){
2134 j=tab1->tmint[i]-1; //
2136 fammore[i]=tab2->tmint[j];
2139 ok=set_one_more_family(famtria3,fammore,nb);
2142 //writing faces(triangles) global numbering
2144 std::cout<<"CreateMEDglobalNumerotation_Faces "<<key1.toLatin1().constData()<<" "<<tab1->size<<std::endl;
2145 err=MEDmeshGlobalNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TRIA3,tab1->size,tab1->tmint);
2146 if (err<0){std::cerr<<"Problem MEDmeshGlobalNumberWr faces"<<std::endl; return false;}
2148 //xx=this->remove_key_mesh_wrap(QRegExp("FC*",true,true));
2149 tmp=tmp.sprintf("GL%d FA",idom);
2150 //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
2151 xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
2152 tmp=tmp.sprintf("GL%d VE",idom);
2153 //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
2154 xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
2159 //************************************
2160 bool ghs3dprl_mesh_wrap::idom_joints()
2163 QString tmp,namejoint,key,key1,key2;
2164 CVWtab *tab,*tab1,*tab2;
2165 med_int ineig,ii,jj,i,j,k,*arrayi,nb,famjoint,*fammore,*inodes,*arrayfaces;
2166 med_float *arraynodes;
2167 char namejnt[MED_NAME_SIZE+1]; //no more 32
2168 char namedist[MED_NAME_SIZE+1];
2169 char descjnt[MED_COMMENT_SIZE+1];
2170 med_int numfam_ini_wrap=100;
2171 joints_node=xmlNewNode(NULL, BAD_CAST "joints"); //masterfile.xml
2172 med_int nbjoints=0,nbnodesneig,nbtria3neig;
2173 std::string sjoints=""; //which domains are neighbourg
2175 char dtunit[MED_SNAME_SIZE+1]="_NO_UNIT";
2176 char axisname[MED_SNAME_SIZE*3+1]="x y z ";
2177 char axisunit[MED_SNAME_SIZE*3+1]="_NO_UNIT _NO_UNIT _NO_UNIT ";
2179 tmp=tmp.sprintf("MS%d *",idom);
2180 //read file .msg if not done
2181 //qt3 if (this->nb_key_mesh_wrap(QRegExp(tmp,true,true))<=0) {
2182 if (this->nb_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp))<=0) {
2185 if (!for_tetrahpc) {
2186 tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".msg";
2189 tmp=pathini+casename+tmp.sprintf(format_tetra.toLatin1().constData(),idom)+".msg";
2192 ok=this->ReadFileMSGnew(tmp);
2194 std::cerr<<"Problem in file "<<tmp.toLatin1().constData()<<std::endl;
2200 for (ineig=1; ineig <= nbfilestot; ineig++) {
2201 if (idom==ineig) continue; //impossible
2203 //!*************nodes
2204 //std::cout<<"\n nodes joints\n";
2205 key1=key1.sprintf("MS%d NE%d VE SE",idom,ineig); //SE or RE identicals
2206 tab1=restore_key(key1);
2207 if (!tab1) continue; //case (ifile,ineig) are not neighbours=>no joints
2208 key1=key1.sprintf("MS%d NE%d VE SE",ineig,idom); //SE or RE identicals
2209 tab2=this->restore_key(key1);
2210 //if not yet loaded (first time) try to load necessary file msg of neighbourg
2213 if (!for_tetrahpc) {
2214 tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,ineig)+".msg";
2217 tmp=pathini+casename+tmp.sprintf(format_tetra.toLatin1().constData(),ineig)+".msg";
2220 this->nofile=ineig; //neighbourg file
2221 ok=this->ReadFileMSGnew(tmp);
2222 this->nofile=idom; //restaure initial domain
2224 std::cerr<<"Problem in file "<<tmp.toLatin1().constData()<<std::endl;
2227 tab2=this->restore_key(key1);
2229 if (!tab2) std::cerr<<"Problem existing nodes joint in domain "<<idom<<
2230 " with none in neighbourg "<<ineig<<" files .msg"<<std::endl;
2231 nb=tab1->size; nbnodesneig=tab2->size;
2232 if (nb!=nbnodesneig) {
2233 std::cerr<<"Problem in file "<<tmp.toLatin1().constData()<<
2234 " number of nodes of joint "<<idom<<"<->"<<ineig<<" not equals"<<std::endl;
2238 nbjoints++; //one more joint for this domain
2239 sjoints=sjoints+" "+i2a(ineig);
2241 std::cout<<"NumberOfNodesOfJoint_"<<idom<<"_"<<ineig<<"="<<nb<<std::endl;
2242 namejoint=namejoint.sprintf("JOINT_%d_%d_Nodes",idom,ineig);
2243 strcpy(namejnt,namejoint.toLatin1().constData());
2244 tmp=tmp.sprintf("JOINT_%d_%d among %d domains of ",idom,ineig,nbfilestot)+nomfinal;
2245 strcpy(descjnt,tmp.toLatin1().constData());
2246 tmp=medname+tmp.sprintf("_%d",ineig);
2247 strcpy(namedist,tmp.toLatin1().constData());
2248 err=MEDsubdomainJointCr(fid,nomfinal,namejnt,descjnt,ineig,namedist);
2249 if (err<0) std::cerr<<"Problem MEDsubdomainJointCr"<<std::endl;
2252 if (namejoint.contains(deletegroups)==0){
2253 ok=families.get_number_of_new_family(1,&famjoint,&tmp);
2254 families.add(tmp,namejoint);
2257 key=key.sprintf("NB%d VC",idom); //files.NoBoite Vertex Coordinates
2258 tab=this->restore_key(key); //tab1=this->mestab[key1];
2259 //nbnodes=tab->size/3;
2261 //writing correspondence nodes-nodes
2262 //two indices for one correspondence
2263 arrayi=new med_int[nb*2];
2264 arraynodes=new med_float[nbnodesneig*3]; //for file DOMAIN_join.med
2265 inodes=new med_int[nbnodes]; //for file DOMAIN_join.med
2266 med_int * fammore=new med_int[nbnodes];
2267 for (i=0; i<nbnodes ; i++) {fammore[i]=0; inodes[i]=-2;} //precautions
2269 for (i=0; i<nb ; i++){
2270 //no need because <send> equals <receive> tab1->tmint[i]==tab2->tmint[i]
2271 j=tab1->tmint[i]-1; //contents of tab1 1->nb, j 0->nb-1
2272 inodes[j]=k; k++; //contents of inodes 1->n ,nodes of joint from nodes of domain
2273 arraynodes[jj]=tab->tmflo[j*3]; jj++;
2274 arraynodes[jj]=tab->tmflo[j*3+1]; jj++;
2275 arraynodes[jj]=tab->tmflo[j*3+2]; jj++;
2277 fammore[j]=famjoint;
2278 arrayi[ii]=tab1->tmint[i]; ii++;
2279 arrayi[ii]=tab2->tmint[i]; ii++;
2281 if (namejoint.contains(deletegroups)==0){
2282 ok=set_one_more_family(famnodes,fammore,nbnodes);
2286 err=MEDsubdomainCorrespondenceWr(fid,nomfinal,namejnt,MED_NO_DT,MED_NO_IT,
2287 MED_NODE,MED_UNDEF_GEOMETRY_TYPE,MED_NODE,MED_UNDEF_GEOMETRY_TYPE,nb,arrayi);
2288 if (err<0) std::cerr<<"Problem MEDsubdomainCorrespondenceWr nodes"<<std::endl;
2291 //!*************TRIA3
2292 //writing correspondence triangles-triangles
2293 //std::cout<<"\n faces joints\n";
2295 key1=key1.sprintf("MS%d NE%d FA SE",idom,ineig); //SE or RE identicals
2296 tab1=this->restore_key(key1); //tab1=this->mestab[key1];
2299 std::cout<<"NumberOfTrianglesOfJoint_"<<idom<<"_"<<ineig<<"=0"<<std::endl;
2300 //continue; //case (ifile,ineig) are not neighbours=>no joints
2302 else //have to set xml may be no faces but nodes in a joint!
2304 key1=key1.sprintf("MS%d NE%d FA SE",ineig,idom); //SE or RE identicals
2305 tab2=this->restore_key(key1);
2306 if (!tab2) std::cerr<<"Problem existing triangles of joint in domain "<<idom<<
2307 " with none in neighbourg "<<ineig<<" files .msg"<<std::endl;
2308 nb=tab1->size; nbtria3neig=tab2->size;
2309 if (nb!=nbtria3neig) {
2310 std::cerr<<"Problem in file "<<tmp.toLatin1().constData()<<
2311 " number of triangles of joint "<<idom<<"<->"<<ineig<<" not equals"<<std::endl;
2314 namejoint=namejoint.sprintf("JOINT_%d_%d_Faces",idom,ineig);
2317 if (namejoint.contains(deletegroups)==0){
2318 ok=families.get_number_of_new_family(-1,&famjoint,&tmp);
2319 families.add(tmp,namejoint);
2322 key=key.sprintf("FC%d",idom); //files.FaCes faces (wrap and triangles only)
2323 tab=this->restore_key(key); //tab1=this->mestab[key1];
2325 med_int nb=tab1->size; nbtria3neig=nb;
2326 //if (verbose>=0) std::cout<<"NumberOfTrianglesOfJoint_"<<idom<<"_"<<ineig<<"="<<nb<<std::endl;
2327 arrayi=new med_int[nb*2]; //correspondance indices triangles in 2 domains
2328 arrayfaces=new med_int[nbtria3neig*3]; //for file DOMAIN_join.med
2329 for (i=0; i<nbtria3neig*3 ; i++) arrayfaces[i]=-1; //precaution
2330 fammore=new med_int[nbtria3];
2331 for (i=0; i<nbtria3 ; i++) fammore[i]=0;
2333 for (i=0; i<nb ; i++){
2334 arrayi[ii]=tab1->tmint[i]; ii++;
2335 arrayi[ii]=tab2->tmint[i]; ii++; //correspondance indices triangles in 2 domains
2337 fammore[tab1->tmint[i]-1]=famjoint;
2338 //famtria3[tab1->tmint[i]-1]=famjoint;
2340 k=tab1->tmint[i]-1; //indice of node connectivity
2341 //std::cout<<"k="<<k<<std::endl;
2342 k=k*7; //indice of node connectivity in tab of triangles
2344 arrayfaces[jj]=inodes[tab->tmint[k]-1]; jj++;
2345 arrayfaces[jj]=inodes[tab->tmint[k+1]-1]; jj++;
2346 arrayfaces[jj]=inodes[tab->tmint[k+2]-1]; jj++;
2349 for (i=0; i<nbtria3neig*3 ; i++) {
2350 if (arrayfaces[i]<=0) {
2351 std::cerr<<"Problem file X_joints.med unknown node in joint "<<idom<<"_"<<ineig<<" face "<<i/3+1<<std::endl; //precaution
2355 /*TODO DEBUG may be bug distene?
2357 std::cout<<"\nNumberOfTrianglesOfJoint_"<<idom<<"_"<<ineig<<"="<<nb<<std::endl;
2358 for (i=0; i<nbnodes ; i++) std::cout<<"inode i "<<i+1<<" "<<inodes[i]<<std::endl;
2359 for (i=0; i<tab1->size ; i++) std::cout<<"triangle i "<<i+1<<" "<<tab1->tmint[i]<<std::endl;
2360 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;
2363 if (namejoint.contains(deletegroups)==0){
2364 ok=set_one_more_family(famtria3,fammore,nbtria3);
2368 err=MEDsubdomainCorrespondenceWr(fid,nomfinal,namejnt,MED_NO_DT,MED_NO_IT,
2369 MED_CELL,MED_TRIA3,MED_CELL,MED_TRIA3,nb,arrayi);
2370 if (err<0) std::cerr<<"Problem MEDsubdomainCorrespondenceWr triangles"<<std::endl;
2374 //!write in file resume DOMAIN.joints.med of all joints for quick display (...may be...)
2375 if (idom<=ineig) { //no duplicate joint_1_2 and joint_2_1
2377 namejoint=namejoint.sprintf("JOINT_%d_%d",idom,ineig);
2378 charendnull(namejnt,namejoint,MED_NAME_SIZE);
2379 tmp=tmp.sprintf("joint between %d and %d",idom,ineig);
2380 charendnull(descjnt,tmp,MED_COMMENT_SIZE);
2381 err=MEDmeshCr(fidjoint,namejnt,3,3,MED_UNSTRUCTURED_MESH,descjnt,dtunit,MED_SORT_DTIT,MED_CARTESIAN,axisname,axisunit);
2382 if (err<0) std::cerr<<"Problem MEDmeshCr "<<namejnt<<std::endl;
2384 err=MEDmeshNodeCoordinateWr(fidjoint,namejnt,MED_NO_DT,MED_NO_IT,0.,MED_FULL_INTERLACE,nbnodesneig,arraynodes);
2385 if (err<0) std::cerr<<"Problem MEDmeshNodeCoordinateWr "<<namejnt<<std::endl;
2386 arrayi=new med_int[nbnodesneig];
2387 for (i=0; i<nbnodesneig ; i++) arrayi[i]=i+1;
2388 err=MEDmeshEntityNumberWr(fidjoint,namejnt,MED_NO_DT,MED_NO_IT,MED_NODE,MED_UNDEF_GEOMETRY_TYPE,nbnodesneig,arrayi);
2390 if (err<0) std::cerr<<"Problem MEDmeshEntityNumberWr of nodes "<<namejnt<<std::endl;
2391 //families zero in file fidjoint ???
2392 //La famille FAMILLE_ZERO n'a pas été trouvée, elle est obligatoire
2393 nb=create_family_zero(fidjoint,namejnt);
2396 if (nbtria3neig>0) {
2397 //for (i=0; i<nbtria3neig ; i++) std::cout<<i+1<<" "<<
2398 // arrayfaces[i*3]<<" "<<arrayfaces[i*3+1]<<" "<<arrayfaces[i*3+2]<<std::endl;
2399 err=MEDmeshElementConnectivityWr(fidjoint,namejnt,MED_NO_DT,MED_NO_IT,0.,
2400 MED_CELL,MED_TRIA3,MED_NODAL,MED_FULL_INTERLACE,nbtria3neig,arrayfaces);
2401 if (err<0) std::cerr<<"Problem MEDmeshElementConnectivityWr for triangles connectivity "<<namejnt<<std::endl;
2402 //writing indices of faces triangles of joint
2403 arrayi=new med_int[nbtria3neig];
2404 for (i=0; i<nbtria3neig ; i++) arrayi[i]=i+1;
2405 err=MEDmeshEntityNumberWr(fidjoint,namejnt,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TRIA3,nbtria3neig,arrayi);
2407 if (err<0) std::cerr<<"Problem MEDmeshEntityNumberWr of triangles "<<namejnt<<std::endl;
2411 delete[] arraynodes;
2412 if (nbtria3neig>0) delete[] arrayfaces;
2416 node=xmlNewChild(joints_node, 0, BAD_CAST "joint", 0);
2417 xmlNewProp(node, BAD_CAST "id", BAD_CAST i2a(ineig).c_str());
2418 xmlNewProp(node, BAD_CAST "nodes_number", BAD_CAST i2a(nbnodesneig).c_str());
2419 xmlNewProp(node, BAD_CAST "faces_number", BAD_CAST i2a(nbtria3neig).c_str());
2420 //node2 = xmlNewChild(node, 0, BAD_CAST "nodes", 0);
2421 //xmlNewProp(node2, BAD_CAST "number", BAD_CAST i2a(nbnodesneig).c_str());
2422 //node2 = xmlNewChild(node, 0, BAD_CAST "faces", 0);
2423 //xmlNewProp(node2, BAD_CAST "number", BAD_CAST i2a(nbtria3neig).c_str());
2427 xmlNewProp(joints_node, BAD_CAST "number", BAD_CAST i2a(nbjoints).c_str());
2428 xmlNewChild(joints_node, 0, BAD_CAST "id_neighbours", BAD_CAST sjoints.substr(1).c_str());
2430 tmp=tmp.sprintf("NB%d VC",idom);
2431 //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
2432 xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
2433 //tmp=tmp.sprintf("MS%d NE*",idom);
2434 //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
2435 //xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
2436 tmp=tmp.sprintf("FC%d",idom);
2437 //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
2438 xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
2439 tmp=tmp.sprintf("GL%d *",idom);
2440 //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
2441 xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
2445 //************************************
2446 bool ghs3dprl_mesh_wrap::idom_tetras()
2454 //writing connectivity of tetrahedra by nodes
2455 key1=key1.sprintf("NB%d EV",idom); //files.NoBoite Elements Vertices (tetra only)
2456 tab1=this->restore_key(key1); //tab1=this->mestab[key1];
2457 nbtetra4=tab1->size/4;
2458 nbtetrastotal=nbtetrastotal + nbtetra4;
2459 if (verbose>5)std::cout<<"NumberOftetrahedra="<<nbtetra4<<std::endl;
2460 err=MEDmeshElementConnectivityWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,0.,MED_CELL,MED_TETRA4,MED_NODAL,MED_FULL_INTERLACE,nbtetra4,tab1->tmint);
2461 if (err<0){std::cerr<<"Problem MEDmeshElementConnectivityWr for tetra connectivity"<<std::endl; return false;}
2463 //writing indices of tetrahedra
2464 arrayi=new med_int[nbtetra4];
2465 for (i=0; i<nbtetra4 ; i++) arrayi[i]=nbseg2+nbtria3+i+1;
2466 //for (i=0; i<nbtria3 ; i++) std::cout<<i<<" "<<arrayi[i]<<std::endl;
2467 err=MEDmeshEntityNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TETRA4,nbtetra4,arrayi);
2469 if (err<0){std::cerr<<"Problem MEDmeshEntityNumberWr of tetrahedra"<<std::endl; return false;}
2471 famtetra4=new med_int[nbtetra4];
2472 for (i=0; i<nbtetra4 ; i++) famtetra4[i]=famnewtetra4;
2474 //writing tetrahedra global numbering
2475 //GLx EL=files.GLo ELements
2476 key1=key1.sprintf("GL%d EL",idom);
2477 tab1=this->restore_key(key1); //tab1=this->mestab[key1];
2479 tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".glo";
2480 ok=this->ReadFileGLO(tmp);
2481 tab1=this->restore_key(key1);
2482 if (!tab1) return false;
2485 if (tab1->size!=nbtetra4){
2486 std::cerr<<"Problem incorrect size of tetrahedra global numbering"<<std::endl; return false;}
2488 std::cout<<"CreateMEDglobalNumerotation_tetrahedra "<<key1.toLatin1().constData()<<" "<<tab1->size<<std::endl;
2489 err=MEDmeshGlobalNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TETRA4,tab1->size,tab1->tmint);
2490 if (err<0){std::cerr<<"Problem MEDmeshGlobalNumberWr tetrahedra"<<std::endl; return false;}
2492 tmp=tmp.sprintf("NB%d EV",idom);
2493 //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
2494 xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
2498 //************************************
2499 med_int ghs3dprl_mesh_wrap::create_families(med_idt fid, int sign)
2500 //if sign < 0 families faces or tria3 etc...
2501 //if sign >= 0 family zero and family nodes
2504 char nomfam[MED_NAME_SIZE+1]; //it.current()->name;
2505 char attdes[MED_COMMENT_SIZE+1]="_NO_DESCRIPTION";
2507 med_int i,attide=1,attval=1,natt=1,num,ngro;
2509 if (sign>=0) pas=1; else pas=-1;
2514 for (it1=families.fam.begin(); it1!=families.fam.end(); ++it1){
2515 num=(*it1).first.toLong();
2516 if ((pas==-1) && (num>=0)) continue; //not good families
2517 if ((pas== 1) && (num< 0)) continue; //not good families
2518 charendnull(nomfam,(*it1).first,MED_NAME_SIZE);
2521 ngro=(*it1).second.size();
2523 std::cout<<"CreateFamilyInMEDFile <"<<nomfam<<">\tNbGroups="<<ngro;
2524 gro=new char[MED_LNAME_SIZE*ngro+2];
2527 for (it2=gb.begin(); it2!=gb.end(); ++it2){
2528 charendnull(&gro[i*MED_LNAME_SIZE],(*it2).first,MED_LNAME_SIZE);
2529 if (verbose>5)std::cout<<" <"<<&gro[i*MED_LNAME_SIZE]<<"> ";
2532 if (verbose>5)std::cout<<std::endl;
2533 err=MEDfamilyCr(fid,nomfinal,nomfam,num,ngro,gro);
2535 if (err<0) std::cerr<<"Problem MEDfamilyCr of "<<nomfam<<std::endl;
2540 med_int ghs3dprl_mesh_wrap::create_family_zero(med_idt fid, QString nameMesh)
2544 char nomfam[MED_NAME_SIZE+1]="FAMILLE_ZERO"; //it.current()->name;
2545 char attdes[MED_COMMENT_SIZE+1]="_NO_DESCRIPTION";
2548 med_int i,attide=1,attval=1,natt=1,num=0,ngro=0;
2550 gro=new char[MED_LNAME_SIZE*ngro+2];
2551 if (verbose>3)std::cout<<"\ncreate_family_ZERO "<<nameMesh.toLatin1().constData()<<std::endl;
2552 err=MEDfamilyCr(fid,nameMesh.toLatin1().constData(),nomfam,num,ngro,gro);
2553 if (err<0) std::cerr<<"Problem MEDfamilyCr FAMILLE_ZERO of "<<nameMesh.toLatin1().constData()<<std::endl;