Salome HOME
Merge branch 'occ/new_mg_licnese'
authorvsr <vsr@opencascade.com>
Fri, 24 Sep 2021 08:54:11 +0000 (11:54 +0300)
committervsr <vsr@opencascade.com>
Fri, 24 Sep 2021 08:54:11 +0000 (11:54 +0300)
1  2 
src/SMESH/MG_ADAPT.cxx
src/SMESH_I/SMESH_Gen_i.cxx

diff --combined src/SMESH/MG_ADAPT.cxx
index 6253f497574ce5d49293e631bad06802edfcd8cd,d490092d1e833ef2c5b00c32760c4ee402bbd343..27a57c894cc24edb5544fa21a0d1b1b1807641dc
  
  #include "MG_ADAPT.hxx"
  
- #include "SMESH_File.hxx"
- #include "SMESH_Comment.hxx"
+ #include <DriverGMF_Read.hxx>
+ #include <SMESH_Comment.hxx>
+ #include <SMESH_File.hxx>
+ #include <SMESH_MGLicenseKeyGen.hxx>
+ #include <SMESH_TypeDefs.hxx>
  
  #include <MEDFileData.hxx>
  #include <MEDFileField.hxx>
@@@ -30,7 -33,6 +33,7 @@@
  
  #include <Utils_SALOME_Exception.hxx>
  #include <Basics_Utils.hxx>
 +#include "SMESH_TypeDefs.hxx"
  
  #ifndef WIN32
  #include <unistd.h> // getpid()
@@@ -320,7 -322,7 +323,7 @@@ MgAdaptHypothesisData* MgAdapt::getData
  }
  void MgAdapt::setMedFileIn(std::string fileName)
  {
-   if ( isFileExist(fileName) )
+   if ( isFileExist( fileName ))
    {
      medFileIn = fileName;
  
@@@ -1006,7 -1008,7 +1009,7 @@@ std::string MgAdapt::getCommandToRun(
          cmd += " --";
        else
          cmd += " ";
- //       std::cout << "--- option: '" << option << ", value: '" << value <<"'"<< std::endl;
      //       std::cout << "--- option: '" << option << ", value: '" << value <<"'"<< std::endl;
        cmd += option + " " + value;
      }
    }
    {
      cmd+= " --verbose "+ ToComment(verbosityLevel);
    }
-     //~}
- //~cmd+= " >"
+   // get license key
+   {
+     smIdType nbVertex, nbEdge, nbFace, nbVol;
+     DriverGMF_Read gmfReader;
+     gmfReader.SetFile( meshIn );
+     gmfReader.GetMeshInfo( nbVertex, nbEdge, nbFace, nbVol );
+     std::string errorTxt;
+     std::string key = SMESHUtils_MGLicenseKeyGen::GetKey( meshIn,
+                                                           FromSmIdType<int>( nbVertex ),
+                                                           FromSmIdType<int>( nbEdge ),
+                                                           FromSmIdType<int>( nbFace ),
+                                                           FromSmIdType<int>( nbVol ),
+                                                           errorTxt );
+     if ( key.empty() )
+       return ToComment( "Problem with library SalomeMeshGemsKeyGenerator: " + errorTxt );
+     cmd += " --key " + key;
+   }
  #ifdef WIN32
-     cmd += " < NUL";
+   cmd += " < NUL";
  #endif
- //   std::cout << "--- cmd :"<< std::endl;
- //   std::cout << cmd << std::endl;
  //   std::cout << "--- cmd :"<< std::endl;
  //   std::cout << cmd << std::endl;
  
    return cmd;
  }
@@@ -1074,7 -1094,9 +1095,9 @@@ std::string MgAdapt::defaultWorkingDire
    {
      aTmpDir = Tmp_dir;
    }
-   else {
+   if ( ! isFileExist( aTmpDir ))
+   {
  #ifdef WIN32
      aTmpDir = "C:\\";
  #else
@@@ -1381,17 -1403,8 +1404,17 @@@ void MgAdapt::convertMedFile(std::strin
      checkTimeStepRank(medFileIn) ;
      MEDCoupling::MCAuto<MEDCoupling::MEDFileAnyTypeFieldMultiTS> fts( mfd->getFields()->getFieldWithName(fieldName) );
      MEDCoupling::MCAuto<MEDCoupling::MEDFileAnyTypeField1TS> f = fts->getTimeStep(timeStep, rank);
 -    MEDCoupling::MCAuto<MEDCoupling::MEDFileFieldMultiTS> tmFts = MEDCoupling::MEDFileFieldMultiTS::New();
 -    tmFts->pushBackTimeStep(f);
 +    MEDCoupling::MCAuto<MEDCoupling::MEDFileFieldMultiTS> tmFts = MEDCoupling::DynamicCast<MEDCoupling::MEDFileAnyTypeFieldMultiTS,MEDCoupling::MEDFileFieldMultiTS>(fts);
 +
 +    // if not able to cast to double field, try float field
 +    if (!tmFts)
 +    {
 +      MEDCoupling::MCAuto<MEDCoupling::MEDFileFloatFieldMultiTS>  tmFtsFloat = MEDCoupling::DynamicCast<MEDCoupling::MEDFileAnyTypeFieldMultiTS,MEDCoupling::MEDFileFloatFieldMultiTS>(fts);
 +      if (!tmFtsFloat)
 +        THROW_SALOME_EXCEPTION("\nUnexpected field type.\n");
 +      // convert float field to double
 +      tmFts = tmFtsFloat->convertToDouble();
 +    }
  
      fields->pushField(tmFts);
  
index 30d0352628819ea10452f6257cbef4ee2c3d539b,b34058a2c5d21cd6078e0cee64fbd25730eac5da..336c341ee501fb83fb0e93880972e95b5f8ec56e
  #include <memory>
  
  #include <boost/archive/text_oarchive.hpp>
- #include <boost/archive/text_iarchive.hpp>
  #include <boost/serialization/list.hpp>
  #include <boost/serialization/string.hpp>
  
@@@ -5917,8 -5916,7 +5916,8 @@@ bool SMESH_Gen_i::Load( SALOMEDS::SComp
                if ( aNewGroup->_is_nil() )
                  continue;
  
 -              string iorSubString = GetORB()->object_to_string( aNewGroup );
 +              CORBA::String_var iorSubStringVar = GetORB()->object_to_string( aNewGroup );
 +              string iorSubString(iorSubStringVar.in());
                int        newSubId = myStudyContext->findId( iorSubString );
                myStudyContext->mapOldToNew( subid, newSubId );
  
@@@ -6241,9 -6239,8 +6240,9 @@@ int SMESH_Gen_i::RegisterObject(CORBA::
  CORBA::Long  SMESH_Gen_i::GetObjectId(CORBA::Object_ptr theObject)
  {
    if ( myStudyContext && !CORBA::is_nil( theObject )) {
 -    string iorString = GetORB()->object_to_string( theObject );
 -    return myStudyContext->findId( iorString );
 +    CORBA::String_var iorString = GetORB()->object_to_string( theObject );
 +    string iorStringCpp(iorString.in()); 
 +    return myStudyContext->findId( iorStringCpp );
    }
    return 0;
  }