]> SALOME platform Git repositories - plugins/ghs3dprlplugin.git/commitdiff
Salome HOME
PAL19772 integration modifications GHS3DPRL plugin, and Hexotic plugin
authoreap <eap@opencascade.com>
Tue, 20 May 2008 09:46:34 +0000 (09:46 +0000)
committereap <eap@opencascade.com>
Tue, 20 May 2008 09:46:34 +0000 (09:46 +0000)
     a message from a CEA developpeur : modified files for plugin GHS3DPRL (and Hexotic) correcting weakness in Hexotic plugin

src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.cxx
src/GHS3DPRLPlugin/GHS3DPRLPlugin_Hypothesis.cxx
src/GHS3DPRLPlugin/Makefile.in
src/gui/GHS3DPRLPluginGUI_HypothesisCreator.cxx
src/tepal2med/ghs3dprl_mesh_wrap.cxx
src/tepal2med/tepal2med.cxx

index 46f7df423a134abb86885e5c54ac906d36958fbd..47e7ccebdd71f5c26476ca2f5ff3fe607bb11bca 100755 (executable)
@@ -83,8 +83,7 @@ bool GHS3DPRLPlugin_GHS3DPRL::CheckHypothesis
                           const TopoDS_Shape& aShape,
                           SMESH_Hypothesis::Hypothesis_Status& aStatus)
 {
-  MESSAGE("GHS3DPRLPlugin_GHS3DPRL::CheckHypothesis");
-
+  //MESSAGE("GHS3DPRLPlugin_GHS3DPRL::CheckHypothesis");
   _hypothesis = NULL;
 
   list<const SMESHDS_Hypothesis*>::const_iterator itl;
@@ -376,7 +375,8 @@ static bool readResult(FILE *                           theFile,
 //=============================================================================
 // Pass parameters to GHS3DPRL
 
-void GHS3DPRLPlugin_GHS3DPRL::SetParameters(const GHS3DPRLPlugin_Hypothesis* hyp) {
+void GHS3DPRLPlugin_GHS3DPRL::SetParameters(const GHS3DPRLPlugin_Hypothesis* hyp)
+{
   if (hyp) {
     MESSAGE("GHS3DPRLPlugin_GHS3DPRL::SetParameters");
     _MEDName = hyp->GetMEDName();  //"DOMAIN\0"
@@ -386,13 +386,13 @@ void GHS3DPRLPlugin_GHS3DPRL::SetParameters(const GHS3DPRLPlugin_Hypothesis* hyp
 }
 
 //=======================================================================
-
+//before launching salome
+//SALOME_TMP_DIR (for keep tepal intermediates files) could be set in user's directories
 static TCollection_AsciiString getTmpDir()
 {
   TCollection_AsciiString aTmpDir;
-
   char *Tmp_dir = getenv("SALOME_TMP_DIR");
-  if (Tmp_dir == NULL) Tmp_dir = getenv("TMPDIR");
+  if (Tmp_dir == NULL) Tmp_dir = getenv("TMP");
   if(Tmp_dir != NULL)
   {
     aTmpDir = Tmp_dir;
@@ -407,10 +407,9 @@ static TCollection_AsciiString getTmpDir()
 #ifdef WIN32
       aTmpDir = TCollection_AsciiString("C:\\");
 #else
-      aTmpDir = TCollection_AsciiString("/export/home/");
+      aTmpDir = TCollection_AsciiString("/tmp/");
 #endif
   }
-  //cout<<"getTmpDir()="<<aTmpDir<<endl;
   return aTmpDir;
 }
 
@@ -418,9 +417,8 @@ static TCollection_AsciiString getTmpDir()
 // Here we are going to use the GHS3DPRL mesher
 
 bool GHS3DPRLPlugin_GHS3DPRL::Compute(SMESH_Mesh&          theMesh,
-                                     const TopoDS_Shape& theShape) {
-
-
+                                     const TopoDS_Shape& theShape)
+{
    bool Ok;
    MESSAGE("GHS3DPRLPlugin_GHS3DPRL::Compute");
 
@@ -453,18 +451,17 @@ bool GHS3DPRLPlugin_GHS3DPRL::Compute(SMESH_Mesh&          theMesh,
 
   if (_countSubMesh == _countTotal )
   {
+      //string tmpDir=getTmpDir_new();
       TCollection_AsciiString
          tmpDir=getTmpDir(),
          GHS3DPRL_In,
          GHS3DPRL_Out,
          NbPart,
-         run_GHS3DPRL("tepal2med "),
-         run_keep_files("rm ");
-
-      //example: tepal2med GHS3DPRL 4 12500000 4 Test noMemu LaunchTepal
-
-      TCollection_AsciiString path;
-      TCollection_AsciiString casenamemed;//_MEDName.c_str());
+         run_GHS3DPRL("tepal2med "), //example: tepal2med GHS3DPRL 4 12500000 4 Test noMenu LaunchTepal
+         run_nokeep_files("rm "),
+         path,
+         casenamemed;  //_MEDName.c_str());
+      
       casenamemed += (char *)_MEDName.c_str();
       int n=casenamemed.SearchFromEnd('/');
       if (n>0)
@@ -488,14 +485,20 @@ bool GHS3DPRLPlugin_GHS3DPRL::Compute(SMESH_Mesh&          theMesh,
       GHS3DPRL_In=path + "GHS3DPRL";
       GHS3DPRL_Out=path + casenamemed;
       NbPart=_NbPart;
-      run_GHS3DPRL += GHS3DPRL_In + " " + NbPart + " 12500000 1 Test noMemu LaunchTepal " + GHS3DPRL_Out;
-      run_keep_files += GHS3DPRL_In + ".*.*.* " + path + "tepal.out";
+      run_GHS3DPRL += GHS3DPRL_In + " " + NbPart + " 12500000 1 Test noMenu LaunchTepal " + GHS3DPRL_Out ;
+      run_nokeep_files += GHS3DPRL_In + ".*.*.* " + path + "tepal.log";
+      
+      system( run_nokeep_files.ToCString() ); //clean files
       cout<<"GHS3DPRL command : "<<run_GHS3DPRL<<endl;
 
       OSD_File( GHS3DPRL_Out ).Remove(); //only the master med file
       Ok=writeGHS3DPRLFiles(GHS3DPRL_In, meshDS, aSmdsToGHS3DPRLIdMap, aGHS3DPRLIdToNodeMap);
 
+      //sometimes it is better to wait flushing files on slow filesystem...
+      system( "sleep 3" );
       if (Ok) system( run_GHS3DPRL.ToCString() );
+      //sometimes it is better to wait flushing files on slow filesystem...
+      system( "sleep 3" );
 
       // read a result, GHS3DPRL_Out is the name of master file (previous xml format)
       FILE * aResultFile = fopen( GHS3DPRL_Out.ToCString(), "r" );
@@ -505,18 +508,15 @@ bool GHS3DPRLPlugin_GHS3DPRL::Compute(SMESH_Mesh&          theMesh,
           Ok = true;
           fclose(aResultFile);
           cout << "GHS3DPRL OK output file "<<GHS3DPRL_Out<<" exist !\n\n";
-          if (!_KeepFiles)
-          {
-             system( run_keep_files.ToCString() );
-          }
+          if (!_KeepFiles) system( run_nokeep_files.ToCString() );
       }
       else
       {
           Ok = false;
           cout << "GHS3DPRL KO output files "<<GHS3DPRL_Out<<" do not exist ! see intermediates files keeped:\n";
-          TCollection_AsciiString run_keep_files("ls -alt ");
-          run_keep_files += GHS3DPRL_Out + "* " + GHS3DPRL_In + "* " + path + "tepal.out";
-          system( run_keep_files.ToCString() );
+          TCollection_AsciiString run_list_files("ls -alt ");
+          run_list_files += GHS3DPRL_Out + "* " + GHS3DPRL_In + "* " + path + "tepal.log";
+          system( run_list_files.ToCString() );
           cout<<endl;
       }
       _countSubMesh=0;
index 866a76eff8f95beaab48d1debc6f5a95db231734..e51f20e9f82e6c0dfde4cfb246f0dead4e4b7717 100755 (executable)
@@ -28,6 +28,7 @@
 using namespace std;
 #include <GHS3DPRLPlugin_Hypothesis.hxx>
 #include <utilities.h>
+#include <qstring.h>
 
 //=============================================================================
 /*!
@@ -53,8 +54,14 @@ GHS3DPRLPlugin_Hypothesis::GHS3DPRLPlugin_Hypothesis (int hypId, int studyId,
 //=============================================================================
 
 void GHS3DPRLPlugin_Hypothesis::SetMEDName(string theVal) {
-  if (theVal != _MEDName) {
-    _MEDName = theVal;
+  //without whitespaces! ..from python?
+  QString tmp1,tmp2;  
+  tmp1 = (QString) theVal;
+  tmp1.simplifyWhiteSpace(); //for qt3
+  tmp1.replace(QChar(' '),QChar('_'));
+  tmp2 = (QString) _MEDName;
+  if (tmp1 != tmp2) {
+    _MEDName = (const char *) tmp1;
     NotifySubMeshesHypothesisModification();
   }
 }
@@ -80,12 +87,15 @@ void GHS3DPRLPlugin_Hypothesis::SetKeepFiles(bool theVal) {
 //=============================================================================
 ostream & GHS3DPRLPlugin_Hypothesis::SaveTo(ostream & save)
 {
-  save << "MEDName=" << _MEDName;
-  save << "NbPart=" << _NbPart;
-  save << "KeepFiles=" << (int)_KeepFiles;
-  cout << endl;
-  cout << "save : " << save << endl;
-  cout << endl;
+  /*save << _MEDName ; //without whitespaces!
+  save << " " << _NbPart;
+  save << " " << (int)_KeepFiles;*/
+
+  //explicit outputs for future code compatibility of saved .hdf
+  //save without any whitespaces!
+  save<<"MEDName="<<_MEDName<<";";
+  save<<"NbPart="<<_NbPart<<";";
+  save<<"KeepFiles="<<(int) _KeepFiles<<";";
   return save;
 }
 
@@ -96,55 +106,31 @@ ostream & GHS3DPRLPlugin_Hypothesis::SaveTo(ostream & save)
 //=============================================================================
 istream & GHS3DPRLPlugin_Hypothesis::LoadFrom(istream & load)
 {
-//   bool isOK = true;
-//   int is;
-//   double val;
-
-//   isOK = (load >> val);
-//   if (isOK)
-//     _maxSize = val;
-//   else
-//     load.clear(ios::badbit | load.rdstate());
-
-//   isOK = (load >> is);
-//   if (isOK)
-//     SetFineness((Fineness) is);
-//   else
-//     load.clear(ios::badbit | load.rdstate());
-
-//   if (_fineness == UserDefined)
-//   {
-//     isOK = (load >> val);
-//     if (isOK)
-//       _growthRate = val;
-//     else
-//       load.clear(ios::badbit | load.rdstate());
-
-//     isOK = (load >> val);
-//     if (isOK)
-//       _nbSegPerEdge = val;
-//     else
-//       load.clear(ios::badbit | load.rdstate());
-
-//     isOK = (load >> val);
-//     if (isOK)
-//       _nbSegPerRadius = val;
-//     else
-//       load.clear(ios::badbit | load.rdstate());
-//   }
-
-//   isOK = (load >> is);
-//   if (isOK)
-//     _secondOrder = (bool) is;
-//   else
-//     load.clear(ios::badbit | load.rdstate());
-
-//   isOK = (load >> is);
-//   if (isOK)
-//     _optimize = (bool) is;
-//   else
-//     load.clear(ios::badbit | load.rdstate());
-  return load;
+   //explicit inputs for future code compatibility of saved .hdf
+   bool isOK = true;
+   int imax;
+   string str1;
+   QString str2,str3,str4,str5;
+   
+   //save without any whitespaces!
+   isOK = (load >> str1);
+   if (!(isOK)) {
+     //defaults values assumed
+     load.clear(ios::badbit | load.rdstate());
+     return load;
+   }
+   str2 = (QString) str1;
+   imax = str2.contains(";");
+   for (int i=0; i<=imax; i++) {
+      str3 = str2.section(";",i,i);
+      str4 = str3.section("=",0,0);
+      str5 = str3.section("=",1,1);
+
+      if (str4=="MEDName") _MEDName = str5.ascii();
+      if (str4=="NbPart") _NbPart = str5.toInt();
+      if (str4=="KeepFiles") _KeepFiles = (bool) str5.toInt();
+   }
+   return load;
 }
 
 //=============================================================================
index 525c23f4414eaa4a703d49284d26ee228c80c1c5..45fd4a7d2ad4d90d0788a8ed7761e5cb6d33e535 100755 (executable)
@@ -51,4 +51,11 @@ LIB_CLIENT_IDL = \
 # Libraries targets
 LIB = libGHS3DPRLEngine.la
 
+CPPFLAGS+=$(QT_INCLUDES)
+LDFLAGSFORBIN+=-lm $(QT_LIBS)
+
+$(BIN):$(OBJ)
+       $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(QT_LIBS)  $< 
+
+
 @CONCLUDE@
index ccb2df8027e84024b2304b4c8a77856913a479fc..bcd9d03e8d457e8815cda2ab948563cea25ea607 100755 (executable)
@@ -65,6 +65,7 @@ bool GHS3DPRLPluginGUI_HypothesisCreator::checkParams() const
   readParamsFromHypo( data_old );
   readParamsFromWidgets( data_new );
   bool res = storeParamsToHypo( data_new );
+  storeParamsToHypo( data_old );
   return res;
 }
 
@@ -179,9 +180,12 @@ bool GHS3DPRLPluginGUI_HypothesisCreator::readParamsFromWidgets( GHS3DPRLHypothe
 {
   h_data.myName = myName ? myName->text() : "";
   h_data.myMEDName = myMEDName->text();
+  //without whitespaces!
+  //h_data.myMEDName.simplified(); //for qt4
+  h_data.myMEDName.simplifyWhiteSpace(); //for qt3
+  h_data.myMEDName.replace(QChar(' '),QChar('_'));
   h_data.myNbPart = myNbPart->value();
   h_data.myKeepFiles = myKeepFiles->isChecked();
-
   return true;
 }
 
index 6a699c249812b3e76deab797c9452a41593599d2..2a15d8b5348cda0d9470b4a91da6736518f6aa63 100755 (executable)
@@ -927,6 +927,7 @@ bool ghs3dprl_mesh_wrap::Write_MEDfiles()
    file<<"#MED Fichier V 2.3"<<" "<<endl;
    file<<"# NumbersOfSubDomains"<<" "<<endl;
    int nbdomains=this->nbfiles;
+   long nbtetrastotal=0;
    file<<nbdomains<<" "<<endl;
 
    //loop on the domains
@@ -1047,7 +1048,8 @@ bool ghs3dprl_mesh_wrap::Write_MEDfiles()
       key1=key1.sprintf("NB%d EV",idom); //files.NoBoite Elements Vertices (tetra only)
       tab1=this->restore_key(key1); //tab1=this->mestab[key1];
       med_int nbtetras=tab1->size/4;
-      if (this->verbose>4) cout<<"NumberOfTetraedes="<<nbtetras<<endl;
+      nbtetrastotal=nbtetrastotal + nbtetras;
+      cout<<"NumberOfTetraedes="<<nbtetras<<endl;
       //arrayi=new med_int[tab1->size];
       //for (long i=0; i<tab1->size ; i++) arrayi[i]=tab1->tmint[i];
       err=MEDconnEcr(fid,namelocal,3,tab1->tmint,MED_FULL_INTERLACE,nbtetras,MED_MAILLE,MED_TETRA4,MED_NOD);
@@ -1315,6 +1317,7 @@ bool ghs3dprl_mesh_wrap::Write_MEDfiles()
       //../Salome_321/hdf5-1.6.3/bin/h5dump exemple11.med
       //../Salome_321/med_231_install/bin/mdump exemple11.med
    }
+   cout<<"\nTotalNumberOfTetraedes="<<nbtetrastotal<<endl;
    return ok;
 }
 
index 5b19e5408a0e9d465dac203df8b4cf1b0691bdaa..827cc5e7588f513b838b7a3b6bf8a851507e19f8 100755 (executable)
@@ -27,7 +27,7 @@ int main(int argc, char **argv)
    bool ok,is_test,is_menu,is_launchtepal;
    int nbfiles,nbelem_limit_swap,verbose;
    QString casename,casenamemed,tmp,cmd,format;
-   QString version="V0.1 beta";
+   QString version="V0.2 beta";
 
 
    if ((argc > 11)||(argc < 2))
@@ -150,22 +150,25 @@ int main(int argc, char **argv)
 
    //verbose=5;
    if (verbose>0)
-   cout<<"CaseNameTepal="<<casename<<
-         " NumberOfFiles="<<nbfiles<<
-         " LimitSwap="<<nbelem_limit_swap<<
-         " Verbose="<<verbose<<
-         " Test="<<is_test<<
-         " Menu="<<is_menu<<
-         " LaunchTepal="<<is_launchtepal<<
-         " CaseNameMed="<<path+casenamemed<<
+   cout<<"tepal2med parameters:"<<
+        "\n CaseNameTepal="<<casename<<
+         "\n NumberOfFiles="<<nbfiles<<
+         "\n LimitSwap="<<nbelem_limit_swap<<
+         "\n Verbose="<<verbose<<
+         "\n Test="<<is_test<<
+         "\n Menu="<<is_menu<<
+         "\n LaunchTepal="<<is_launchtepal<<
+         "\n CaseNameMed="<<path+casenamemed<<
          "\n";
 
    //"tepal -f exemple1 -n 4"
    if (is_launchtepal)
    {
-   cmd="tepal -f "+casename+" -n "+cmd.sprintf("%d",nbfiles)+" > "+path+"tepal.out";
-   cout<<"LaunchTepal Command = "<<cmd<<endl;
-   system( (const char *) cmd ); // run
+      cmd="tepal -f "+casename+" -n "+cmd.sprintf("%d",nbfiles)+" > "+path+"tepal.log";
+      cout<<"\nLaunchTepal Command = "<<cmd<<endl;
+      system( (const char *) cmd ); // run
+      //sometimes it is better to wait flushing files on slow filesystem...
+      system( "sleep 3" );
    }
 
    ghs3dprl_mesh_wrap *mymailw=new ghs3dprl_mesh_wrap;