X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_I%2FMG_ADAPT_i.cxx;h=188a3523659271c089883d98bd624d1a446f84dd;hp=6a770c68c39df339e4728d17390941854a675ce6;hb=a463e4643121ceea8a13c2fad631e0ef0ac8a824;hpb=8731eed9296c2b3541e18b9133971d579d55d9b2 diff --git a/src/SMESH_I/MG_ADAPT_i.cxx b/src/SMESH_I/MG_ADAPT_i.cxx index 6a770c68c..188a35236 100644 --- a/src/SMESH_I/MG_ADAPT_i.cxx +++ b/src/SMESH_I/MG_ADAPT_i.cxx @@ -17,25 +17,13 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// Remarques : -// L'ordre de description des fonctions est le meme dans tous les fichiers -// HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx : -// 1. Les generalites : Name, Delete, DumpPython, Dump, Restore -// 2. Les caracteristiques -// 3. Le lien avec les autres structures -// -// Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier -// - #include "MG_ADAPT_i.hxx" -//~#include "ADAPT_Gen_i.hxx" + #include "string.h" #include "SMESH_Gen_i.hxx" #include #include #include CORBA_CLIENT_HEADER(SALOMEDS) -//~#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog) -//~#include CORBA_CLIENT_HEADER(SMESH_Gen) //============================================================================= @@ -50,61 +38,61 @@ using namespace SMESH; void MG_ADAPT_i::copyHypothesisDataToImpl(const SMESH::MgAdaptHypothesisData& from, ::MG_ADAPT::MgAdaptHypothesisData* to) const { - to->myFileInDir = from.myFileInDir; - to->myMeshFileIn = from.myMeshFileIn; - to->myMeshFileBackground = from.myMeshFileBackground; - to->myOutMeshName = from.myOutMeshName; - to->myMeshFileOut = from.myMeshFileOut; - to->myFileOutDir = from.myFileOutDir; - to->myFileSizeMapDir = from.myFileSizeMapDir; - to->myFieldName = from.myFieldName; - to->fromMedFile = from.fromMedFile; - to->myPublish = from.myPublish; - to->myMeshOutMed = from.myMeshOutMed; - to->myUseLocalMap = from.myUseLocalMap; - to->myUseBackgroundMap = from.myUseBackgroundMap; - to->myUseConstantValue = from.myUseConstantValue; - to->myConstantValue = from.myConstantValue; - to->myTimeStep = from.myTimeStep; - to->myRank = from.myRank; - to->myUseNoTimeStep = from.myUseNoTimeStep; - to->myUseLastTimeStep = from.myUseLastTimeStep; - to->myUseChosenTimeStep = from.myUseChosenTimeStep; - to->myWorkingDir = from.myWorkingDir; - to->myLogFile = from.myLogFile; - to->myPrintLogInFile = from.myPrintLogInFile; - to->myKeepFiles = from.myKeepFiles; - to->myRemoveLogOnSuccess = from.myRemoveLogOnSuccess; - to->myVerboseLevel = from.myVerboseLevel; + to->myFileInDir = from.myFileInDir; + to->myMeshFileIn = from.myMeshFileIn; + to->myMeshFileBackground = from.myMeshFileBackground; + to->myOutMeshName = from.myOutMeshName; + to->myMeshFileOut = from.myMeshFileOut; + to->myFileOutDir = from.myFileOutDir; + to->myFileSizeMapDir = from.myFileSizeMapDir; + to->myFieldName = from.myFieldName; + to->fromMedFile = from.fromMedFile; + to->myPublish = from.myPublish; + to->myMeshOutMed = from.myMeshOutMed; + to->myUseLocalMap = from.myUseLocalMap; + to->myUseBackgroundMap = from.myUseBackgroundMap; + to->myUseConstantValue = from.myUseConstantValue; + to->myConstantValue = from.myConstantValue; + to->myTimeStep = from.myTimeStep; + to->myRank = from.myRank; + to->myUseNoTimeStep = from.myUseNoTimeStep; + to->myUseLastTimeStep = from.myUseLastTimeStep; + to->myUseChosenTimeStep = from.myUseChosenTimeStep; + to->myWorkingDir = from.myWorkingDir; + to->myLogFile = from.myLogFile; + to->myPrintLogInFile = from.myPrintLogInFile; + to->myKeepFiles = from.myKeepFiles; + to->myRemoveLogOnSuccess = from.myRemoveLogOnSuccess; + to->myVerboseLevel = from.myVerboseLevel; } void MG_ADAPT_i::copyHypothesisDataFromImpl(const ::MG_ADAPT::MgAdaptHypothesisData* from, SMESH::MgAdaptHypothesisData* to) const { - to->myFileInDir = CORBA::string_dup(from->myFileInDir.c_str()); - to->myMeshFileIn = CORBA::string_dup(from->myMeshFileIn.c_str()); - to->myMeshFileBackground = CORBA::string_dup(from->myMeshFileBackground.c_str()); - to->myOutMeshName = CORBA::string_dup(from->myOutMeshName.c_str()); - to->myMeshFileOut = CORBA::string_dup(from->myMeshFileOut.c_str()); - to->myFileOutDir = CORBA::string_dup(from->myFileOutDir.c_str()); - to->myFileSizeMapDir = CORBA::string_dup(from->myFileSizeMapDir.c_str()); - to->myFieldName = CORBA::string_dup(from->myFieldName.c_str()); - to->fromMedFile = from->fromMedFile; - to->myPublish = from->myPublish; - to->myMeshOutMed = from->myMeshOutMed; - to->myUseLocalMap = from->myUseLocalMap; - to->myUseBackgroundMap = from->myUseBackgroundMap; - to->myUseConstantValue = from->myUseConstantValue; - to->myConstantValue = from->myConstantValue; - to->myTimeStep = from->myTimeStep; - to->myRank = from->myRank; - to->myUseNoTimeStep = from->myUseNoTimeStep; - to->myUseLastTimeStep = from->myUseLastTimeStep; - to->myUseChosenTimeStep = from->myUseChosenTimeStep; - to->myWorkingDir = CORBA::string_dup(from->myWorkingDir.c_str()); - to->myLogFile = CORBA::string_dup(from->myLogFile.c_str()); - to->myPrintLogInFile = from->myPrintLogInFile; - to->myKeepFiles = from->myKeepFiles; - to->myRemoveLogOnSuccess = from->myRemoveLogOnSuccess; - to->myVerboseLevel = from->myVerboseLevel; + to->myFileInDir = CORBA::string_dup(from->myFileInDir.c_str()); + to->myMeshFileIn = CORBA::string_dup(from->myMeshFileIn.c_str()); + to->myMeshFileBackground = CORBA::string_dup(from->myMeshFileBackground.c_str()); + to->myOutMeshName = CORBA::string_dup(from->myOutMeshName.c_str()); + to->myMeshFileOut = CORBA::string_dup(from->myMeshFileOut.c_str()); + to->myFileOutDir = CORBA::string_dup(from->myFileOutDir.c_str()); + to->myFileSizeMapDir = CORBA::string_dup(from->myFileSizeMapDir.c_str()); + to->myFieldName = CORBA::string_dup(from->myFieldName.c_str()); + to->fromMedFile = from->fromMedFile; + to->myPublish = from->myPublish; + to->myMeshOutMed = from->myMeshOutMed; + to->myUseLocalMap = from->myUseLocalMap; + to->myUseBackgroundMap = from->myUseBackgroundMap; + to->myUseConstantValue = from->myUseConstantValue; + to->myConstantValue = from->myConstantValue; + to->myTimeStep = from->myTimeStep; + to->myRank = from->myRank; + to->myUseNoTimeStep = from->myUseNoTimeStep; + to->myUseLastTimeStep = from->myUseLastTimeStep; + to->myUseChosenTimeStep = from->myUseChosenTimeStep; + to->myWorkingDir = CORBA::string_dup(from->myWorkingDir.c_str()); + to->myLogFile = CORBA::string_dup(from->myLogFile.c_str()); + to->myPrintLogInFile = from->myPrintLogInFile; + to->myKeepFiles = from->myKeepFiles; + to->myRemoveLogOnSuccess = from->myRemoveLogOnSuccess; + to->myVerboseLevel = from->myVerboseLevel; } SMESH::MG_ADAPT_ptr SMESH_Gen_i::CreateMG_ADAPT() { @@ -112,10 +100,27 @@ SMESH::MG_ADAPT_ptr SMESH_Gen_i::CreateMG_ADAPT() SMESH::MG_ADAPT_var anObj = aMGadapt->_this(); return anObj._retn(); } +SMESH::MG_ADAPT_ptr SMESH_Gen_i::CreateAdaptationHypothesis() +{ + SMESH::MG_ADAPT_i* aMGadapt = new SMESH::MG_ADAPT_i(); + SMESH::MG_ADAPT_var anObj = aMGadapt->_this(); + return anObj._retn(); +} +SMESH::MG_ADAPT_OBJECT_ptr SMESH_Gen_i::Adaptation( const char* adaptationType) +{ + + if (!strcmp(adaptationType, "MG_Adapt")) + { + SMESH::MG_ADAPT_OBJECT_i* mg_adapt_object = new SMESH::MG_ADAPT_OBJECT_i(); + SMESH::MG_ADAPT_OBJECT_var anObj = mg_adapt_object->_this(); + return anObj._retn(); + } + +} //~SMESH::MG_ADAPT_ptr MG_ADAPT_i::CreateMG_ADAPT() //~{ - - //~SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen(); + + //~SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen(); //~SMESH::MG_ADAPT_i* aMGadapt = new SMESH::MG_ADAPT_i(smeshGen_i->GetPOA()); //~SMESH::MG_ADAPT_var anObj = aMGadapt->_this(); //~return anObj._retn(); @@ -158,270 +163,366 @@ MG_ADAPT_i::~MG_ADAPT_i() } void MG_ADAPT_i::setData( SMESH::MgAdaptHypothesisData& data) { - ::MG_ADAPT::MgAdaptHypothesisData* baseData = new ::MG_ADAPT::MgAdaptHypothesisData(); - copyHypothesisDataToImpl(data, baseData); - myMgAdapt->setData(baseData); - delete baseData; -} + ::MG_ADAPT::MgAdaptHypothesisData* baseData = new ::MG_ADAPT::MgAdaptHypothesisData(); + copyHypothesisDataToImpl(data, baseData); + myMgAdapt->setData(baseData); + delete baseData; +} void MG_ADAPT_i::setMedFileIn(const char* str) { - myMgAdapt->setMedFileIn(str); + myMgAdapt->setMedFileIn(str); } char* MG_ADAPT_i::getMedFileIn() { - return CORBA::string_dup(myMgAdapt->getMedFileIn().c_str()); + return CORBA::string_dup(myMgAdapt->getMedFileIn().c_str()); } void MG_ADAPT_i::setMedFileOut(const char* str) { - myMgAdapt->setMedFileOut(str); + myMgAdapt->setMedFileOut(str); } char* MG_ADAPT_i::getMedFileOut() { - return CORBA::string_dup(myMgAdapt->getMedFileOut().c_str()); + return CORBA::string_dup(myMgAdapt->getMedFileOut().c_str()); } void MG_ADAPT_i::setMeshName(const char* str) { - myMgAdapt->setMeshName(str); + myMgAdapt->setMeshName(str); } char* MG_ADAPT_i::getMeshName() { - return CORBA::string_dup(myMgAdapt->getMeshName().c_str()); + return CORBA::string_dup(myMgAdapt->getMeshName().c_str()); } void MG_ADAPT_i::setMeshNameOut(const char* str) { - myMgAdapt->setMeshNameOut(str); + myMgAdapt->setMeshNameOut(str); } char* MG_ADAPT_i::getMeshNameOut() { - return CORBA::string_dup(myMgAdapt->getMeshNameOut().c_str()); + return CORBA::string_dup(myMgAdapt->getMeshNameOut().c_str()); } void MG_ADAPT_i::setMeshOutMed(bool mybool) { - myMgAdapt->setMeshOutMed(mybool); + myMgAdapt->setMeshOutMed(mybool); } bool MG_ADAPT_i::getMeshOutMed() { - return myMgAdapt->getMeshOutMed(); + return myMgAdapt->getMeshOutMed(); } void MG_ADAPT_i::setPublish(bool mybool) { - myMgAdapt->setPublish(mybool); + myMgAdapt->setPublish(mybool); } bool MG_ADAPT_i::getPublish() { - return myMgAdapt->getPublish(); + return myMgAdapt->getPublish(); } -void MG_ADAPT_i::setFieldName(const char* str) +void MG_ADAPT_i::setSizeMapFieldName(const char* str) { - myMgAdapt->setFieldName(str); + myMgAdapt->setFieldName(str); } -char* MG_ADAPT_i::getFieldName() +char* MG_ADAPT_i::getSizeMapFieldName() { - return CORBA::string_dup(myMgAdapt->getFieldName().c_str()); + return CORBA::string_dup(myMgAdapt->getFieldName().c_str()); } void MG_ADAPT_i::setTimeStep(CORBA::Long t) { - myMgAdapt->setTimeStep(t); + myMgAdapt->setTimeStep(t); } -CORBA::Long MG_ADAPT_i::getTimeStep() +CORBA::Long MG_ADAPT_i::getTimeStep() { - return myMgAdapt->getTimeStep(); + return myMgAdapt->getTimeStep(); } -void MG_ADAPT_i::setRankTimeStep(CORBA::Long t, CORBA::Long r) +void MG_ADAPT_i::setTimeStepRank(CORBA::Long t, CORBA::Long r) { - myMgAdapt->setRankTimeStep(t, r); + myMgAdapt->setChosenTimeStepRank(); + myMgAdapt->setRankTimeStep(t, r); } CORBA::Long MG_ADAPT_i::getRank() { - return myMgAdapt->getRank(); + return myMgAdapt->getRank(); } void MG_ADAPT_i::setTimeStepRankLast() { - myMgAdapt->setTimeStepRankLast(); + myMgAdapt->setTimeStepRankLast(); } void MG_ADAPT_i::setNoTimeStep() { - myMgAdapt->setNoTimeStep(); + myMgAdapt->setNoTimeStep(); } void MG_ADAPT_i::setLogFile(const char* str) { - myMgAdapt->setLogFile(str); + myMgAdapt->setLogFile(str); } char* MG_ADAPT_i::getLogFile() { - return CORBA::string_dup(myMgAdapt->getLogFile().c_str()); + return CORBA::string_dup(myMgAdapt->getLogFile().c_str()); } void MG_ADAPT_i::setVerbosityLevel(CORBA::Long v) { - myMgAdapt->setVerbosityLevel(v); + myMgAdapt->setVerbosityLevel(v); } CORBA::Long MG_ADAPT_i::getVerbosityLevel() { - return myMgAdapt->getVerbosityLevel(); + return myMgAdapt->getVerbosityLevel(); } void MG_ADAPT_i::setRemoveOnSuccess(bool mybool) { - myMgAdapt->setRemoveOnSuccess(mybool); + myMgAdapt->setRemoveOnSuccess(mybool); } bool MG_ADAPT_i::getRemoveOnSuccess() { - myMgAdapt->getRemoveOnSuccess(); + myMgAdapt->getRemoveOnSuccess(); } -SMESH::MgAdaptHypothesisData* MG_ADAPT_i::getData() +SMESH::MgAdaptHypothesisData* MG_ADAPT_i::getData() { - SMESH::MgAdaptHypothesisData* result = new SMESH::MgAdaptHypothesisData(); - ::MG_ADAPT::MgAdaptHypothesisData* from = myMgAdapt->getData(); - copyHypothesisDataFromImpl(from, result); - return result; + SMESH::MgAdaptHypothesisData* result = new SMESH::MgAdaptHypothesisData(); + ::MG_ADAPT::MgAdaptHypothesisData* from = myMgAdapt->getData(); + copyHypothesisDataFromImpl(from, result); + return result; } void MG_ADAPT_i::setUseLocalMap(bool mybool) { - myMgAdapt->setUseLocalMap(mybool); + myMgAdapt->setUseLocalMap(mybool); } bool MG_ADAPT_i::getUseLocalMap() { - return myMgAdapt->getUseLocalMap(); + return myMgAdapt->getUseLocalMap(); } void MG_ADAPT_i::setUseBackgroundMap(bool mybool) { - myMgAdapt->setUseBackgroundMap(mybool); + myMgAdapt->setUseBackgroundMap(mybool); } bool MG_ADAPT_i::getUseBackgroundMap() { - return myMgAdapt->getUseBackgroundMap(); + return myMgAdapt->getUseBackgroundMap(); } void MG_ADAPT_i::setUseConstantValue(bool mybool) { - myMgAdapt->setUseConstantValue(mybool); + myMgAdapt->setUseConstantValue(mybool); } bool MG_ADAPT_i::getUseConstantValue() { - return myMgAdapt->getUseConstantValue(); + return myMgAdapt->getUseConstantValue(); } - -void MG_ADAPT_i::setConstantValue(double value) +void MG_ADAPT_i::setConstantSize(double value) { - myMgAdapt->setConstantValue(value); + myMgAdapt->setConstantValue(value); } -double MG_ADAPT_i::getConstantValue() +double MG_ADAPT_i::getConstantSize() { - return myMgAdapt->getConstantValue(); + return myMgAdapt->getConstantValue(); } void MG_ADAPT_i::setSizeMapFile(const char* str) { - myMgAdapt->setSizeMapFile(str); + myMgAdapt->setSizeMapFile(str); } char* MG_ADAPT_i::getSizeMapFile() { - return CORBA::string_dup(myMgAdapt->getSizeMapFile().c_str()); + return CORBA::string_dup(myMgAdapt->getSizeMapFile().c_str()); } void MG_ADAPT_i::setFromMedFile(bool mybool) { - myMgAdapt->setFromMedFile(mybool); + myMgAdapt->setFromMedFile(mybool); } bool MG_ADAPT_i::isFromMedFile() { - return myMgAdapt->isFromMedFile(); + return myMgAdapt->isFromMedFile(); } void MG_ADAPT_i::setKeepWorkingFiles(bool mybool) { - myMgAdapt->setKeepWorkingFiles(mybool); + myMgAdapt->setKeepWorkingFiles(mybool); } bool MG_ADAPT_i::getKeepWorkingFiles() { - return myMgAdapt->getKeepWorkingFiles(); + return myMgAdapt->getKeepWorkingFiles(); } //~void MG_ADAPT_i::setPrCORBA::LongLogInFile(bool); //~bool MG_ADAPT_i::getPrCORBA::LongLogInFile(); +void MG_ADAPT_i::setSizeMapType(const char* type) +{ + setUseLocalMap(false); + setUseBackgroundMap(false); + setUseConstantValue(false); + + if (!strcmp("Local", type)) + setUseLocalMap(true); + else if (!strcmp("Background", type)) + setUseBackgroundMap(true); + else + setUseConstantValue(true); +} void MG_ADAPT_i::setWorkingDir(const char* dir) { - myMgAdapt->setWorkingDir(dir); + myMgAdapt->setWorkingDir(dir); } -char* MG_ADAPT_i::getWorkingDir() +char* MG_ADAPT_i::getWorkingDir() { - return CORBA::string_dup(myMgAdapt->getWorkingDir().c_str()); + return CORBA::string_dup(myMgAdapt->getWorkingDir().c_str()); } bool MG_ADAPT_i::setAll() { - return myMgAdapt->setAll(); + return myMgAdapt->setAll(); } char* MG_ADAPT_i::getCommandToRun() { - return CORBA::string_dup(myMgAdapt->getCommandToRun().c_str()); + return CORBA::string_dup(myMgAdapt->getCommandToRun().c_str()); } -CORBA::Long MG_ADAPT_i::compute(::CORBA::String_out errStr) -{ - std::string err(""); - CORBA::Long ret = myMgAdapt->compute(err); - errStr = err.c_str(); - return ret; -} -char* MG_ADAPT_i::getFileName() -{ - return CORBA::string_dup(myMgAdapt->getFileName().c_str()); +void MG_ADAPT_i::compute() +{ + errStr = ""; + try + { + myMgAdapt->compute(errStr); + } + catch (const std::exception& e) + { + std::ostringstream oss; oss << "Exception thrown on MG_ADAPT_i::compute invocation with error message \"" << errStr + << "\" with exception message \"" << e.what() << "\""; + THROW_SALOME_CORBA_EXCEPTION(oss.str().c_str(),SALOME::INTERNAL_ERROR); + } + if(myMgAdapt->getPublish()) + { + SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen(); + SMESH::DriverMED_ReadStatus theStatus; + smeshGen_i->CreateMeshesFromMED(myMgAdapt->getMedFileOut().c_str(), theStatus); + } +} +char* MG_ADAPT_i::getErrMsg() +{ + return CORBA::string_dup(errStr.c_str()); +} +char* MG_ADAPT_i::getFileName() +{ + return CORBA::string_dup(myMgAdapt->getFileName().c_str()); } char* MG_ADAPT_i::getExeName() { - return CORBA::string_dup(myMgAdapt->getExeName().c_str()); + return CORBA::string_dup(myMgAdapt->getExeName().c_str()); } void MG_ADAPT_i::copyMgAdaptHypothesisData( const SMESH::MgAdaptHypothesisData& data) { - ::MG_ADAPT::MgAdaptHypothesisData* baseData = new ::MG_ADAPT::MgAdaptHypothesisData(); - copyHypothesisDataToImpl(data, baseData); - myMgAdapt->copyMgAdaptHypothesisData(baseData); - delete baseData; + ::MG_ADAPT::MgAdaptHypothesisData* baseData = new ::MG_ADAPT::MgAdaptHypothesisData(); + copyHypothesisDataToImpl(data, baseData); + myMgAdapt->copyMgAdaptHypothesisData(baseData); + delete baseData; } //~void MG_ADAPT_i::checkDirPath(char*& str) //~{ - //~myMgAdapt->checkDirPath(str); + //~myMgAdapt->checkDirPath(str); //~} -bool MG_ADAPT_i::hasOptionDefined( const char* optionName ) +bool MG_ADAPT_i::hasOptionDefined( const char* optionName ) { - return myMgAdapt->hasOptionDefined(optionName); + return myMgAdapt->hasOptionDefined(optionName); } void MG_ADAPT_i::setOptionValue(const char* optionName, - const char* optionValue) throw (std::invalid_argument) + const char* optionValue) throw (std::invalid_argument) { - myMgAdapt->setOptionValue(optionName, optionValue); -} + myMgAdapt->setOptionValue(optionName, optionValue); +} char* MG_ADAPT_i::getOptionValue(const char* optionName, - bool& isDefault) throw (std::invalid_argument) + bool& isDefault) throw (std::invalid_argument) { - return CORBA::string_dup(myMgAdapt->getOptionValue(optionName, &isDefault).c_str()); + return CORBA::string_dup(myMgAdapt->getOptionValue(optionName, &isDefault).c_str()); } -str_array* MG_ADAPT_i::getCustomOptionValuesStrVec() +str_array* MG_ADAPT_i::getCustomOptionValuesStrVec() { - SMESH::str_array_var result = new SMESH::str_array(); - std::vector vals = myMgAdapt->getCustomOptionValuesStrVec(); - result->length(vals.size()); - for (int i = 0; i vals = myMgAdapt->getCustomOptionValuesStrVec(); + result->length(vals.size()); + for (int i = 0; i vals = myMgAdapt->getOptionValuesStrVec(); - result->length(vals.size()); - for (int i = 0; i vals = myMgAdapt->getOptionValuesStrVec(); + result->length(vals.size()); + for (int i = 0; isetPrintLogInFile(mybool); + myMgAdapt->setPrintLogInFile(mybool); } bool MG_ADAPT_i::getPrintLogInFile() { - return myMgAdapt->getPrintLogInFile(); + return myMgAdapt->getPrintLogInFile(); } //~TOptionValues MG_ADAPT_i::getOptionValues() const; //~const TOptionValues& MG_ADAPT_i::getCustomOptionValues() const ; + +MG_ADAPT_OBJECT_i::MG_ADAPT_OBJECT_i(): SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() ) +{ + medFileIn=""; + medFileOut=""; + medFileBackground=""; + publish = false; + //~myMesh = CORBA::nil; +} + +void MG_ADAPT_OBJECT_i::setMeshIn(SMESH::SMESH_Mesh_ptr theMesh ) +{ + myMesh = SMESH::SMESH_Mesh::_duplicate(theMesh); +} +void MG_ADAPT_OBJECT_i::setMEDFileIn(const char* f) +{ + medFileIn = f; +} +void MG_ADAPT_OBJECT_i::setMEDFileOut(const char* f) +{ + medFileOut = f; +} +void MG_ADAPT_OBJECT_i::setMEDFileBackground(const char* f) +{ + medFileBackground = f; +} +void MG_ADAPT_OBJECT_i::AddHypothesis(SMESH::MG_ADAPT_ptr mg) +{ + + mg->setMedFileIn(medFileIn.c_str()); + mg->setMedFileOut(medFileOut.c_str()); + mg->setSizeMapFile(medFileBackground.c_str()); + hypothesis = SMESH::MG_ADAPT::_duplicate(mg); +} +CORBA::Long MG_ADAPT_OBJECT_i::Compute(bool publish) +{ + if(!checkMeshFileIn()){ + std::cerr<< "\n Error : Please check the MED file input or mesh input. \n"; + return -1; + } + hypothesis->setPublish(publish); + hypothesis->compute(); + return 0; +} + +bool MG_ADAPT_OBJECT_i::checkMeshFileIn() +{ + bool ret = false; // 1 ok , 0 nook + if(!::MG_ADAPT::MgAdapt::isFileExist(medFileIn)) + { + if(!myMesh->_is_nil()) + { + bool toOverwrite = true; + bool toFindOutDim = true; + medFileIn = hypothesis->getFileName(); + medFileIn+= ".med"; + myMesh->ExportMED(medFileIn.c_str(), false, -1, toOverwrite, toFindOutDim); + hypothesis->setMedFileIn(medFileIn.c_str()); + ret = true; + } + } + else + ret = true; + + return ret; +}