-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// ---
// File : ghs3dprl_mesh_wrap.cxx
-// Author : Christian VAN WAMBEKE (CEA) (from Hexotic plugin Lioka RAZAFINDRAZAKA)
+// Author : Christian VAN WAMBEKE (CEA)
// ---
-//
+
#include "ghs3dprl_mesh_wrap.h"
#include <string>
#include <sstream>
#include <fstream>
+#include <libxml/tree.h>
+#include <libxml/parser.h>
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+
#include <QFile>
#include <QRegExp>
+using namespace std;
using namespace med_2_2;
+//utils procedures
+
+//************************************
+string i2a(const int &v)
+{
+ ostringstream ss;
+ ss<<v;
+ return ss.str();
+}
+
+//************************************
+QString endspace(QString deb,int lg)
+//better fill by spaces for char unicoo[3*MED_TAILLE_PNOM+1]; etc...
+{
+ QString fin,spa;
+ //spa.fill(' ',lg);
+ //fin=deb+spa;
+ //fin.truncate(lg);
+ fin=deb.leftJustified(lg,' ',true);
+ return fin;
+}
+
+//************************************
+void charendnull(char *p, QString deb, int lg)
+{
+ QString fin;
+ fin=deb;
+ fin.truncate(lg-1);
+ strcpy(p,fin.toLatin1().constData()); // 0 at end
+ for (int i=fin.length();i<lg-1;i++){
+ p[i]='\0';
+ }
+}
+
+//class familles
+//************************************
+ void familles::newfam(QString nom){
+ //cout<<"newfam "<<nom<<endl;
+ if (fam.find(nom)!=fam.end()){
+ cout<<"***newfam*** "<<nom.toLatin1().constData()<<" deja present\n";
+ return;
+ }
+ fend gb;
+ fam[nom]=gb;
+ }
+
+//************************************
+ void familles::newgro(QString nom){
+ //cout<<"newgro "<<nom<<endl;
+ if (gro.find(nom)!=gro.end()){
+ cout<<"***newgro*** "<<nom.toLatin1().constData()<<" deja present\n";
+ return;
+ }
+ fend gb;
+ gro[nom]=gb;
+ }
+
+//************************************
+ void familles::write(){
+ fend gb;
+ fagr::iterator it1;
+ fend::iterator it2;
+ //cout<<"\n***familles.write()***\n";
+ for (it1=fam.begin(); it1!=fam.end(); ++it1){
+ cout<<"Family=<"<<(*it1).first.toLatin1().constData()<<">\tGroups=";
+ gb=(*it1).second;
+ for (it2=gb.begin(); it2!=gb.end(); ++it2){
+ cout<<"<"<<(*it2).first.toLatin1().constData()<<"> ";
+ }
+ cout<<endl;
+ }
+ for (it1=gro.begin(); it1!=gro.end(); ++it1){
+ cout<<"Group=<"<<(*it1).first.toLatin1().constData()<<">\tFamilies=";
+ gb=(*it1).second;
+ for (it2=gb.begin(); it2!=gb.end(); ++it2){
+ cout<<"<"<<(*it2).first.toLatin1().constData()<<"> ";
+ }
+ cout<<endl;
+ }
+ }
+
+//************************************
+ xmlNodePtr familles::xml_groups(){
+ fend gb;
+ fagr::iterator it1;
+ fend::iterator it2;
+ int nb=0,nbf;
+ string ss;
+ xmlNodePtr res,node;
+ res=xmlNewNode(NULL, BAD_CAST "groups");
+ for (it1=gro.begin(); it1!=gro.end(); ++it1){
+ node = xmlNewChild(res, 0, BAD_CAST "group",0);
+ ss=(*it1).first.toLatin1().constData();
+ xmlNewProp(node, BAD_CAST "name", BAD_CAST ss.c_str());
+ nb++;
+ gb=(*it1).second;
+ nbf=0; ss="";
+ for (it2=gb.begin(); it2!=gb.end(); ++it2){
+ ss=ss+" "+(*it2).first.toLatin1().constData();
+ nbf++;
+ }
+ xmlNewProp(node, BAD_CAST "families_number", BAD_CAST i2a(nbf).c_str());
+ xmlNewProp(node, BAD_CAST "families", BAD_CAST ss.substr(1).c_str());
+ //cout<<endl;
+ }
+ xmlNewProp(res, BAD_CAST "number", BAD_CAST i2a(nb).c_str());
+ return res;
+ }
+
+//************************************
+ void familles::add(QString nomfam, QString nomgro)
+ {
+ //cout<<"add family <"<<nomfam<<">\t<"<<nomgro<<">\n";
+ fagr::iterator it;
+ it=fam.find(nomfam);
+ if (it==fam.end()){
+ //cout<<"add new family <"<<nomfam<<">\t<"<<nomgro<<">\n";
+ newfam(nomfam);
+ it=fam.find(nomfam);
+ }
+ if (nomgro=="") return; //no group
+ (*it).second[nomgro]=0;
+ it=gro.find(nomgro);
+ if (it==gro.end()){
+ //cout<<"***new*** "<<nomgro<<" non present\n";
+ newgro(nomgro);
+ it=gro.find(nomgro);
+ }
+ (*it).second[nomfam]=0;
+
+ }
+
+
+//************************************
+bool familles::get_number_of_new_family(int sign, med_int *ires, QString *tmp)
+//if sign < 0 families faces or tria3 etc...
+//if sign >= 0 family zero and family nodes
+//outputs in *ires and *tmp
+{
+ int pas,i,ii;
+ QString nomfam;
+ fagr::iterator it;
+ if (sign>=0) pas=1; else pas=-1;
+ *tmp="0"; *ires=0;
+ ii=pas;
+ for (i=0;i<10000;i++) { //mefiance
+ nomfam=nomfam.sprintf("%d",ii);
+ it=fam.find(nomfam);
+ if (it==fam.end()) {
+ *tmp=nomfam; *ires=ii;
+ //cout<<"NewFamily Found<"<<*ires<<"><"<<*tmp<<">\n";
+ return true;
+ }
+ ii=ii+pas;
+ }
+ cerr<<"***get_number_of_new_family*** Problem new family not found"<<endl;
+ return false;
+}
+
+//************************************
+ med_int familles::find_family_on_groups(med_int fam1, med_int fam2)
+ {
+ med_int ires=0;
+ if (fam1==fam2) {ires=fam1; return ires;}
+ //find one family whith groups of fam1 and groups of fam2
+ fend gb=fuse_goups(fam1,fam2);
+ //find if one family have theses groups
+ fagr::iterator it1;
+ fend::iterator it2;
+ for (it1=fam.begin(); it1!=fam.end(); ++it1){
+ if (gb==(*it1).second){
+ ires=(*it1).first.toLong();
+ //cout<<"find_family_on_groups old <"<<ires<<"> from <"<<
+ // fam1<<"><"<<fam2<<">\n";
+ return ires;
+ }
+ }
+ //cout<<"no family found!!! - groups of "<<fam1<<" and "<<fam2<<endl;
+ QString tmp;
+ //fam1 positive for nodes negative faces & mailles
+ bool oktmp=get_number_of_new_family(fam1,&ires,&tmp);
+ fend::iterator it;
+ for (it=gb.begin(); it!=gb.end(); ++it){
+ this->add(tmp,(*it).first);
+ }
+ //cout<<"new family <"<<ires<<"> intersection of <"<<fam1<<"><"<<fam2<<">\n";
+ return ires;
+ }
+
+//************************************
+ fend familles::fuse_goups(med_int fam1, med_int fam2)
+ //concatenation/fusion deux map groupes
+ {
+ QString nom1,nom2;
+ fagr::iterator it1,it2;
+ nom1=nom1.sprintf("%d",fam1);
+ it1=fam.find(nom1);
+ nom2=nom2.sprintf("%d",fam2);
+ it2=fam.find(nom2);
+ if ( (it1==fam.end())||(it2==fam.end()) ) {
+ cerr<<"***fuse_goups*** non existing family "<<fam1<<" or "<<fam2<<endl;
+ fend gb;
+ return gb; //empty
+ }
+ fend gb=(*it1).second; //firt groups
+ gb.insert((*it2).second.begin(),(*it2).second.end()); //other groups
+ return gb;
+ //for debug
+ cout<<"fuse_goups "<<fam1<<" "<<fam2<<" ";
+ fend::iterator it;
+ for (it=gb.begin(); it!=gb.end(); ++it){
+ cout<<"<"<<(*it).first.toLatin1().constData()<<"> ";
+ }
+ cout<<endl;
+ return gb;
+ }
+
+long CVWtab::memoryuse=0; //static
+long CVWtab::memorymax=1000*1000000; //static
+
//************************************
CVWtab::CVWtab(long nb, med_int *pmint)
//constructor with pmint allocated yet with new
{
- //std::cout"***constructor med_int CVWtab***\n";
- size=nb;
- type=1; //only tmint valide
- tmint=pmint;
- tmflo=NULL;
+ //cout"***constructor med_int CVWtab***\n";
+ size=nb;
+ type=1; //only tmint valide
+ tmint=pmint;
+ tmflo=NULL;
+ memoryuse=memoryuse+sizeof(med_int)*nb;
+ //cout<<"memoryuse int "<<sizeof(med_int)<<" "<<nb<<" "<<memoryuse<<" "<<memorymax<<endl;
+ if (memoryuse>memorymax) {
+ cout<<"***WARNING*** memory max reached "<<memorymax<<endl;
+ //cout<<"memoryuse int "<<sizeof(med_int)<<" "<<nb<<" "<<memoryuse<<endl;
+ }
}
//************************************
CVWtab::CVWtab(long nb, med_float *pmflo)
//constructor with pmflo allocated yet with new
{
- //std::cout<<"***constructor med_float CVWtab***\n";
- size=nb;
- type=2; //only tmflo valide
- tmint=NULL;
- tmflo=pmflo;
+ //cout<<"***constructor med_float CVWtab***\n";
+ size=nb;
+ type=2; //only tmflo valide
+ tmint=NULL;
+ tmflo=pmflo;
+ memoryuse=memoryuse+sizeof(med_float)*nb;
+ //cout<<"memoryuse float "<<sizeof(med_float)<<" "<<nb<<" "<<memoryuse<<" "<<memorymax<<endl;
+ if (memoryuse>memorymax) {
+ cout<<"***WARNING*** memory max reached "<<memorymax<<endl;
+ //cout<<"memoryuse float "<<sizeof(med_float)<<" "<<nb<<" "<<memoryuse<<endl;
+ }
}
//************************************
CVWtab::~CVWtab()
{
- bool ok;
- //std::cout<<" destructor CVWtab *** "<<this->filename<<std::endl;
- ok = CVWtab_deallocate();
- //remove temporary file
- if (filename!="_NO_FILE")
- {
- QFile::remove(filename);
- //std::cout<<this->filename<<" successfully deleted\n";
- }
+ bool ok;
+ //cout<<" destructor CVWtab *** "<<this->filename<<endl;
+ ok=this->CVWtab_deallocate();
+ //remove temporary file
+ if (this->filename!="_NO_FILE")
+ {
+ remove(this->filename.toLatin1().constData()); //#include <stdio.h>
+ //cout<<this->filename<<" successfully deleted\n";
+ }
+
}
//************************************
bool CVWtab::CVWtab_deallocate()
{
- //std::cout<<" deallocate CVWtab*** "<<size<<std::endl;
- if (size <= 0) return false;
- if (tmint)
- {
- delete[] tmint;
- size=-size; //precaution
- }
- if (tmflo)
- {
- delete[] tmflo;
- size=-size; //precaution
- }
- return true;
+ //cout<<" deallocate CVWtab*** "<<size<<endl;
+ if (size <= 0) return false;
+ if (tmint)
+ {
+ delete[] tmint;
+ memoryuse=memoryuse-sizeof(med_int)*size;
+ size=-size; //precaution
+ }
+ if (tmflo)
+ {
+ delete[] tmflo;
+ memoryuse=memoryuse-sizeof(med_float)*size;
+ size=-size; //precaution
+ }
+ if (memoryuse<0) cout<<"***WARNING*** memoryuse <0 "<<memoryuse<<endl;
+ if (memoryuse==0) cout<<"***CVWtab_deallocate*** memoryuse=0 "<<endl;
+ return true;
}
//************************************
bool CVWtab::is_equal(CVWtab *tab2)
{
- //std::cout<<"is_equal tab1 tab2 type="<<this->type<<" size="<<this->size<<" "<<tab2->size<<std::endl;
- //if (this->type==1) std::cout<<"med_int tab1[0]="<<this->tmint[0]<<std::endl;
- //if (this->type==2) std::cout<<"med_float tab1[0]="<<this->tmflo[0]<<std::endl;
- if (this->size!=tab2->size) return false;
- if (this->type!=tab2->type) return false;
- if (this->type==1)
- {
- if (!this->tmint)
- { std::cout<<"***is_equal*** pb pointer NULL with tmint size="<<this->size<<std::endl;
- return false;
- }
- for (long i=0; i < this->size; i++)
- if (this->tmint[i]!=tab2->tmint[i]) return false;
- }
- if (this->type==2)
- {
- if (!this->tmflo)
- { std::cout<<"***is_equal*** pb pointer NULL with tmflo size="<<this->size<<std::endl;
- return false;
- }
- for (long i=0; i < this->size; i++)
- if (this->tmflo[i]!=tab2->tmflo[i]) return false;
- }
- return true;
+ //cout<<"is_equal tab1 tab2 type="<<this->type<<" size="<<this->size<<" "<<tab2->size<<endl;
+ //if (this->type==1) cout<<"med_int tab1[0]="<<this->tmint[0]<<endl;
+ //if (this->type==2) cout<<"med_float tab1[0]="<<this->tmflo[0]<<endl;
+ if (this->size!=tab2->size) return false;
+ if (this->type!=tab2->type) return false;
+ if (this->type==1)
+ {
+ if (!this->tmint)
+ { cout<<"***is_equal*** pb pointer NULL with tmint size="<<this->size<<endl;
+ return false;
+ }
+ for (long i=0; i < this->size; i++)
+ if (this->tmint[i]!=tab2->tmint[i]) return false;
+ }
+ if (this->type==2)
+ {
+ if (!this->tmflo)
+ { cout<<"***is_equal*** pb pointer NULL with tmflo size="<<this->size<<endl;
+ return false;
+ }
+ for (long i=0; i < this->size; i++)
+ if (this->tmflo[i]!=tab2->tmflo[i]) return false;
+ }
+ return true;
}
//************************************
//verbose 1 for print vertices not equals
//verbose 2 for print also vertices equals (debug)
{
- //std::cout<<"is_equal_vertice size="<<tab1->size<<" "<<tab2->size<<std::endl;
- bool ok=false;
- med_float *p1,*p2;
- //vertices indices from 1 not 0!
- long di1=(i1-1)*3, di2=(i2-1)*3;
- if (di1<0 || di1>=tab1->size)
- {
- std::cerr<<"BadIndice tab1 in is_equal_vertices "<<
- di1<<" not in "<<tab1->size<<std::endl;
- return false;
- }
- if (di2<0 || di2>=tab2->size)
- {
- std::cerr<<"BadIndice tab2 in is_equal_vertices "<<
- di2<<" not in "<<tab2->size<<std::endl;
- return false;
- }
- p1=(tab1->tmflo+di1);
- p2=(tab2->tmflo+di2);
- if (p1[0]==p2[0] && p1[1]==p2[1] && p1[2]==p2[2]) ok=true ;
- if (!ok && verbose>0) printf("Vertices differents (%.16g %.16g %.16g) (%.16g %.16g %.16g)\n",
- p1[0],p1[1],p1[2],p2[0],p2[1],p2[2]);
- else
- if (verbose>1) printf("Vertices equals (%.16g %.16g %.16g)\n",
- p1[0],p1[1],p1[2]);
- return ok;
+ //cout<<"is_equal_vertice size="<<tab1->size<<" "<<tab2->size<<endl;
+ bool ok=false;
+ med_float *p1,*p2;
+ //vertices indices from 1 not 0!
+ long di1=(i1-1)*3, di2=(i2-1)*3;
+ if (di1<0 || di1>=tab1->size)
+ {
+ cerr<<"BadIndice tab1 in is_equal_vertices "<<
+ di1<<" not in "<<tab1->size<<endl;
+ return false;
+ }
+ if (di2<0 || di2>=tab2->size)
+ {
+ cerr<<"BadIndice tab2 in is_equal_vertices "<<
+ di2<<" not in "<<tab2->size<<endl;
+ return false;
+ }
+ p1=(tab1->tmflo+di1);
+ p2=(tab2->tmflo+di2);
+ if (p1[0]==p2[0] && p1[1]==p2[1] && p1[2]==p2[2]) ok=true ;
+ if (!ok && verbose>0) printf(
+ "Vertices differents (%.16g %.16g %.16g) (%.16g %.16g %.16g)\n",
+ p1[0],p1[1],p1[2],p2[0],p2[1],p2[2]);
+ else
+ if (verbose>1) printf(
+ "Vertices equals (%.16g %.16g %.16g)\n",
+ p1[0],p1[1],p1[2]);
+ return ok;
}
//************************************
-bool CVW_FindString(const std::string &str, std::fstream &Ff, long &count)
+bool CVW_FindString(const string &str,fstream &Ff, long &count)
//find in file first line with string str in first position of line
//converts count value expected after "='" in line found
{
- std::string line;
- do
- {
- if (getline(Ff,line))
- {
- if (line[0]==str[0]) //faster
+ string line;
+ QString tmp;
+ do
+ {
+ if (getline(Ff,line))
{
- if (line.find(str)==0)
- {
- QString tmp=line.c_str();
- bool ok;
- count=tmp.section('\'',1,1).toLong(&ok);
- return ok;
- }
+ if (line[0]==str[0]) //faster
+ {
+ if (line.find(str)==0)
+ {
+ tmp=line.c_str();
+ bool ok;
+ count=tmp.section('\'',1,1).toLong(&ok);
+ return ok;
+ }
+ }
}
- }
- else
- {
- std::cerr<<"Problem line '"<<str<<"' not found in file\n"<<std::endl;
- return false;
- }
- } while (1);
- return true;
+ else
+ {
+ cerr<<"Problem line '"<<str<<"' not found in file\n"<<endl;
+ return false;
+ }
+ } while (1);
+ return true;
}
//************************************
+bool ghs3dprl_mesh_wrap::ReadFileMSGnew(const QString FileName)
+//read file .glo with no parser xml because big file (volume)
+//no read of <receive> for speed (and so no test)
+{
+ QString tmp;
+ fstream Ff(FileName.toLatin1().constData(),ios_base::in);
+ string line;
+ long i,count,nbneighbour,ineighbour;
+ bool ok;
+
+ if (!Ff.is_open())
+ {
+ cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<endl;
+ return false;
+ }
+
+ //Lit les données :
+ if (!CVW_FindString("<neighbours count=",Ff,nbneighbour)) return false;
+ if (verbose>2) cout<<"NeighboursCount="<<nbneighbour<<endl;
+ for (i=1; i<=nbneighbour; i++)
+ {
+ if (!CVW_FindString("<neighbour indice=",Ff,ineighbour)) return false;
+ if (!CVW_FindString("<vertices count=",Ff,count)) return false;
+ if (count>0){
+ med_int *tmint=new med_int[count];
+ for (int i=0; i<count; i++) Ff>>tmint[i];
+ if (verbose>4) cout<<"Vertices "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<endl;
+
+ CVWtab *montab=new CVWtab(count,tmint);
+ tmp=tmp.sprintf("MS%ld NE%ld VE SE",this->nofile,ineighbour);
+ ok=this->insert_key(tmp,montab);
+ }
+ if (!CVW_FindString("<edges count=",Ff,count)) return false;
+ if (count>0){
+ med_int *tmint=new med_int[count];
+ for (int i=0; i<count; i++) Ff>>tmint[i];
+ if (verbose>4) cout<<"Edges "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<endl;
+
+ CVWtab *montab=new CVWtab(count,tmint);
+ tmp=tmp.sprintf("MS%ld NE%ld ED SE",this->nofile,ineighbour);
+ ok=this->insert_key(tmp,montab);
+ }
+ if (!CVW_FindString("<faces count=",Ff,count)) return false;
+ if (count>0){
+ med_int *tmint=new med_int[count];
+ for (int i=0; i<count; i++) Ff>>tmint[i];
+ if (verbose>4) cout<<"Faces "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<endl;
+
+ CVWtab *montab=new CVWtab(count,tmint);
+ tmp=tmp.sprintf("MS%ld NE%ld FA SE",this->nofile,ineighbour);
+ ok=this->insert_key(tmp,montab);
+ }
+ if (!CVW_FindString("<elements count=",Ff,count)) return false;
+ if (count>0){
+ med_int *tmint=new med_int[count];
+ for (int i=0; i<count; i++) Ff>>tmint[i];
+ if (verbose>4) cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<endl;
+
+ CVWtab *montab=new CVWtab(count,tmint);
+ tmp=tmp.sprintf("MS%ld NE%ld EL SE",this->nofile,ineighbour);
+ ok=this->insert_key(tmp,montab);
+ }
+ }
+
+ //Ferme le fichier :
+ Ff.close();
+ this->nbfiles++;
+ return true;
+}
+
+///************************************
bool ghs3dprl_mesh_wrap::ReadFileGLO(const QString FileName)
//read file .glo with no parser xml because big file (volume)
{
- QString tmp;
- std::fstream Ff(FileName.toLatin1().constData(),std::ios_base::in);
- std::string line;
- long count;
- bool ok;
-
- if (!Ff.is_open())
- {
- std::cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
- return false;
- }
-
- //Lit les données :
- if (!CVW_FindString("<vertices count=",Ff,count)) return false;
- if (this->verbose>2) std::cout<<"VerticesCount="<<count<<std::endl;
- if (count>0)
- {
- med_int *tmint=new med_int[count];
- for (int i=0; i<count; i++) Ff>>tmint[i];
- if (this->verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
-
- CVWtab *montab=new CVWtab(count,tmint);
- tmp=tmp.sprintf("GL%ld VE",this->nofile);
- ok=this->insert_key(tmp,montab);
- }
-
- if (!CVW_FindString("<edges count=",Ff,count)) return false;
- if (this->verbose>2) std::cout<<"EdgesCount="<<count<<std::endl;
- if (count>0)
- {
- med_int *tmint=new med_int[count];
- for (int i=0; i<count; i++) Ff>>tmint[i];
- if (this->verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
-
- CVWtab *montab=new CVWtab(count,tmint);
- tmp=tmp.sprintf("GL%ld ED",this->nofile);
- ok=this->insert_key(tmp,montab);
- }
-
- if (!CVW_FindString("<faces count=",Ff,count)) return false;
- if (this->verbose>2) std::cout<<"FacesCount="<<count<<std::endl;
- if (count>0)
- {
- med_int *tmint=new med_int[count];
- for (int i=0; i<count; i++) Ff>>tmint[i];
- if (this->verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
-
- CVWtab *montab=new CVWtab(count,tmint);
- tmp=tmp.sprintf("GL%ld FA",this->nofile);
- ok=this->insert_key(tmp,montab);
- }
-
- if (!CVW_FindString("<elements count=",Ff,count)) return false;
- if (this->verbose>2) std::cout<<"ElementsCount="<<count<<std::endl;
- if (count>0)
- {
- med_int *tmint=new med_int[count];
- for (int i=0; i<count; i++) Ff>>tmint[i];
- if (this->verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
-
- CVWtab *montab=new CVWtab(count,tmint);
- tmp=tmp.sprintf("GL%ld EL",this->nofile);
- ok=this->insert_key(tmp,montab);
- }
- //Ferme le fichier :
- Ff.close();
- this->nbfiles++;
- return true;
+ QString tmp;
+ fstream Ff(FileName.toLatin1().constData(),ios_base::in);
+ string line;
+ long count;
+ bool ok;
+
+ if (!Ff.is_open())
+ {
+ cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<endl;
+ return false;
+ }
+
+ //Lit les données :
+ if (!CVW_FindString("<vertices count=",Ff,count)) return false;
+ if (verbose>3) cout<<"GloVerticesCount="<<count<<endl;
+ if (count>0)
+ {
+ med_int *tmint=new med_int[count];
+ for (int i=0; i<count; i++) Ff>>tmint[i];
+ if (verbose>4) cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<endl;
+
+ CVWtab *montab=new CVWtab(count,tmint);
+ tmp=tmp.sprintf("GL%ld VE",this->nofile);
+ ok=this->insert_key(tmp,montab);
+ }
+
+ if (!CVW_FindString("<edges count=",Ff,count)) return false;
+ if (verbose>3) cout<<"GloEdgesCount="<<count<<endl;
+ if (count>0)
+ {
+ med_int *tmint=new med_int[count];
+ for (int i=0; i<count; i++) Ff>>tmint[i];
+ if (verbose>4) cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<endl;
+
+ CVWtab *montab=new CVWtab(count,tmint);
+ tmp=tmp.sprintf("GL%ld ED",this->nofile);
+ ok=this->insert_key(tmp,montab);
+ }
+
+ if (!CVW_FindString("<faces count=",Ff,count)) return false;
+ if (verbose>3) cout<<"GloFacesCount="<<count<<endl;
+ if (count>0)
+ {
+ med_int *tmint=new med_int[count];
+ for (int i=0; i<count; i++) Ff>>tmint[i];
+ if (verbose>4) cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<endl;
+
+ CVWtab *montab=new CVWtab(count,tmint);
+ tmp=tmp.sprintf("GL%ld FA",this->nofile);
+ ok=this->insert_key(tmp,montab);
+ }
+
+ if (!CVW_FindString("<elements count=",Ff,count)) return false;
+ if (verbose>3) cout<<"GloElementsCount="<<count<<endl;
+ if (count>0)
+ {
+ med_int *tmint=new med_int[count];
+ for (int i=0; i<count; i++) Ff>>tmint[i];
+ if (verbose>4) cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<endl;
+
+ CVWtab *montab=new CVWtab(count,tmint);
+ tmp=tmp.sprintf("GL%ld EL",this->nofile);
+ ok=this->insert_key(tmp,montab);
+ }
+ //Ferme le fichier :
+ Ff.close();
+ this->nbfiles++;
+ return true;
}
//************************************
bool ghs3dprl_mesh_wrap::ReadFileFACES(const QString FileName)
//read file .faces (wrap)
{
- QString tmp;
- std::fstream Ff(FileName.toLatin1().constData(),std::ios_base::in);
- std::string line;
- long nbelem,ntype;
- bool ok;
-
- if (!Ff.is_open())
- {
- std::cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
- return false;
- }
-
- //Lit les données :
- //Replace le pointeur de fichier au début :f.seekg(0);
- if (getline(Ff,line))
- {
- tmp=line.c_str();
- nbelem=tmp.section(' ',0,0).toLong(&ok);
- }
- else
- {
- std::cerr<<"Problem on first line of file"<<std::endl;
- return false;
- }
- if (this->verbose>2) std::cout<<"NumberOfElements="<<nbelem<<std::endl;
- med_int *tmint=new med_int[nbelem*7];
- for (int i=0; i<nbelem*7; i=i+7)
- {
- Ff>>ntype;
- if (ntype!=3) //only triangles
- {
- std::cerr<<"Problem on ntype != 3"<<std::endl;
+ QString tmp;
+ fstream Ff(FileName.toLatin1().constData(),ios_base::in);
+ string line;
+ long nbelem,ntype;
+ bool ok;
+
+ if (!Ff.is_open())
+ {
+ cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<endl;
return false;
- }
- for (int j=0; j<7; j++) Ff>>tmint[i+j];
- //for (int j=0; j<7; j++) std::cout<<tmint[i+j]<<' '; std::cout<<std::endl;
- }
- if (this->verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[nbelem*7-1]<<std::endl;
-
- CVWtab *montab=new CVWtab(nbelem*7,tmint);
- tmp=tmp.sprintf("FC%ld",this->nofile);
- ok=this->insert_key(tmp,montab);
-
- Ff.close();
- this->nbfiles++;
- return true;
+ }
+
+ //Lit les données :
+ //Replace le pointeur de fichier au début :f.seekg(0);
+ if (getline(Ff,line))
+ {
+ tmp=line.c_str();
+ nbelem=tmp.section(' ',0,0).toLong(&ok);
+ }
+ else
+ {
+ cerr<<"Problem on first line of file"<<endl;
+ return false;
+ }
+ if (verbose>3) cout<<"FacesNumberOfElements="<<nbelem<<endl;
+ med_int *tmint=new med_int[nbelem*7];
+ for (int i=0; i<nbelem*7; i=i+7)
+ {
+ Ff>>ntype;
+ if (ntype!=3) //only triangles
+ {
+ cerr<<"Problem on ntype != 3"<<endl;
+ return false;
+ }
+ for (int j=0; j<7; j++) Ff>>tmint[i+j];
+ //for (int j=0; j<7; j++) cout<<tmint[i+j]<<' '; cout<<endl;
+ }
+ if (verbose>4) cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[nbelem*7-1]<<endl;
+
+ CVWtab *montab=new CVWtab(nbelem*7,tmint);
+ tmp=tmp.sprintf("FC%ld",this->nofile);
+ ok=this->insert_key(tmp,montab);
+
+ Ff.close();
+ this->nbfiles++;
+ return true;
}
//************************************
//for huge files it could be better use ReadFileNOBOITEB (B=binary format)
//(parameter option of ghs3d but NOT tepal)
{
- QString tmp;
- std::fstream Ff(FileName.toLatin1().constData(),std::ios_base::in);
- long ne,np,npfixe,subnumber,reste;
- bool ok;
-
- if (!Ff.is_open())
- {
- std::cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
- return false;
- }
-
- //lit les données :
- Ff>>ne>>np>>npfixe;
- if (this->verbose>2)
- {
- std::cout<<"NumberOfElements="<<ne<<std::endl;
- std::cout<<"NumberOfVertices="<<np<<std::endl;
- std::cout<<"NumberOfSpecifiedPoints="<<npfixe<<std::endl;
- }
- for (int i=1; i<=17-3; i++) Ff>>reste;
- //printf("reste %ld\n",reste);
- med_int *tmint=new med_int[ne*4];
- for (int i=0; i<ne*4; i++) Ff>>tmint[i];
- if (this->verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[ne*4-1]<<std::endl;
-
- CVWtab *montab=new CVWtab(ne*4,tmint);
- tmp=tmp.sprintf("NB%ld EV",this->nofile);
- ok=this->insert_key(tmp,montab);
-
- med_float *tmflo=new med_float[np*3];
- for (int i=0; i<np*3; i++) Ff>>tmflo[i];
- if (this->verbose>4) std::cout<<"Vertices "<<tmflo[0]<<" "<<tmflo[1]<<"... "<<tmflo[np*3-1]<<std::endl;
-
- montab=new CVWtab(np*3,tmflo);
- tmp=tmp.sprintf("NB%ld VC",this->nofile);
- ok=this->insert_key(tmp,montab);
-
- Ff>>subnumber;
- if (this->verbose>2) std::cout<<"NumberOfSubdomains="<<subnumber<<std::endl;
- tmint=new med_int[subnumber*3];
- for (int i=0; i<subnumber*3; i++) Ff>>tmint[i];
- if (this->verbose>4) std::cout<<"Subdomains "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[subnumber*3-1]<<std::endl;
-
- montab=new CVWtab(subnumber*3,tmint);
- tmp=tmp.sprintf("NB%ld SN",this->nofile);
- ok=this->insert_key(tmp,montab);
-
- //beware record 6 lenght 1
- //ferme le fichier :
- Ff.close();
- this->nbfiles++;
- return true;
+ QString tmp;
+ fstream Ff(FileName.toLatin1().constData(),ios_base::in);
+ long ne,np,npfixe,subnumber,reste;
+ bool ok;
+
+ if (!Ff.is_open()){
+ cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<endl;
+ return false;
+ }
+
+ //lit les données :
+ Ff>>ne>>np>>npfixe;
+ if (verbose>3){
+ cout<<"NoboiteNumberOfElements="<<ne<<endl;
+ cout<<"NoboiteNumberOfVertices="<<np<<endl;
+ cout<<"NoboiteNumberOfSpecifiedPoints="<<npfixe<<endl;
+ }
+
+ for (int i=1; i<=17-3; i++) Ff>>reste;
+ //printf("reste %ld\n",reste);
+ med_int *tmint=new med_int[ne*4];
+ for (int i=0; i<ne*4; i++) Ff>>tmint[i];
+ if (verbose>4) cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[ne*4-1]<<endl;
+
+ CVWtab *montab=new CVWtab(ne*4,tmint);
+ tmp=tmp.sprintf("NB%ld EV",this->nofile);
+ ok=this->insert_key(tmp,montab);
+
+ med_float *tmflo=new med_float[np*3];
+ for (int i=0; i<np*3; i++) Ff>>tmflo[i];
+ if (verbose>4) cout<<"Vertices "<<tmflo[0]<<" "<<tmflo[1]<<"... "<<tmflo[np*3-1]<<endl;
+
+ montab=new CVWtab(np*3,tmflo);
+ tmp=tmp.sprintf("NB%ld VC",this->nofile);
+ ok=this->insert_key(tmp,montab);
+
+ Ff>>subnumber;
+ if (verbose>2) cout<<"NumberOfSubdomains="<<subnumber<<endl;
+ tmint=new med_int[subnumber*3];
+ for (int i=0; i<subnumber*3; i++) Ff>>tmint[i];
+ if (verbose>4) cout<<"Subdomains "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[subnumber*3-1]<<endl;
+
+ montab=new CVWtab(subnumber*3,tmint);
+ tmp=tmp.sprintf("NB%ld SN",this->nofile);
+ ok=this->insert_key(tmp,montab);
+
+ //swap on file if too big for memory in one cpu
+ //default 1GOctet/8(for double)/10(for arrays in memory at the same time)
+ if (np*3>this->nbelem_limit_swap)
+ this->SwapOutOfMemory_key_mesh_wrap(QRegExp("NB",Qt::CaseSensitive,QRegExp::RegExp));
+ //beware record 6 lenght 1
+ //ferme le fichier :
+ Ff.close();
+ this->nbfiles++;
+ return true;
}
//************************************
//but NOT parameter option of tepal
//idem ReadFileNOBOITE with read unformatted
{
- bool ok;
-
- std::cerr<<"Problem function ReadFileNOBOITEB\n"
- <<"(no FORTRAN binary format files in tepal)\n\n";
-
- QString tmp;
- //file binary
- FILE *Ff=fopen(FileName.toLatin1().constData(),"rb");
- long ne,np,npfixe,reste,subnumber; /*,cube,npbli,
- nbele,loele,nbelef,loelef,
- nbpoi,lopoi,nbpoif,lopoif,
- nbsub,losub,nbsubf,losubf,reste;*/
-
- //http://www.math.utah.edu/software/c-with-fortran.html
- //record 1 from format FORTRAN begins and ends with lengh of record
- //=> 2*long(68) (68=17*4octets)
- long r1[17+2];
-
- if (!Ff)
- {
- std::cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
- return false;
- }
-
- //read datas :
- fread(&r1,sizeof(long),17+2,Ff);
- for (long i=1; i<18; i++) std::cout<<"R1("<<i<<")="<<r1[i]<<std::endl;
-
- if (r1[0]!=68)
- {
- std::cerr<<"First FORTRAN record of File '"<<FileName.toLatin1().constData()<<"' not length 17*long"<<std::endl;
- return false;
- }
- ne=r1[1];
- np=r1[2];
- npfixe=r1[3];
- if (this->verbose>2)
- {
- std::cout<<"NumberOfElements="<<ne<<std::endl;
- std::cout<<"NumberOfVertices="<<np<<std::endl;
- std::cout<<"NumberOfSpecifiedPoints="<<npfixe<<std::endl;
- }
- ///etc...could be done if necessary not debugged
- fread(&reste,sizeof(long),1,Ff);
- long *tlong=new long[ne*4];
- med_int *tmint=new med_int[ne*4];
- fread(tlong,sizeof(long),ne*4,Ff);
- fread(&reste,sizeof(long),1,Ff);
- for (long i=0; i<ne*4; i++) tmint[i]=tlong[i];
- delete tlong;
- if (this->verbose>4) std::cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[ne*4-1]<<std::endl;
-
- CVWtab *montab=new CVWtab(ne*4,tmint);
- tmp=tmp.sprintf("NB%ld EV",this->nofile);
- ok=this->insert_key(tmp,montab);
-
- fread(&reste,sizeof(long),1,Ff);
- //std::cout<<"info "<<reste<<" "<<np*3<<" "<<sizeof(med_float)<<std::endl;
- float *tfloat=new float[np*3];
- med_float *tmflo=new med_float[np*3];
- fread(tfloat,sizeof(float),np*3,Ff);
- fread(&reste,sizeof(long),1,Ff);
- for (long i=0; i<np*3; i++) tmflo[i]=tfloat[i];
- delete tfloat;
- if (this->verbose>4) printf("Vertices %g %g ... %g \n",tmflo[0],tmflo[1],tmflo[np*3-1]);
-
- montab=new CVWtab(np*3,tmflo);
- tmp=tmp.sprintf("NB%ld VC",this->nofile);
- ok=this->insert_key(tmp,montab);
-
- fread(&reste,sizeof(long),1,Ff);
- fread(&subnumber,sizeof(long),1,Ff);
- fread(&reste,sizeof(long),1,Ff);
- if (this->verbose>2) std::cout<<"NumberOfSubdomains="<<subnumber<<std::endl;
- fread(&reste,sizeof(long),1,Ff);
- tlong=new long[subnumber*3];
- fread(tlong,sizeof(long),subnumber*3,Ff);
- fread(&reste,sizeof(long),1,Ff);
- if (this->verbose>4) printf("Subdomains %ld %ld ... %ld \n",tlong[0],tlong[1],tlong[subnumber*3-1]);
-
- tmint=new med_int[subnumber*3];
- for (long i=0; i<subnumber*3; i++) tmint[i]=tlong[i];
- delete tlong;
- montab=new CVWtab(subnumber*3,tmint);
- tmp=tmp.sprintf("NB%ld SN",this->nofile);
- ok=this->insert_key(tmp,montab);
-
- //beware record 6 lenght 1
- //ferme le fichier :
- fclose(Ff);
- this->nbfiles++;
- return true;
+ bool ok;
+ QString tmp;
+ cerr<<"Problem function ReadFileNOBOITEB\n"
+ <<"(no FORTRAN binary format files in tepal)\n\n";
+ //file binary
+ FILE *Ff=fopen(FileName.toLatin1().constData(),"rb");
+ long ne,np,npfixe,reste,subnumber;
+
+ //http://www.math.utah.edu/software/c-with-fortran.html
+ //record 1 from format FORTRAN begins and ends with lengh of record
+ //=> 2*long(68) (68=17*4octets)
+ long r1[17+2];
+ if (!Ff){
+ cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<endl;
+ return false;
+ }
+ //read datas :
+ fread(&r1,sizeof(long),17+2,Ff);
+ for (long i=1; i<18; i++) cout<<"R1("<<i<<")="<<r1[i]<<endl;
+
+ if (r1[0]!=68){
+ cerr<<"First FORTRAN record of File '"<<FileName.toLatin1().constData()<<"' not length 17*long"<<endl;
+ return false;
+ }
+ ne=r1[1];
+ np=r1[2];
+ npfixe=r1[3];
+ if (verbose>3){
+ cout<<"NoboitebNumberOfElements="<<ne<<endl;
+ cout<<"NoboitebNumberOfVertices="<<np<<endl;
+ cout<<"NoboitebNumberOfSpecifiedPoints="<<npfixe<<endl;
+ }
+ //etc...could be done if necessary not debugged
+ fread(&reste,sizeof(long),1,Ff);
+ long *tlong=new long[ne*4];
+ med_int *tmint=new med_int[ne*4];
+ fread(tlong,sizeof(long),ne*4,Ff);
+ fread(&reste,sizeof(long),1,Ff);
+ for (long i=0; i<ne*4; i++) tmint[i]=tlong[i];
+ delete tlong;
+ if (verbose>4) cout<<"Elements "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[ne*4-1]<<endl;
+
+ CVWtab *montab=new CVWtab(ne*4,tmint);
+ tmp=tmp.sprintf("NB%ld EV",this->nofile);
+ ok=this->insert_key(tmp,montab);
+
+ fread(&reste,sizeof(long),1,Ff);
+ //cout<<"info "<<reste<<" "<<np*3<<" "<<sizeof(med_float)<<endl;
+ float *tfloat=new float[np*3];
+ med_float *tmflo=new med_float[np*3];
+ fread(tfloat,sizeof(float),np*3,Ff);
+ fread(&reste,sizeof(long),1,Ff);
+ for (long i=0; i<np*3; i++) tmflo[i]=tfloat[i];
+ delete tfloat;
+ if (verbose>4) printf("Vertices %g %g ... %g \n",tmflo[0],tmflo[1],tmflo[np*3-1]);
+
+ montab=new CVWtab(np*3,tmflo);
+ tmp=tmp.sprintf("NB%ld VC",this->nofile);
+ ok=this->insert_key(tmp,montab);
+
+ fread(&reste,sizeof(long),1,Ff);
+ fread(&subnumber,sizeof(long),1,Ff);
+ fread(&reste,sizeof(long),1,Ff);
+ if (verbose>2) cout<<"NumberOfSubdomains="<<subnumber<<endl;
+ fread(&reste,sizeof(long),1,Ff);
+ tlong=new long[subnumber*3];
+ fread(tlong,sizeof(long),subnumber*3,Ff);
+ fread(&reste,sizeof(long),1,Ff);
+ if (verbose>4) printf("Subdomains %ld %ld ... %ld \n",tlong[0],tlong[1],tlong[subnumber*3-1]);
+
+ tmint=new med_int[subnumber*3];
+ for (long i=0; i<subnumber*3; i++) tmint[i]=tlong[i];
+ delete tlong;
+ montab=new CVWtab(subnumber*3,tmint);
+ tmp=tmp.sprintf("NB%ld SN",this->nofile);
+ ok=this->insert_key(tmp,montab);
+
+ //swap on file if too big for memory in one cpu
+ //default 1GOctet/8(for double)/10(for arrays in memory at the same time)
+ if (np*3>this->nbelem_limit_swap)
+ this->SwapOutOfMemory_key_mesh_wrap(QRegExp("NB",Qt::CaseSensitive,QRegExp::RegExp));
+
+ //beware record 6 lenght 1
+ //ferme le fichier :
+ fclose(Ff);
+ this->nbfiles++;
+ return true;
}
//************************************
bool ghs3dprl_mesh_wrap::ReadFilePOINTS(const QString FileName)
//read file .points (wrap)
{
- QString tmp;
- long nb;
- long maxlen=128;
- bool ok=true;
-
- //Lit les données :
- QFile Ff(FileName);
- //NOT Raw because Raw=non-buffered file access
- ok=Ff.open(QIODevice::ReadOnly|QIODevice::Text);
- if (!ok)
- {
- std::cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
- return false;
- }
-
- tmp=Ff.readLine(maxlen);
- tmp=tmp.simplified();
- nb=tmp.toLong(&ok);
- if (!ok)
- {
- std::cerr<<"Problem conversion File '"<<FileName.toLatin1().constData()<<"\n"<<std::endl;
- return false;
- }
- if (this->verbose>2) std::cout<<"NumberOfVertices="<<nb<<std::endl;
- med_float *tmflo=new med_float[3*nb]; //coordinates
- med_int *tmint=new med_int[nb]; //nrs (attribute of point)
- long il3=0;
- for ( long il=0; il<nb; il++ )
- {
- tmp=Ff.readLine(maxlen);
- tmp=tmp.simplified();
- for ( int j=0; j<3; j++ )
- {
- tmflo[il3]=tmp.section(' ',j,j).toDouble(&ok);
- //std::cout<<"cv '"<<tmflo[il3]<<"' "<<il3<<std::endl;
- il3++;
- if (!ok)
- {
- std::cerr<<"Problem conversion File '"<<FileName.toLatin1().constData()<<"\n"<<std::endl;
- return false;
- }
- }
- //nrs is vertex attribute
- tmint[il]=tmp.section(' ',3,3).toLong(&ok);
- if (!ok)
- {
- std::cerr<<"Problem conversion File '"<<FileName.toLatin1().constData()<<"\n"<<std::endl;
- return false;
- }
- }
- //beware no examples with each specified points (if any) here
+ QString tmp;
+ long nb;
+ long maxlen=128;
+ bool ok=true;
- {CVWtab *montab=new CVWtab(nb,tmint); //init montab->tmint nrs
- tmp=tmp.sprintf("PO%ld NRS",this->nofile);
- ok=this->insert_key(tmp,montab);}
+ //Lit les données :
+ QFile Ff(FileName);
+ //NOT Raw because Raw=non-buffered file access
+ //qt3 ok=Ff.open(IO_ReadOnly|IO_Translate);
+ ok=Ff.open(QIODevice::ReadOnly|QIODevice::Text);
+ if (!ok){
+ cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<endl;
+ return false;
+ }
+ tmp=Ff.readLine(maxlen);
+ tmp=tmp.simplified();
+ nb=tmp.toLong(&ok);
+ if (!ok){
+ cerr<<"Problem conversion File '"<<FileName.toLatin1().constData()<<"\n"<<endl;
+ return false;
+ }
+ if (verbose>2) cout<<"NumberOfVertices="<<nb<<endl;
+ med_float *tmflo=new med_float[3*nb]; //coordinates
+ med_int *tmint=new med_int[nb]; //nrs (attribute of point)
+ long il3=0;
+ for ( long il=0; il<nb; il++ ){
+ tmp=Ff.readLine(maxlen);
+ tmp=tmp.simplified();
+ for ( int j=0; j<3; j++ ){
+ tmflo[il3]=tmp.section(' ',j,j).toDouble(&ok);
+ //cout<<"cv '"<<tmflo[il3]<<"' "<<il3<<endl;
+ il3++;
+ if (!ok){
+ cerr<<"Problem conversion File '"<<FileName.toLatin1().constData()<<"\n"<<endl;
+ return false;
+ }
+ }
+ //nrs is vertex attribute
+ tmint[il]=tmp.section(' ',3,3).toLong(&ok);
+ if (!ok){
+ cerr<<"Problem conversion File '"<<FileName.toLatin1().constData()<<"\n"<<endl;
+ return false;
+ }
+ }
+ //beware no examples with each specified points (if any) here
+ CVWtab *montab=new CVWtab(nb,tmint); //init montab->tmint nrs
+ tmp=tmp.sprintf("PO%ld NRS",this->nofile);
+ ok=this->insert_key(tmp,montab);
- {CVWtab *montab=new CVWtab(nb,tmflo); //init montab->tmflo xyz
- tmp=tmp.sprintf("PO%ld XYZ",this->nofile);
- ok=this->insert_key(tmp,montab);}
+ montab=new CVWtab(nb,tmflo); //init montab->tmflo xyz
+ tmp=tmp.sprintf("PO%ld XYZ",this->nofile);
+ ok=this->insert_key(tmp,montab);
- //Ferme le fichier :
- Ff.close();
- this->nbfiles++;
- return true;
+ //Ferme le fichier :
+ Ff.close();
+ this->nbfiles++;
+ return true;
}
//************************************
bool ghs3dprl_mesh_wrap::list_keys_mesh_wrap()
{
- QHashIterator<QString,CVWtab*> it( this->mestab);
- while ( it.hasNext() )
- {
- it.next();
- QString nom = it.key().leftJustified(20,' ');
- std::cout<<nom.toLatin1().constData()<<"-> size="<<it.value()->size<<std::endl;
- }
- return true;
+ QHashIterator<QString,CVWtab*> it( this->mestab);
+ while ( it.hasNext() ) {
+ it.next();
+ QString nom = it.key().leftJustified(32,' ');
+ cout<<nom.toLatin1().constData()<<"-> size="<<it.value()->size<<endl;
+ }
+ return true;
}
//************************************
long ghs3dprl_mesh_wrap::remove_all_keys_mesh_wrap()
{
- long nb=this->remove_key_mesh_wrap(QRegExp("."));
- return nb;
+ long nb=this->remove_key_mesh_wrap(QRegExp(".",Qt::CaseSensitive,QRegExp::RegExp));
+ return nb;
}
//************************************
long ghs3dprl_mesh_wrap::remove_key_mesh_wrap(const QRegExp &rxp)
{
- long nbremove=0;
- QMutableHashIterator<QString,CVWtab*> it(this->mestab);
- while ( it.hasNext() )
- {
- it.next();
- if (it.key().contains(rxp)) {
- nbremove++;
- if (this->verbose>4) std::cout<<"remove key "<<it.key().toLatin1().constData()<<std::endl;
- delete it.value();
- it.remove();
- }
- }
- return nbremove;
+ long nbremove=0;
+ QMutableHashIterator<QString,CVWtab*> it(this->mestab);
+ while ( it.hasNext() ){
+ it.next();
+ if (it.key().contains(rxp)) {
+ nbremove++;
+ if (this->verbose>6) cout<<"remove key "<<it.key().toLatin1().constData()<<endl;
+ delete it.value();
+ it.remove();
+ }
+ }
+ return nbremove;
+}
+
+//************************************
+long ghs3dprl_mesh_wrap::nb_key_mesh_wrap(const QRegExp &rxp)
+{
+ long nbremove=0;
+ //cout<<"nb_key_mesh_wrap on "<<endl;
+ QMutableHashIterator<QString,CVWtab*> it(this->mestab);
+ while ( it.hasNext() ){
+ it.next();
+ if (it.key().contains(rxp)) nbremove++;
+ }
+ //cout<<"nb_key_mesh_wrap found "<<nbremove<<endl;
+ return nbremove;
}
//************************************
bool SwapOnFile(const QString &key,const QString &path,CVWtab *tab,int verbose)
//
{
- //return true;
- if (tab->filename=="_NO_FILE")
- {
- tab->filename=path+key+".tmp";
- tab->filename.replace(" ","_"); //replace " " by "_"
-
- //swap disque binaire
- //montab->tmint=new long[10]; //for test
- //for (int i=0; i<10; i++) montab->tmint[i]=i*2;
- FILE *fichier=fopen(tab->filename.toLatin1().constData(),"wb");
- long taille;
- taille=tab->size;
- fwrite(&taille,sizeof(taille),1,fichier);
- if (tab->tmint)
- {
- if (verbose>3)
- std::cout<<"SwapOnFile in binary file "<<tab->filename.toLatin1().constData()<<
- " number of elements "<<taille<<
- " size_element med_int "<<sizeof(med_int)<<
- " total_size_binary " <<taille*sizeof(med_int)<<std::endl;
- fwrite(tab->tmint,sizeof(med_int),taille,fichier);
- //fread(&gagnants,sizeof(gagnants),1,fichier);
- }
- if (tab->tmflo)
- {
- if (verbose>3)
- std::cout<<"SwapOnFile in binary file "<<tab->filename.toLatin1().constData()<<
- " number of elements "<<taille<<
- " size_element med_float "<<sizeof(med_float)<<
- " total_size_binary " <<taille*sizeof(med_float)<<std::endl;
- fwrite(tab->tmflo,sizeof(med_float),taille,fichier);
- }
- fclose(fichier);
- }
- else
- {
- if (verbose>3) std::cout<<"SwapOnFile in binary file done yet "<<tab->filename.toLatin1().constData()<<std::endl;
- }
- //deallocate because swap disk binary mode
- tab->CVWtab_deallocate(); //free memory
- return true;
+ //return true;
+ if (tab->filename=="_NO_FILE"){
+ tab->filename=path+key+".tmp";
+ tab->filename.replace(" ","_"); //replace " " by "_"
+
+ //swap disque binaire
+ //montab->tmint=new long[10]; //for test
+ //for (int i=0; i<10; i++) montab->tmint[i]=i*2;
+ FILE *fichier=fopen(tab->filename.toLatin1().constData(),"wb");
+ long taille;
+ taille=tab->size;
+ fwrite(&taille,sizeof(taille),1,fichier);
+ if (tab->tmint){
+ if (verbose>3)
+ cout<<"SwapOnFile_binary "<<tab->filename.toLatin1().constData()<<
+ " NbElements "<<taille<<
+ " SizeElement_med_int "<<sizeof(med_int)<<
+ " TotalSizeBinary " <<taille*sizeof(med_int)<<endl;
+ fwrite(tab->tmint,sizeof(med_int),taille,fichier);
+ //fread(&gagnants,sizeof(gagnants),1,fichier);
+ }
+ if (tab->tmflo){
+ if (verbose>3)
+ cout<<"SwapOnFile_binary "<<tab->filename.toLatin1().constData()<<
+ " NbElements "<<taille<<
+ " SizeElement_med_float "<<sizeof(med_float)<<
+ " TotalSizeBinary " <<taille*sizeof(med_float)<<endl;
+ fwrite(tab->tmflo,sizeof(med_float),taille,fichier);
+ }
+ fclose(fichier);
+ }
+ else{
+ if (verbose>3) cout<<"SwapOnFile in binary file done yet "<<
+ tab->filename.toLatin1().constData()<<endl;
+ }
+ //deallocate because swap disk binary mode
+ tab->CVWtab_deallocate(); //free memory
+ return true;
}
//************************************
-long ghs3dprl_mesh_wrap::SwapOutOfMemory_key_mesh_wrap(const QRegExp &rxp)
-//
+long ghs3dprl_mesh_wrap::SwapOutOfMemory_key_mesh_wrap(const QRegExp &rxp,
+ long ifgreaterthan)
+//swap on file if not yet and if size greater than ifgreaterthan
{
- long nb=0;
- bool ok;
- QHashIterator<QString,CVWtab*> it(this->mestab);
- while ( it.hasNext() )
- {
- it.next();
- if (it.key().contains(rxp))
- {
- nb++;
- if (it.value()->size>0)
- ok=SwapOnFile(it.key(),this->path,it.value(),this->verbose); //free memory
- //if (this->verbose) std::cout<<"SwapOutOfMemory key "<<it.currentKey()<<std::endl;
- }
- }
- return nb;
+ long nb=0;
+ bool ok;
+ QHashIterator<QString,CVWtab*> it(this->mestab);
+ while ( it.hasNext() ) {
+ it.next();
+ if (it.key().contains(rxp)) {
+ nb++;
+ if ((it.value()->size>0)&&(it.value()->size>ifgreaterthan)){
+ if (verbose>3)
+ cout<<"SwapOutOfMemory_key_mesh_wrap on demand "<<
+ it.key().toLatin1().constData()<<
+ " size "<<it.value()->size<<">"<<ifgreaterthan<<endl;
+ //free memory
+ ok=SwapOnFile(it.key(),this->path,it.value(),this->verbose);
+ }
+ }
+ }
+ return nb;
}
//************************************
bool ghs3dprl_mesh_wrap::list_onekey_mesh_wrap(const QString &key)
{
- CVWtab *montab=this->mestab[key];
- if (montab)
- {
- //std::cout<<"key "<<key<<"trouvee -> size="<<montab->size<<std::endl;
- if (montab->type==1)
- for ( long i=0; i<montab->size; i++ )
- std::cout<<montab->tmint[i]<<" ";
- if (montab->type==2)
- for ( long i=0; i<montab->size; i++ )
- std::cout<<montab->tmflo[i]<<" ";
- std::cout<<std::endl;
- }
- else
- std::cout<<"key "<<key.toLatin1().constData()<<" not found"<<std::endl;
- return true;
+ CVWtab *montab=this->mestab[key];
+ if (montab){
+ //cout<<"key "<<key<<"trouvee -> size="<<montab->size<<endl;
+ if (montab->type==1)
+ for ( long i=0; i<montab->size; i++ )
+ cout<<montab->tmint[i]<<" ";
+ if (montab->type==2)
+ for ( long i=0; i<montab->size; i++ )
+ cout<<montab->tmflo[i]<<" ";
+ cout<<endl;
+ }
+ else
+ cout<<"key "<<key.toLatin1().constData()<<" not found"<<endl;
+ return true;
}
//************************************
//si tableaux contenus on dimension superieure
//alors swap disque dans getenv(tmp) fichier temporaire binaire
{
- bool ok;
- if (this->verbose>4)
- std::cout<<"InsertKey "<<key.toLatin1().constData()<<" size="<<tab->size<<std::endl;
- tab->filename="_NO_FILE";
- if (this->nbelem_limit_swap < tab->size)
- ok=SwapOnFile(key,this->path,tab,this->verbose);
- this->mestab.insert(key,tab);
- return true;
+ bool ok;
+ if (verbose>4)
+ cout<<"insert key "<<key.toLatin1().constData()<<
+ " size="<<tab->size<<endl;
+ tab->filename="_NO_FILE";
+ if (this->nbelem_limit_swap<tab->size) {
+ if (verbose>3) cout<<"insert key automatic SwapOnFile "<<
+ key.toLatin1().constData()<<endl;
+ ok=SwapOnFile(key,this->path,tab,this->verbose);
+ }
+ this->mestab.insert(key,tab);
+ return true;
}
//************************************
CVWtab* ghs3dprl_mesh_wrap::restore_key(const QString &key)
//alors swap disque dans getenv(tmp) fichier temporaire
//alors lecture du fichier (et reallocate memory)
{
- CVWtab *tab=NULL;
- tab=this->mestab[key];
- /*if (tab) std::cout<<" -> size in proc "<<tab->size<<std::endl;
- else std::cout<<" -> tab NULL\n";*/
- if (!tab) //it is NOT a problem
- {
- if (this->verbose>6) std::cout<<"restore_key key not found "<<key.toLatin1().constData()<<std::endl;
- return NULL;
- }
- if (tab->size > 0)
- {
- if (this->verbose>5) std::cout<<"restore_key direct from memory "<<key.toLatin1().constData()<<" size="<<tab->size<<std::endl;
- return tab;
- }
- //restore from binary file
- if ((tab->type<1)||(tab->type>2))
- {
- std::cerr<<"Problem restore_key from binary file "<<tab->filename.toLatin1().constData()<<
- " type unexpexted "<<tab->type<<std::endl;
- return NULL;
- }
- //std::cout<<"restore_key from binary file "<<tab->filename<<std::endl;
-
- //swap disque binaire
- FILE *fichier=fopen(tab->filename.toLatin1().constData(),"rb");
- long taille;
- fread(&taille,sizeof(long),1,fichier);
- if (taille!=-tab->size)
- {
- std::cerr<<"Problem restore_key from binary file "<<tab->filename.toLatin1().constData()<<
- " size unexpexted "<<taille<<" expected "<<-tab->size<<std::endl;
- fclose(fichier);
- return NULL;
- }
- if (tab->type==1)
- {
- if (this->verbose>5)
- std::cout<<"restore_key from binary file "<<tab->filename.toLatin1().constData()<<
- " number of elements "<<taille<<
- " size_element med_float "<<sizeof(med_float)<<
- " total_size_binary " <<taille*sizeof(med_float)<<std::endl;
-
- //allocate because swap disque binaire
- tab->tmint=new med_int[taille]; //allocate memory
- fread(tab->tmint,sizeof(med_int),taille,fichier);
- }
- if (tab->type==2)
- {
- if (this->verbose>5)
- std::cout<<"restore_key from binary file "<<tab->filename.toLatin1().constData()<<
- " number of elements "<<taille<<
- " size_element med_float "<<sizeof(med_float)<<
- " total_size_binary " <<taille*sizeof(med_float)<<std::endl;
- //allocate because swap disque binaire
- tab->tmflo=new med_float[taille]; //allocate memory
- for (int i=0; i<taille ; i++) tab->tmflo[i]=-1e0;
- fread(tab->tmflo,sizeof(med_float),taille,fichier);
- /*for (int i=0; i<taille ; i++) std::cout<<tab->tmflo[i]<<"/";
- std::cout<<std::endl;*/
- }
- fclose(fichier);
- tab->size=-tab->size;
- return tab;
+ CVWtab *tab=NULL;
+ tab=this->mestab[key];
+ /*if (tab) cout<<" -> size in proc "<<tab->size<<endl;
+ else cout<<" -> tab NULL\n";*/
+ if (!tab) //it is NOT a problem
+ {
+ if (verbose>6) cout<<"restore key not found "<<key.toLatin1().constData()<<endl;
+ return NULL;
+ }
+ if (tab->size > 0){
+ if (verbose>5) cout<<"restore key direct from memory "<<key.toLatin1().constData()<<" size="<<tab->size<<endl;
+ return tab;
+ }
+ //restore from binary file
+ if ((tab->type<1)||(tab->type>2)){
+ cerr<<"Problem restore key from binary file "<<tab->filename.toLatin1().constData()<<
+ " type unexpexted "<<tab->type<<endl;
+ return NULL;
+ }
+ //cout<<"restore_key from binary file "<<tab->filename<<endl;
+
+ //swap disque binaire
+ FILE *fichier=fopen(tab->filename.toLatin1().constData(),"rb");
+ long taille;
+ fread(&taille,sizeof(long),1,fichier);
+ if (taille!=-tab->size){
+ cerr<<"Problem restore_key from binary file "<<tab->filename.toLatin1().constData()<<
+ " size unexpexted "<<taille<<" expected "<<-tab->size<<endl;
+ fclose(fichier);
+ return NULL;
+ }
+ if (tab->type==1){
+ if (verbose>5)
+ cout<<"restore key from binary file "<<tab->filename.toLatin1().constData()<<
+ " number of elements "<<taille<<
+ " size_element med_float "<<sizeof(med_float)<<
+ " total_size_binary " <<taille*sizeof(med_float)<<endl;
+
+ //allocate because swap disque binaire
+ tab->tmint=new med_int[taille]; //allocate memory
+ fread(tab->tmint,sizeof(med_int),taille,fichier);
+ }
+ if (tab->type==2){
+ if (verbose>5)
+ cout<<"restore key from binary file "<<tab->filename.toLatin1().constData()<<
+ " number of elements "<<taille<<
+ " size_element med_float "<<sizeof(med_float)<<
+ " total_size_binary " <<taille*sizeof(med_float)<<endl;
+ //allocate because swap disque binaire
+ tab->tmflo=new med_float[taille]; //allocate memory
+ for (int i=0; i<taille ; i++) tab->tmflo[i]=-1e0;
+ fread(tab->tmflo,sizeof(med_float),taille,fichier);
+ /*for (int i=0; i<taille ; i++) cout<<tab->tmflo[i]<<"/";
+ cout<<endl;*/
+ }
+ fclose(fichier);
+ tab->size=-tab->size;
+ return tab;
}
//************************************
bool ghs3dprl_mesh_wrap::test_msg_wrap()
//tests sur resultats fichiers msg
{
- QString key1,key2,typ="FA VE ED EL"; //pour faces vertice edges elements
- CVWtab *tab1,*tab2;
- bool ok=true;
- //test send=receive
- //numerotations locales sont identiques
- long nb=typ.count(' ',Qt::CaseSensitive) + 1; //nb chiffres detectes
- for (long i=0; i < nb; i++)
- {
- for (long ifile=1; ifile <= this->nbfiles; ifile++)
- {
- for (long ineig=1; ineig <= this->nbfiles; ineig++)
+ QString key1,key2,typ="FA VE ED EL"; //pour faces vertice edges elements
+ CVWtab *tab1,*tab2;
+ bool ok=true;
+ //test send=receive
+ //numerotations locales sont identiques
+ long nb=typ.count(' ',Qt::CaseSensitive) + 1; //nb chiffres detectes
+ for (long i=0; i < nb; i++)
+ for (long ifile=1; ifile <= this->nbfiles; ifile++)
+ for (long ineig=1; ineig <= this->nbfiles; ineig++)
+ {
+ if (ifile==ineig) continue; //impossible
+ key1=key1.sprintf("MS%ld NE%ld ",ifile,ineig)+typ.section(' ',i,i)+" SE";
+ key2=key2.sprintf("MS%ld NE%ld ",ifile,ineig)+typ.section(' ',i,i)+" RE";
+ //cout<<"key "<<key1<<" et key "<<key2<<endl;
+ tab1=this->restore_key(key1);
+ //tab1=this->mestab[key1];
+ tab2=this->restore_key(key2);
+ //tab2=this->mestab[key2];
+ //cout<<"sortie key "<<key1<<" et key "<<key2<<endl;
+ if (!tab1 && !tab2) continue; //case not neighbours
+ if (!tab1)
+ { cout<<"key "<<key1.toLatin1().constData()<<" inexistante avec key "<<key2.toLatin1().constData()<<" existante"<<endl;
+ ok=false;
+ }
+ else
{
- if (ifile==ineig) continue; //impossible
- key1=key1.sprintf("MS%ld NE%ld ",ifile,ineig)+typ.section(' ',i,i)+" SE";
- key2=key2.sprintf("MS%ld NE%ld ",ifile,ineig)+typ.section(' ',i,i)+" RE";
- //std::cout<<"key "<<key1<<" et key "<<key2<<std::endl;
- tab1=this->restore_key(key1);
- //tab1=this->mestab[key1];
- tab2=this->restore_key(key2);
- //tab2=this->mestab[key2];
- //std::cout<<"sortie key "<<key1<<" et key "<<key2<<std::endl;
- if (!tab1 && !tab2) continue; //case not neighbours
- if (!tab1)
- {
- std::cout<<"key "<<key1.toLatin1().constData()<<" inexistante avec key "<<key2.toLatin1().constData()<<" existante"<<std::endl;
- ok=false;
- }
- else
- {
- if (!tab2)
- {
- std::cout<<"key "<<key2.toLatin1().constData()<<" inexistante avec key "<<key1.toLatin1().constData()<<" existante"<<std::endl;
- ok=false;
- }
- else if (!tab1->is_equal(tab2))
- {
- std::cout<<"key "<<key1.toLatin1().constData()<<" et key "<<key2.toLatin1().constData()<<" de contenu differents"<<std::endl;
- ok=false;
- }
- }
- /*else
- printf("key '%s' et key '%s' identiques \n",
- (const char *)key2,(const char *)key1);*/
+ if (!tab2)
+ { cout<<"key "<<key2.toLatin1().constData()<<" inexistante avec key "<<key1.toLatin1().constData()<<" existante"<<endl;
+ ok=false;
+ }
+ else
+ if (!tab1->is_equal(tab2))
+ { cout<<"key "<<key1.toLatin1().constData()<<" et key "<<key2.toLatin1().constData()<<" de contenu differents"<<endl;
+ ok=false;
+ }
}
- }
- }
-
- //test size neighbourg=ifile
- //numerotations locales sont differentes mais de tailles identiques
- //pas besoin de verifier " RE " car deja fait au dessus
- for (long i=0; i < nb; i++)
- {
- for (long ifile=1; ifile <= this->nbfiles; ifile++)
- {
- for (long ineig=ifile+1; ineig <= this->nbfiles; ineig++)
+ /*else
+ printf("key '%s' et key '%s' identiques \n",
+ (const char *)key2,(const char *)key1);*/
+ }
+
+ //test size neighbourg=ifile
+ //numerotations locales sont differentes mais de tailles identiques
+ //pas besoin de verifier " RE " car deja fait au dessus
+ for (long i=0; i < nb; i++)
+ for (long ifile=1; ifile <= this->nbfiles; ifile++)
+ for (long ineig=ifile+1; ineig <= this->nbfiles; ineig++)
+ {
+ if (ifile==ineig) continue; //cas impossible
+ key1=key1.sprintf("MS%ld NE%ld ",ifile,ineig)+typ.section(' ',i,i)+" SE";
+ tab1=this->restore_key(key1); //tab1=this->mestab[key1];
+ key2=key2.sprintf("MS%ld NE%ld ",ineig,ifile)+typ.section(' ',i,i)+" SE";
+ tab2=this->restore_key(key2); //tab2=this->mestab[key2];
+ if (!tab1 && !tab2) continue; //case not neighbours
+ if (!tab1)
+ { cout<<"key "<<key1.toLatin1().constData()<<" inexistante avec key "<<key2.toLatin1().constData()<<" existante"<<endl;
+ ok=false;
+ }
+ else
{
- if (ifile==ineig) continue; //cas impossible
- key1=key1.sprintf("MS%ld NE%ld ",ifile,ineig)+typ.section(' ',i,i)+" SE";
- tab1=this->restore_key(key1); //tab1=this->mestab[key1];
- key2=key2.sprintf("MS%ld NE%ld ",ineig,ifile)+typ.section(' ',i,i)+" SE";
- tab2=this->restore_key(key2); //tab2=this->mestab[key2];
- if (!tab1 && !tab2) continue; //case not neighbours
- if (!tab1)
- {
- std::cout<<"key "<<key1.toLatin1().constData()<<" inexistante avec key "<<key2.toLatin1().constData()<<" existante"<<std::endl;
- ok=false;
- }
- else
- {
- if (!tab2)
- {
- std::cout<<"key "<<key2.toLatin1().constData()<<" inexistante avec key "<<key1.toLatin1().constData()<<" existante"<<std::endl;
- ok=false;
- }
- else if ((tab1->type!=tab2->type)||(tab1->size!=tab2->size))
- {
- std::cout<<"key "<<key1.toLatin1().constData()<<" et key "<<key2.toLatin1().constData()<<" de type ou tailles differents"<<std::endl;
- ok=false;
- }
- }
+ if (!tab2)
+ { cout<<"key "<<key2.toLatin1().constData()<<" inexistante avec key "<<key1.toLatin1().constData()<<" existante"<<endl;
+ ok=false;
+ }
+ else
+ if ((tab1->type!=tab2->type)||(tab1->size!=tab2->size))
+ { cout<<"key "<<key1.toLatin1().constData()<<" et key "<<key2.toLatin1().constData()<<" de type ou tailles differents"<<endl;
+ ok=false;
+ }
}
- }
- }
- return ok;
+ }
+ return ok;
}
//************************************
bool ghs3dprl_mesh_wrap::test_vertices_wrap()
//tests sur vertices
{
- QString key1,key2,key11,key22,key11old,key22old;
- CVWtab *tab1,*tab2,*tab11,*tab22;
- bool ok=true;
- key11old="_NO_KEY";key22old="_NO_KEY";
- //test size neighbourg=ifile
- //numerotations locales sont differentes mais de tailles identiques
- //pas besoin de verifier " RE " car deja fait au dessus
- //for (int ifile=1; ifile <= this->nbfiles; ifile++)
- //for (int ineig=ifile+1; ineig <= this->nbfiles; ineig++)
- for (int ifile=this->nbfiles; ifile >= 1; ifile--)
- {
- for (int ineig=this->nbfiles; ineig >= ifile+1; ineig--)
- {
+ QString key1,key2,key11,key22,key11old,key22old;
+ CVWtab *tab1,*tab2,*tab11,*tab22;
+ bool ok=true;
+ key11old="_NO_KEY";key22old="_NO_KEY";
+ //test size neighbourg=ifile
+ //numerotations locales sont differentes mais de tailles identiques
+ //pas besoin de verifier " RE " car deja fait au dessus
+ //for (int ifile=1; ifile <= this->nbfiles; ifile++)
+ //for (int ineig=ifile+1; ineig <= this->nbfiles; ineig++)
+ bool swap=false;
+ for (int ifile=this->nbfiles; ifile >= 1; ifile--)
+ for (int ineig=this->nbfiles; ineig >= ifile+1; ineig--)
+ {
if (ifile==ineig) continue; //cas impossible
key1=key1.sprintf("MS%d NE%d VE SE",ifile,ineig);
key11=key11.sprintf("NB%d VC",ifile);
if (!tab1 && !tab2) continue; //cas non voisins
if (!tab1)
{
- std::cerr<<"TestEqualityCoordinates key "<<key1.toLatin1().constData()<<" NOT existing but key "<<key2.toLatin1().constData()<<" existing"<<std::endl;
- ok=false; continue;
+ cerr<<"TestEqualityCoordinates key "<<key1.toLatin1().constData()<<
+ " NOT existing but key "<<key2.toLatin1().constData()<<" existing"<<endl;
+ ok=false; continue;
}
if (!tab2)
{
- std::cerr<<"TestEqualityCoordinates key "<<key2.toLatin1().constData()<<" NOT existing but key "<<key1.toLatin1().constData()<<" existing"<<std::endl;
- ok=false; continue;
+ cerr<<"TestEqualityCoordinates key "<<key2.toLatin1().constData()<<
+ " NOT existing but key "<<key1.toLatin1().constData()<<" existing"<<endl;
+ ok=false; continue;
}
if (tab1->size!=tab2->size)
{
- std::cerr<<"TestEqualityCoordinates key "<<key1.toLatin1().constData()<<" and key "<<key2.toLatin1().constData()<<" NOT same size"<<std::endl;
- ok=false; continue;
+ cerr<<"TestEqualityCoordinates key "<<key1.toLatin1().constData()<<
+ " and key "<<key2.toLatin1().constData()<<" NOT same size"<<endl;
+ ok=false; continue;
}
if (ok)
{
- //Swap out of memory if no use
- if ((key11old!=key11)&&(key11old!=key22))
- this->SwapOutOfMemory_key_mesh_wrap(QRegExp(key11old));
- if ((key22old!=key11)&&(key22old!=key22))
- this->SwapOutOfMemory_key_mesh_wrap(QRegExp(key22old));
-
- tab11=this->restore_key(key11); //tab11=this->mestab[key11];
- tab22=this->restore_key(key22); //tab22=this->mestab[key22];
- long i1,i2;
- bool ok1=true;
- //test on equality of xyz_coordinates of commons vertices
- for (long j=0; j < tab1->size-1; j++)
- {
- i1=tab1->tmint[j];
- i2=tab2->tmint[j];
- //1 for print vertices not equals
- if (!CVW_is_equal_vertices(tab11,i1,tab22,i2,1))
- {
- std::cerr<<j<<" Vertice "<<i1<<" != Vertice "<<i2<<"\n"<<std::endl;
- ok=false; ok1=false;
- }
- }
- if ((this->verbose>2)&&(ok1))
- std::cout<<"TestEqualityCoordinates "<<tab1->size<<
- " Vertices "<<key1.toLatin1().constData()<<" and "<<key2.toLatin1().constData()<<" ok"<<std::endl;
- if (!ok1)
- std::cerr<<"TestEqualityCoordinates "<<tab1->size<<
- " Vertices "<<key1.toLatin1().constData()<<" and "<<key2.toLatin1().constData()<<" NO_OK"<<std::endl;
- key11old=key11; key22old=key22;
+ if (swap) {
+ //Swap out of memory if no use
+ if ((key11old!=key11)&&(key11old!=key22))
+ this->SwapOutOfMemory_key_mesh_wrap(QRegExp(key11old,Qt::CaseSensitive,QRegExp::RegExp));
+ if ((key22old!=key11)&&(key22old!=key22))
+ this->SwapOutOfMemory_key_mesh_wrap(QRegExp(key22old,Qt::CaseSensitive,QRegExp::RegExp));
+ }
+ tab11=this->restore_key(key11); //tab11=this->mestab[key11];
+ tab22=this->restore_key(key22); //tab22=this->mestab[key22];
+ if (tab11->size>this->nbelem_limit_swap ||
+ tab22->size>this->nbelem_limit_swap) swap=true ;
+ long i1,i2;
+ bool ok1=true;
+ //test on equality of xyz_coordinates of commons vertices
+ for (long j=0; j < tab1->size-1; j++)
+ {
+ i1=tab1->tmint[j];
+ i2=tab2->tmint[j];
+ //1 for print vertices not equals
+ if (!CVW_is_equal_vertices(tab11,i1,tab22,i2,1))
+ {
+ cerr<<j<<" Vertice "<<i1<<" != Vertice "<<i2<<"\n"<<endl;
+ ok=false; ok1=false;
+ }
+ }
+ if ((verbose>2)&&(ok1))
+ cout<<"TestEqualityCoordinates "<<tab1->size<<
+ " Vertices "<<key1.toLatin1().constData()<<" and "<<key2.toLatin1().constData()<<" ok"<<endl;
+ if (!ok1)
+ cerr<<"TestEqualityCoordinates "<<tab1->size<<
+ " Vertices "<<key1.toLatin1().constData()<<" and "<<key2.toLatin1().constData()<<" NO_OK"<<endl;
+ key11old=key11; key22old=key22;
}
- }
- }
- //Swap out of memory (supposed no use?)
- //NO because NB1&NB2 VC supposed future use
- //YES precaution
- this->SwapOutOfMemory_key_mesh_wrap(QRegExp(key11old));
- this->SwapOutOfMemory_key_mesh_wrap(QRegExp(key22old));
- return ok;
+ }
+ //Swap out of memory (supposed no use?)
+ //NO because NB1&NB2 VC supposed future use
+ //YES precaution
+ if (swap) {
+ this->SwapOutOfMemory_key_mesh_wrap(QRegExp(key11old,Qt::CaseSensitive,QRegExp::RegExp));
+ this->SwapOutOfMemory_key_mesh_wrap(QRegExp(key22old,Qt::CaseSensitive,QRegExp::RegExp));
+ }
+ return ok;
}
//************************************
-bool ghs3dprl_mesh_wrap::Write_MEDfiles()
+bool ghs3dprl_mesh_wrap::Find_VerticesDomainToVerticesSkin()
+//initialise correspondances vertice skin et vertices locaux pour chaque domaine
+//calcule un med_int new tab[nb_vertices_of_domain]
+//avec nieme vertice of skin=tab[ieme vertice de domain]
+//apres verification tepal garde bien dans la global numbering "GLi VE"
+//les indices initiaux des noeuds (attention: de 1 a nbNodes)
{
- bool ok=false,oklocal;
- QString key1,tmp,filename;
- CVWtab *tab1,*tab2;
- med_err err;
- char namelocal[MED_TAILLE_NOM+1]; //no more 32
- char distfilename[MED_TAILLE_DESC+1];
- char description[MED_TAILLE_DESC+1];
-
- //remove path
- //precaution because casename->med_namelocal no more 32 character
- //if path, in this->path.
- //20 preserve for add postfixes "_idom" etc...
- this->casename=this->casename.section('/',-1);
- if (this->casename.length()>20)
- {
- std::cerr<<"CaseNameMed truncated (no more 20 characters)"<<std::endl;
- this->casename.truncate(20);
- }
- filename=this->path+this->casename;
- std::ofstream file(filename.toLatin1().constData()); //master file
- file<<"#MED Fichier V 2.3"<<" "<<std::endl;
- file<<"# NumbersOfSubDomains"<<" "<<std::endl;
- int nbdomains=this->nbfiles;
- long nbtetrastotal=0;
- file<<nbdomains<<" "<<std::endl;
-
- //loop on the domains
- for (int idom=1; idom<=nbdomains; idom++)
- {
- oklocal=true;
- std::ostringstream suffix;
- suffix<<filename.toLatin1().constData()<<"_"<<idom<<".med";
- strcpy(distfilename,suffix.str().c_str());
- //tmp=filename+tmp.sprintf("_%d.med",idom);
- //strcpy(distfilename,tmp);
- if (this->verbose>0)
- {
- if (this->verbose>2) std::cout<<std::endl;
- std::cout<<"CreateMEDFile "<<idom<<" "<<distfilename<<std::endl;
- }
-
- med_idt fid=MEDouvrir(distfilename,MED_CREATION);
- if (fid<0) std::cerr<<"Problem MEDouvrir "<<distfilename<<std::endl;
-
- //updating the ascii master description file
- tmp=tmp.sprintf(QString(this->casename+"_%d").toLatin1().constData(),idom);
- file<<this->casename.toLatin1().constData()<<" "<<idom<<" "<<
- tmp.toLatin1().constData()<<" "<<"localhost "<<distfilename<<" "<<std::endl;
-
- //create mesh
- strcpy(namelocal,tmp.toLatin1().constData());
- tmp=tmp.sprintf("domain %d among %d",idom,nbdomains);
- strcpy(description,tmp.toLatin1().constData());
- if (this->verbose>4) std::cout<<"File "<<distfilename<<" : "<<description<<std::endl;
- //std::cout<<namelocal<<":"<<description<<std::endl
- err=MEDmaaCr(fid,namelocal,3,MED_NON_STRUCTURE,description);
- if (err<0) std::cerr<<"Problem MEDmaaCr"<<std::endl;
-
- //writing node(vertices) coordinates
- //NBx VC=files.NoBoite Vertex Coordinates
- // 123456789012345612345678901234561234567890123456
- char nomcoo[3*MED_TAILLE_PNOM+1]="x y z ";
- char unicoo[3*MED_TAILLE_PNOM+1]="? ? ? ";
- key1=key1.sprintf("NB%d VC",idom); //files.NoBoite Vertex Coordinates
- tab1=this->restore_key(key1); //tab1=this->mestab[key1];
- med_int nbnodes=tab1->size/3;
-
- /*(med_idt fid, char *maa, med_int mdim, med_float *coo,
- med_mode_switch mode_switch, med_int n,
- med_repere type_rep, char *nom, char *unit)*/
- err=MEDcoordEcr(fid,namelocal,3,tab1->tmflo,MED_FULL_INTERLACE,
- nbnodes,MED_CART,nomcoo,unicoo);
- if (err<0) std::cerr<<"Problem MEDcoordEcr"<<std::endl;
- if (this->verbose>4)std::cout<<"NumberOfNodes="<<nbnodes<<std::endl;
- this->SwapOutOfMemory_key_mesh_wrap(QRegExp(key1));
-
- //writing indices of nodes
- med_int *arrayi=new med_int[nbnodes];
- for (long i=0; i<nbnodes ; i++) arrayi[i]=i+1;
- med_2_2::med_geometrie_element medgeoele0=(med_2_2::med_geometrie_element) 0;
- err=MEDnumEcr(fid,namelocal,arrayi,nbnodes,MED_NOEUD,medgeoele0);
- if (err<0) std::cerr<<"Problem MEDnumEcr of nodes"<<std::endl;
- delete[] arrayi;
-
- //writing connectivity of faces triangles of wrap by nodes
- key1=key1.sprintf("FC%d",idom); //files.FaCes faces (wrap and triangles only)
- tab1=this->restore_key(key1); //tab1=this->mestab[key1];
- med_int nbfaces=tab1->size/7;
- if (this->verbose>4) std::cout<<"NumberOfTrianglesOfWrap="<<nbfaces<<std::endl;
- arrayi=new med_int[nbfaces*3];
- long ii=0,i=0 ;
- for (long j=0; j<nbfaces ; j++)
- {
- arrayi[ii]=tab1->tmint[i]; ii++;
- arrayi[ii]=tab1->tmint[i+1]; ii++;
- arrayi[ii]=tab1->tmint[i+2]; ii++;
- i=i+7;
- }
- err=MEDconnEcr(fid,namelocal,3,arrayi,MED_FULL_INTERLACE,nbfaces,MED_FACE,MED_TRIA3,MED_NOD);
- if (err<0) std::cerr<<"Problem MEDconnEcr for triangles connectivity"<<std::endl;
- delete[] arrayi;
-
- //writing indices of faces triangles of wrap
- //caution!
- //generate "overlapping of numbers of elements" in "import med file" in salome
- //if not in "//writing indices of tetraedes" -> arrayi[i]=!NBFACES!+i+1
- arrayi=new med_int[nbfaces];
- for (long i=0; i<nbfaces ; i++) arrayi[i]=i+1;
- err=MEDnumEcr(fid,namelocal,arrayi,nbfaces,MED_FACE,MED_TRIA3);
- if (err<0) std::cerr<<"Problem MEDnumEcr of triangles"<<std::endl;
- delete[] arrayi;
-
- //create global family wrap default
- char nomfam[MED_TAILLE_NOM+1]="PART_OF_GLOBAL_WRAP";
- char attdes[MED_TAILLE_DESC+1]="part of wrap of global volume";
- char gro[MED_TAILLE_LNOM+1]="PART_OF_GLOBAL_WRAP";
- med_int numfam,attide,attval,natt,ngro,numfam_ini_wrap=200;
- //caution numfam_ini_wrap!=numfam_ini_nodes
- numfam=-numfam_ini_wrap; attide=1; attval=numfam; natt=1; ngro=1;
- err=MEDfamCr(fid,namelocal,nomfam,numfam,&attide,&attval,attdes,natt,gro,ngro);
- if (err<0) std::cerr<<"Problem MEDfamCr of "<<nomfam<<std::endl;
-
- //for joints
- //init default indices of families of faces triangles of wrap = -numfam_ini_wrap
- //(for faces not in joints=PART_OF_GLOBAL_WRAP, why not!)
- //others -> -numfam_ini_wrap-indice_of_neighbourg ([1;number_of_neighbourg])
- //(for existing joints)
- int sizefamilies=nbfaces;
- med_int *familiesi=new med_int[sizefamilies];
- for (int i=0; i<sizefamilies ; i++) familiesi[i]=-numfam_ini_wrap;
-
- //families known in faces in wrap PART_OF_GLOBAL_WRAP
- //writing indices of families of faces triangles of wrap = nsd why not?
- //not implemented yet because subdomain(s) of family PART_OF_GLOBAL_WRAP
- /*arrayi=new med_int[nbfaces];
- for (int i=0; i<nbfaces ; i++) arrayi[i]=tab1->tmint[(i*7)+3];
- err=MEDfamEcr(fid,namelocal,arrayi,nbfaces,MED_FACE,MED_TRIA3);
- if (err<0) std::cerr<<"Problem MEDfamEcr faces of wrap"<<std::endl;
- delete[] arrayi;*/
-
- //writing connectivity of tetraedes by nodes
- key1=key1.sprintf("NB%d EV",idom); //files.NoBoite Elements Vertices (tetra only)
- tab1=this->restore_key(key1); //tab1=this->mestab[key1];
- med_int nbtetras=tab1->size/4;
- nbtetrastotal=nbtetrastotal + nbtetras;
- std::cout<<"NumberOfTetraedes="<<nbtetras<<std::endl;
- //arrayi=new med_int[tab1->size];
- //for (long i=0; i<tab1->size ; i++) arrayi[i]=tab1->tmint[i];
- err=MEDconnEcr(fid,namelocal,3,tab1->tmint,MED_FULL_INTERLACE,nbtetras,MED_MAILLE,MED_TETRA4,MED_NOD);
- if (err<0) std::cerr<<"Problem MEDconnEcr for tetra connectivity"<<std::endl;
- //delete[] arrayi;
- this->SwapOutOfMemory_key_mesh_wrap(QRegExp(key1));
-
- //writing indices of tetraedes
- arrayi=new med_int[nbtetras];
- for (long i=0; i<nbtetras ; i++) arrayi[i]=nbfaces+i+1;
- err=MEDnumEcr(fid,namelocal,arrayi,nbtetras,MED_MAILLE,MED_TETRA4);
- if (err<0) std::cerr<<"Problem MEDnumEcr of tetraedes"<<std::endl;
- delete[] arrayi;
-
- //writing indices of families of nodes = nrs why not?
- //before create families of nodes fonction of existing values of nrs of files .points
- arrayi=new med_int[nbnodes];
- key1=key1.sprintf("PO%d NRS",idom); //files.POints Vertex of wrap
- tab1=this->restore_key(key1); //tab1=this->mestab[key1];
- med_int nbwrap=tab1->size;
- //families known in points in wrap
- //more than 30 families is stupid? (too many)?
- int itest,i2,ifam[30],imax=1,imess=0,numfam_ini_nodes=numfam_ini_wrap-100;
- //caution numfam_ini_wrap!=numfam_ini_nodes
- //ifam[:]<-existing values of nrs (in [0,97])
- //ifam[0]<-first family default=99 for new nodes IN volume (out of wrap)
- ifam[0]=99;
- for (int i=0; i<nbwrap ; i++)
- {
- itest=tab1->tmint[i];
- if ((itest<0)||(itest>97))
+ QString key1,key2,tmp;
+ CVWtab *cooskin,*coodom,*glodom,*montab;
+ bool ok=true;
+ med_float *p1,*p2;
+ med_int i,nb,jd,js;
+
+ cooskin=this->restore_key(QString("SKIN_VERTICES_COORDINATES"));
+ if (verbose>4)cout<<"NumberVerticesSKIN="<<cooskin->size/3<<endl;
+ if (!cooskin) return false;
+ //ici pourrait creer BBtree sur skin
+ for (int ifile=1; ifile<=this->nbfiles; ifile++)
+ {
+ key1=key1.sprintf("NB%ld VC",ifile);
+ coodom=this->restore_key(key1);
+ if (!coodom) continue; //Problem
+ key2=key2.sprintf("GL%ld VE",ifile);
+ glodom=this->restore_key(key2);
+ if (verbose>4)
+ cout<<"NumberVerticesDOMAIN_"<<ifile<<"="<<glodom->size<<endl;
+ if (coodom->size!=glodom->size*3)
{
- if (imess==0)
- {
- std::cerr<<"Problem for domain "<<idom<<" nrs="<<itest<<
- " shoud be in [0;97] forced 98"<<std::endl;
- imess=1; //message only once
- }
- itest=98; //0<=nrs<=97 precaution 98=family garbage
+ cerr<<"Find_VerticesDomainToVerticesSkin key "<<key1.toLatin1().constData()<<
+ " and key "<<key2.toLatin1().constData()<<" NOT coherent sizes"<<endl;
+ ok=false; continue;
}
- arrayi[i]=-numfam_ini_nodes-itest;
- i2=0;
- while (1)
+ //test on equality of xyz_coordinates of commons vertices
+ med_int *tab=new med_int[glodom->size];
+ i=0;
+ nb=0; //nb equals vertices
+ if (verbose>8){
+ cout<<"\nglobal numbering nodes: no iglo\n";
+ for (jd=0; jd < glodom->size; jd++)
+ cout<<"\t"<<jd<<"\t"<<glodom->tmint[jd]<<endl;
+ cout<<"\nresults: no i js iglo\n";
+ for (jd=0; jd < coodom->size; jd=jd+3)
{
- if (i2==imax)
- {
- ifam[imax]=itest ; imax++ ; break;
- }
- if (itest==ifam[i2]) break;
- i2++;
- if (i2>=30) break;
+ p2=(coodom->tmflo+jd);
+ tab[i]=0;
+ //ici pourrait utiliser BBtree
+ for (js=0; js < cooskin->size; js=js+3)
+ {
+ p1=(cooskin->tmflo+js);
+ if (p1[0]==p2[0] && p1[1]==p2[1] && p1[2]==p2[2])
+ {
+ cout<<"\t"<<nb<<"\t"<<i<<"\t"<<js/3<<"\t"<<glodom->tmint[i]-1<<
+ key2.sprintf("\t%13.5e%13.5e%13.5e",p1[0],p1[1],p1[2]).toLatin1().constData()<<endl;
+ tab[i]=js/3; nb++; continue;
+ }
+ }
+ i++;
}
- if (imax>=30) {
- std::cerr<<"Problem more than 30 families of nodes"<<std::endl;
- break;
+ montab=new CVWtab(glodom->size,tab);
+ tmp=tmp.sprintf("NB%ld GL_SKIN",ifile);
+ ok=this->insert_key(tmp,montab);
+ if (verbose>4){
+ cout<<"NumberOfEqualsVerticesDOMAIN_"<<ifile<<"="<<nb<<endl;
}
}
- for (int i=0 ; i<imax ; i++)
- {
- //create families of nodes as nrs
- if (i==0)
- tmp=tmp.sprintf("IN_VOLUME");
- else
- tmp=tmp.sprintf("NRS_%d",ifam[i]);
- strcpy(nomfam,tmp.toLatin1().constData());
- if (this->verbose>2) std::cout<<"CreateFamilyOfNodes_"<<nomfam<<std::endl;
- strcpy(gro,tmp.toLatin1().constData());
- if(i==0)
- tmp=tmp.sprintf("nodes in local volume");
- else
- tmp=tmp.sprintf("nodes of nrs_%d on local wrap",ifam[i]);
- strcpy(attdes,tmp.toLatin1().constData());
- numfam=-numfam_ini_nodes-ifam[i];
- //attide=1;
- attval=numfam;
- //natt=1;
- ngro=1;
- if (this->verbose>4) std::cout<<"MEDfamCr (nodes) of "<<nomfam<<" / "<<attdes<<" / FamilyNumber="<<numfam<<std::endl;
- err=MEDfamCr(fid,namelocal,nomfam,numfam,&attide,&attval,attdes,natt,gro,ngro);
- if (err<0) std::cerr<<"Problem MEDfamCr of "<<nomfam<<std::endl;
- }
- //defaults ifam[0] for new points in new volume
- for (int i=nbwrap; i<nbnodes ; i++) arrayi[i]=-numfam_ini_nodes-ifam[0];
-
- err=MEDfamEcr(fid,namelocal,arrayi,nbnodes,MED_NOEUD,medgeoele0);
- if (err<0) std::cerr<<"Problem MEDfamEcr nodes"<<std::endl;
- delete[] arrayi;
-
- /*Le nom du maillage local est une chaîne de MED_TAILLE_NOM (32) caractères.
- Le tableau des numéros "num" est un tableau à 1 dimension de taille égale à "n".
- Les numéros globaux sont obligatoirement supérieur à 1
- Le type de l'entite "typent" est soit MED_NOEUD,MED_MAILLE, MED_FACE ou MED_ARETE.
- Le type géométrique peut être :
- Pour les noeuds : 0.
- Pour les mailles : MED_POINT1, MED_SEG2, MED_SEG3, MED_TRIA3, MED_TRIA6, MED_QUAD4, MED_QUAD8, MED_POLYGONE.
- Pour les faces : MED_TRIA3, MED_TRIA6, MED_QUAD4, MED_QUAD8, MED_POLYGONE.
- Pour les arêtes : MED_SEG2 et MED_SEG3.*/
-
- //writing nodes(vertices) global numbering
- //GLx VE=files.GLo VErtices
- key1=key1.sprintf("GL%d VE",idom);
- tab1=this->restore_key(key1); //tab1=this->mestab[key1];
- nbnodes=tab1->size;
- if (this->verbose>2)
- std::cout<<"CreateMEDglobalNumerotation_Nodes "<<key1.toLatin1().constData()<<" "<<tab1->size<<std::endl;
- if (nbnodes<=0) std::cerr<<"Problem MEDglobalNumEcr not in memory"<<std::endl;
- //arrayi=new med_int[nbnodes];
- //for (int i=0; i<tab1->size ; i++) arrayi[i]=tab1->tmint[i];
- //med_2_2::med_geometrie_element toto=MED_POINT1;
- //std::cout<<"MED_POINT1="<<toto<<" medgeoele0="<<medgeoele0<<std::endl;
- /*MEDglobalNumEcr(med_idt fid, char *maa, med_int *num, med_int n,
- med_entite_maillage type_ent, med_geometrie_element type_geo)*/
- err=MEDglobalNumEcr(fid,namelocal,tab1->tmint,nbnodes,MED_NOEUD,medgeoele0);
- if (err<0) std::cerr<<"Problem MEDglobalNumEcr nodes"<<std::endl;
- //std::cout<<"MEDglobalNumEcr vertices size="<<nbnodes<<std::endl;
- //delete[] arrayi;
- this->SwapOutOfMemory_key_mesh_wrap(QRegExp(key1));
-
- //writing faces(triangles) global numbering
- //GLx FA=files.GLo FAces
- key1=key1.sprintf("GL%d FA",idom);
- tab1=this->restore_key(key1); //tab1=this->mestab[key1];
- nbfaces=tab1->size;
- //arrayi=new med_int[nbfaces];
- //for (int i=0; i<tab1->size ; i++) arrayi[i]=tab1->tmint[i];
- if (this->verbose>2)
- std::cout<<"CreateMEDglobalNumerotation_Faces "<<key1.toLatin1().constData()<<" "<<tab1->size<<std::endl;
- err=MEDglobalNumEcr(fid,namelocal,tab1->tmint,nbfaces,MED_FACE,MED_TRIA3);
- if (err<0) std::cerr<<"Problem MEDglobalNumEcr faces"<<std::endl;
- //std::cout<<"MEDglobalNumEcr faces size="<<nbfaces<<std::endl;
- //delete[] arrayi;
- this->SwapOutOfMemory_key_mesh_wrap(QRegExp(key1));
-
- //writing tetraedes global numbering
- //GLx EL=files.GLo ELements
- key1=key1.sprintf("GL%d EL",idom);
- tab1=this->restore_key(key1); //tab1=this->mestab[key1];
- med_int nbtetrasglo=tab1->size;
- if (nbtetrasglo!=nbtetras)
- std::cerr<<"Problem incorrect size of tetraedes global numbering"<<std::endl;
- //arrayi=new med_int[nbtetrasglo];
- //for (int i=0; i<tab1->size ; i++) arrayi[i]=tab1->tmint[i];
- if (this->verbose>2)
- std::cout<<"CreateMEDglobalNumerotation_Tetraedes "<<key1.toLatin1().constData()<<" "<<tab1->size<<std::endl;
- err=MEDglobalNumEcr(fid,namelocal,tab1->tmint,nbtetrasglo,MED_MAILLE,MED_TETRA4);
- if (err<0) std::cerr<<"Problem MEDglobalNumEcr tetraedes"<<std::endl;
- //std::cout<<"MEDglobalNumEcr tetraedes size="<<nbtetrasglo<<std::endl;
- //delete[] arrayi;
- this->SwapOutOfMemory_key_mesh_wrap(QRegExp(key1));
-
- //writing joints
- for (int ineig=1; ineig <= this->nbfiles; ineig++)
- {
- char namejnt[MED_TAILLE_NOM+1]; //no more 32
- char namedist[MED_TAILLE_NOM+1];
- char descjnt[MED_TAILLE_DESC+1];
-
- if (idom==ineig) continue; //impossible
- key1=key1.sprintf("MS%d NE%d VE SE",idom,ineig); //SE or RE?
- tab1=this->restore_key(key1);
- if (!tab1) continue; //case (ifile,ineig) are not neighbours=>no joints
- key1=key1.sprintf("MS%d NE%d VE RE",idom,ineig); //SE or RE
- tab2=tab1; //tab2=this->restore_key(key1); //no need because <send> equals <receive>
- if (!tab2) std::cerr<<"Problem nodes joint <send> with no <receive> in file .msg"<<std::endl;
- nbnodes=tab1->size;
-
- if (this->verbose>4)
- std::cout<<"NumberOfNodesOfJoint_"<<ineig<<"="<<nbnodes<<std::endl;
- strcpy(namejnt,tmp.sprintf("joint_%d",ineig).toLatin1().constData());
- tmp=tmp.sprintf("joint_%d among %d domains of ",ineig,nbdomains)+namelocal;
- strcpy(descjnt,tmp.toLatin1().constData());
- //std::cout<<descjnt<<std::endl;
- strcpy(namedist,tmp.sprintf("joint_%d",idom).toLatin1().constData()); //or this->casename+"_%d",ineig));
- err=MEDjointCr(fid,namelocal,namejnt,descjnt,ineig,namedist);
- if (err<0) std::cerr<<"Problem MEDjointCr"<<std::endl;
-
- //writing correspondence nodes-nodes
- //two indices for one correspondence
- arrayi=new med_int[nbnodes*2];
- ii=0;
- for (int i=0; i<nbnodes ; i++)
- {
- //no need because <send> equals <receive> tab1->tmint[i]==tab2->tmint[i]
- arrayi[ii]=tab1->tmint[i]; ii++;
- arrayi[ii]=tab2->tmint[i]; ii++;
+ }
+ return ok;
+}
+
+//fin utils procedures
+
+//************************************
+bool ghs3dprl_mesh_wrap::Write_masterxmlMEDfile()
+{
+ QString tmp;
+
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!first call
+ if (idom==1)
+ {
+ //define master file (.xml) in memory
+ tmp=path+medname+".xml";
+ filemaster=tmp.toLatin1().constData();
+ domainname=medname.toLatin1().constData();
+ char buff[256];
+
+ //Creating the XML document
+ master_doc = xmlNewDoc(BAD_CAST "1.0");
+ root_node = xmlNewNode(0, BAD_CAST "root");
+ xmlDocSetRootElement(master_doc,root_node);
+
+ //Creating child nodes
+ //Version tag
+ med_int majeur,mineur,release;
+ //Quelle version de MED est utilisée
+ MEDversionDonner(&majeur,&mineur,&release);
+ if (verbose>0) fprintf(stdout,"Files write with MED V%d.%d.%d\n",majeur,mineur,release);
+ node = xmlNewChild(root_node, 0, BAD_CAST "version",0);
+ //xmlNewProp(node, BAD_CAST "maj", BAD_CAST int2string2(majeur).c_str());
+ xmlNewProp(node, BAD_CAST "maj", BAD_CAST i2a(majeur).c_str());
+ xmlNewProp(node, BAD_CAST "min", BAD_CAST i2a(mineur).c_str());
+ xmlNewProp(node, BAD_CAST "ver", BAD_CAST i2a(release).c_str());
+
+ //Description tag
+ node = xmlNewChild(root_node,0, BAD_CAST "description",0);
+ xmlNewProp(node, BAD_CAST "what", BAD_CAST "tetrahedral mesh by tepal");
+ time_t present;
+ time(&present);
+ struct tm *time_asc = localtime(&present);
+ sprintf(buff,"%04d/%02d/%02d %02dh%02dm",
+ time_asc->tm_year+1900,time_asc->tm_mon+1,time_asc->tm_mday,
+ time_asc->tm_hour,time_asc->tm_min);
+ xmlNewProp(node, BAD_CAST "when", BAD_CAST buff);
+ xmlNewProp(node, BAD_CAST "from", BAD_CAST "tepal2med");
+
+ //Content tag
+ node =xmlNewChild(root_node,0, BAD_CAST "content",0);
+ node2 = xmlNewChild(node, 0, BAD_CAST "mesh",0);
+ xmlNewProp(node2, BAD_CAST "name", BAD_CAST domainname.c_str());
+ info_node = xmlNewChild(node, 0, BAD_CAST "tepal2med_info",0);
+
+ //Splitting tag
+ node=xmlNewChild(root_node,0,BAD_CAST "splitting",0);
+ node2=xmlNewChild(node,0,BAD_CAST "subdomain",0);
+ xmlNewProp(node2, BAD_CAST "number", BAD_CAST i2a(nbfilestot).c_str());
+ node2=xmlNewChild(node,0,BAD_CAST "global_numbering",0);
+ xmlNewProp(node2, BAD_CAST "present", BAD_CAST "yes");
+
+ //Files tag
+ files_node=xmlNewChild(root_node,0,BAD_CAST "files",0);
+
+ //Mapping tag
+ node = xmlNewChild(root_node,0,BAD_CAST "mapping",0);
+ mesh_node = xmlNewChild(node, 0, BAD_CAST "mesh",0);
+ xmlNewProp(mesh_node, BAD_CAST "name", BAD_CAST domainname.c_str());
+ }
+
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!all calls
+ {
+ char *hostname = getenv("HOSTNAME");
+ node = xmlNewChild(files_node,0,BAD_CAST "subfile",0);
+ xmlNewProp(node, BAD_CAST "id", BAD_CAST i2a(idom).c_str());
+ node2 = xmlNewChild(node, 0, BAD_CAST "name", BAD_CAST distfilename);
+ if (hostname == NULL)
+ node2 = xmlNewChild(node, 0, BAD_CAST "machine",BAD_CAST "localhost");
+ else
+ node2 = xmlNewChild(node, 0, BAD_CAST "machine",BAD_CAST hostname);
+
+ node = xmlNewChild(mesh_node,0,BAD_CAST "chunk",0);
+ xmlNewProp(node, BAD_CAST "subdomain", BAD_CAST i2a(idom).c_str());
+ node2 = xmlNewChild(node, 0, BAD_CAST "name", BAD_CAST nomfinal);
+
+ //tepal2med_info
+ node = xmlNewChild(info_node, 0, BAD_CAST "chunk",0);
+ xmlNewProp(node, BAD_CAST "subdomain", BAD_CAST i2a(idom).c_str());
+ xmlNewProp(node, BAD_CAST "nodes_number", BAD_CAST i2a(nbnodes).c_str());
+ xmlNewProp(node, BAD_CAST "faces_number", BAD_CAST i2a(nbtria3).c_str());
+ xmlNewProp(node, BAD_CAST "tetrahedra_number", BAD_CAST i2a(nbtetra4).c_str());
+ //node2 = xmlNewChild(node, 0, BAD_CAST "name", BAD_CAST nomfinal);
+
+ //node2 = xmlNewChild(node, 0, BAD_CAST "nodes", 0);
+ //xmlNewProp(node2, BAD_CAST "number", BAD_CAST i2a(nbnodes).c_str());
+ //node2 = xmlNewChild(node, 0, BAD_CAST "faces", 0);
+ //xmlNewProp(node2, BAD_CAST "number", BAD_CAST i2a(nbtria3).c_str());
+ //node2 = xmlNewChild(node, 0, BAD_CAST "tetrahedra", 0);
+ //xmlNewProp(node2, BAD_CAST "number", BAD_CAST i2a(nbtetra4).c_str());
+
+ //tepal2med_info about joints of one subdomain
+ xmlAddChild(node,joints_node);
+ //tepal2med_info about groups and families of one subdomain
+ xmlAddChild(node,families.xml_groups());
+ }
+
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!last call
+ if (idom==nbfilestot)
+ {
+ node2 = xmlNewChild(info_node, 0, BAD_CAST "global",0);
+ xmlNewProp(node2, BAD_CAST "tetrahedra_number", BAD_CAST i2a(nbtetrastotal).c_str());
+ //save masterfile
+ xmlSaveFormatFileEnc(filemaster.c_str(), master_doc, "UTF-8", 1);
+ xmlFreeDoc(master_doc);
+ xmlCleanupParser();
+ }
+ return true;
+}
+
+
+//************************************
+bool ghs3dprl_mesh_wrap::Write_MEDfiles_v2(bool deletekeys)
+//deletekeys=true to delete non utils keys and arrays "au fur et a mesure"
+{
+ bool ok=true,oktmp;
+ QString tmp,cmd;
+ char description[MED_TAILLE_DESC];
+ med_int nb;
+
+ //remove path
+ //precaution because casename->med_nomfinal no more 32 character
+ //if path, in this->path.
+ //20 preserve for add postfixes "_idom" etc...
+ if (verbose>0)cout<<"\nWrite_MEDfiles_v2\n";
+ if (verbose>6){cout<<"\nInitialFamilies\n"; families.write();}
+
+ medname=medname.section('/',-1);
+ if (medname.length()>20) {
+ cerr<<"CaseNameMed truncated (no more 20 characters)"<<endl;
+ medname.truncate(20);
+ }
+
+ //create file resume DOMAIN.joints.med of all joints for quick display (...may be...)
+ tmp=path+medname+tmp.sprintf("_joints.med",idom);
+ charendnull(distfilename,tmp,MED_TAILLE_DESC);
+ fidjoint=MEDouvrir(distfilename,MED_CREATION);
+ if (fidjoint<0) cerr<<"Problem MEDouvrir "<<distfilename<<endl;
+ if (verbose>0) cout<<"CreateMEDFile for all joints <"<<distfilename<<">\n";
+
+ //copy file source/GHS3DPRL_skin.med as destination/DOMAIN.skin.med
+ tmp=path+medname+"_skin.med";
+ cmd="cp "+pathini+casename+"_skin.med "+tmp;
+ //cout<<"Copy skin.med Command = "<<cmd<<endl;
+ system(cmd.toLatin1().constData());
+ if (verbose>0)cout<<"CreateMEDFile for initial skin <"<<tmp.toLatin1().constData()<<">\n";
+
+ //define family 0 if not existing, no groups
+ families.add("0","");
+ //define family Group_of_New_Nodes (which not exists before tetrahedra)
+ famallnodes=0;
+ if (QString("All_Nodes").contains(deletegroups)==0){
+ oktmp=families.get_number_of_new_family(1,&famallnodes,&tmp);
+ families.add(tmp,"All_Nodes");
+ }
+ else if (verbose>3) cout<<"--deletegroups matches \"All_Nodes\"\n";
+
+ famalltria3=0;
+ if (QString("All_Faces").contains(deletegroups)==0){
+ oktmp=families.get_number_of_new_family(-1,&famalltria3,&tmp);
+ families.add(tmp,"All_Faces");
+ }
+ else if (verbose>3) cout<<"--deletegroups matches \"All_Faces\"\n";
+
+ famalltetra4=0;
+ if (QString("All_Tetrahedra").contains(deletegroups)==0){
+ oktmp=families.get_number_of_new_family(-1,&famalltetra4,&tmp);
+ families.add(tmp,"All_Tetrahedra");
+ }
+ else if (verbose>3) cout<<"--deletegroups matches \"All_Tetrahedra\"\n";
+
+ famnewnodes=0;
+ if (QString("New_Nodes").contains(deletegroups)==0){
+ oktmp=families.get_number_of_new_family(1,&famnewnodes,&tmp);
+ families.add(tmp,"New_Nodes");
+ }
+ else if (verbose>3) cout<<"--deletegroups matches \"New_Nodes\"\n";
+
+ famnewtria3=0;
+ if (QString("New_Faces").contains(deletegroups)==0){
+ oktmp=families.get_number_of_new_family(-1,&famnewtria3,&tmp);
+ families.add(tmp,"New_Faces");
+ }
+ else if (verbose>3) cout<<"--deletegroups matches \"New_Faces\"\n";
+
+ famnewtetra4=0;
+ if (QString("New_Tetrahedra").contains(deletegroups)==0){
+ oktmp=families.get_number_of_new_family(-1,&famnewtetra4,&tmp);
+ families.add(tmp,"New_Tetrahedra");
+ }
+ else if (verbose>3) cout<<"--deletegroups matches \"New_Tetrahedra\"\n";
+
+ if (verbose>6){cout<<"\nIntermediatesFamilies\n"; families.write();}
+ if (verbose>6) cout<<"\nNumber0fFiles="<<nbfilestot<<endl;
+ familles intermediatesfamilies=families;
+ //initialisations on all domains
+ nbtetrastotal=0;
+
+ //loop on the domains
+ //for (idom=1; idom<=nbfilestot; idom++) {
+ for (idom=1; idom<=nbfilestot; idom++) {
+
+ this->nofile=idom;
+ //restore initial context of families
+ if (idom>1) families=intermediatesfamilies;
+ //if (idom>1) continue;
+ tmp=path+medname+tmp.sprintf("_%d.med",idom);
+ charendnull(distfilename,tmp,MED_TAILLE_DESC);
+
+ //cout<<"<"<<distfilename<<">"<<endl;
+ fid=MEDouvrir(distfilename,MED_CREATION);
+ if (fid<0) {cerr<<"Problem MEDouvrir "<<distfilename<<endl; goto erreur;}
+ if (verbose>0){
+ if (verbose>2) cout<<endl;
+ cout<<"CreateMEDFile "<<idom<<" <"<<distfilename<<">\n";
+ }
+
+ //create mesh
+ tmp=medname+tmp.sprintf("_%d",idom);
+ charendnull(nomfinal,tmp,MED_TAILLE_NOM);
+ tmp=tmp.sprintf("domain %d among %d",idom,nbfilestot);
+ charendnull(description,tmp,MED_TAILLE_DESC);
+
+ if (verbose>4) cout<<"Description : "<<description<<endl;
+ err=MEDmaaCr(fid,nomfinal,3,MED_NON_STRUCTURE,description);
+ if (err<0) {cerr<<"Problem MEDmaaCr"<<nomfinal<<endl; goto erreur;}
+
+ if (!idom_nodes()) {cerr<<"Problem on Nodes"<<endl; goto erreur;}
+ if (!idom_edges()) {cerr<<"Problem on Edges"<<endl; goto erreur;}
+ if (!idom_faces()) {cerr<<"Problem on Faces"<<endl; goto erreur;}
+ if (!idom_tetras()) {cerr<<"Problem on tetrahedra"<<endl; goto erreur;}
+ if (!idom_joints()) {cerr<<"Problem on Joints"<<endl; goto erreur;}
+
+ if (verbose>6){cout<<"\nFinalsFamilies\n"; families.write();}
+ //for nodes families
+ nb=create_families(fid,1);
+ if (verbose>5)cout<<"NumberOfFamiliesNodes="<<nb<<endl;
+
+ err=MEDfamEcr(fid,nomfinal,famnodes,nbnodes,MED_NOEUD,MED_NONE);
+ if (verbose>8)
+ cout<<"MEDfamEcr nodes "<<nbnodes<<":"<<
+ famnodes[0]<<"..."<<famnodes[nbnodes-1]<<" "<<endl;
+ delete[] famnodes;
+ if (err<0) cerr<<"Problem MEDfamEcr nodes"<<endl;
+
+ //for others families
+ nb=create_families(fid,-1);
+ if (verbose>5)cout<<"NumberOfFamiliesFacesAndEdgesEtc="<<nb<<endl;
+
+ err=MEDfamEcr(fid,nomfinal,famtria3,nbtria3,MED_MAILLE,MED_TRIA3);
+ if (verbose>8)
+ cout<<"MEDfamEcr tria3 "<<nbtria3<<":"<<
+ famtria3[0]<<"..."<<famtria3[nbtria3-1]<<" "<<endl;
+ delete[] famtria3;
+ if (err<0) cerr<<"Problem MEDfamEcr tria3"<<endl;
+
+ err=MEDfamEcr(fid,nomfinal,famtetra4,nbtetra4,MED_MAILLE,MED_TETRA4);
+ if (verbose>8)
+ cout<<"MEDfamEcr tetra4 "<<nbtetra4<<":"<<
+ famtetra4[0]<<"..."<<famtetra4[nbtria3-1]<<" "<<endl;
+ delete[] famtetra4;
+ if (err<0) cerr<<"Problem MEDfamEcr tria3"<<endl;
+
+ MEDfermer(fid); //no error
+ //master.xml writings
+ oktmp=Write_masterxmlMEDfile();
+ continue; //and loop on others domains
+
+ erreur: //error
+ ok=false;
+ MEDfermer(fid); //but loop on others domains
+
+ }
+ MEDfermer(fidjoint); //no error
+ if (verbose>0)cout<<"\nTotalNumberOftetrahedra="<<nbtetrastotal<<endl;
+
+ return ok;
+}
+
+//************************************
+bool ghs3dprl_mesh_wrap::idom_nodes()
+{
+ bool ok=true;
+ QString tmp,key,key1,key2,key3;
+ CVWtab *tab,*tab1,*tab2,*tab3;
+ med_int i,j,*arrayi;
+ int xx;
+
+ //writing node(vertices) coordinates
+ //NBx VC=files.NoBoite Vertex Coordinates
+ key=key.sprintf("NB%d VC",idom); //files.NoBoite Vertex Coordinates
+ tab=this->restore_key(key); //tab1=this->mestab[key1];
+ if (!tab) {
+ tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".noboite";
+ ok=this->ReadFileNOBOITE(tmp);
+ tab=this->restore_key(key); //tab1=this->mestab[key1];
+ if (!tab) return false;
}
- err=MEDjointEcr(fid,namelocal,namejnt,arrayi,nbnodes,
- MED_NOEUD,medgeoele0,MED_NOEUD,medgeoele0);
- if (err<0) std::cerr<<"Problem MEDjointEcr nodes"<<std::endl;
+ tmp=tmp.sprintf("NB%d SN",idom);
+ //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
+ xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
+ nbnodes=tab->size/3;
+ err=MEDcoordEcr(fid,nomfinal,3,tab->tmflo,MED_FULL_INTERLACE,
+ nbnodes,MED_CART,nomcoo,unicoo);
+ if (err<0) {cerr<<"Problem MEDcoordEcr"<<endl; return false;}
+ if (verbose>4)cout<<"NumberOfNodes="<<nbnodes<<endl;
+
+ //writing indices of nodes
+ arrayi=new med_int[nbnodes];
+ for (i=0; i<nbnodes ; i++) arrayi[i]=i+1;
+ err=MEDnumEcr(fid,nomfinal,arrayi,nbnodes,MED_NOEUD,MED_NONE);
delete[] arrayi;
-
- //writing correspondence triangles-triangles
- key1=key1.sprintf("MS%d NE%d FA SE",idom,ineig); //SE or RE?
+ if (err<0) {cerr<<"Problem MEDnumEcr of nodes"<<endl; return false;}
+
+ key1=key1.sprintf("GL%d VE",idom); //global numerotation
tab1=this->restore_key(key1); //tab1=this->mestab[key1];
- if (!tab1)
- {
- if (this->verbose>4)
- std::cout<<"NumberOfTrianglesOfJoint_"<<ineig<<"="<<0<<std::endl;
- continue; //case (ifile,ineig) are not neighbours=>no joints
+ if (!tab1) {
+ tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".glo";
+ ok=this->ReadFileGLO(tmp);
+ if (!ok) {cerr<<"Problem file "<<tmp.toLatin1().constData()<<endl; return false;}
+ tab1=this->restore_key(key1); //tab1=this->mestab[key1];
+ if (!tab1) return false;
+ }
+ if (nbnodes!=tab1->size){cerr<<"Problem size GLi VE!=nbnodes!"<<endl; return false;}
+
+ key2=key2.sprintf("SKIN_VERTICES_FAMILIES",idom); //on global numerotation
+ tab2=this->restore_key(key2); //tab1=this->mestab[key1];
+ med_int nbskin=tab2->size;
+ //for (i=0; i<nbskin; i++) cout<<i<<" "<<tab2->tmint[i]<<endl;
+
+ //set families of nodes existing in GHS3DPRL_skin.med
+ med_int nb=nbnodes;
+ famnodes=new med_int[nb];
+ for (i=0; i<nb ; i++) famnodes[i]=famallnodes;
+ med_int * fammore=new med_int[nb];
+ for (i=0; i<nb ; i++) fammore[i]=famnewnodes;
+
+ //set families of nodes of skin
+ for (i=0; i<nb ; i++){
+ j=tab1->tmint[i]-1; //
+ if (j<nbskin){
+ fammore[i]=tab2->tmint[j];
+ }
+ }
+ ok=set_one_more_family(famnodes,fammore,nb);
+ delete[] fammore;
+
+ //cout<<"nodes loc "<<i<<" = gl "<<j<<"\t << "<<tab2->tmint[j]<<
+ // tmp.sprintf("\t%23.15e%23.15e%23.15e",tab3->tmflo[i*3],
+ // tab3->tmflo[i*3+1],tab3->tmflo[i*3+2])<<endl;
+
+ //writing nodes(vertices) global numbering
+ err=MEDglobalNumEcr(fid,nomfinal,tab1->tmint,nbnodes,MED_NOEUD,MED_NONE);
+ if (err<0){cerr<<"Problem MEDglobalNumEcr nodes"<<endl; return false;}
+
+ return ok;
+}
+
+/*
+//************************************
+bool ghs3dprl_mesh_wrap::set_one_more_family_old(med_int *fami, med_int *more, med_int nb)
+//fuse array of med_int families more et fami as kind of groups
+//because there are possibilities of intersections
+{
+ QString tmp;
+ med_int i,newfam,morfam,oldfam;
+ for (i=0; i<nb ; i++) {
+ if (more[i]==0) continue;
+ if (fami[i]==0) {
+ fami[i]=more[i];
+ //cout<<"sur "<<i<<" en plus "<<more[i]<<endl;
}
- key1=key1.sprintf("MS%d NE%d FA RE",idom,ineig); //SE or RE?
- tab2=tab1; //tab2=this->restore_key(key1); //no need because <send> equals <receive>
- if (!tab2) std::cerr<<"Problem triangles joint send with no receive"<<std::endl;
- med_int nbtriangles=tab1->size;
+ else { //intersection
+ if (fami[i]==more[i]) continue; //same families
+ oldfam=fami[i];
+ morfam=more[i];
+ //create new family intersection if needed
+ newfam=families.find_family_on_groups(oldfam,morfam);
+ //cout<<"oldfam "<<oldfam<<" morfam "<<morfam<<" -> newfam "<<newfam<<endl;
+ fami[i]=newfam;
+ }
+ }
+ return true;
+}*/
+
+//************************************
+bool ghs3dprl_mesh_wrap::set_one_more_family(med_int *fami, med_int *more, med_int nb)
+//fuse array of med_int families more et fami as kind of groups
+//because there are possibilities of intersections
+{
+ QString tmp;
+ med_int i,ii,j,newfam,morfam,oldfam,morfami,oldfami,i_zero,nb_fam,nb_max,nb_tot,nb_mess;
+ med_int *newfami;
+
+ nb_fam=families.fam.size(); //on families negative and positive
+ //cout<<"size families "<<nb_fam<<endl;
+ if (nb_fam<=0) nb_fam=5; //precaution
+ i_zero=nb_fam*2; //offset for negative indices of families
+ nb_max=nb_fam*4;
+ if (nb_fam>300) cout<<
+ "***set_one_more_family*** warning many initial families could decrease speed "<<nb_fam<<endl;
+ nb_tot=nb_max*nb_max; //max oversizing *2 on families
+ //newfami is for speed (avoid calls find_family_on_groups)
+ //it is an array[nb_fam*4][nb_fam*4] implemented on vector[nb_max]
+ //to memorize newfam in array[oldfam][morfam]
+ newfami=new med_int[nb_tot];
+ for (i=0; i<nb_tot ; i++) newfami[i]=0; //not yet met!
+
+ nb_mess=0;
+ for (i=0; i<nb ; i++) {
+ if (more[i]==0) continue;
+ if (fami[i]==0) {
+ fami[i]=more[i];
+ //cout<<"sur "<<i<<" en plus "<<more[i]<<endl;
+ }
+ else { //intersection
+ if (fami[i]==more[i]) continue; //same families
+ oldfam=fami[i]; oldfami=oldfam+i_zero;
+ morfam=more[i]; morfami=morfam+i_zero;
+ //not yet met?
+ ii=oldfami+morfami*nb_max; //array 2d on vector
+ if ((ii>=0)&&(ii<nb_tot)) {
+ newfam=newfami[ii];
+ }
+ else {
+ if (nb_mess<3) {
+ nb_mess++;
+ cout<<"***set_one_more_family*** warning many new families decrease speed "<<nb_fam<<endl;
+ }
+ ii=-1;
+ newfam=0;
+ }
+ if (newfam==0) {
+ //create new family intersection if needed
+ newfam=families.find_family_on_groups(oldfam,morfam);
+ //cout<<"new oldfam "<<oldfam<<" morfam "<<morfam<<" -> newfam "<<newfam<<endl;
+ if (ii>=0) newfami[ii]=newfam;
+ }
+ /*else {
+ cout<<"!!! oldfam "<<oldfam<<" morfam "<<morfam<<" -> newfam "<<newfam<<endl;
+ }*/
+ fami[i]=newfam;
+ }
+ }
+ delete[] newfami;
+ return true;
+}
+
+//************************************
+bool ghs3dprl_mesh_wrap::idom_edges()
+{
+ bool ok=true;
+ QString tmp;
+ nbseg2=0;
+ return ok;
+}
+
+//************************************
+bool ghs3dprl_mesh_wrap::idom_faces()
+{
+ bool ok=true;
+ QString tmp,key,key1,key2,key3;
+ CVWtab *tab,*tab1,*tab2,*tab3;
+ med_int ii,i,j,*arrayi;
+ int xx;
+
+ //writing connectivity of faces triangles of wrap by nodes
+ key1=key1.sprintf("FC%d",idom); //files.FaCes faces (wrap and triangles only)
+ tab1=this->restore_key(key1); //tab1=this->mestab[key1];
+ if (!tab1) {
+ tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".faces";
+ ok=this->ReadFileFACES(tmp);
+ tab1=this->restore_key(key1);
+ if (!tab1) return false;
+ }
+ nbtria3=tab1->size/7;
+ if (verbose>4) cout<<"NumberOfTriangles="<<nbtria3<<endl;
+ arrayi=new med_int[nbtria3*3];
+ ii=0,i=0 ;
+ for (j=0; j<nbtria3 ; j++){
+ arrayi[ii]=tab1->tmint[i]; ii++;
+ arrayi[ii]=tab1->tmint[i+1]; ii++;
+ arrayi[ii]=tab1->tmint[i+2]; ii++;
+ i=i+7;
+ }
+ err=MEDconnEcr(fid,nomfinal,3,arrayi,MED_FULL_INTERLACE,nbtria3,MED_MAILLE,MED_TRIA3,MED_NOD);
+ delete[] arrayi; //need immediately more little array
+ if (err<0){cerr<<"Problem MEDconnEcr for triangles connectivity"<<endl; return false;}
- if (this->verbose>4)
- std::cout<<"NumberOfTrianglesOfJoint_"<<ineig<<"="<<nbtriangles<<std::endl;
- arrayi=new med_int[nbtriangles*2];
- ii=0;
- for (int i=0; i<nbtriangles ; i++)
- {
- //no need because <send> equals <receive> tab1->tmint[i]==tab2->tmint[i]
- arrayi[ii]=tab1->tmint[i]; ii++;
- familiesi[tab1->tmint[i]-1]=-numfam_ini_wrap-ineig;
- arrayi[ii]=tab2->tmint[i]; ii++;
- //std::cout<<arrayi[ii-1]<<"="<<arrayi[ii-2]<<std::endl;
+ //writing indices of faces triangles of wrap
+ //caution!
+ //generate "overlapping of numbers of elements" in "import med file" in salome
+ //if not in "//writing indices of tetrahedra" -> arrayi[i]=!NBFACES!+i+1
+ arrayi=new med_int[nbtria3];
+ for (i=0; i<nbtria3 ; i++) arrayi[i]=nbseg2+i+1;
+ err=MEDnumEcr(fid,nomfinal,arrayi,nbtria3,MED_MAILLE,MED_TRIA3);
+ delete[] arrayi;
+ if (err<0){cerr<<"Problem MEDnumEcr of triangles"<<endl; return false;}
+
+ //GLx FA=files.GLo FAces
+ key1=key1.sprintf("GL%d FA",idom);
+ tab1=this->restore_key(key1); //tab1=this->mestab[key1];
+ if (nbtria3!=tab1->size){cerr<<"Problem size GLi FA!=nbtria3!"<<endl; return false;}
+
+ key2=key2.sprintf("SKIN_TRIA3_FAMILIES",idom); //on global numerotation
+ tab2=this->restore_key(key2); //tab1=this->mestab[key1];
+ med_int nbskin=tab2->size;
+
+ //set families of faces existing in GHS3DPRL_skin.med
+ med_int nb=nbtria3;
+ famtria3=new med_int[nb];
+ for (i=0; i<nb ; i++) famtria3[i]=famalltria3;
+ med_int * fammore=new med_int[nb];
+ for (i=0; i<nb ; i++) fammore[i]=famnewtria3;
+
+ //set families of faces of skin
+ for (i=0; i<nb ; i++){
+ j=tab1->tmint[i]-1; //
+ if (j<nbskin){
+ fammore[i]=tab2->tmint[j];
+ }
+ }
+ ok=set_one_more_family(famtria3,fammore,nb);
+ delete[] fammore;
+
+ //writing faces(triangles) global numbering
+ //if (verbose>2)
+ // cout<<"CreateMEDglobalNumerotation_Faces "<<key1<<" "<<tab1->size<<endl;
+ err=MEDglobalNumEcr(fid,nomfinal,tab1->tmint,tab1->size,MED_MAILLE,MED_TRIA3);
+ if (err<0){cerr<<"Problem MEDglobalNumEcr faces"<<endl; return false;}
+
+ //xx=this->remove_key_mesh_wrap(QRegExp("FC*",true,true));
+ tmp=tmp.sprintf("GL%d FA",idom);
+ //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
+ xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
+ tmp=tmp.sprintf("GL%d VE",idom);
+ //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
+ xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
+
+ return ok;
+}
+
+//************************************
+bool ghs3dprl_mesh_wrap::idom_joints()
+{
+ bool ok=true;
+ QString tmp,namejoint,key,key1,key2;
+ CVWtab *tab,*tab1,*tab2;
+ med_int ineig,ii,jj,i,j,k,*arrayi,nb,famjoint,*fammore,*inodes,*arrayfaces;
+ med_float *arraynodes;
+ char namejnt[MED_TAILLE_NOM+1]; //no more 32
+ char namedist[MED_TAILLE_NOM+1];
+ char descjnt[MED_TAILLE_DESC+1];
+ med_int numfam_ini_wrap=100;
+ joints_node=xmlNewNode(NULL, BAD_CAST "joints"); //masterfile.xml
+ med_int nbjoints=0,nbnodesneig,nbtria3neig;
+ string sjoints=""; //which domains are neighbourg
+ int xx;
+
+ tmp=tmp.sprintf("MS%d *",idom);
+ //read file .msg if not done
+ //qt3 if (this->nb_key_mesh_wrap(QRegExp(tmp,true,true))<=0) {
+ if (this->nb_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp))<=0) {
+ this->nofile=idom;
+ /*old version with xml parser too slow
+ ghs3dprl_msg_parser handler;
+ handler.mailw=this;
+ QXmlSimpleReader reader;
+ reader.setContentHandler(&handler);
+ tmp=pathini+casename+tmp.sprintf(format,nbfilestot,idom)+".msg";
+ QFile File(tmp);
+ QXmlInputSource source(&File);
+ reader.parse(source);
+ File.close();*/
+ tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".msg";
+ ok=this->ReadFileMSGnew(tmp);
+ if (!ok) {
+ cerr<<"Problem in file "<<tmp.toLatin1().constData()<<endl;
+ return false;
+ }
+ }
+
+ //writing joints
+ for (ineig=1; ineig <= nbfilestot; ineig++) {
+ if (idom==ineig) continue; //impossible
+
+ //!*************nodes
+ //cout<<"\n nodes joints\n";
+ key1=key1.sprintf("MS%d NE%d VE SE",idom,ineig); //SE or RE?
+ tab1=restore_key(key1);
+ if (!tab1) continue; //case (ifile,ineig) are not neighbours=>no joints
+ key1=key1.sprintf("MS%d NE%d VE RE",idom,ineig); //SE or RE
+ tab2=tab1; //tab2=this->restore_key(key1); //no need because <send> equals <receive>
+ if (!tab2) cerr<<"Problem nodes joint <send> with no <receive> in file .msg"<<endl;
+ nb=tab1->size; nbnodesneig=nb;
+
+ nbjoints++; //one more joint for this domain
+ sjoints=sjoints+" "+i2a(ineig);
+ if (verbose>4)
+ cout<<"NumberOfNodesOfJoint_"<<idom<<"_"<<ineig<<"="<<nb<<endl;
+ namejoint=namejoint.sprintf("JOINT_%d_%d_Nodes",idom,ineig);
+ strcpy(namejnt,namejoint.toLatin1().constData());
+ tmp=tmp.sprintf("JOINT_%d_%d among %d domains of ",idom,ineig,nbfilestot)+nomfinal;
+ strcpy(descjnt,tmp.toLatin1().constData());
+ tmp=medname+tmp.sprintf("_%d",ineig);
+ strcpy(namedist,tmp.toLatin1().constData());
+ err=MEDjointCr(fid,nomfinal,namejnt,descjnt,ineig,namedist);
+ if (err<0) cerr<<"Problem MEDjointCr"<<endl;
+
+ ok=families.get_number_of_new_family(1,&famjoint,&tmp);
+ families.add(tmp,namejoint);
+
+ key=key.sprintf("NB%d VC",idom); //files.NoBoite Vertex Coordinates
+ tab=this->restore_key(key); //tab1=this->mestab[key1];
+ //nbnodes=tab->size/3;
+
+ //writing correspondence nodes-nodes
+ //two indices for one correspondence
+ arrayi=new med_int[nb*2];
+ arraynodes=new med_float[nbnodesneig*3]; //for file DOMAIN_join.med
+ inodes=new med_int[nbnodes]; //for file DOMAIN_join.med
+ med_int * fammore=new med_int[nbnodes];
+ for (i=0; i<nbnodes ; i++) {fammore[i]=0; inodes[i]=-1;}
+ ii=0; jj=0; k=0;
+ for (i=0; i<nb ; i++){
+ //no need because <send> equals <receive> tab1->tmint[i]==tab2->tmint[i]
+ j=tab1->tmint[i]-1; //contents of tab1 1 to nb
+ inodes[j]=k; k++; //indices 0->n-1 of nodes of joint from nodes of domain
+ arraynodes[jj]=tab->tmflo[j*3]; jj++;
+ arraynodes[jj]=tab->tmflo[j*3+1]; jj++;
+ arraynodes[jj]=tab->tmflo[j*3+2]; jj++;
+
+ fammore[j]=famjoint;
+ arrayi[ii]=tab1->tmint[i]; ii++;
+ arrayi[ii]=tab2->tmint[i]; ii++;
+ }
+ ok=set_one_more_family(famnodes,fammore,nbnodes);
+ delete[] fammore;
+
+ err=MEDjointEcr(fid,nomfinal,namejnt,arrayi,nb,
+ MED_NOEUD,MED_NONE,MED_NOEUD,MED_NONE);
+ if (err<0) cerr<<"Problem MEDjointEcr nodes"<<endl;
+ delete[] arrayi;
+
+ //!*************TRIA3
+ //writing correspondence triangles-triangles
+ //cout<<"\n faces joints\n";
+ nbtria3neig=0;
+ key1=key1.sprintf("MS%d NE%d FA SE",idom,ineig); //SE or RE?
+ tab1=this->restore_key(key1); //tab1=this->mestab[key1];
+ if (!tab1){
+ if (verbose>4)
+ cout<<"NumberOfTrianglesOfJoint_"<<idom<<"_"<<ineig<<"=0"<<endl;
+ //continue; //case (ifile,ineig) are not neighbours=>no joints
+ }
+ else //have to set xml may be no faces but nodes in a joint!
+ {
+ key1=key1.sprintf("MS%d NE%d FA RE",idom,ineig); //SE or RE?
+ tab2=tab1; //tab2=this->restore_key(key1); //no need because <send> equals <receive>
+ if (!tab2) cerr<<"Problem triangles joint send with no receive"<<endl;
+ namejoint=namejoint.sprintf("JOINT_%d_%d_Faces",idom,ineig);
+
+ ok=families.get_number_of_new_family(-1,&famjoint,&tmp);
+ families.add(tmp,namejoint);
+
+ key=key.sprintf("FC%d",idom); //files.FaCes faces (wrap and triangles only)
+ tab=this->restore_key(key); //tab1=this->mestab[key1];
+
+ med_int nb=tab1->size; nbtria3neig=nb;
+ if (verbose>4)
+ cout<<"NumberOfTrianglesOfJoint_"<<idom<<"_"<<ineig<<"="<<nb<<endl;
+ arrayi=new med_int[nb*2];
+ arrayfaces=new med_int[nbtria3neig*3]; //for file DOMAIN_join.med
+ fammore=new med_int[nbtria3];
+ for (i=0; i<nbtria3 ; i++) fammore[i]=0;
+ ii=0; jj=0;
+ for (i=0; i<nb ; i++){
+ //no need because <send> equals <receive> tab1->tmint[i]==tab2->tmint[i]
+ arrayi[ii]=tab1->tmint[i]; ii++;
+ fammore[tab1->tmint[i]-1]=famjoint;
+ //famtria3[tab1->tmint[i]-1]=famjoint;
+ arrayi[ii]=tab2->tmint[i]; ii++;
+ //cout<<arrayi[ii-1]<<"="<<arrayi[ii-2]<<endl;
+ k=(tab1->tmint[i]-1)*7; //indice of node connectivity
+ arrayfaces[jj]=inodes[tab->tmint[k]-1]+1; jj++;
+ arrayfaces[jj]=inodes[tab->tmint[k+1]-1]+1; jj++;
+ arrayfaces[jj]=inodes[tab->tmint[k+2]-1]+1; jj++;
+ }
+ ok=set_one_more_family(famtria3,fammore,nbtria3);
+ delete[] fammore;
+
+ err=MEDjointEcr(fid,nomfinal,namejnt,arrayi,nb,MED_MAILLE,MED_TRIA3,MED_MAILLE,MED_TRIA3);
+ if (err<0) cerr<<"Problem MEDjointEcr triangles"<<endl;
+ delete[] arrayi;
+ }
+
+ //!write in file resume DOMAIN.joints.med of all joints for quick display (...may be...)
+ if (idom<=ineig) { //no duplicate joint_1_2 and joint_2_1
+ //create mesh
+ namejoint=namejoint.sprintf("JOINT_%d_%d",idom,ineig);
+ charendnull(namejnt,namejoint,MED_TAILLE_NOM);
+ tmp=tmp.sprintf("joint between %d and %d",idom,ineig);
+ charendnull(descjnt,tmp,MED_TAILLE_DESC);
+ err=MEDmaaCr(fidjoint,namejnt,3,MED_NON_STRUCTURE,descjnt);
+ if (err<0) cerr<<"Problem MEDmaaCr "<<namejnt<<endl;
+ //write nodes
+ err=MEDcoordEcr(fidjoint,namejnt,3,arraynodes,MED_FULL_INTERLACE,
+ nbnodesneig,MED_CART,nomcoo,unicoo);
+ if (err<0) cerr<<"Problem MEDcoordEcr "<<namejnt<<endl;
+ arrayi=new med_int[nbnodesneig];
+ for (i=0; i<nbnodesneig ; i++) arrayi[i]=i+1;
+ err=MEDnumEcr(fidjoint,namejnt,arrayi,nbnodesneig,MED_NOEUD,MED_NONE);
+ delete[] arrayi;
+ if (err<0) cerr<<"Problem MEDnumEcr of nodes "<<namejnt<<endl;
+
+ //write tria3
+ if (nbtria3neig>0) {
+ //for (i=0; i<nbtria3neig ; i++) cout<<i+1<<" "<<
+ // arrayfaces[i*3]<<" "<<arrayfaces[i*3+1]<<" "<<arrayfaces[i*3+2]<<endl;
+ err=MEDconnEcr(fidjoint,namejnt,3,arrayfaces,MED_FULL_INTERLACE,
+ nbtria3neig,MED_MAILLE,MED_TRIA3,MED_NOD);
+ if (err<0) cerr<<"Problem MEDconnEcr for triangles connectivity "<<namejnt<<endl;
+ //writing indices of faces triangles of joint
+ arrayi=new med_int[nbtria3neig];
+ for (i=0; i<nbtria3neig ; i++) arrayi[i]=i+1;
+ err=MEDnumEcr(fidjoint,namejnt,arrayi,nbtria3neig,MED_MAILLE,MED_TRIA3);
+ delete[] arrayi;
+ if (err<0) cerr<<"Problem MEDnumEcr of triangles "<<namejnt<<endl;
+ }
+ }
+
+ delete[] arraynodes;
+ if (nbtria3neig>0) delete[] arrayfaces;
+ delete[] inodes;
+
+ //!masterfile.xml
+ node=xmlNewChild(joints_node, 0, BAD_CAST "joint", 0);
+ xmlNewProp(node, BAD_CAST "id", BAD_CAST i2a(ineig).c_str());
+ xmlNewProp(node, BAD_CAST "nodes_number", BAD_CAST i2a(nbnodesneig).c_str());
+ xmlNewProp(node, BAD_CAST "faces_number", BAD_CAST i2a(nbtria3neig).c_str());
+ //node2 = xmlNewChild(node, 0, BAD_CAST "nodes", 0);
+ //xmlNewProp(node2, BAD_CAST "number", BAD_CAST i2a(nbnodesneig).c_str());
+ //node2 = xmlNewChild(node, 0, BAD_CAST "faces", 0);
+ //xmlNewProp(node2, BAD_CAST "number", BAD_CAST i2a(nbtria3neig).c_str());
}
- err=MEDjointEcr(fid,namelocal,namejnt,arrayi,nbtriangles,MED_FACE,MED_TRIA3,MED_FACE,MED_TRIA3);
- if (err<0) std::cerr<<"Problem MEDjointEcr triangles"<<std::endl;
+
+ //masterfile.xml
+ xmlNewProp(joints_node, BAD_CAST "number", BAD_CAST i2a(nbjoints).c_str());
+ xmlNewChild(joints_node, 0, BAD_CAST "id_neighbours", BAD_CAST sjoints.substr(1).c_str());
+
+ tmp=tmp.sprintf("NB%d VC",idom);
+ //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
+ xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
+ tmp=tmp.sprintf("MS%d NE*",idom);
+ //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
+ xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
+ tmp=tmp.sprintf("FC%d",idom);
+ //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
+ xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
+ tmp=tmp.sprintf("GL%d *",idom);
+ //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
+ xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
+ return ok;
+}
+
+//************************************
+bool ghs3dprl_mesh_wrap::idom_tetras()
+{
+ bool ok=true;
+ QString tmp,key1;
+ CVWtab *tab1;
+ med_int i,*arrayi;
+ int xx;
+
+ //writing connectivity of tetrahedra by nodes
+ key1=key1.sprintf("NB%d EV",idom); //files.NoBoite Elements Vertices (tetra only)
+ tab1=this->restore_key(key1); //tab1=this->mestab[key1];
+ nbtetra4=tab1->size/4;
+ nbtetrastotal=nbtetrastotal + nbtetra4;
+ if (verbose>5)cout<<"NumberOftetrahedra="<<nbtetra4<<endl;
+ err=MEDconnEcr(fid,nomfinal,3,tab1->tmint,MED_FULL_INTERLACE,nbtetra4,MED_MAILLE,MED_TETRA4,MED_NOD);
+ if (err<0){cerr<<"Problem MEDconnEcr for tetra connectivity"<<endl; return false;}
+
+ //writing indices of tetrahedra
+ arrayi=new med_int[nbtetra4];
+ for (i=0; i<nbtetra4 ; i++) arrayi[i]=nbseg2+nbtria3+i+1;
+ //for (i=0; i<nbtria3 ; i++) cout<<i<<" "<<arrayi[i]<<endl;
+ err=MEDnumEcr(fid,nomfinal,arrayi,nbtetra4,MED_MAILLE,MED_TETRA4);
delete[] arrayi;
-
- tmp=tmp.sprintf("JOINT_%d",ineig);
- strcpy(nomfam,tmp.toLatin1().constData());
-
- //err=MEDnumEcr(fid,nomfam,arrayi,nbtriangles,MED_FACE,MED_TRIA3);
- //if (err<0) std::cerr<<"Problem MEDnumEcr of triangles of "<<nomfam<<std::endl;
-
- //char gro[MED_TAILLE_LNOM+1]="PART_OF_GLOBAL_WRAP_PLUS_JOINTS";
- strcpy(gro,tmp.toLatin1().constData());
- /*char gro[MED_TAILLE_LNOM*2+1];
- strcpy(gro,"PART_OF_GLOBAL_WRAP_PLUS_JOINTS ");
- for (int i=32;i<MED_TAILLE_LNOM;i++) gro[i]=' ';
- gro[MED_TAILLE_LNOM]='\0';
- strcat(gro,tmp);
- //for (i=7;i<MED_TAILLE_LNOM;i++) gro[MED_TAILLE_LNOM+i]=' ';
- //gro[2*MED_TAILLE_LNOM]='\0';*/
-
- tmp=tmp.sprintf("joint of neighbourg_%d on local wrap",ineig);
- strcpy(attdes,tmp.toLatin1().constData());
- numfam=-numfam_ini_wrap-ineig;
- //attide=1;
- attval=numfam;
- //natt=1;
- ngro=1;
- if (this->verbose>2)
- std::cout<<"CreateFamilyOfFaces_"<<nomfam<<std::endl;
- if (this->verbose>4) std::cout<<"MEDfamCr (faces) of "<<nomfam<<" / "<<attdes<<" / FamilyNumber="<<numfam<<std::endl;
-
- err=MEDfamCr(fid,namelocal,nomfam,numfam,&attide,&attval,attdes,natt,gro,ngro);
- if (err<0) std::cerr<<"Problem MEDfamCr of "<<nomfam<<std::endl;
+ if (err<0){cerr<<"Problem MEDnumEcr of tetrahedra"<<endl; return false;}
- }
- //writing indices of families of faces triangles of wrap = joint<-100 or not=100?
- //arrayi=new med_int[nbtriangles];
- //families known in faces in wrap
- //for (int i=0; i<nbtriangles ; i++) arrayi[i]=-100-ineig; //tab1->tlong[(i*7)+3];
- err=MEDfamEcr(fid,namelocal,familiesi,sizefamilies,MED_FACE,MED_TRIA3);
- if (err<0) std::cerr<<"Problem MEDfamEcr faces of all joints"<<std::endl;
- delete[] familiesi;
-
- MEDfermer(fid);
-
- //examples of test of med files ( ... for me!)
- //../Salome_321/med_231_install/bin/medconforme exemple11.med
- //../Salome_321/hdf5-1.6.3/bin/h5dump exemple11.med
- //../Salome_321/med_231_install/bin/mdump exemple11.med
- }
- std::cout<<"\nTotalNumberOfTetraedes="<<nbtetrastotal<<std::endl;
- return ok;
+ famtetra4=new med_int[nbtetra4];
+ for (i=0; i<nbtetra4 ; i++) famtetra4[i]=famnewtetra4;
+
+ //writing tetrahedra global numbering
+ //GLx EL=files.GLo ELements
+ key1=key1.sprintf("GL%d EL",idom);
+ tab1=this->restore_key(key1); //tab1=this->mestab[key1];
+ if (!tab1) {
+ tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".glo";
+ ok=this->ReadFileGLO(tmp);
+ tab1=this->restore_key(key1);
+ if (!tab1) return false;
+ }
+
+ if (tab1->size!=nbtetra4){
+ cerr<<"Problem incorrect size of tetrahedra global numbering"<<endl; return false;}
+ if (verbose>2)
+ cout<<"CreateMEDglobalNumerotation_tetrahedra "<<key1.toLatin1().constData()<<" "<<tab1->size<<endl;
+ err=MEDglobalNumEcr(fid,nomfinal,tab1->tmint,tab1->size,MED_MAILLE,MED_TETRA4);
+ if (err<0){cerr<<"Problem MEDglobalNumEcr tetrahedra"<<endl; return false;}
+
+ tmp=tmp.sprintf("NB%d EV",idom);
+ //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
+ xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
+ return ok;
}
+//************************************
+med_int ghs3dprl_mesh_wrap::create_families(med_idt fid, int sign)
+//if sign < 0 families faces or tria3 etc...
+//if sign >= 0 family zero and family nodes
+{
+ med_int pas,ires;
+ char nomfam[MED_TAILLE_NOM+1]; //it.current()->name;
+ char attdes[MED_TAILLE_DESC+1]="_NO_DESCRIPTION";
+ char *gro;
+ med_int i,attide=1,attval=1,natt=1,num,ngro;
+
+ if (sign>=0) pas=1; else pas=-1;
+ ires=0;
+ fend gb;
+ fagr::iterator it1;
+ fend::iterator it2;
+ for (it1=families.fam.begin(); it1!=families.fam.end(); ++it1){
+ num=(*it1).first.toLong();
+ if ((pas==-1) && (num>=0)) continue; //not good families
+ if ((pas== 1) && (num< 0)) continue; //not good families
+ charendnull(nomfam,(*it1).first,MED_TAILLE_NOM);
+ ires++;
+ //med_int natt=0;
+ ngro=(*it1).second.size();
+ if (verbose>5)
+ cout<<"CreateFamilyInMEDFile <"<<nomfam<<">\tNbGroups="<<ngro;
+ gro=new char[MED_TAILLE_LNOM*ngro+2];
+ gb=(*it1).second;
+ i=0;
+ for (it2=gb.begin(); it2!=gb.end(); ++it2){
+ charendnull(&gro[i*MED_TAILLE_LNOM],(*it2).first,MED_TAILLE_LNOM);
+ if (verbose>5)cout<<" <"<<&gro[i*MED_TAILLE_LNOM]<<"> ";
+ i++;
+ }
+ if (verbose>5)cout<<endl;
+ err=MEDfamCr(fid,nomfinal,nomfam,num,NULL,NULL,NULL,0,gro,ngro);
+ //&attide,&attval,attdes,natt,gro,ngro);
+ if (err<0) cerr<<"Problem MEDfamCr"<<endl;
+ delete[] gro;
+ if (err<0) cerr<<"Problem MEDfamCr of "<<nomfam<<endl;
+ }
+ return ires;
+}
+
+
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// ---
// File : tepal2med.cxx
-// Author : Christian VAN WAMBEKE (CEA) (from Hexotic plugin Lioka RAZAFINDRAZAKA)
+// Author : Christian VAN WAMBEKE (CEA)
// ---
-//
+
/*
-** prog principal de test de ghs3dprl
+** prog principal de ghs3dprl
*/
#include <stdio.h> /* printf clrscr fopen fread fwrite fclose */
#include <string>
#include <cstring>
#include <iostream>
+#include <sstream>
#include <fstream>
#include <qstring.h>
#include "ghs3dprl_msg_parser.h"
#include "dlg_ghs3dmain.h"
+//#include "MEDMEM_Exception.hxx"
+//#include "MEDMEM_define.hxx"
+
+extern "C" {
+#include <med.h>
+//#include <med_config.h>
+#include <med_utils.h>
+//#include <med_misc.h>
+#include <stdlib.h>
+}
+
+using namespace std;
using namespace med_2_2;
//************************************
-int main(int argc, char **argv)
+med_idt ouvre_fichier_MED(char *fichier,int verbose)
{
- bool ok,is_test,is_menu,is_launchtepal;
- int nbfiles,nbelem_limit_swap,verbose;
- QString casename,casenamemed,tmp,cmd,format;
- QString version="V0.2 beta";
-
- if ((argc > 11)||(argc < 2))
- {
- std::cerr<<"tepal2med "<<version.toLatin1().constData()<<std::endl;
- std::cerr<<"Usage: "<<argv[0]<<" CaseNameTepal NumberOfFiles [LimitSwap] [Verbose[0->6]] [Test|noTest] [Menu|noMenu] [LaunchTepal|noLaunchTepal] CaseNameMed\n";
- return 1;
- }
- casename=argv[1];
- tmp=argv[2];
- nbfiles=tmp.toLong(&ok,10);
- if (!ok)
- {
- std::cerr<<"NumberOfFiles: an integer is expected\n\n";
- return 1;
- }
- if (nbfiles<=0)
- {
- std::cerr<<"NumberOfFiles: a positive integer is expected\n\n";
- return 1;
- }
- if (nbfiles>512) //delirium in 2007
- {
- std::cerr<<"NumberOfFiles: a positive integer <= 512 is expected\n\n";
- return 1;
+ med_idt fid = 0;
+ med_err ret = 0;
+ med_int majeur,mineur,release;
+
+ /* on regarde si le fichier existe */
+ ret = (int) access(fichier,F_OK);
+ if (ret < 0) return fid;
+
+ /* on regarde s'il s'agit d'un fichier au format HDF5 */
+ ret = MEDformatConforme(fichier);
+ if (ret < 0){
+ cerr<<"File "<<fichier<<" not HDF V5 formatted\n";
+ return fid;
}
+
+ /* Quelle version de MED est utilise par mdump ? */
+ MEDversionDonner(&majeur,&mineur,&release);
+ if (verbose>0)fprintf(stdout,"\nReading %s with MED V%d.%d.%d",
+ fichier,majeur,mineur,release);
+
+ /* Ouverture du fichier MED en lecture seule */
+ fid = MEDouvrir(fichier,MED_LECTURE);
+ if (ret < 0) return fid;
+
+ MEDversionLire(fid, &majeur, &mineur, &release);
+ if (majeur < 2 || majeur == 2 && mineur < 2) {
+ fprintf(stderr,"File %s from MED V%d.%d.%d not assumed\n",
+ fichier,majeur,mineur,release);
+ //" version est antérieure à la version 2.2";
+ ret = MEDfermer(fid);
+ fid=0; }
+ else {
+ if (verbose>0)fprintf(stdout,", file from MED V%d.%d.%d\n",majeur,mineur,release); }
+
+ return fid;
+}
+
+//************************************
+bool ReadFileMED(QString nomfilemed,ghs3dprl_mesh_wrap *mymailw)
+{
+ med_err ret;
+ med_idt fid=0;
+ med_int i,j,mdim,nmaa,edim,majeur_lu,mineur_lu,release_lu,nprofils;
+ med_maillage type_maillage;
+ int numero=1;
+ med_connectivite typ_con=MED_NOD;
+ QString key,tmp;
+
+ //version qt3
+ char chaine[nomfilemed.length()+1];
+ strncpy(chaine,nomfilemed.toLatin1().constData(),nomfilemed.length()+1);
+ //cout<<"*** ReadFileMED *** "<<chaine<<"\n";
+
+ /*version qt4
+ char chaine[nomfilemed.length() + 1];
+ strncpy(chaine, nomfilemed.toStdString().c_str(), nomfilemed.length());
+ //?chaine[nomfilemed.length()]= '\0';
+ cout<<"fichier "<<chaine<<"\n";*/
+
+ //char *pt=chaine;
+ fid=ouvre_fichier_MED(chaine,mymailw->verbose);
+ if (fid == 0) {
+ cerr<<"Problem opening file "<<nomfilemed.toLatin1().constData()<<"\n";
+ //ret = MEDfermer(fid);
+ return false;
+ }
+
+ nmaa = MEDnMaa(fid);
+ if (nmaa <= 0){
+ cerr<<"No meshes in "<<nomfilemed.toLatin1().constData()<<"\n";
+ ret = MEDfermer(fid);
+ return false;
+ }
+ if (nmaa > 1) cout<<"More than one mesh in "<<nomfilemed.toLatin1().constData()<<", first one taken\n";
+ ret = MEDmaaInfo(fid,numero,mymailw->nommaa,&mdim,&type_maillage,
+ mymailw->maillage_description);
+ if (ret < 0){
+ cerr<<"Problem MEDmaaInfo in "<<nomfilemed.toLatin1().constData()<<"\n";
+ ret = MEDfermer(fid);
+ return false;
+ }
+ if (mdim != 3){
+ cerr<<"Problem dimension mesh should be 3: "<<mdim<<"\n";
+ ret = MEDfermer(fid);
+ return false;
+ }
+ edim = MEDdimEspaceLire(fid,mymailw->nommaa);
+ if (!((edim == 3)||(edim == -1))){
+ cerr<<"Problem dimension Espace should be 3 or -1: "<<edim<<"\n";
+ ret = MEDfermer(fid);
+ return false;
+ }
+ if (type_maillage != MED_NON_STRUCTURE){
+ cerr<<"Problem type mesh should be MED_NON_STRUCTURE: "<<type_maillage<<endl;
+ ret = MEDfermer(fid);
+ return false;
+ }
+
+ //lecture nb de noeuds
+ med_int nnoe=MEDnEntMaa(fid,mymailw->nommaa,MED_COOR,MED_NOEUD,
+ (med_geometrie_element)0,(med_connectivite)0);
+ if (nnoe<1){
+ cerr<<"Problem number of Vertices < 1\n";
+ ret = MEDfermer(fid);
+ return false;
+ }
+
+ //nombre d'objets MED : mailles, faces, aretes , ...
+ med_int nmailles[MED_NBR_GEOMETRIE_MAILLE],nbtria3;
+ med_int nfaces[MED_NBR_GEOMETRIE_FACE];
+ med_int naretes[MED_NBR_GEOMETRIE_ARETE],nbseg2;
+ //polygones et polyedres familles equivalences joints
+ med_int nmpolygones,npolyedres,nfpolygones,nfam,nequ,njnt;
+
+ //Combien de mailles, faces ou aretes pour chaque type geometrique ?
+ /*for (i=0;i<MED_NBR_GEOMETRIE_MAILLE;i++){
+ nmailles[i]=MEDnEntMaa(fid,mymailw->nommaa,MED_CONN,MED_MAILLE,typmai[i],typ_con);
+ //lecture_nombre_mailles_standards(fid,nommaa,typmai[i],typ_con,i);
+ if (mymailw->verbose>6) cout<<"NumberOf"<<nommai[i]<<"="<<nmailles[i]<<endl;
+ }*/
+ nbtria3=MEDnEntMaa(fid,mymailw->nommaa,MED_CONN,MED_MAILLE,MED_TRIA3,typ_con);
+ nbseg2=MEDnEntMaa(fid,mymailw->nommaa,MED_CONN,MED_MAILLE,MED_SEG2,typ_con);
+
+ //Combien de mailles polygones quelconques ?
+ //nmpolygones = lecture_nombre_mailles_polygones(fid,nommaa,typ_con);
+ //Combien de mailles polyedres quelconques ?
+ //npolyedres = lecture_nombre_mailles_polyedres(fid,nommaa,typ_con);
+
+ //combien de familles ?
+ nfam=MEDnFam(fid,mymailw->nommaa);
+ if (mymailw->verbose>2) {
+ cout<<"\nNumberOfFamilies="<<nfam<<endl;
+ cout<<"NumberOfVertices="<<nnoe<<endl;
+ cout<<"NumberOfMED_SEG2="<<nbseg2<<endl;
+ cout<<"NumberOfMED_TRIA3="<<nbtria3<<"\n\n";
+ }
+ if (nbtria3<3){
+ cerr<<"Problem number of MED_TRIA3 < 3, not a skin of a volume\n";
+ ret = MEDfermer(fid);
+ return false;
+ }
+
+med_int famdelete[nfam],ifamdelete=0,idelete;
+{
+ med_int natt,ngro;
+ char *attdes,*gro;
+ med_int *attval,*attide;
+ char nomfam[MED_TAILLE_NOM+1];
+ med_int numfam;
+ char str1[MED_TAILLE_DESC+1];
+ char str2[MED_TAILLE_LNOM+1];
+ med_err ret = 0;
- //default 1GOctet/8(for double)/10(for arrays in memory at the same time)
- nbelem_limit_swap=1000000000/8/10;
- if (argc > 3)
- {
- tmp=argv[3];
- nbelem_limit_swap=tmp.toLong(&ok,10);
- if (!ok)
- {
- std::cerr<<"LimitSwap: an integer is expected\n\n";
- return 1;
+ for (i=0;i<nfam;i++) famdelete[i]=0;
+ for (i=0;i<nfam;i++) {
+
+ //nombre de groupes
+ ngro = MEDnGroupe(fid,mymailw->nommaa,i+1);
+ if (ngro < 0){
+ cerr<<"Problem reading number of groups of family\n";
+ continue;
}
- if (nbelem_limit_swap<=0)
- {
- std::cerr<<"LimitSwap: a positive integer is expected\n\n";
- return 1;
+
+ //nombre d'attributs
+ natt = MEDnAttribut(fid,mymailw->nommaa,i+1);
+ if (natt < 0){
+ cerr<<"Problem reading number of attributes of family\n";
+ continue;
}
- }
-
- verbose=1; //default
- if (argc > 4)
- {
- tmp=argv[4];
- verbose=tmp.toLong(&ok,10);
- if (!ok)
- {
- std::cerr<<"Verbose: an integer is expected\n\n";
- return 1;
+
+ //nom,numero,attributs,groupes
+ //allocation memoire par exces
+ attide = (med_int*) malloc(sizeof(med_int)*(natt+1));
+ attval = (med_int*) malloc(sizeof(med_int)*(natt+1));
+ attdes = (char *) malloc(MED_TAILLE_DESC*(natt+1));
+ gro = (char*) malloc(MED_TAILLE_LNOM*(ngro+1));
+
+ ret = MEDfamInfo(fid,mymailw->nommaa,i+1,nomfam,&numfam,attide,attval,
+ attdes,&natt,gro,&ngro);
+ if (ret < 0){
+ cerr<<"Problem reading informations of family\n";
+ continue;
}
- if (verbose<0)
- {
- std::cerr<<"Verbose: a positive integer is expected\n\n";
- return 1;
+
+ if (mymailw->verbose>8) {
+ cout<<"Family "<<numfam<<" have "<<natt<<" attributes and "<<ngro<<" groups\n";
+ //affichage des resultats
+ for (j=0;j<natt;j++) {
+ if (j==0) cout<<" Attributes :\n";
+ strncpy(str1,attdes+j*MED_TAILLE_DESC,MED_TAILLE_DESC);
+ str1[MED_TAILLE_DESC] = '\0';
+ fprintf(stdout," ident = %d\t value = %d\t description = %s\n",
+ *(attide+j),*(attval+j),str1);
+ }
+ for (j=0;j<ngro;j++) {
+ if (j==0) cout<<" Groups :\n";
+ strncpy(str2,gro+j*MED_TAILLE_LNOM,MED_TAILLE_LNOM);
+ str2[MED_TAILLE_LNOM] = '\0';
+ fprintf(stdout," name = %s\n",str2);
+ }
+ if (i==nfam-1) cout<<endl;
}
+ QString sfam,sgro;
+ sfam=sfam.sprintf("%d",numfam);
+ idelete=0;
+ for (j=0;j<ngro;j++){
+ strncpy(str2,gro+j*MED_TAILLE_LNOM,MED_TAILLE_LNOM);
+ str2[MED_TAILLE_LNOM]='\0';
+ sgro=str2;
+ if (sgro.contains(mymailw->deletegroups)>0) {
+ //cout<<"idelete++ "<<sgro<<endl;
+ idelete++;
+ }
+ }
+
+ if (idelete==ngro && ngro>0) { //only delete family whith all delete groups
+ //cout<<"famdelete++ "<<numfam<<" "<<ifamdelete<<" "<<ngro<<endl;
+ famdelete[ifamdelete]=numfam;
+ ifamdelete++;
+ }
+
+ else {
+ for (j=0;j<ngro;j++){
+ strncpy(str2,gro+j*MED_TAILLE_LNOM,MED_TAILLE_LNOM);
+ str2[MED_TAILLE_LNOM]='\0';
+ sgro=str2;
+ QRegExp qgroup=QRegExp("Group_Of_All",Qt::CaseSensitive,QRegExp::RegExp);
+ if (sgro.contains(mymailw->deletegroups)==0){
+ if (sgro.contains(qgroup)>0) {
+ sgro="Skin_"+sgro; //pas sur que ce soit pertinent
+ }
+ if (mymailw->verbose>8) cout<<"families.add("<<sfam.toLatin1().constData()<<
+ ","<<sgro.toLatin1().constData()<<")\n";
+ mymailw->families.add(sfam,sgro);
+ }
+ else {
+ //sgro="Skin_"+sgro; //pas sur que ce soit pertinent
+ //cout<<"--deletegroups matches \""<<sfam<<","<<sgro<<"\"\n";
+ if (mymailw->verbose>3) cout<<"--deletegroups matches \""<<
+ sgro.toLatin1().constData()<<
+ "\" in family "<<numfam<<endl;
+ }
+ }
+ }
+
+ /*for (j=0;j<ngro;j++){
+ strncpy(str2,gro+j*MED_TAILLE_LNOM,MED_TAILLE_LNOM);
+ str2[MED_TAILLE_LNOM]='\0';
+ sgro=str2;
+ //cout<<"families.add("<<sfam<<","<<sgro<<")\n";
+ if (sgro.contains(mymailw->deletegroups)==0){
+ //sgro="Skin_"+sgro; //pas sur que ce soit pertinent
+ cout<<"families.add("<<sfam<<","<<sgro<<")\n";
+ mymailw->families.add(sfam,sgro);
+ }
+ else {
+ cout<<"--deletegroups matches \""<<sgro<<"\"\n";
+ famdelete[ifamdelete]=numfam
+ ifamdelete++;
+ }
+ }*/
+
+ //on libere la memoire
+ free(attide);
+ free(attval);
+ free(attdes);
+ free(gro);
}
+}
+
+//cout<<"famdelete"; for (j=0;j<ifamdelete;j++) cout<<" "<<famdelete[j]; cout<<endl;
+
+if (mymailw->verbose>3){
+ cout<<"\nFamiliesAndGroupsOf "<<nomfilemed.toLatin1().constData()<<endl;
+ mymailw->families.write();
+}
+
+ med_repere rep;
+ med_mode_switch mode_coo=MED_FULL_INTERLACE;
- is_test=false; //default
- if (argc > 5)
- {
- tmp=argv[5];
- if (tmp=="Test") is_test=true;
- }
-
- is_menu=false; //default
- if (argc > 6)
- {
- tmp=argv[6];
- if (tmp=="Menu") is_menu=true;
- }
-
- is_launchtepal=false; //default
- if (argc > 7)
- {
- tmp=argv[7];
- if (tmp=="LaunchTepal") is_launchtepal=true;
- }
-
- casenamemed=casename;
- if (argc > 8)
- {
- casenamemed=argv[8];
+ /* Allocations memoires */
+ /* table des coordonnees profil : (dimension * nombre de noeuds ) */
+ med_float *coo=new med_float[nnoe*mdim];
+ /* table des numeros de familles des noeuds profil : (nombre de noeuds) */
+ med_int *famnodesskin=new med_int[nnoe];
+ med_int *pfltab=new med_int[1]; //inutilise car on lit tout
+ //lecture des noeuds : coordonnees
+ ret=MEDcoordLire(fid,mymailw->nommaa,mdim,coo,
+ mode_coo,MED_ALL,
+ pfltab,0,&rep,mymailw->nomcoo,mymailw->unicoo);
+ if (ret < 0){
+ cerr<<"Problem reading nodes\n";
+ ret = MEDfermer(fid);
+ //return false;
+ }
+ ret=MEDfamLire(fid,mymailw->nommaa,famnodesskin,nnoe,MED_NOEUD,(med_geometrie_element) 0);
+ if (ret < 0){
+ cerr<<"Problem reading families of nodes\n";
+ ret = MEDfermer(fid);
+ return false;
+ }
+ if (mymailw->verbose>9) {
+ cout<<"\nVertices: no x y z family\n";
+ for (i=0;i<nnoe*mdim;i=i+3) {
+ fprintf(stdout,"%5d %13.5e %13.5e %13.5e %5d \n",
+ (i/3+1), coo[i], coo[i+1], coo[i+2], famnodesskin[i/3]);
+ }
+ cout<<endl;
+ }
+
+ med_int *conn2=new med_int[nbseg2*2];
+ ret=MEDconnLire(fid,mymailw->nommaa,mdim,conn2,mode_coo,
+ pfltab,0,MED_MAILLE,MED_SEG2,MED_NOD);
+ if (ret < 0){
+ cerr<<"Problem reading MED_SEG2\n";
+ ret = MEDfermer(fid);
+ //return false;
+ }
+ med_int *famseg2skin=new med_int[nbseg2];
+ ret=MEDfamLire(fid,mymailw->nommaa,famseg2skin,nbseg2,MED_MAILLE,MED_SEG2);
+ if (ret < 0){
+ cerr<<"Problem reading families of MED_SEG2\n";
+ ret = MEDfermer(fid);
+ return false;
+ }
+ if (mymailw->verbose>9) {
+ cout<<"\nConnectivity MED_SEG2: no node1 node2 family\n";
+ for (i=0;i<nbseg2*2;i=i+2) {
+ fprintf(stdout,"%5d %5d %5d %5d \n",
+ (i/2+1), conn2[i], conn2[i+1], famseg2skin[i/2]);
+ }
+ cout<<endl;
+ }
+
+ med_int *conn3=new med_int[nbtria3*3];
+ ret=MEDconnLire(fid,mymailw->nommaa,mdim,conn3,mode_coo,
+ pfltab,0,MED_MAILLE,MED_TRIA3,MED_NOD);
+ if (ret < 0){
+ cerr<<"Problem reading MED_TRIA3\n";
+ ret = MEDfermer(fid);
+ //return false;
+ }
+ med_int *famtria3skin=new med_int[nbtria3];
+ ret=MEDfamLire(fid,mymailw->nommaa,famtria3skin,nbtria3,MED_MAILLE,MED_TRIA3);
+ if (ret < 0){
+ cerr<<"Problem reading families of MED_TRIA3\n";
+ ret = MEDfermer(fid);
+ return false;
+ }
+ if (mymailw->verbose>9) {
+ cout<<"\nConnectivity MED_TRIA3: no node1 node2 node3 family\n";
+ for (i=0;i<nbtria3*3;i=i+3) {
+ fprintf(stdout,"%5d %5d %5d %5d %5d \n",
+ (i/3+1), conn3[i], conn3[i+1], conn3[i+2], famtria3skin[i/3]);
+ }
+ cout<<endl;
+ }
+
+ /*liberation memoire?
+ delete[] coo;
+ delete[] nomnoe;
+ delete[] numnoe;
+ delete[] nufano;*/
+
+ if (ifamdelete>0) {
+ //cout<<"!!!!!!!!nodes "<<famnodesskin[0]<<" "<<nnoe<<famdelete[1]<<endl;
+ for (i=0;i<nnoe;i++) {
+ for (j=0;j<ifamdelete;j++) {
+ if (famnodesskin[i]==famdelete[j]) {
+ //cout<<"nodes "<<famnodesskin[i]<<" "<<i<<" "<<famdelete[j]<<endl;
+ famnodesskin[i]=0; }
+ }
+ }
+ for (i=0;i<nbseg2;i++) {
+ for (j=0;j<ifamdelete;j++) {
+ if (famseg2skin[i]==famdelete[j]) famseg2skin[i]=0;
+ }
+ }
+ for (i=0;i<nbtria3;i++) {
+ for (j=0;j<ifamdelete;j++) {
+ if (famtria3skin[i]==famdelete[j]) famtria3skin[i]=0;
+ }
+ }
}
-
- // We must always have an application
- if (is_menu)
- {
+ //stocks data for future use
+ CVWtab *montab;
+ bool ok;
+
+ montab=new CVWtab(nnoe*mdim,coo);
+ tmp="SKIN_VERTICES_COORDINATES";
+ ok=mymailw->insert_key(tmp,montab);
+
+ montab=new CVWtab(nnoe,famnodesskin);
+ tmp="SKIN_VERTICES_FAMILIES";
+ ok=mymailw->insert_key(tmp,montab);
+
+ montab=new CVWtab(nbseg2*2,conn2);
+ tmp="SKIN_SEG2_CONNECTIVITIES";
+ ok=mymailw->insert_key(tmp,montab);
+
+ montab=new CVWtab(nbtria3,famseg2skin);
+ tmp="SKIN_SEG2_FAMILIES";
+ ok=mymailw->insert_key(tmp,montab);
+
+ montab=new CVWtab(nbtria3*3,conn3);
+ tmp="SKIN_TRIA3_CONNECTIVITIES";
+ ok=mymailw->insert_key(tmp,montab);
+
+ montab=new CVWtab(nbtria3,famtria3skin);
+ tmp="SKIN_TRIA3_FAMILIES";
+ ok=mymailw->insert_key(tmp,montab);
+
+ //if (mymailw->verbose>6) ok=mymailw->list_keys_mesh_wrap();
+
+ ret = MEDfermer(fid);
+ if (ret < 0){
+ cerr<<"Problem closing "<<nomfilemed.toLatin1().constData()<<"\n";
+ return false;
+ }
+ return true;
+}
+
+/*
+//************************************
+string char2string(char *d, int lg)
+{
+ string fin;
+ for (int i=0;i<lg-1;i++){
+ fin=fin+d[i];
+ }
+ return fin;
+}
+
+//************************************
+bool string2int(const string &s, int *v)
+//string s=argv[1] ; int ii;
+//ok=string2int(s,&ii);
+//cout<<"test "<<ii<<" "<<ok<<endl;
+{
+ string splus=s + " -1"; //evite conversion ok sur "+9truc" qui passe sinon
+ istringstream ss(splus);
+ int v2;
+ if (ss >> *v >> v2) return true; else {*v=0 ;return false;}
+}
+
+//************************************
+bool string2float(const string &s, float *v)
+//float ff;
+//ok=string2float(s,&ff);
+//cout<<"test3 "<<ff<<" "<<ok<<endl;
+{
+ string splus=s + " -1"; //evite conversion ok sur "+9truc" qui passe sinon
+ istringstream ss(splus);
+ float v2;
+ if (ss >> *v >> v2) return true; else {*v=0. ;return false;}
+}
+
+//************************************
+string int2string(const int &v)
+{
+ ostringstream ss;
+ ss<<v;
+ return ss.str();
+}
+
+//************************************
+string float2string(const float &v)
+{
+ ostringstream ss;
+ ss<<v;
+ return ss.str();
+}
+*/
+
+//************************************
+int main(int argc, char *argv[])
+{
+ bool ok;
+ int i,nb,nbfiles,limit_swap,nbelem_limit_swap,limit_swap_defaut,verbose;
+ QString path,pathini,casename,casenamemed,fileskinmed,
+ tmp,cmd,format,
+ test,menu,launchtepal,background,deletegroups,
+ version="V1.4";
+
+ char *chelp=NULL,
+ *ccasename=NULL,
+ *cnumber=NULL,
+ *cmedname=NULL,
+ *climitswap=NULL,
+ *cverbose=NULL,
+ *ctest=NULL,
+ *cmenu=NULL,
+ *claunchtepal=NULL,
+ *cbackground=NULL,
+ *cdeletegroups=NULL;
+
+ for (i = 0; i < argc; i++){
+ if (!strncmp (argv[i], "--help", sizeof ("--help"))) chelp = &(argv[i][0]);
+ else if (!strncmp (argv[i], "--casename=", sizeof ("--casename"))) ccasename = &(argv[i][sizeof ("--casename")]);
+ else if (!strncmp (argv[i], "--number=", sizeof ("--number"))) cnumber = &(argv[i][sizeof ("--number")]);
+ else if (!strncmp (argv[i], "--medname=", sizeof ("--medname"))) cmedname = &(argv[i][sizeof ("--medname")]);
+ else if (!strncmp (argv[i], "--limitswap=", sizeof ("--limitswap"))) climitswap = &(argv[i][sizeof ("--limitswap")]);
+ else if (!strncmp (argv[i], "--verbose=", sizeof ("--verbose"))) cverbose = &(argv[i][sizeof ("--verbose")]);
+ else if (!strncmp (argv[i], "--test=", sizeof ("--test"))) ctest = &(argv[i][sizeof ("--test")]);
+ else if (!strncmp (argv[i], "--menu=", sizeof ("--menu"))) cmenu = &(argv[i][sizeof ("--menu")]);
+ else if (!strncmp (argv[i], "--launchtepal=", sizeof ("--launchtepal"))) claunchtepal = &(argv[i][sizeof ("--launchtepal")]);
+ else if (!strncmp (argv[i], "--background=", sizeof ("--background"))) cbackground = &(argv[i][sizeof ("--background")]);
+ else if (!strncmp (argv[i], "--deletegroups=", sizeof ("--deletegroups"))) cdeletegroups = &(argv[i][sizeof ("--deletegroups")]);
+ }
+
+ if (argc < 2 || chelp){
+ cout<<"Available options:\n"
+ " --help : produces this help message\n"<<
+ " --casename : path and name of input tepal2med files which are\n"<<
+ " - output files of tepal .msg .noboite .faces .points .glo\n"<<
+ " - output file of GHS3DPRL_Plugin casename_skin.med (optional)\n"<<
+ " with initial skin and its initial groups\n"<<
+ " --number : number of partitions\n"<<
+ " --medname : path and name of output MED files\n"<<
+ " --limitswap : max size of working cpu memory (Mo) (before swapping on .temp files)\n"<<
+ " --verbose : trace of execution (0->6)\n"<<
+ " --test : more tests about joints, before generation of output files\n"<<
+ " --menu : a GUI menu for option number\n"<<
+ " --launchtepal : also launch tepal on files casename.faces and casename.points and option number\n"<<
+ " --background : force background mode from launch tepal and generation of final MED files (big meshes)\n"<<
+ " --deletegroups : regular expression (see QRegExp) which matches unwanted groups in final MED files\n"<<
+ " (try --deletegroups=\"(\\bAll_Nodes|\\bAll_Faces)\"\n"<<
+ " (try --deletegroups=\"((\\bAll_|\\bNew_)(N|F|T))\"\n";
+ cout<<"example:\n tepal2med --casename=/tmp/GHS3DPRL --number=2 --medname=DOMAIN "<<
+ "--limitswap=1000 --verbose=0 --test=yes --menu=no --launchtepal=no\n\n";
+ return 1; //no output files
+ }
+
+ if (!ccasename){
+ cerr<<"--casename: a path/name is expected\n\n";
+ return 1;
+ }
+ casename=ccasename;
+ if (!cnumber){
+ cerr<<"--number: an integer is expected\n\n";
+ return 1;
+ }
+ tmp=cnumber;
+ nbfiles=tmp.toLong(&ok,10);
+ if (!ok){
+ cerr<<"--number: an integer is expected\n\n";
+ return 1;
+ }
+ if (nbfiles<=0){
+ cerr<<"--number: a positive integer is expected\n\n";
+ return 1;
+ }
+ if (nbfiles>2048){ //delirium in 2008
+ cerr<<"--number: a positive integer <= 2048 is expected\n\n";
+ return 1;
+ }
+ if (!cmedname) cmedname=ccasename;
+ casenamemed=cmedname;
+ limit_swap_defaut=1000; //1000Mo
+ limit_swap=limit_swap_defaut;
+ if (climitswap){
+ tmp=climitswap;
+ limit_swap=tmp.toLong(&ok,10);
+ if (!ok){
+ cerr<<"--limitswap: an integer is expected. try 1000\n\n";
+ return 1;
+ }
+ if (limit_swap<1 || limit_swap>32000){
+ cerr<<"--limitswap: [1->32000] expected. try 1000\n\n";
+ return 1;
+ }
+ }
+ //default 1GOctet/8(for float)
+ nbelem_limit_swap=limit_swap*1000000; //100%
+ CVWtab::memorymax=nbelem_limit_swap;
+
+ verbose=1; //default
+ if (cverbose){
+ tmp=cverbose;
+ verbose=tmp.toLong(&ok,10);
+ if (!ok){
+ cerr<<"--verbose: an integer is expected\n\n";
+ return 1;
+ }
+ if (verbose<0){
+ cerr<<"--verbose: a positive integer is expected\n\n";
+ return 1;
+ }
+ }
+
+ test="no"; //default
+ if (ctest){
+ tmp=ctest;
+ if (tmp=="yes") test="yes";
+ }
+
+ menu="no"; //default
+ if (cmenu){
+ tmp=cmenu;
+ if (tmp=="yes") menu="yes";
+ }
+
+ launchtepal="no"; //default
+ if (claunchtepal){
+ tmp=claunchtepal;
+ if (tmp=="yes") launchtepal="yes";
+ }
+
+ background="no"; //default
+ if (cbackground){
+ tmp=cbackground;
+ if (tmp=="yes") background="yes";
+ }
+
+
+ // We must always have an application
+ if (menu=="yes") {
QApplication a(argc,argv);
dlg_ghs3dmain *m = new dlg_ghs3dmain();
m->setWindowTitle("tepal2med 2.1");
m->show();
a.exec();
if ( m->result() == QDialog::Accepted ) {
- std::cout<<"parameters "<<m->KeepFiles()<<" "<<m->NbPart()<<std::endl;
+ cout<<"parameters "<<m->KeepFiles()<<" "<<m->NbPart()<<endl;
nbfiles=m->NbPart();
}
else {
return 1;
}
delete m;
- }
-
- QString path;
- int n=casenamemed.count('/');
- if (n>0)
- path=casenamemed.section('/',-n-1,-2)+"/";
- else
- path="./";
- casenamemed=casenamemed.section('/',-1);
- if (casenamemed.length()>20)
- {
- std::cerr<<"CaseNameMed truncated (no more 20 characters)"<<std::endl;
- casenamemed.truncate(20);
- }
-
- /*std::cout<<"CaseNameMed="<<casenamemed<<std::endl;
- std::cout<<"PathMed="<<path<<std::endl;*/
-
- //verbose=5;
- if (verbose>0)
- std::cout<<"tepal2med parameters:"<<
- "\n CaseNameTepal="<<casename.toLatin1().constData()<<
- "\n NumberOfFiles="<<nbfiles<<
- "\n LimitSwap="<<nbelem_limit_swap<<
- "\n Verbose="<<verbose<<
- "\n Test="<<is_test<<
- "\n Menu="<<is_menu<<
- "\n LaunchTepal="<<is_launchtepal<<
- "\n CaseNameMed="<<path.toLatin1().constData()<<casenamemed.toLatin1().constData()<<
- "\n";
-
- //"tepal -f exemple1 -n 4"
- if (is_launchtepal)
- {
- cmd="tepal -f "+casename+" -n "+cmd.sprintf("%d",nbfiles)+" > "+path+"tepal.log";
- std::cout<<"\nLaunchTepal Command = "<<cmd.toLatin1().constData()<<std::endl;
- system( cmd.toLatin1().constData() ); // run
- //sometimes it is better to wait flushing files on slow filesystem...
- system( "sleep 3" );
- }
-
- ghs3dprl_mesh_wrap *mymailw=new ghs3dprl_mesh_wrap;
- //no constructor, later maybe
- mymailw->nbfiles=0;
- mymailw->nbelem_limit_swap=nbelem_limit_swap; //for huge cases big array swap in huge binary files
- mymailw->verbose=verbose;
- mymailw->casename=casenamemed;
- mymailw->path=path;
-
- ghs3dprl_msg_parser handler;
- //constructor later maybe
- //handler.verbose=true;
- handler.mailw=mymailw;
-
- QXmlSimpleReader reader;
- reader.setContentHandler(&handler);
- format=format.sprintf("%d",nbfiles);
- int nbf=format.length();
- format=format.sprintf(".%%.%dd.%%.%dd",nbf,nbf);
- //read files .msg
- for (int i=1; i<=nbfiles; i++)
- {
- mymailw->nofile=i;
- //tmp=casename+tmp.sprintf(".%d.%d.msg",nbfiles,i);
- tmp=casename+tmp.sprintf(format.toLatin1().constData(),nbfiles,i)+".msg";
- if (verbose>0) std::cout<<"FileName="<<tmp.toLatin1().constData()<<std::endl;
- QFile File(tmp);
- QXmlInputSource source(&File);
- reader.parse(source);
- File.close();
- }
- if (verbose>0)
- std::cout<<"NumberOfFilesMSGAcquired="<<mymailw->nbfiles<<"\n";
- if (mymailw->nbfiles != nbfiles)
- {
- std::cerr<<"NumberOfFiles != NumberOfFilesAcquired is unexpected\n";
- return 1;
- }
-
- if (is_test)
- {
- ok=mymailw->test_msg_wrap();
- if (ok)
- {
- if (verbose>0) std::cout<<"\nResult_test_msg_wrap=ok\n\n";
- }
- else
- {
- std::cerr<<"\nResult_test_msg_wrap=NO_OK!\n\n";
+ }
+
+ int n=casenamemed.count('/');
+ if (n>0)
+ path=casenamemed.section('/',-n-1,-2)+"/";
+ else
+ path="./";
+ casenamemed=casenamemed.section('/',-1);
+ if (casenamemed.length()>20){
+ cerr<<"--medname truncated (no more 20 characters)"<<endl;
+ casenamemed.truncate(20);
+ }
+
+ n=casename.count('/');
+ if (n>0)
+ pathini=casename.section('/',-n-1,-2)+"/";
+ else
+ pathini="./";
+ casename=casename.section('/',-1);
+ if (casename.length()>20){
+ cerr<<"--casename truncated (no more 20 characters)"<<endl;
+ casename.truncate(20);
+ }
+
+ /*cout<<"CaseNameMed="<<casenamemed<<endl;
+ cout<<"PathMed="<<path<<endl;*/
+
+ deletegroups="(\\bxyz)"; //default improbable name
+ if (cdeletegroups){
+ deletegroups=cdeletegroups;
+ }
+
+ //verbose=5;
+ if (verbose>0)
+ cout<<"tepal2med "<<version.toLatin1().constData()<<" parameters:"<<
+ "\n --casename="<<pathini.toLatin1().constData()<<casename.toLatin1().constData()<<
+ "\n --number="<<nbfiles<<
+ "\n --medname="<<path.toLatin1().constData()<<casenamemed.toLatin1().constData()<<
+ "\n --limitswap="<<limit_swap<<
+ "\n --verbose="<<verbose<<
+ "\n --test="<<test.toLatin1().constData()<<
+ "\n --menu="<<menu.toLatin1().constData()<<
+ "\n --launchtepal="<<launchtepal.toLatin1().constData()<<
+ "\n --background="<<background.toLatin1().constData()<<
+ "\n --deletegroups=\""<<deletegroups.toLatin1().constData()<<"\"\n";
+
+ //med_idt fid=MEDouvrir("/tmp/empty.med",MED_CREATION);
+ //med_err ret=MEDfermer(fid);
+ //system("sleep 30");
+ //return 0; //ok
+
+ //utile si appel par plugin ghs3dprl sur big meshes et tepal sur plusieurs jours
+ if (background=="yes"){
+ pid_t pid = fork();
+ if (pid > 0) {
+ //Process father
+ exit(0); //temporary ok for plugin
+ }
+ //process children
+ //On rend le fils independant de tout terminal
+ //from here everything in background: tepal AND generation of final MED files
+ setsid();
+ system("sleep 10"); //for debug
+ }
+
+ //"tepal -f exemple1 -n 4"
+ if (launchtepal=="yes"){
+ //tepal64.exe -f /home/wambeke/tmp/GHS3DPRL -n 5 --tetmesh_args "-c 0"
+ //cmd="tepal --tetmesh_args \"-c 0\" -f "+pathini+casename+" -n "+cmd.sprintf("%d",nbfiles)+" > "+path+"tepal.log";
+ cmd="tepal -f "+pathini+casename+" -n "+cmd.sprintf("%d",nbfiles)+" > "+path+"tepal.log";
+ cout<<"\nlaunchtepal command: background="<<cbackground<<
+ "\n "<<cmd.toLatin1().constData()<<endl;
+ system(cmd.toLatin1().constData()); // run
+ //sometimes it is better to wait flushing files on slow filesystem...
+ system("sleep 3");
+ }
+ ghs3dprl_mesh_wrap *mymailw=new ghs3dprl_mesh_wrap;
+ //no constructor, later maybe
+ mymailw->nbfiles=0;
+ mymailw->nbfilestot=nbfiles;
+ //for huge cases big array swap in huge binary files
+ mymailw->nbelem_limit_swap=nbelem_limit_swap;
+ mymailw->verbose=verbose;
+ mymailw->casename=casename;
+ mymailw->medname=casenamemed;
+ mymailw->path=path;
+ mymailw->pathini=pathini;
+ mymailw->deletegroups=QRegExp(deletegroups,Qt::CaseSensitive,QRegExp::RegExp);
+ ghs3dprl_msg_parser handler;
+ //constructor later maybe
+ //handler.verbose=true;
+ handler.mailw=mymailw;
+ mymailw->families.no=1;
+ //cout<<"coucou1 "<<mymailw->families.no<<endl;
+ //mymailw->families.add(casename,casenamemed);
+ format=format.sprintf("%d",nbfiles);
+ int nbf=format.length();
+ format=format.sprintf(".%%.%dd.%%.%dd",nbf,nbf);
+ mymailw->format=format;
+
+ //something like "/home/wambeke/tmp/GHS3DPRL_skin.med"
+ fileskinmed=pathini+casename+"_skin.med";
+ //fileskinmed="/home/wambeke/tmp/GHS3DPRL_skin.med";
+ /*for debug
+ {
+ char ctmp[fileskinmed.length()+1] ; strcpy(ctmp,fileskinmed);
+ int res=dumpMED(&ctmp[0],1);
+ }*/
+ ok=ReadFileMED(fileskinmed,mymailw);
+
+//if test read all files before (only small files)
+ if (test=="yes"){
+ if (verbose>0) cout<<"\nReading output files of tepal as input files of tepal2med...\n";
+
+ //read files .msg
+ //supposed big files big arrays so don't read with parser
+ mymailw->nbfiles=0;
+ for (int i=1; i<=nbfiles; i++){
+ mymailw->nofile=i;
+ tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfiles,i)+".msg";
+ if (verbose>0) cout<<"FileName="<<tmp.toLatin1().constData()<<endl;
+ ok=mymailw->ReadFileMSGnew(tmp);
+ }
+ if (verbose>0)
+ cout<<"NumberOfFilesMSGacquired="<<mymailw->nbfiles<<"\n\n";
+ if (mymailw->nbfiles != nbfiles){
+ cerr<<"NumberOfFiles != NumberOfFilesAcquired is unexpected\n\n";
return 1;
- }
- }
-
- //after verification remove unusued data
- //"NE0 FI" for/from <version>1.0</version>
- //after verification remove duplicates data
- //for debug but don't do that because reliability
- // and locality of datas files
- //" RE " for duplicates <receive>
- //int nb=mymailw->remove_key_mesh_wrap(QRegExp("( NE0 | RE)",true,false));
-
- //because <send> equals <receive>
- int nb=0;
- nb=mymailw->remove_key_mesh_wrap(QRegExp("RE"));
- if (verbose>3) std::cout<<"NumberOfKeysRemoved="<<nb<<std::endl;
- if (verbose>3) ok=mymailw->list_keys_mesh_wrap();
-
- //test read files .noboiteb
- //tmp=casename+".noboiteb";
- //ok=mymailw->ReadFileNOBOITEB(tmp);
-
- //read files .noboite
- //supposed big files
- mymailw->nbfiles=0;
- for (int i=1; i<=nbfiles; i++)
- {
- mymailw->nofile=i;
- tmp=casename+tmp.sprintf(format.toLatin1().constData(),nbfiles,i)+".noboite";
- if (verbose>0) std::cout<<"FileName="<<tmp.toLatin1().constData()<<std::endl;
- ok=mymailw->ReadFileNOBOITE(tmp);
- //mymailw->SwapOutOfMemory_key_mesh_wrap(QRegExp("NB",true,false));
- }
- if (verbose>0)
- std::cout<<"NumberOfFilesNOBOITEAcquired="<<mymailw->nbfiles<<"\n";
- if (mymailw->nbfiles != nbfiles)
- {
- std::cerr<<"NumberOfFiles != NumberOfFilesAcquired is unexpected\n";
- return 1;
- }
-
- if (is_test)
- {
- ok=mymailw->test_vertices_wrap();
- if (ok)
- {
- if (verbose>0) std::cout<<"\nResult_test_vertices_wrap=ok\n\n";
- }
- else
- {
- std::cerr<<"\nResult_test_vertices_wrap=NO_OK!\n\n";
+ }
+
+ /*old version with xml parser too slow
+ QXmlSimpleReader reader;
+ reader.setContentHandler(&handler);
+ //read files .msg
+ for (int i=1; i<=nbfiles; i++)
+ {
+ mymailw->nofile=i;
+ //tmp=casename+tmp.sprintf(".%d.%d.msg",nbfiles,i);
+ tmp=pathini+casename+tmp.sprintf(format,nbfiles,i)+".msg";
+ if (verbose>0) cout<<"FileName="<<tmp<<endl;
+ QFile File(tmp);
+ QXmlInputSource source(&File);
+ reader.parse(source);
+ File.close();
+ }
+ if (verbose>0)
+ cout<<"NumberOfFilesMSGAcquired="<<mymailw->nbfiles<<"\n";
+ if (mymailw->nbfiles != nbfiles){
+ cerr<<"Problem NumberOfFiles != NumberOfFilesAcquired\n";
return 1;
- }
- }
-
- //read files .faces
- mymailw->nbfiles=0;
- for (int i=1; i<=nbfiles; i++)
- {
- mymailw->nofile=i;
- tmp=casename+tmp.sprintf(format.toLatin1().constData(),nbfiles,i)+".faces";
- if (verbose>0) std::cout<<"FileName="<<tmp.toLatin1().constData()<<std::endl;
- ok=mymailw->ReadFileFACES(tmp);
- }
- if (verbose>0)
- std::cout<<"NumberOfFilesFACESAcquired="<<mymailw->nbfiles<<"\n\n";
- if (mymailw->nbfiles != nbfiles)
- {
- std::cerr<<"NumberOfFiles != NumberOfFilesAcquired is unexpected\n\n";
- return 1;
- }
-
- //read files .points
- mymailw->nbfiles=0;
- for (int i=1; i<=nbfiles; i++)
- {
- mymailw->nofile=i;
- tmp=casename+tmp.sprintf(format.toLatin1().constData(),nbfiles,i)+".points";
- if (verbose>0) std::cout<<"FileName="<<tmp.toLatin1().constData()<<std::endl;
- ok=mymailw->ReadFilePOINTS(tmp);
- }
- if (verbose>0)
- std::cout<<"NumberOfFilesPOINTSAcquired="<<mymailw->nbfiles<<"\n\n";
- if (mymailw->nbfiles != nbfiles)
- {
- std::cerr<<"NumberOfFiles != NumberOfFilesAcquired is unexpected\n\n";
- return 1;
- }
-
- //read files .glo
- //supposed big files big arrays so don't read with parser
- mymailw->nbfiles=0;
- for (int i=1; i<=nbfiles; i++)
- {
- mymailw->nofile=i;
- tmp=casename+tmp.sprintf(format.toLatin1().constData(),nbfiles,i)+".glo";
- if (verbose>0) std::cout<<"FileName="<<tmp.toLatin1().constData()<<std::endl;
- ok=mymailw->ReadFileGLO(tmp);
- //mymailw->SwapOutOfMemory_key_mesh_wrap(QRegExp("GL",true,false));
- }
- if (verbose>0)
- std::cout<<"NumberOfFilesGLOAcquired="<<mymailw->nbfiles<<"\n\n";
- if (mymailw->nbfiles != nbfiles)
- {
- std::cerr<<"NumberOfFiles != NumberOfFilesAcquired is unexpected\n\n";
+ }
+
+ if (test=="yes"){
+ ok=mymailw->test_msg_wrap();
+ if (ok){
+ if (verbose>0) cout<<"\nResult_test_msg_wrap=ok\n\n";
+ }
+ else{
+ cerr<<"\nResult_test_msg_wrap=NO_OK!\n\n";
+ return 1;
+ }
+ }
+ */
+
+ //after verification remove unusued data
+ //"NE0 FI" for/from <version>1.0</version>
+ //after verification remove duplicates data
+ //for debug but don't do that because reliability
+ // and locality of datas files
+ //" RE " for duplicates <receive>
+ //int nb=mymailw->remove_key_mesh_wrap(QRegExp("( NE0 | RE)",true,false));
+
+ //because <send> equals <receive>
+ nb=0;
+ nb=mymailw->remove_key_mesh_wrap(QRegExp("RE",Qt::CaseSensitive,QRegExp::RegExp));
+ if (verbose>3) cout<<"NumberOfKeysRemoved="<<nb<<endl;
+ if (verbose>3) ok=mymailw->list_keys_mesh_wrap();
+
+ //test read files .noboiteb
+ //tmp=casename+".noboiteb";
+ //ok=mymailw->ReadFileNOBOITEB(tmp);
+
+ //read files .noboite
+ //supposed big files
+ mymailw->nbfiles=0;
+ for (int i=1; i<=nbfiles; i++){
+ mymailw->nofile=i;
+ tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfiles,i)+".noboite";
+ if (verbose>0) cout<<"FileName="<<tmp.toLatin1().constData()<<endl;
+ ok=mymailw->ReadFileNOBOITE(tmp);
+ }
+ if (verbose>0)
+ cout<<"NumberOfFilesNOBOITEAcquired="<<mymailw->nbfiles<<"\n";
+ if (mymailw->nbfiles != nbfiles){
+ cerr<<"NumberOfFiles != NumberOfFilesAcquired is unexpected\n";
return 1;
- }
-
- /*exemples
- ok=mymailw->list_keys_mesh_wrap();
- tmp="FA RE NE4 FI1";
- ok=mymailw->list_onekey_mesh_wrap(tmp);
- tmp="FA SE NE4 FI1";
- ok=mymailw->list_onekey_mesh_wrap(tmp);
- tmp="FA RE NE1 FI4";
- ok=mymailw->list_onekey_mesh_wrap(tmp);
- tmp="FA SE NE1 FI4";
- ok=mymailw->list_onekey_mesh_wrap(tmp);
-
- tmp="FA RE NE4 FI1";
- ok=mymailw->list_onekey_mesh_wrap(tmp);*/
-
- //test remove points (type 3)
- //nb=mymailw->remove_key_mesh_wrap(QRegExp("PO",true,false));
- //std::cout<<"***remove_key_mesh_wrap*** remove nb="<<nb<<std::endl;
- //ok=mymailw->list_keys_mesh_wrap();
-
- ok=mymailw->Write_MEDfiles();
- //int nb=mymailw->remove_key_mesh_wrap(QRegExp(".",true,false));
- nb=mymailw->remove_all_keys_mesh_wrap();
- if (verbose>3)
- std::cout<<"***remove_all_key_mesh_wrap*** "<<nb<<" keys removed\n";
- std::cout<<std::endl<<"===end of "<<argv[0]<<"==="<<std::endl;
-
- return 0; //ok
-}
+ }
+ //if (test=="yes"){
+ ok=mymailw->test_vertices_wrap();
+ if (ok){
+ if (verbose>0) cout<<"\nResult_test_vertices_wrap=ok\n\n";
+ }
+ else{
+ cerr<<"\nResult_test_vertices_wrap=NO_OK!\n\n";
+ return 1;
+ }
+ //}
+
+ //read files .faces
+ mymailw->nbfiles=0;
+ for (int i=1; i<=nbfiles; i++){
+ mymailw->nofile=i;
+ tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfiles,i)+".faces";
+ if (verbose>0) cout<<"FileName="<<tmp.toLatin1().constData()<<endl;
+ ok=mymailw->ReadFileFACES(tmp);
+ }
+ if (verbose>0)
+ cout<<"NumberOfFilesFACESAcquired="<<mymailw->nbfiles<<"\n\n";
+ if (mymailw->nbfiles != nbfiles){
+ cerr<<"NumberOfFiles != NumberOfFilesAcquired is unexpected\n\n";
+ return 1;
+ }
+
+ /*
+ //read files .points
+ mymailw->nbfiles=0;
+ for (int i=1; i<=nbfiles; i++){
+ mymailw->nofile=i;
+ tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfiles,i)+".points";
+ if (verbose>0) cout<<"FileName="<<tmp.toLatin1().constData()<<endl;
+ ok=mymailw->ReadFilePOINTS(tmp);
+ }
+ if (verbose>0)
+ cout<<"NumberOfFilesPOINTSAcquired="<<mymailw->nbfiles<<"\n\n";
+ if (mymailw->nbfiles != nbfiles)
+ {
+ cerr<<"NumberOfFiles != NumberOfFilesAcquired is unexpected\n\n";
+ return 1;
+ }
+ */
+
+ //read files .glo
+ //supposed big files big arrays so don't read with parser
+ mymailw->nbfiles=0;
+ for (int i=1; i<=nbfiles; i++){
+ mymailw->nofile=i;
+ tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfiles,i)+".glo";
+ if (verbose>0) cout<<"FileName="<<tmp.toLatin1().constData()<<endl;
+ ok=mymailw->ReadFileGLO(tmp);
+ //mymailw->SwapOutOfMemory_key_mesh_wrap(QRegExp("GL",true,false));
+ }
+ if (verbose>0)
+ cout<<"NumberOfFilesGLOAcquired="<<mymailw->nbfiles<<"\n\n";
+ if (mymailw->nbfiles != nbfiles){
+ cerr<<"NumberOfFiles != NumberOfFilesAcquired is unexpected\n\n";
+ return 1;
+ }
+
+ /*exemples
+ ok=mymailw->list_keys_mesh_wrap();
+ tmp="FA RE NE4 FI1";
+ ok=mymailw->list_onekey_mesh_wrap(tmp);
+ tmp="FA SE NE4 FI1";
+ ok=mymailw->list_onekey_mesh_wrap(tmp);
+ tmp="FA RE NE1 FI4";
+ ok=mymailw->list_onekey_mesh_wrap(tmp);
+ tmp="FA SE NE1 FI4";
+ ok=mymailw->list_onekey_mesh_wrap(tmp);
+
+ tmp="FA RE NE4 FI1";
+ ok=mymailw->list_onekey_mesh_wrap(tmp);*/
+
+ //test remove points (type 3)
+ //nb=mymailw->remove_key_mesh_wrap(QRegExp("PO",true,false));
+ //cout<<"***remove_key_mesh_wrap*** remove nb="<<nb<<endl;
+ //ok=mymailw->list_keys_mesh_wrap();
+
+ ok=mymailw->Find_VerticesDomainToVerticesSkin();
+ } //end if test
+
+ ok=mymailw->Write_MEDfiles_v2(true); //deletekeys=true
+
+ nb=mymailw->remove_all_keys_mesh_wrap();
+ if (verbose>3)cout<<"***remove_all_key_mesh_wrap*** "<<nb<<" keys removed\n";
+ if (verbose>0)cout<<endl<<"===end of "<<argv[0]<<"==="<<endl;
+
+ //for debug
+ //int res=dumpMED("/home/wambeke/tmp/DOMAIN_1.med",1);
+
+ return 0; //ok
+}