a message from a CEA developpeur : modified files for plugin GHS3DPRL (and Hexotic) correcting weakness in Hexotic plugin
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;
//=============================================================================
// 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"
}
//=======================================================================
-
+//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;
#ifdef WIN32
aTmpDir = TCollection_AsciiString("C:\\");
#else
- aTmpDir = TCollection_AsciiString("/export/home/");
+ aTmpDir = TCollection_AsciiString("/tmp/");
#endif
}
- //cout<<"getTmpDir()="<<aTmpDir<<endl;
return aTmpDir;
}
// 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");
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)
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" );
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;
using namespace std;
#include <GHS3DPRLPlugin_Hypothesis.hxx>
#include <utilities.h>
+#include <qstring.h>
//=============================================================================
/*!
//=============================================================================
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();
}
}
//=============================================================================
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;
}
//=============================================================================
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;
}
//=============================================================================
# Libraries targets
LIB = libGHS3DPRLEngine.la
+CPPFLAGS+=$(QT_INCLUDES)
+LDFLAGSFORBIN+=-lm $(QT_LIBS)
+
+$(BIN):$(OBJ)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(QT_LIBS) $<
+
+
@CONCLUDE@
readParamsFromHypo( data_old );
readParamsFromWidgets( data_new );
bool res = storeParamsToHypo( data_new );
+ storeParamsToHypo( data_old );
return res;
}
{
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;
}
file<<"#MED Fichier V 2.3"<<" "<<endl;
file<<"# NumbersOfSubDomains"<<" "<<endl;
int nbdomains=this->nbfiles;
+ long nbtetrastotal=0;
file<<nbdomains<<" "<<endl;
//loop on the domains
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);
//../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;
}
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))
//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;