From: jfa Date: Tue, 9 Dec 2008 13:28:44 +0000 (+0000) Subject: Bug 0020072: GHS3DPRLPLUGIN update. Integrating the attached patch. X-Git-Tag: V5_1_0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5a511844cfee3629f7addcff2138c98bc63d171c;p=plugins%2Fghs3dprlplugin.git Bug 0020072: GHS3DPRLPLUGIN update. Integrating the attached patch. --- diff --git a/configure.ac b/configure.ac index 03e6ff9..45da081 100644 --- a/configure.ac +++ b/configure.ac @@ -342,6 +342,14 @@ echo CHECK_SMESH +echo +echo --------------------------------------------- +echo testing LIBXML2 +echo --------------------------------------------- +echo libxml_ok=no +CHECK_LIBXML +dnl libxml_ok is set to yes by CHECK_LIBXML + echo echo --------------------------------------------- echo Summary @@ -351,11 +359,11 @@ echo #AM_CONDITIONAL( USE_GFORTRAN, [test "$F77" = "gfortran"]) if test "${GHS3DPRLPLUGIN_WITH_GUI}" = "yes"; then -variables="cc_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok omniORB_ok occ_ok doxygen_ok graphviz_ok Kernel_ok Geom_ok Med_ok SMesh_ok SalomeGUI_ok" +variables="cc_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok omniORB_ok occ_ok doxygen_ok graphviz_ok Kernel_ok Geom_ok Med_ok SMesh_ok SalomeGUI_ok libxml_ok" opt_variables="GHS3DPRL_ok" fi if test "${GHS3DPRLPLUGIN_WITH_GUI}" = "no"; then -variables="cc_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok hdf5_ok omniORB_ok occ_ok doxygen_ok graphviz_ok Kernel_ok Geom_ok Med_ok SMesh_ok" +variables="cc_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok hdf5_ok omniORB_ok occ_ok doxygen_ok graphviz_ok Kernel_ok Geom_ok Med_ok SMesh_ok libxml_ok" opt_variables="GHS3DPRL_ok" fi diff --git a/idl/GHS3DPRLPlugin_Algorithm.idl b/idl/GHS3DPRLPlugin_Algorithm.idl index 486848a..0d2d4ca 100755 --- a/idl/GHS3DPRLPlugin_Algorithm.idl +++ b/idl/GHS3DPRLPlugin_Algorithm.idl @@ -20,7 +20,7 @@ // File : GHS3DPRLPlugin_Algorithm.idl // Author : Christian VAN WAMBEKE (CEA) // --- -// + #ifndef _SMESH_GHS3DPRLALGORITHM_IDL_ #define _SMESH_GHS3DPRLALGORITHM_IDL_ @@ -51,8 +51,10 @@ module GHS3DPRLPlugin void SetKeepFiles(in boolean value); boolean GetKeepFiles(); - }; + void SetBackground(in boolean value); + boolean GetBackground(); + }; }; #endif diff --git a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.cxx b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.cxx index be2b5ea..744b32c 100755 --- a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.cxx +++ b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.cxx @@ -1,4 +1,4 @@ -// 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 @@ -20,7 +20,7 @@ // File : GHS3DPRLPlugin_GHS3DPRL.cxx // Author : Christian VAN WAMBEKE (CEA) (from Hexotic plugin Lioka RAZAFINDRAZAKA) // --- -// + #include "GHS3DPRLPlugin_GHS3DPRL.hxx" #include "GHS3DPRLPlugin_Hypothesis.hxx" @@ -50,8 +50,17 @@ #include #include -//============================================================================= +/* +extern "C" { +#include +//#include +#include +//#include +#include +} +using namespace med_2_2;*/ +//============================================================================= GHS3DPRLPlugin_GHS3DPRL::GHS3DPRLPlugin_GHS3DPRL(int hypId, int studyId, SMESH_Gen* gen) : SMESH_3D_Algo(hypId, studyId, gen) { @@ -64,14 +73,12 @@ GHS3DPRLPlugin_GHS3DPRL::GHS3DPRLPlugin_GHS3DPRL(int hypId, int studyId, SMESH_G } //============================================================================= - GHS3DPRLPlugin_GHS3DPRL::~GHS3DPRLPlugin_GHS3DPRL() { MESSAGE("GHS3DPRLPlugin_GHS3DPRL::~GHS3DPRLPlugin_GHS3DPRL"); } //============================================================================= - bool GHS3DPRLPlugin_GHS3DPRL::CheckHypothesis (SMESH_Mesh& aMesh, const TopoDS_Shape& aShape, @@ -108,13 +115,13 @@ bool GHS3DPRLPlugin_GHS3DPRL::CheckHypothesis } //======================================================================= - static bool writeGHS3DPRLFiles (const TCollection_AsciiString & GHS3DPRL_In, SMESHDS_Mesh * theMesh, map & theSmdsToGHS3DPRLIdMap, map & theGHS3DPRLIdToNodeMap) { bool Ok; + int ifam=0; TCollection_AsciiString namefile(GHS3DPRL_In); namefile+=".points"; OSD_File(namefile).Remove(); @@ -130,6 +137,7 @@ static bool writeGHS3DPRLFiles (const TCollection_AsciiString & GHS3DPRL_In, INFOS("Can't write into "<NbNodes(); @@ -140,16 +148,20 @@ static bool writeGHS3DPRLFiles (const TCollection_AsciiString & GHS3DPRL_In, // Writing SMESH points into GHS3DPRL File.points theFile<nodesIterator(); + SMDS_NodeIteratorPtr itOnNode=theMesh->nodesIterator(); + //int ifam=100;//test famille + theFile.precision(15); theFile.setf(ios::scientific,ios::floatfield); + //cout<<"set precision 15 on float\n"; while (itOnNode->more()) { node_2 = itOnNode->next(); theSmdsToGHS3DPRLIdMap.insert(map ::value_type(node_2->GetID(),aSmdsNodeID)); theGHS3DPRLIdToNodeMap.insert(map ::value_type(aSmdsNodeID,node_2)); + theFile<X()<Y()<Z()<X()<Y()<Z()<facesIterator(); long nbNoTriangles=0; + int ifaces=0; + //ifam=300; while (itOnSmdsFace->more()) { aFace=itOnSmdsFace->next(); itOnFaceNode=aFace->nodesIterator(); const int nbNodes=aFace->NbNodes(); if (nbNodes!=3) nbNoTriangles++; + ifaces++; theFile<more()) { @@ -193,7 +208,9 @@ static bool writeGHS3DPRLFiles (const TCollection_AsciiString & GHS3DPRL_In, theFile<GetMEDName(); //"DOMAIN\0" _NbPart = hyp->GetNbPart(); _KeepFiles = hyp->GetKeepFiles(); + _Background = hyp->GetBackground(); } } @@ -409,65 +423,58 @@ static TCollection_AsciiString getTmpDir() //============================================================================= // Here we are going to use the GHS3DPRL mesher - -bool GHS3DPRLPlugin_GHS3DPRL::Compute(SMESH_Mesh& theMesh, +bool GHS3DPRLPlugin_GHS3DPRL::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape& theShape) { bool Ok; - MESSAGE("GHS3DPRLPlugin_GHS3DPRL::Compute"); - - if (_hypothesis==NULL) - { - Ok = false; - cout <<"\nNo existing parameters/hypothesis for GHS3DPRL!\n\n"; - return Ok; - } - SetParameters(_hypothesis); - - cout << endl; - cout << _name << " parameters :" << endl; - cout << " generic path/name of MED Files = " << _MEDName << endl; - cout << " number of partitions = " << _NbPart << endl; - cout << " keep intermediates files (from tepal) = " << _KeepFiles << endl; - cout << endl; - - SMESHDS_Mesh* meshDS = theMesh.GetMeshDS(); - - if (_countSubMesh==0) - { + TCollection_AsciiString pluginerror("ghs3dprl: "); + SMESHDS_Mesh* meshDS = theMesh.GetMeshDS(); + //cout<<"GetMeshDS done\n"; + if (_countSubMesh==0){ + MESSAGE("GHS3DPRLPlugin_GHS3DPRL::Compute"); _countTotal=0; TopExp_Explorer expf(meshDS->ShapeToMesh(), TopAbs_SOLID); - for ( ; expf.More(); expf.Next() ) - _countTotal++; - } - - _countSubMesh++; + for ( ; expf.More(); expf.Next() ) _countTotal++; + } + _countSubMesh++; + //cout<<"Compute _countSubMesh "<<_countSubMesh<0) - { + if (n>0) { path=casenamemed.SubString(1,n); - casenamemed=casenamemed.SubString(n+1,casenamemed.Length()); + casenamemed=casenamemed.SubString(n+1,casenamemed.Length()); } else path=tmpDir; - if (casenamemed.Length()>20) - { + path="/export/home/wambeke/"; + + if (casenamemed.Length()>20){ casenamemed=casenamemed.SubString(1,20); cerr<<"MEDName truncated (no more 20 characters) = "< aSmdsToGHS3DPRLIdMap; map aGHS3DPRLIdToNodeMap; - GHS3DPRL_In=path + "GHS3DPRL"; - GHS3DPRL_Out=path + casenamemed; + GHS3DPRL_In = path + "GHS3DPRL"; + GHS3DPRL_Out = path + casenamemed; + GHS3DPRL_Outxml = path + casenamemed + ".xml"; //master file NbPart=_NbPart; - run_GHS3DPRL += GHS3DPRL_In + " " + NbPart + " 12500000 1 Test noMenu LaunchTepal " + GHS3DPRL_Out ; - run_nokeep_files += GHS3DPRL_In + ".*.*.* " + path + "tepal.log"; + //tepal2med --casename=/home/whoami/tmp/GHS3DPRL --number=5 --medname=DOMAIN + // --limitswap=1000 --verbose=0 --test=no --menu=no --launchtepal=yes; + run_GHS3DPRL = run_GHS3DPRL + + " --casename=" + GHS3DPRL_In + + " --number=" + NbPart + + " --medname=" + GHS3DPRL_Out + + " --launchtepal=yes --background="; + if (_Background) run_GHS3DPRL += "yes"; else run_GHS3DPRL += "no"; + run_nokeep_files += GHS3DPRL_In + "* " + path + "tepal.log"; + system( run_nokeep_files.ToCString() ); //clean files - cout<<"GHS3DPRL command : "< avoid warning message + //med_idt fid=MEDouvrir((const char *)fileskinmed.ToCString(),MED_CREATION); + //med_err ret=MEDfermer(fid); + //fileskinmed=fileskinmed + "cp /home/wambeke/empty.med "+ path + "GHS3DPRL_skin.med"; + //system( fileskinmed.ToCString() ); + fileskinmed=path + "GHS3DPRL_skin.med"; + cout<<"Write file "< 0) { + //Processus père + cout<<"le pere est la\n"; + system("echo le pere > lepere.tmp"); + system("sleep 10"); + system("ps -edf |grep wambeke > pslepere.tmp"); + cout<<"le pere return 0\n"; + return 0; //ok + //exit(0); + } else if (pid == 0) { + //Processus fils + cout<<"le fils est la\n"; + //On rend le fils indépendant de tout terminal + setsid(); + system("sleep 20"); + system("echo le fils > lefils.tmp"); + system("sleep 20"); + system("ps -edf |grep wambeke > pslefils.tmp"); + cout<<"le fils return 0\n"; + return 0; //ok + } else { + //Traitement d'erreur + cout<<"ya probleme sur fork()\n"; + return 1; //ko + }*/ } //============================================================================= - ostream & GHS3DPRLPlugin_GHS3DPRL::SaveTo(ostream & save) { return save; } //============================================================================= - istream & GHS3DPRLPlugin_GHS3DPRL::LoadFrom(istream & load) { return load; } //============================================================================= - ostream & operator << (ostream & save, GHS3DPRLPlugin_GHS3DPRL & hyp) { return hyp.SaveTo( save ); } //============================================================================= - istream & operator >> (istream & load, GHS3DPRLPlugin_GHS3DPRL & hyp) { return hyp.LoadFrom( load ); diff --git a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.hxx b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.hxx index 3caff91..33b92c9 100755 --- a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.hxx +++ b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.hxx @@ -1,4 +1,4 @@ -// 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 @@ -20,7 +20,7 @@ // File : GHS3DPRLPlugin_GHS3DPRL.hxx // Author : Christian VAN WAMBEKE (CEA) (from Hexotic plugin Lioka RAZAFINDRAZAKA) // --- -// + #ifndef _GHS3DPRLPlugin_GHS3DPRL_HXX_ #define _GHS3DPRLPlugin_GHS3DPRL_HXX_ @@ -61,6 +61,7 @@ private: string _MEDName; //number of partitions int _NbPart; //number of partitions bool _KeepFiles; //tepal file .noboite binary or not + bool _Background; //true for big meshes }; #endif diff --git a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.cxx b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.cxx index 1e023d8..b49e210 100755 --- a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.cxx +++ b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.cxx @@ -1,4 +1,4 @@ -// 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 @@ -20,7 +20,7 @@ // File : GHS3DPRLPlugin_Hypothesis.cxx // Author : Christian VAN WAMBEKE (CEA) (from Hexotic plugin Lioka RAZAFINDRAZAKA) // --- -// + #include #include @@ -34,7 +34,8 @@ GHS3DPRLPlugin_Hypothesis::GHS3DPRLPlugin_Hypothesis (int hypId, int studyId, : SMESH_Hypothesis(hypId, studyId, gen), _MEDName( GetDefaultMEDName() ), _NbPart( GetDefaultNbPart() ), - _KeepFiles( GetDefaultKeepFiles() ) + _KeepFiles( GetDefaultKeepFiles() ), + _Background( GetDefaultBackground() ) { MESSAGE("GHS3DPRLPlugin_Hypothesis::GHS3DPRLPlugin_Hypothesis"); _name = "GHS3DPRL_Parameters"; @@ -104,6 +105,14 @@ void GHS3DPRLPlugin_Hypothesis::SetKeepFiles(bool theVal) { } } +void GHS3DPRLPlugin_Hypothesis::SetBackground(bool theVal) { + if (theVal != _Background) { + _Background = theVal; + NotifySubMeshesHypothesisModification(); + } +} + + //============================================================================= /*! * @@ -120,6 +129,7 @@ std::ostream& GHS3DPRLPlugin_Hypothesis::SaveTo(std::ostream& save) save<<"MEDName="<<_MEDName<<";"; save<<"NbPart="<<_NbPart<<";"; save<<"KeepFiles="<<(int) _KeepFiles<<";"; + save<<"Background="<<(int) _Background<<";"; return save; } @@ -154,6 +164,7 @@ std::istream& GHS3DPRLPlugin_Hypothesis::LoadFrom(std::istream& load) if (str3=="MEDName") _MEDName = str4.c_str(); if (str3=="NbPart") _NbPart = atoi(str4.c_str()); if (str3=="KeepFiles") _KeepFiles = (bool) atoi(str4.c_str()); + if (str3=="Background") _Background = (bool) atoi(str4.c_str()); } return load; } @@ -205,8 +216,15 @@ int GHS3DPRLPlugin_Hypothesis::GetDefaultNbPart() return 16; } +//============================================================================= bool GHS3DPRLPlugin_Hypothesis::GetDefaultKeepFiles() { return false; } +//============================================================================= +bool GHS3DPRLPlugin_Hypothesis::GetDefaultBackground() +{ + return false; +} + diff --git a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.hxx b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.hxx index f55c3da..48de717 100755 --- a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.hxx +++ b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.hxx @@ -1,4 +1,4 @@ -// 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 @@ -20,7 +20,7 @@ // File : GHS3DPRLPlugin_Hypothesis.hxx // Author : Christian VAN WAMBEKE (CEA) (from Hexotic plugin Lioka RAZAFINDRAZAKA) // --- -// + #ifndef _GHS3DPRLPlugin_Hypothesis_HXX_ #define _GHS3DPRLPlugin_Hypothesis_HXX_ @@ -45,11 +45,15 @@ public: void SetKeepFiles(bool theVal); bool GetKeepFiles() const { return _KeepFiles; } + void SetBackground(bool theVal); + bool GetBackground() const { return _Background; } + // the parameters default values static std::string GetDefaultMEDName(); static int GetDefaultNbPart(); static bool GetDefaultKeepFiles(); + static bool GetDefaultBackground(); // Persistence virtual std::ostream& SaveTo(std::ostream& save); @@ -73,6 +77,7 @@ private: std::string _MEDName; // generic path/name of med files int _NbPart; // number of partitions bool _KeepFiles; // keep intermediates tepal files or not + bool _Background; // tepal in background }; #endif diff --git a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.cxx b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.cxx index b367d4a..20a25b4 100755 --- a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.cxx +++ b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.cxx @@ -1,4 +1,4 @@ -// 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 @@ -20,7 +20,7 @@ // File : GHS3DPRLPlugin_Hypothesis_i.cxx // Author : Christian VAN WAMBEKE (CEA) (from Hexotic plugin Lioka RAZAFINDRAZAKA) // --- -// + #include "GHS3DPRLPlugin_Hypothesis_i.hxx" #include "SMESH_Gen.hxx" #include "SMESH_PythonDump.hxx" @@ -65,6 +65,7 @@ GHS3DPRLPlugin_Hypothesis_i::~GHS3DPRLPlugin_Hypothesis_i() * GHS3DPRLPlugin_Hypothesis_i::SetMEDName * GHS3DPRLPlugin_Hypothesis_i::SetNbPart * GHS3DPRLPlugin_Hypothesis_i::SetKeepFiles + * GHS3DPRLPlugin_Hypothesis_i::SetBackground */ //============================================================================= @@ -92,11 +93,20 @@ void GHS3DPRLPlugin_Hypothesis_i::SetKeepFiles (CORBA::Boolean theValue) SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << theValue << " )"; } +void GHS3DPRLPlugin_Hypothesis_i::SetBackground (CORBA::Boolean theValue) +{ + MESSAGE("GHS3DPRLPlugin_Hypothesis_i::SetBackground"); + ASSERT(myBaseImpl); + this->GetImpl()->SetBackground(theValue); + SMESH::TPythonDump() << _this() << ".SetBackground( " << theValue << " )"; +} + //============================================================================= /*! * GHS3DPRLPlugin_Hypothesis_i::GetMEDName * GHS3DPRLPlugin_Hypothesis_i::GetNbPart * GHS3DPRLPlugin_Hypothesis_i::GetKeepFiles + * GHS3DPRLPlugin_Hypothesis_i::GetBackground */ //============================================================================= @@ -123,6 +133,13 @@ CORBA::Boolean GHS3DPRLPlugin_Hypothesis_i::GetKeepFiles() return this->GetImpl()->GetKeepFiles(); } +CORBA::Boolean GHS3DPRLPlugin_Hypothesis_i::GetBackground() +{ + MESSAGE("GHS3DPRLPlugin_Hypothesis_i::GetBackground"); + ASSERT(myBaseImpl); + return this->GetImpl()->GetBackground(); +} + //============================================================================= /*! * GHS3DPRLPlugin_Hypothesis_i::GetImpl @@ -139,8 +156,8 @@ CORBA::Boolean GHS3DPRLPlugin_Hypothesis_i::GetKeepFiles() //================================================================================ /*! * \brief Verify whether hypothesis supports given entity type - * \param type - dimension (see SMESH::Dimension enumeration) - * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise + * \param type - dimension (see SMESH::Dimension enumeration) + * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise * * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration) */ diff --git a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.hxx b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.hxx index 2dc3e70..bddddd6 100755 --- a/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.hxx +++ b/src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis_i.hxx @@ -1,4 +1,4 @@ -// 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 @@ -20,7 +20,7 @@ // File : GHS3DPRLPlugin_Hypothesis_i.hxx // Author : Christian VAN WAMBEKE (CEA) (from Hexotic plugin Lioka RAZAFINDRAZAKA) // --- -// + #ifndef _GHS3DPRLPlugin_Hypothesis_i_HXX_ #define _GHS3DPRLPlugin_Hypothesis_i_HXX_ @@ -56,6 +56,9 @@ class GHS3DPRLPlugin_Hypothesis_i: void SetKeepFiles(CORBA::Boolean theVal); CORBA::Boolean GetKeepFiles(); + void SetBackground(CORBA::Boolean theVal); + CORBA::Boolean GetBackground(); + // Get implementation ::GHS3DPRLPlugin_Hypothesis* GetImpl(); diff --git a/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.cxx b/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.cxx index e9779d2..4e645d9 100755 --- a/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.cxx +++ b/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.cxx @@ -1,4 +1,4 @@ -// 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 @@ -20,7 +20,7 @@ // File : GHS3DPRLPluginGUI_HypothesisCreator.cxx // Author : Christian VAN WAMBEKE (CEA) (from Hexotic plugin Lioka RAZAFINDRAZAKA) // --- -// + #include "GHS3DPRLPluginGUI_HypothesisCreator.h" #include @@ -107,6 +107,10 @@ QFrame* GHS3DPRLPluginGUI_HypothesisCreator::buildFrame() myKeepFiles->setWhatsThis( tr( "GHS3DPRL_WhatsThis_KeepFiles" ) ); l->addWidget( myKeepFiles, row++, 0, 1, 2 ); + myBackground = new QCheckBox( tr( "GHS3DPRL_Background" ), GroupC1 ); + myBackground->setWhatsThis( tr( "GHS3DPRL_WhatsThis_Background" ) ); + l->addWidget( myBackground, row++, 0, 1, 2 ); + myIs3D = true; return fr; @@ -121,6 +125,7 @@ void GHS3DPRLPluginGUI_HypothesisCreator::retrieveParams() const myMEDName->setText( data.myMEDName ); myNbPart->setValue( data.myNbPart ); myKeepFiles->setChecked( data.myKeepFiles ); + myBackground->setChecked( data.myBackground ); //myNbPart->setEnabled( true ); } @@ -131,9 +136,10 @@ QString GHS3DPRLPluginGUI_HypothesisCreator::storeParams() const storeParamsToHypo( data ); QString valStr; - valStr += tr( "GHS3DPRL_MEDName" ) + " = " + data.myMEDName + "; "; - valStr += tr( "GHS3DPRL_NbPart" ) + " = " + QString::number( data.myNbPart ) + "; "; - valStr += tr( "GHS3DPRL_KeepFiles" ) + " = " + QString::number( data.myKeepFiles ) + "; "; + valStr += tr( "GHS3DPRL_MEDName" ) + " = " + data.myMEDName + "; "; + valStr += tr( "GHS3DPRL_NbPart" ) + " = " + QString::number( data.myNbPart ) + "; "; + valStr += tr( "GHS3DPRL_KeepFiles" ) + " = " + QString::number( data.myKeepFiles ) + "; "; + valStr += tr( "GHS3DPRL_Background" ) + " = " + QString::number( data.myBackground ) + "; "; return valStr; } @@ -148,6 +154,7 @@ bool GHS3DPRLPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DPRLHypothesis h_data.myMEDName = h->GetMEDName(); //"DOMAIN\0"; h_data.myNbPart = h->GetNbPart(); h_data.myKeepFiles = h->GetKeepFiles(); + h_data.myBackground = h->GetBackground(); return true; } @@ -166,6 +173,7 @@ bool GHS3DPRLPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DPRLHypot h->SetMEDName( h_data.myMEDName.toLatin1().constData() ); h->SetNbPart( h_data.myNbPart ); h->SetKeepFiles( h_data.myKeepFiles ); + h->SetBackground( h_data.myBackground ); } catch ( const SALOME::SALOME_Exception& ex ) { @@ -177,10 +185,11 @@ bool GHS3DPRLPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DPRLHypot bool GHS3DPRLPluginGUI_HypothesisCreator::readParamsFromWidgets( GHS3DPRLHypothesisData& h_data ) const { - h_data.myName = myName ? myName->text() : ""; - h_data.myMEDName = myMEDName->text().simplified().replace(' ', '_'); - h_data.myNbPart = myNbPart->value(); - h_data.myKeepFiles = myKeepFiles->isChecked(); + h_data.myName = myName ? myName->text() : ""; + h_data.myMEDName = myMEDName->text().simplified().replace(' ', '_'); + h_data.myNbPart = myNbPart->value(); + h_data.myKeepFiles = myKeepFiles->isChecked(); + h_data.myBackground = myBackground->isChecked(); return true; } diff --git a/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.h b/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.h index ae30bf9..9421232 100755 --- a/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.h +++ b/src/gui/GHS3DPRLPluginGUI_HypothesisCreator.h @@ -1,4 +1,4 @@ -// 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 @@ -20,7 +20,7 @@ // File : GHS3DPRLPluginGUI_HypothesisCreator.h // Author : Christian VAN WAMBEKE (CEA) (from Hexotic plugin Lioka RAZAFINDRAZAKA) // --- -// + #ifndef GHS3DPRLPLUGINGUI_HypothesisCreator_H #define GHS3DPRLPLUGINGUI_HypothesisCreator_H @@ -36,6 +36,7 @@ typedef struct QString myMEDName; int myNbPart; bool myKeepFiles; + bool myBackground; } GHS3DPRLHypothesisData; /*! @@ -70,6 +71,7 @@ private: QLineEdit* myMEDName; QtxIntSpinBox* myNbPart; QCheckBox* myKeepFiles; + QCheckBox* myBackground; bool myIs3D; }; diff --git a/src/gui/GHS3DPRLPlugin_msg_en.ts b/src/gui/GHS3DPRLPlugin_msg_en.ts index 61d705b..e5f24a5 100644 --- a/src/gui/GHS3DPRLPlugin_msg_en.ts +++ b/src/gui/GHS3DPRLPlugin_msg_en.ts @@ -34,6 +34,10 @@ GHS3DPRL_KeepFiles Keep_Files + + GHS3DPRL_Background + Tepal_in_Background + GHS3DPRL_MEDName MED_Name @@ -46,6 +50,10 @@ GHS3DPRL_WhatsThis_KeepFiles Keep intemediates tepal Files (.faces,.points,.msg,.noboite...) + + GHS3DPRL_WhatsThis_Background + lanch tepal in background (for a big mesh, a long time...) + GHS3DPRL_WhatsThis_MEDName Generic path/name of finals outputs files (.med) diff --git a/src/tepal2med/Makefile.am b/src/tepal2med/Makefile.am index 4e40aaa..c051a74 100644 --- a/src/tepal2med/Makefile.am +++ b/src/tepal2med/Makefile.am @@ -1,4 +1,4 @@ -# 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 @@ -20,7 +20,7 @@ # File : Makefile.am # Author : Vadim SANDLER, Open CASCADE S.A.S (vadim.sandler@opencascade.com) # --- -# + include $(top_srcdir)/adm_local/unix/make_common_starter.am bin_PROGRAMS = tepal2med @@ -42,6 +42,6 @@ BUILT_SOURCES = $(UIC_FILES) nodist_tepal2med_SOURCES = $(MOC_FILES) $(UIC_FILES) -tepal2med_CPPFLAGS = $(QT_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) +tepal2med_CPPFLAGS = $(QT_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) $(LIBXML_INCLUDES) -tepal2med_LDADD = $(QT_LIBS) $(MED2_LIBS) $(HDF5_LIBS) +tepal2med_LDADD = $(QT_LIBS) $(MED2_LIBS) $(HDF5_LIBS) $(LIBXML_LIBS) diff --git a/src/tepal2med/ghs3dprl_mesh_wrap.cxx b/src/tepal2med/ghs3dprl_mesh_wrap.cxx index 5825672..b9b2f5c 100755 --- a/src/tepal2med/ghs3dprl_mesh_wrap.cxx +++ b/src/tepal2med/ghs3dprl_mesh_wrap.cxx @@ -1,4 +1,4 @@ -// 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 @@ -18,9 +18,9 @@ // // --- // 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 @@ -28,92 +28,335 @@ #include #include +#include +#include +#include +#include + #include #include +using namespace std; using namespace med_2_2; +//utils procedures + +//************************************ +string i2a(const int &v) +{ + ostringstream ss; + ss<\tGroups="; + gb=(*it1).second; + for (it2=gb.begin(); it2!=gb.end(); ++it2){ + cout<<"<"<<(*it2).first.toLatin1().constData()<<"> "; + } + cout<\tFamilies="; + gb=(*it1).second; + for (it2=gb.begin(); it2!=gb.end(); ++it2){ + cout<<"<"<<(*it2).first.toLatin1().constData()<<"> "; + } + cout<\t<"<\n"; + fagr::iterator it; + it=fam.find(nomfam); + if (it==fam.end()){ + //cout<<"add new family <"<\t<"<\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*** "<= 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"< from <"<< + // fam1<<"><"<\n"; + return ires; + } + } + //cout<<"no family found!!! - groups of "<add(tmp,(*it).first); + } + //cout<<"new family <"< intersection of <"<<"<\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 "< "; + } + cout<memorymax) { + cout<<"***WARNING*** memory max reached "<memorymax) { + cout<<"***WARNING*** memory max reached "<filename<filename<<" successfully deleted\n"; - } + bool ok; + //cout<<" destructor CVWtab *** "<filename<CVWtab_deallocate(); + //remove temporary file + if (this->filename!="_NO_FILE") + { + remove(this->filename.toLatin1().constData()); //#include + //cout<filename<<" successfully deleted\n"; + } + } //************************************ bool CVWtab::CVWtab_deallocate() { - //std::cout<<" deallocate CVWtab*** "<size<type==1) std::cout<<"med_int tab1[0]="<tmint[0]<type==2) std::cout<<"med_float tab1[0]="<tmflo[0]<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="<size<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="<size<size; i++) - if (this->tmflo[i]!=tab2->tmflo[i]) return false; - } - return true; + //cout<<"is_equal tab1 tab2 type="<type<<" size="<size<<" "<size<type==1) cout<<"med_int tab1[0]="<tmint[0]<type==2) cout<<"med_float tab1[0]="<tmflo[0]<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="<size<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="<size<size; i++) + if (this->tmflo[i]!=tab2->tmflo[i]) return false; + } + return true; } //************************************ @@ -123,188 +366,262 @@ bool CVW_is_equal_vertices(CVWtab *tab1, long i1, //verbose 1 for print vertices not equals //verbose 2 for print also vertices equals (debug) { - //std::cout<<"is_equal_vertice size="<size<<" "<size<=tab1->size) - { - std::cerr<<"BadIndice tab1 in is_equal_vertices "<< - di1<<" not in "<size<=tab2->size) - { - std::cerr<<"BadIndice tab2 in is_equal_vertices "<< - di2<<" not in "<size<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="<size<<" "<size<=tab1->size) + { + cerr<<"BadIndice tab1 in is_equal_vertices "<< + di1<<" not in "<size<=tab2->size) + { + cerr<<"BadIndice tab2 in is_equal_vertices "<< + di2<<" not in "<size<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 '"< 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 '"<nofile,ineighbour); + ok=this->insert_key(tmp,montab); + } + if (!CVW_FindString("nofile,ineighbour); + ok=this->insert_key(tmp,montab); + } + if (!CVW_FindString("nofile,ineighbour); + ok=this->insert_key(tmp,montab); + } + if (!CVW_FindString("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 '"<nofile); - ok=this->insert_key(tmp,montab); - } - - if (!CVW_FindString("nofile); - ok=this->insert_key(tmp,montab); - } - - if (!CVW_FindString("nofile); - ok=this->insert_key(tmp,montab); - } - - if (!CVW_FindString("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 '"<nofile); + ok=this->insert_key(tmp,montab); + } + + if (!CVW_FindString("nofile); + ok=this->insert_key(tmp,montab); + } + + if (!CVW_FindString("nofile); + ok=this->insert_key(tmp,montab); + } + + if (!CVW_FindString("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 '"<verbose>2) std::cout<<"NumberOfElements="<>ntype; - if (ntype!=3) //only triangles - { - std::cerr<<"Problem on ntype != 3"<>tmint[i+j]; - //for (int j=0; j<7; j++) std::cout<verbose>4) std::cout<<"Elements "<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"<3) cout<<"FacesNumberOfElements="<>ntype; + if (ntype!=3) //only triangles + { + cerr<<"Problem on ntype != 3"<>tmint[i+j]; + //for (int j=0; j<7; j++) cout<4) cout<<"Elements "<nofile); + ok=this->insert_key(tmp,montab); + + Ff.close(); + this->nbfiles++; + return true; } //************************************ @@ -313,58 +630,61 @@ bool ghs3dprl_mesh_wrap::ReadFileNOBOITE(const QString FileName) //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 '"<>ne>>np>>npfixe; - if (this->verbose>2) - { - std::cout<<"NumberOfElements="<>tmint[i]; - if (this->verbose>4) std::cout<<"Elements "<nofile); - ok=this->insert_key(tmp,montab); - - med_float *tmflo=new med_float[np*3]; - for (int i=0; i>tmflo[i]; - if (this->verbose>4) std::cout<<"Vertices "<nofile); - ok=this->insert_key(tmp,montab); - - Ff>>subnumber; - if (this->verbose>2) std::cout<<"NumberOfSubdomains="<>tmint[i]; - if (this->verbose>4) std::cout<<"Subdomains "<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 '"<>ne>>np>>npfixe; + if (verbose>3){ + cout<<"NoboiteNumberOfElements="<>tmint[i]; + if (verbose>4) cout<<"Elements "<nofile); + ok=this->insert_key(tmp,montab); + + med_float *tmflo=new med_float[np*3]; + for (int i=0; i>tmflo[i]; + if (verbose>4) cout<<"Vertices "<nofile); + ok=this->insert_key(tmp,montab); + + Ff>>subnumber; + if (verbose>2) cout<<"NumberOfSubdomains="<>tmint[i]; + if (verbose>4) cout<<"Subdomains "<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; } //************************************ @@ -374,293 +694,293 @@ bool ghs3dprl_mesh_wrap::ReadFileNOBOITEB(const QString FileName) //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 '"<verbose>2) - { - std::cout<<"NumberOfElements="<nofile); - ok=this->insert_key(tmp,montab); - - fread(&reste,sizeof(long),1,Ff); - //std::cout<<"info "<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="<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; inofile); - 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 '"<3){ + cout<<"NoboitebNumberOfElements="<nofile); + ok=this->insert_key(tmp,montab); + + fread(&reste,sizeof(long),1,Ff); + //cout<<"info "<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="<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; inofile); + 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 '"<verbose>2) std::cout<<"NumberOfVertices="<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 '"<2) cout<<"NumberOfVertices="<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 it( this->mestab); - while ( it.hasNext() ) - { - it.next(); - QString nom = it.key().leftJustified(20,' '); - std::cout< size="<size< it( this->mestab); + while ( it.hasNext() ) { + it.next(); + QString nom = it.key().leftJustified(32,' '); + cout< size="<size<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 it(this->mestab); - while ( it.hasNext() ) - { - it.next(); - if (it.key().contains(rxp)) { - nbremove++; - if (this->verbose>4) std::cout<<"remove key "< it(this->mestab); + while ( it.hasNext() ){ + it.next(); + if (it.key().contains(rxp)) { + nbremove++; + if (this->verbose>6) cout<<"remove key "< it(this->mestab); + while ( it.hasNext() ){ + it.next(); + if (it.key().contains(rxp)) nbremove++; + } + //cout<<"nb_key_mesh_wrap found "<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 "<filename.toLatin1().constData()<< - " number of elements "<tmint,sizeof(med_int),taille,fichier); - //fread(&gagnants,sizeof(gagnants),1,fichier); - } - if (tab->tmflo) - { - if (verbose>3) - std::cout<<"SwapOnFile in binary file "<filename.toLatin1().constData()<< - " number of elements "<tmflo,sizeof(med_float),taille,fichier); - } - fclose(fichier); - } - else - { - if (verbose>3) std::cout<<"SwapOnFile in binary file done yet "<filename.toLatin1().constData()<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 "<filename.toLatin1().constData()<< + " NbElements "<tmint,sizeof(med_int),taille,fichier); + //fread(&gagnants,sizeof(gagnants),1,fichier); + } + if (tab->tmflo){ + if (verbose>3) + cout<<"SwapOnFile_binary "<filename.toLatin1().constData()<< + " NbElements "<tmflo,sizeof(med_float),taille,fichier); + } + fclose(fichier); + } + else{ + if (verbose>3) cout<<"SwapOnFile in binary file done yet "<< + tab->filename.toLatin1().constData()<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 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(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 "<size<<">"<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 "< size="<size<type==1) - for ( long i=0; isize; i++ ) - std::cout<tmint[i]<<" "; - if (montab->type==2) - for ( long i=0; isize; i++ ) - std::cout<tmflo[i]<<" "; - std::cout<mestab[key]; + if (montab){ + //cout<<"key "< size="<size<type==1) + for ( long i=0; isize; i++ ) + cout<tmint[i]<<" "; + if (montab->type==2) + for ( long i=0; isize; i++ ) + cout<tmflo[i]<<" "; + cout<verbose>4) - std::cout<<"InsertKey "<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 "<nbelem_limit_swapsize) { + if (verbose>3) cout<<"insert key automatic SwapOnFile "<< + key.toLatin1().constData()<path,tab,this->verbose); + } + this->mestab.insert(key,tab); + return true; } //************************************ CVWtab* ghs3dprl_mesh_wrap::restore_key(const QString &key) @@ -685,178 +1009,161 @@ 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 "<size< tab NULL\n";*/ - if (!tab) //it is NOT a problem - { - if (this->verbose>6) std::cout<<"restore_key key not found "<size > 0) - { - if (this->verbose>5) std::cout<<"restore_key direct from memory "<filename.toLatin1().constData()<< - " type unexpexted "<type<filename<filename.toLatin1().constData(),"rb"); - long taille; - fread(&taille,sizeof(long),1,fichier); - if (taille!=-tab->size) - { - std::cerr<<"Problem restore_key from binary file "<filename.toLatin1().constData()<< - " size unexpexted "<size<type==1) - { - if (this->verbose>5) - std::cout<<"restore_key from binary file "<filename.toLatin1().constData()<< - " number of elements "<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 "<filename.toLatin1().constData()<< - " number of elements "<tmflo=new med_float[taille]; //allocate memory - for (int i=0; itmflo[i]=-1e0; - fread(tab->tmflo,sizeof(med_float),taille,fichier); - /*for (int i=0; itmflo[i]<<"/"; - std::cout<size=-tab->size; - return tab; + CVWtab *tab=NULL; + tab=this->mestab[key]; + /*if (tab) cout<<" -> size in proc "<size< tab NULL\n";*/ + if (!tab) //it is NOT a problem + { + if (verbose>6) cout<<"restore key not found "<size > 0){ + if (verbose>5) cout<<"restore key direct from memory "<filename.toLatin1().constData()<< + " type unexpexted "<type<filename<filename.toLatin1().constData(),"rb"); + long taille; + fread(&taille,sizeof(long),1,fichier); + if (taille!=-tab->size){ + cerr<<"Problem restore_key from binary file "<filename.toLatin1().constData()<< + " size unexpexted "<size<type==1){ + if (verbose>5) + cout<<"restore key from binary file "<filename.toLatin1().constData()<< + " number of elements "<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 "<filename.toLatin1().constData()<< + " number of elements "<tmflo=new med_float[taille]; //allocate memory + for (int i=0; itmflo[i]=-1e0; + fread(tab->tmflo,sizeof(med_float),taille,fichier); + /*for (int i=0; itmflo[i]<<"/"; + cout<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 "<restore_key(key1); + //tab1=this->mestab[key1]; + tab2=this->restore_key(key2); + //tab2=this->mestab[key2]; + //cout<<"sortie key "<restore_key(key1); - //tab1=this->mestab[key1]; - tab2=this->restore_key(key2); - //tab2=this->mestab[key2]; - //std::cout<<"sortie key "<is_equal(tab2)) - { - std::cout<<"key "<is_equal(tab2)) + { cout<<"key "<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 "<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 "<type!=tab2->type)||(tab1->size!=tab2->size)) - { - std::cout<<"key "<type!=tab2->type)||(tab1->size!=tab2->size)) + { cout<<"key "<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); @@ -867,478 +1174,1004 @@ bool ghs3dprl_mesh_wrap::test_vertices_wrap() if (!tab1 && !tab2) continue; //cas non voisins if (!tab1) { - std::cerr<<"TestEqualityCoordinates key "<size!=tab2->size) { - std::cerr<<"TestEqualityCoordinates key "<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<verbose>2)&&(ok1)) - std::cout<<"TestEqualityCoordinates "<size<< - " Vertices "<size<< - " Vertices "<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<2)&&(ok1)) + cout<<"TestEqualityCoordinates "<size<< + " Vertices "<size<< + " Vertices "<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)"<casename.truncate(20); - } - filename=this->path+this->casename; - std::ofstream file(filename.toLatin1().constData()); //master file - file<<"#MED Fichier V 2.3"<<" "<nbfiles; - long nbtetrastotal=0; - file<verbose>0) - { - if (this->verbose>2) std::cout<casename+"_%d").toLatin1().constData(),idom); - file<casename.toLatin1().constData()<<" "<verbose>4) std::cout<<"File "<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"<verbose>4)std::cout<<"NumberOfNodes="<SwapOutOfMemory_key_mesh_wrap(QRegExp(key1)); - - //writing indices of nodes - med_int *arrayi=new med_int[nbnodes]; - for (long i=0; irestore_key(key1); //tab1=this->mestab[key1]; - med_int nbfaces=tab1->size/7; - if (this->verbose>4) std::cout<<"NumberOfTrianglesOfWrap="<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"< arrayi[i]=!NBFACES!+i+1 - arrayi=new med_int[nbfaces]; - for (long i=0; i -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; itmint[(i*7)+3]; - err=MEDfamEcr(fid,namelocal,arrayi,nbfaces,MED_FACE,MED_TRIA3); - if (err<0) std::cerr<<"Problem MEDfamEcr faces of wrap"<restore_key(key1); //tab1=this->mestab[key1]; - med_int nbtetras=tab1->size/4; - nbtetrastotal=nbtetrastotal + nbtetras; - std::cout<<"NumberOfTetraedes="<size]; - //for (long i=0; isize ; 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"<SwapOutOfMemory_key_mesh_wrap(QRegExp(key1)); - - //writing indices of tetraedes - arrayi=new med_int[nbtetras]; - for (long i=0; irestore_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; itmint[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="<size/3<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_"<size<size!=glodom->size*3) { - if (imess==0) - { - std::cerr<<"Problem for domain "<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"<tmint[jd]<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"<tmint[i]-1<< + key2.sprintf("\t%13.5e%13.5e%13.5e",p1[0],p1[1],p1[2]).toLatin1().constData()<=30) { - std::cerr<<"Problem more than 30 families of nodes"<size,tab); + tmp=tmp.sprintf("NB%ld GL_SKIN",ifile); + ok=this->insert_key(tmp,montab); + if (verbose>4){ + cout<<"NumberOfEqualsVerticesDOMAIN_"<verbose>2) std::cout<<"CreateFamilyOfNodes_"<verbose>4) std::cout<<"MEDfamCr (nodes) of "<restore_key(key1); //tab1=this->mestab[key1]; - nbnodes=tab1->size; - if (this->verbose>2) - std::cout<<"CreateMEDglobalNumerotation_Nodes "<size<size ; i++) arrayi[i]=tab1->tmint[i]; - //med_2_2::med_geometrie_element toto=MED_POINT1; - //std::cout<<"MED_POINT1="<restore_key(key1); //tab1=this->mestab[key1]; - nbfaces=tab1->size; - //arrayi=new med_int[nbfaces]; - //for (int i=0; isize ; i++) arrayi[i]=tab1->tmint[i]; - if (this->verbose>2) - std::cout<<"CreateMEDglobalNumerotation_Faces "<size<tmint,nbfaces,MED_FACE,MED_TRIA3); - if (err<0) std::cerr<<"Problem MEDglobalNumEcr faces"<restore_key(key1); //tab1=this->mestab[key1]; - med_int nbtetrasglo=tab1->size; - if (nbtetrasglo!=nbtetras) - std::cerr<<"Problem incorrect size of tetraedes global numbering"<size ; i++) arrayi[i]=tab1->tmint[i]; - if (this->verbose>2) - std::cout<<"CreateMEDglobalNumerotation_Tetraedes "<size<tmint,nbtetrasglo,MED_MAILLE,MED_TETRA4); - if (err<0) std::cerr<<"Problem MEDglobalNumEcr tetraedes"<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 equals - if (!tab2) std::cerr<<"Problem nodes joint with no in file .msg"<size; - - if (this->verbose>4) - std::cout<<"NumberOfNodesOfJoint_"<casename+"_%d",ineig)); - err=MEDjointCr(fid,namelocal,namejnt,descjnt,ineig,namedist); - if (err<0) std::cerr<<"Problem MEDjointCr"< equals 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)"<0) cout<<"CreateMEDFile for all joints <"<\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 = "<0)cout<<"CreateMEDFile for initial skin <"<\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="<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<<"<"<"<0){ + if (verbose>2) cout<\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 : "<6){cout<<"\nFinalsFamilies\n"; families.write();} + //for nodes families + nb=create_families(fid,1); + if (verbose>5)cout<<"NumberOfFamiliesNodes="<8) + cout<<"MEDfamEcr nodes "<5)cout<<"NumberOfFamiliesFacesAndEdgesEtc="<8) + cout<<"MEDfamEcr tria3 "<8) + cout<<"MEDfamEcr tetra4 "<0)cout<<"\nTotalNumberOftetrahedra="<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"<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"<4)cout<<"NumberOfNodes="<restore_key(key1); //tab1=this->mestab[key1]; - if (!tab1) - { - if (this->verbose>4) - std::cout<<"NumberOfTrianglesOfJoint_"<no joints + if (!tab1) { + tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".glo"; + ok=this->ReadFileGLO(tmp); + if (!ok) {cerr<<"Problem file "<restore_key(key1); //tab1=this->mestab[key1]; + if (!tab1) return false; + } + if (nbnodes!=tab1->size){cerr<<"Problem size GLi VE!=nbnodes!"<restore_key(key2); //tab1=this->mestab[key1]; + med_int nbskin=tab2->size; + //for (i=0; itmint[i]<tmint[i]-1; // + if (jtmint[j]; + } + } + ok=set_one_more_family(famnodes,fammore,nb); + delete[] fammore; + + //cout<<"nodes loc "<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])<tmint,nbnodes,MED_NOEUD,MED_NONE); + if (err<0){cerr<<"Problem MEDglobalNumEcr nodes"<restore_key(key1); //no need because equals - if (!tab2) std::cerr<<"Problem triangles joint send with no receive"<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 "< newfam "<300) cout<< + "***set_one_more_family*** warning many initial families could decrease speed "<=0)&&(ii newfam "<=0) newfami[ii]=newfam; + } + /*else { + cout<<"!!! oldfam "< newfam "<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="<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"<verbose>4) - std::cout<<"NumberOfTrianglesOfJoint_"< equals 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[i]=!NBFACES!+i+1 + arrayi=new med_int[nbtria3]; + for (i=0; irestore_key(key1); //tab1=this->mestab[key1]; + if (nbtria3!=tab1->size){cerr<<"Problem size GLi FA!=nbtria3!"<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; itmint[i]-1; // + if (jtmint[j]; + } + } + ok=set_one_more_family(famtria3,fammore,nb); + delete[] fammore; + + //writing faces(triangles) global numbering + //if (verbose>2) + // cout<<"CreateMEDglobalNumerotation_Faces "<size<tmint,tab1->size,MED_MAILLE,MED_TRIA3); + if (err<0){cerr<<"Problem MEDglobalNumEcr faces"<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 "<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 equals + if (!tab2) cerr<<"Problem nodes joint with no in file .msg"<size; nbnodesneig=nb; + + nbjoints++; //one more joint for this domain + sjoints=sjoints+" "+i2a(ineig); + if (verbose>4) + cout<<"NumberOfNodesOfJoint_"<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 equals 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"<restore_key(key1); //tab1=this->mestab[key1]; + if (!tab1){ + if (verbose>4) + cout<<"NumberOfTrianglesOfJoint_"<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 equals + if (!tab2) cerr<<"Problem triangles joint send with no receive"<restore_key(key); //tab1=this->mestab[key1]; + + med_int nb=tab1->size; nbtria3neig=nb; + if (verbose>4) + cout<<"NumberOfTrianglesOfJoint_"< equals 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<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"<0) { + //for (i=0; i0) 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"<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="<tmint,MED_FULL_INTERLACE,nbtetra4,MED_MAILLE,MED_TETRA4,MED_NOD); + if (err<0){cerr<<"Problem MEDconnEcr for tetra connectivity"<verbose>2) - std::cout<<"CreateFamilyOfFaces_"<verbose>4) std::cout<<"MEDfamCr (faces) of "<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"<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"<2) + cout<<"CreateMEDglobalNumerotation_tetrahedra "<size<tmint,tab1->size,MED_MAILLE,MED_TETRA4); + if (err<0){cerr<<"Problem MEDglobalNumEcr tetrahedra"<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 <"<\tNbGroups="<5)cout<<" <"<<&gro[i*MED_TAILLE_LNOM]<<"> "; + i++; + } + if (verbose>5)cout< - -class QRegExp; +#include +#include //Med File V 2.2 attributes #undef MED_H @@ -38,12 +38,21 @@ namespace med_2_2 { } } +#include +#include +#include +#include + +using namespace std; using namespace med_2_2; class CVWtab //contains size=size of vector and the vector (med_int or med_float) { + public: + static long memoryuse; + static long memorymax; long size,type; med_int *tmint; //integer med med_float *tmflo; //float med @@ -56,36 +65,102 @@ public: bool is_equal(CVWtab *tab2); }; +typedef map fend; +typedef map fagr; +class familles{ + private: + void newfam(QString nom); + void newgro(QString nom); + public: + int no; + fagr fam; + fagr gro; + void write(); + xmlNodePtr xml_groups(); + void add(QString nomfam, QString nomgro); + void addgro(); + bool get_number_of_new_family(int sign,med_int *num,QString *tmp); + med_int find_family_on_groups(med_int fam1, med_int fam2); + fend fuse_goups(med_int fam1, med_int fam2); +}; + class ghs3dprl_mesh_wrap { public: - QString casename,path; + QString medname,casename,path,pathini,filemed,format; + QRegExp deletegroups; //regular expression long - nofile,nbfiles, + nbtetrastotal, + nofile,nbfiles,nbfilestot, nbelem_limit_swap, verbose; + med_err err; + med_idt fid,fidjoint; + med_int idom; + + //master.xml + string filemaster,domainname; + char distfilename[MED_TAILLE_DESC]; + xmlDocPtr master_doc; + xmlNodePtr root_node,node,node2, + joints_node,info_node,files_node,mesh_node; + QHash mestab; + familles families; + + //from skin.med + char nommaa[MED_TAILLE_NOM+1]; + char maillage_description[MED_TAILLE_DESC+1]; + char nomcoo[3*MED_TAILLE_PNOM+1]; + char unicoo[3*MED_TAILLE_PNOM+1]; + med_int *famnodesskin; //from skin.med... + med_int *famseg2skin; //...valid on global index/numerotation + med_int *famtria3skin; + + //to final files .med with tetrahedra + char nomfinal[MED_TAILLE_NOM+1]; + med_int *famnodes,nbnodes,famnewnodes,famallnodes; //to final files .med with tetrahedra + med_int *famseg2,nbseg2,famnewseg2,famallseg2; + med_int *famtria3,nbtria3,famnewtria3,famalltria3; + med_int *famtetra4,nbtetra4,famnewtetra4,famalltetra4; //low level bool list_keys_mesh_wrap(); //list keys bool list_onekey_mesh_wrap(const QString &key); long remove_key_mesh_wrap(const QRegExp &rxp); + long nb_key_mesh_wrap(const QRegExp &rxp); long remove_all_keys_mesh_wrap(); bool insert_key(const QString &key,CVWtab *tab); CVWtab* restore_key(const QString &key); + //family level + bool set_one_more_family(med_int *fami, med_int *more, med_int nb); + med_int create_families(med_idt fid,int sign); + void add_family(med_int num,QString newgro); + void cout_families_and_groups(); + bool idom_nodes(); + bool idom_edges(); + bool idom_faces(); + bool idom_joints(); + bool idom_tetras(); + //test level bool test_msg_wrap(); bool test_vertices_wrap(); //hight level - long SwapOutOfMemory_key_mesh_wrap(const QRegExp &rxp); + long SwapOutOfMemory_key_mesh_wrap(const QRegExp &rxp,long ifgreaterthan=0); + bool ReadFileMSGnew(const QString FileName); bool ReadFileGLO(const QString FileName); bool ReadFileFACES(const QString FileName); bool ReadFileNOBOITE(const QString FileName); bool ReadFileNOBOITEB(const QString FileName); bool ReadFilePOINTS(const QString FileName); - bool Write_MEDfiles(); + bool Find_VerticesDomainToVerticesSkin(); + bool Write_masterxmlMEDfile(); + bool Write_MEDfiles_v0(bool deletekeys=FALSE); + bool Write_MEDfiles_v1(bool deletekeys=FALSE); + bool Write_MEDfiles_v2(bool deletekeys=FALSE); }; #endif diff --git a/src/tepal2med/tepal2med.cxx b/src/tepal2med/tepal2med.cxx index 581140b..3e87f02 100755 --- a/src/tepal2med/tepal2med.cxx +++ b/src/tepal2med/tepal2med.cxx @@ -1,4 +1,4 @@ -// 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 @@ -18,17 +18,18 @@ // // --- // 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 /* printf clrscr fopen fread fwrite fclose */ #include #include #include +#include #include #include @@ -39,342 +40,942 @@ #include "ghs3dprl_msg_parser.h" #include "dlg_ghs3dmain.h" +//#include "MEDMEM_Exception.hxx" +//#include "MEDMEM_define.hxx" + +extern "C" { +#include +//#include +#include +//#include +#include +} + +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 "<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 "<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 *** "<verbose); + if (fid == 0) { + cerr<<"Problem opening file "< 1) cout<<"More than one mesh in "<nommaa,&mdim,&type_maillage, + mymailw->maillage_description); + if (ret < 0){ + cerr<<"Problem MEDmaaInfo in "<nommaa); + if (!((edim == 3)||(edim == -1))){ + cerr<<"Problem dimension Espace should be 3 or -1: "<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;inommaa,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"<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="< 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;inommaa,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 "<deletegroups)>0) { + //cout<<"idelete++ "<0) { //only delete family whith all delete groups + //cout<<"famdelete++ "<deletegroups)==0){ + if (sgro.contains(qgroup)>0) { + sgro="Skin_"+sgro; //pas sur que ce soit pertinent + } + if (mymailw->verbose>8) cout<<"families.add("<families.add(sfam,sgro); + } + else { + //sgro="Skin_"+sgro; //pas sur que ce soit pertinent + //cout<<"--deletegroups matches \""<verbose>3) cout<<"--deletegroups matches \""<< + sgro.toLatin1().constData()<< + "\" in family "<deletegroups)==0){ + //sgro="Skin_"+sgro; //pas sur que ce soit pertinent + cout<<"families.add("<families.add(sfam,sgro); + } + else { + cout<<"--deletegroups matches \""<verbose>3){ + cout<<"\nFamiliesAndGroupsOf "<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;inommaa,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;inommaa,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;i0) { + //cout<<"!!!!!!!!nodes "<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 "<> *v >> v2) return true; else {*v=0 ;return false;} +} + +//************************************ +bool string2float(const string &s, float *v) +//float ff; +//ok=string2float(s,&ff); +//cout<<"test3 "<> *v >> v2) return true; else {*v=0. ;return false;} +} + +//************************************ +string int2string(const int &v) +{ + ostringstream ss; + ss<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 "<KeepFiles()<<" "<NbPart()<KeepFiles()<<" "<NbPart()<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)"< "+path+"tepal.log"; - std::cout<<"\nLaunchTepal Command = "<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="<0) - std::cout<<"NumberOfFilesMSGAcquired="<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)"<0) + pathini=casename.section('/',-n-1,-2)+"/"; + else + pathini="./"; + casename=casename.section('/',-1); + if (casename.length()>20){ + cerr<<"--casename truncated (no more 20 characters)"<0) + cout<<"tepal2med "< 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="<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 "<families.no<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="<ReadFileMSGnew(tmp); + } + if (verbose>0) + cout<<"NumberOfFilesMSGacquired="<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 1.0 - //after verification remove duplicates data - //for debug but don't do that because reliability - // and locality of datas files - //" RE " for duplicates - //int nb=mymailw->remove_key_mesh_wrap(QRegExp("( NE0 | RE)",true,false)); - - //because equals - int nb=0; - nb=mymailw->remove_key_mesh_wrap(QRegExp("RE")); - if (verbose>3) std::cout<<"NumberOfKeysRemoved="<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="<ReadFileNOBOITE(tmp); - //mymailw->SwapOutOfMemory_key_mesh_wrap(QRegExp("NB",true,false)); - } - if (verbose>0) - std::cout<<"NumberOfFilesNOBOITEAcquired="<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="<0) + cout<<"NumberOfFilesMSGAcquired="<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="<ReadFileFACES(tmp); - } - if (verbose>0) - std::cout<<"NumberOfFilesFACESAcquired="<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="<ReadFilePOINTS(tmp); - } - if (verbose>0) - std::cout<<"NumberOfFilesPOINTSAcquired="<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="<ReadFileGLO(tmp); - //mymailw->SwapOutOfMemory_key_mesh_wrap(QRegExp("GL",true,false)); - } - if (verbose>0) - std::cout<<"NumberOfFilesGLOAcquired="<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 1.0 + //after verification remove duplicates data + //for debug but don't do that because reliability + // and locality of datas files + //" RE " for duplicates + //int nb=mymailw->remove_key_mesh_wrap(QRegExp("( NE0 | RE)",true,false)); + + //because equals + nb=0; + nb=mymailw->remove_key_mesh_wrap(QRegExp("RE",Qt::CaseSensitive,QRegExp::RegExp)); + if (verbose>3) cout<<"NumberOfKeysRemoved="<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="<ReadFileNOBOITE(tmp); + } + if (verbose>0) + cout<<"NumberOfFilesNOBOITEAcquired="<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="<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*** "<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="<ReadFileFACES(tmp); + } + if (verbose>0) + cout<<"NumberOfFilesFACESAcquired="<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="<ReadFilePOINTS(tmp); + } + if (verbose>0) + cout<<"NumberOfFilesPOINTSAcquired="<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="<ReadFileGLO(tmp); + //mymailw->SwapOutOfMemory_key_mesh_wrap(QRegExp("GL",true,false)); + } + if (verbose>0) + cout<<"NumberOfFilesGLOAcquired="<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="<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*** "<0)cout<