From: vsr Date: Fri, 20 Jan 2017 12:50:46 +0000 (+0300) Subject: Patch for MacOS (from SALOME forum) X-Git-Tag: V8_3_0a2~27 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=21af9b3a2c317f5693f228cd8ed55c2bb44b0a07;p=modules%2Fsmesh.git Patch for MacOS (from SALOME forum) --- diff --git a/src/SMDS/SMDS_MemoryLimit.cxx b/src/SMDS/SMDS_MemoryLimit.cxx index c254b50ba..3086a8f7b 100644 --- a/src/SMDS/SMDS_MemoryLimit.cxx +++ b/src/SMDS/SMDS_MemoryLimit.cxx @@ -25,7 +25,7 @@ // This is not done inside a function of SALOME because allocated memory is not always // returned to the system. (PAL16631) // -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ #include #endif @@ -36,7 +36,7 @@ int main (int argc, char ** argv) { // To better understand what is going on here, consult bug [SALOME platform 0019911] -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ struct sysinfo si; int err = sysinfo( &si ); if ( err ) diff --git a/src/SMDS/SMDS_Mesh.cxx b/src/SMDS/SMDS_Mesh.cxx index 13a2aa40f..ffb2926b9 100644 --- a/src/SMDS/SMDS_Mesh.cxx +++ b/src/SMDS/SMDS_Mesh.cxx @@ -56,7 +56,7 @@ #include using namespace std; -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ #include #endif @@ -77,7 +77,7 @@ int SMDS_Mesh::chunkSize = 1024; int SMDS_Mesh::CheckMemory(const bool doNotRaise) throw (std::bad_alloc) { -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ struct sysinfo si; int err = sysinfo( &si ); if ( err ) @@ -2819,7 +2819,7 @@ namespace { IdSortedIterator(const SMDS_MeshElementIDFactory& fact, const SMDSAbs_ElementType type, // SMDSAbs_All NOT allowed!!! const int totalNb) - :myIDFact( fact ), + :myIDFact( const_cast(fact) ), myID(1), myMaxID( myIDFact.GetMaxID() ),myNbFound(0), myTotalNb( totalNb ), myType( type ), myElem(0) diff --git a/src/SMDS/chrono.cxx b/src/SMDS/chrono.cxx index f2f076df5..9493b7d16 100644 --- a/src/SMDS/chrono.cxx +++ b/src/SMDS/chrono.cxx @@ -59,20 +59,20 @@ void counters::stats() } } -chrono::chrono(int i) : +salome_chrono::salome_chrono(int i) : _run(true), _ctr(i) { //MESSAGE("chrono::chrono " << _ctr << " " << _run); _start = clock(); } -chrono::~chrono() +salome_chrono::~salome_chrono() { if (_run) stop(); } -void chrono::stop() +void salome_chrono::stop() { //MESSAGE("chrono::stop " << _ctr << " " << _run); if (_run) diff --git a/src/SMDS/chrono.hxx b/src/SMDS/chrono.hxx index 31e2828e0..38ebff8a5 100644 --- a/src/SMDS/chrono.hxx +++ b/src/SMDS/chrono.hxx @@ -46,11 +46,11 @@ protected: static int _nbChrono; }; -class SMDS_EXPORT chrono +class SMDS_EXPORT salome_chrono { public: - chrono(int i); - ~chrono(); + salome_chrono(int i); + ~salome_chrono(); void stop(); protected: bool _run; @@ -61,7 +61,7 @@ protected: #ifdef CHRONODEF #define CHRONO(i) counters::_ctrs[i]._ctrNames = (char *)__FILE__; \ counters::_ctrs[i]._ctrLines = __LINE__; \ - chrono aChrono##i(i); + salome_chrono aChrono##i(i); #define CHRONOSTOP(i) aChrono##i.stop(); diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index 716780318..d975229cf 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -4568,7 +4568,11 @@ void SMESH_MeshEditor::sweepElement(const SMDS_MeshElement* elem, std::swap( itNN[0], itNN[1] ); std::swap( prevNod[0], prevNod[1] ); std::swap( nextNod[0], nextNod[1] ); +#if defined(__APPLE__) + std::swap( isSingleNode[0], isSingleNode[1] ); +#else isSingleNode.swap( isSingleNode[0], isSingleNode[1] ); +#endif if ( nbSame > 0 ) sames[0] = 1 - sames[0]; iNotSameNode = 1 - iNotSameNode; diff --git a/src/SMESH/memoire.h b/src/SMESH/memoire.h index b153ac73d..ef953601f 100644 --- a/src/SMESH/memoire.h +++ b/src/SMESH/memoire.h @@ -20,14 +20,18 @@ #ifndef _MEMOIRE_H_ #define _MEMOIRE_H_ +#ifdef __APPLE__ +#include +#else #include +#endif #include void memostat(const char* f, int l); void memostat(const char* f, int l) { -#ifdef WIN32 +#if defined WIN32 || defined __APPLE__ //rnv: TODO: find alternative of the malloc_stats() on windows platform #else struct mallinfo mem = mallinfo(); diff --git a/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx b/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx index 752957abd..32b472ff6 100644 --- a/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx @@ -102,7 +102,7 @@ #include #include -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ #include #endif @@ -786,7 +786,7 @@ SMESHGUI_ComputeDlg_QThreadQDialog(QWidget * parent, QLabel * nbElemsName = new QLabel(tr("SMESH_MESHINFO_ELEMENTS"), this ); nbNodesLabel = new QLabel("0", this ); nbElemsLabel = new QLabel("0", this ); -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ QLabel * freeRAMName = new QLabel(tr("SMESH_FREERAM"), this ); freeRAMLabel = new QLabel("", this ); #endif @@ -802,7 +802,7 @@ SMESHGUI_ComputeDlg_QThreadQDialog(QWidget * parent, layout->addWidget(nbNodesLabel, row++, 1); layout->addWidget(nbElemsName, row, 0); layout->addWidget(nbElemsLabel, row++, 1); -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ layout->addWidget(freeRAMName, row, 0); layout->addWidget(freeRAMLabel, row++, 1); #endif @@ -842,7 +842,7 @@ void SMESHGUI_ComputeDlg_QThreadQDialog::timerEvent(QTimerEvent *event) { nbNodesLabel->setText( QString("%1").arg( qthread.getMesh()->NbNodes() )); nbElemsLabel->setText( QString("%1").arg( qthread.getMesh()->NbElements() )); -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ struct sysinfo si; const int err = sysinfo( &si ); if ( err ) diff --git a/src/SMESHGUI/SMESHGUI_XmlHandler.cxx b/src/SMESHGUI/SMESHGUI_XmlHandler.cxx index 3482d7672..a3c1c5b19 100644 --- a/src/SMESHGUI/SMESHGUI_XmlHandler.cxx +++ b/src/SMESHGUI/SMESHGUI_XmlHandler.cxx @@ -91,11 +91,12 @@ bool SMESHGUI_XmlHandler::startElement (const QString&, const QString&, */ if( !myClientLib.isEmpty() ) { -#ifdef WIN32 +#if defined(WIN32) //myServerLib += ".dll"; myClientLib += ".dll"; +#elif defined(__APPLE__) + myClientLib = "lib" + myClientLib + ".dylib"; #else - //myServerLib = "lib" + myServerLib + ".so"; myClientLib = "lib" + myClientLib + ".so"; #endif } diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 845e0d9f0..d4d65b56c 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -54,6 +54,7 @@ #include #else #include + #include // for basename function #endif #ifdef WIN32 @@ -382,8 +383,10 @@ GenericHypothesisCreator_i* SMESH_Gen_i::getHypothesisCreator(const char* theHyp !strcmp( theLibName+libNameLen-3, ".so" )) { //the old format -#ifdef WIN32 +#if defined(WIN32) aPlatformLibName = std::string( theLibName+3, libNameLen-6 ) + ".dll"; +#elif defined(__APPLE__) + aPlatformLibName = std::string( theLibName, libNameLen-3 ) + ".dylib"; #else aPlatformLibName = theLibName; #endif @@ -391,11 +394,13 @@ GenericHypothesisCreator_i* SMESH_Gen_i::getHypothesisCreator(const char* theHyp else { //try to use new format -#ifdef WIN32 +#if defined(WIN32) aPlatformLibName = theLibName; aPlatformLibName += ".dll"; +#elif defined(__APPLE__) + aPlatformLibName = std::string( "lib" ) + std::string( theLibName ) + ".dylib"; #else - aPlatformLibName = "lib" + std::string( theLibName ) + ".so"; + aPlatformLibName = std::string( "lib" ) + std::string( theLibName ) + ".so"; #endif } } @@ -1169,7 +1174,7 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMEDorSAUV( const char* theFileNa _splitpath( theFileNameForPython, NULL, NULL, bname, NULL ); string aFileName = bname; #else - string aFileName = basename( theFileNameForPython ); + string aFileName = basename( const_cast(theFileNameForPython) ); #endif // Retrieve mesh names from the file DriverMED_R_SMESHDS_Mesh myReader; @@ -1318,7 +1323,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromSTL( const char* theFileName _splitpath( theFileName, NULL, NULL, bname, NULL ); string aFileName = bname; #else - string aFileName = basename( theFileName ); + string aFileName = basename( const_cast(theFileName) ); #endif // publish mesh in the study if ( CanPublishInStudy( aMesh ) ) { @@ -1447,7 +1452,7 @@ SMESH_Gen_i::CreateMeshesFromGMF( const char* theFileName, _splitpath( theFileName, NULL, NULL, bname, NULL ); string aFileName = bname; #else - string aFileName = basename( theFileName ); + string aFileName = basename( const_cast(theFileName) ); #endif // publish mesh in the study if ( CanPublishInStudy( aMesh ) ) { diff --git a/src/Tools/MeshCut/MeshCut_DC.cxx b/src/Tools/MeshCut/MeshCut_DC.cxx index 1639f0bdc..b05d434d3 100644 --- a/src/Tools/MeshCut/MeshCut_DC.cxx +++ b/src/Tools/MeshCut/MeshCut_DC.cxx @@ -180,10 +180,10 @@ int main(int argc, char *argv[]) //int NG[4]; // Num. globaux des sommets // Acquisition maillage initial - //cout << chrono() << " - Acquisition du maillage initial" << endl; + //cout << salome_chrono() << " - Acquisition du maillage initial" << endl; MAILLAGE1 = new Maillage((string) "TEMP"); MAILLAGE1->inputMED(ficMEDin); - cout << chrono() << " - End of mesh read" << endl; + cout << salome_chrono() << " - End of mesh read" << endl; indexNouveauxNoeuds = MAILLAGE1->nombreNoeudsMaillage; // Le maillage ne contient aucun TETRA4 : on rend le maillage initial sans modification @@ -192,7 +192,7 @@ int main(int argc, char *argv[]) cout << "WARNING: mesh does not contain tetra4 elements, it will not be modified" << endl; MAILLAGE1->ID = str_id_maillagenew; MAILLAGE1->outputMED(ficMEDout); - cout << chrono() << " - Finished!" << endl << endl; + cout << salome_chrono() << " - Finished!" << endl << endl; exit(0); } // A partir de cet instant le maillage contient forcément des TETRA4 @@ -202,7 +202,7 @@ int main(int argc, char *argv[]) DNP = (float*) malloc(sizeof(float) * MAILLAGE1->nombreNoeudsMaillage); for (int k = 0; k < MAILLAGE1->nombreNoeudsMaillage; k++) DNP[k] = distanceNoeudPlan(k + 1); - cout << chrono() << " - End of computation of distances between nodes and plane" << endl; + cout << salome_chrono() << " - End of computation of distances between nodes and plane" << endl; // Longueur d'arête moyenne des T4 intersectant le plan de coupe float LONGUEURS = 0.0; @@ -246,7 +246,7 @@ int main(int argc, char *argv[]) << endl; MAILLAGE1->ID = str_id_maillagenew; MAILLAGE1->outputMED(ficMEDout); - cout << chrono() << " - Finished!" << endl << endl; + cout << salome_chrono() << " - Finished!" << endl << endl; exit(0); } // A partir de cet instant le maillage contient forcément des TETRA4 intersectant le plan de coupe @@ -256,7 +256,7 @@ int main(int argc, char *argv[]) epsilon = tolerance * longueurMoyenne; int nT4coupe = cptLONGUEURS / 6; - cout << chrono() << " - End of computation of mean length of tetra4 edges near the cut plane" << endl; + cout << salome_chrono() << " - End of computation of mean length of tetra4 edges near the cut plane" << endl; cout << "Number of tetra4 to be cut = " << nT4coupe << endl; cout << "Mean length = " << longueurMoyenne << endl; @@ -274,7 +274,7 @@ int main(int argc, char *argv[]) else POSN[k] = 0; } - cout << chrono() << " - End of nodes qualification above or below the cut plane" << endl; + cout << salome_chrono() << " - End of nodes qualification above or below the cut plane" << endl; cout << "Start of iteration on tetra4" << endl; for (int it4 = 0; it4 < MAILLAGE1->EFFECTIFS_TYPES[TETRA4]; it4++) @@ -993,7 +993,7 @@ int main(int argc, char *argv[]) ERREUR("Case not taken into account"); } - cout << chrono() << " - End of iteration on tetra4" << endl; + cout << salome_chrono() << " - End of iteration on tetra4" << endl; // cout << "indexNouveauxNoeuds = " << indexNouveauxNoeuds << endl; newXX.resize(indexNouveauxNoeuds - MAILLAGE1->nombreNoeudsMaillage); @@ -1011,7 +1011,7 @@ int main(int argc, char *argv[]) // 2. Constitution du maillage final // ========================================================================================= - cout << chrono() << " - Constitution of final mesh" << endl; + cout << salome_chrono() << " - Constitution of final mesh" << endl; MAILLAGE2 = new Maillage(str_id_maillagenew); MAILLAGE2->dimensionMaillage = MAILLAGE1->dimensionMaillage; @@ -1114,10 +1114,10 @@ int main(int argc, char *argv[]) MAILLAGE2->eliminationMailles(TETRA4, cutTetras); - cout << chrono() << " - MED file writing" << endl; + cout << salome_chrono() << " - MED file writing" << endl; MAILLAGE2->outputMED(ficMEDout); - cout << chrono() << " - Finished!" << endl << endl; + cout << salome_chrono() << " - Finished!" << endl << endl; return 0; diff --git a/src/Tools/MeshCut/MeshCut_Utils.cxx b/src/Tools/MeshCut/MeshCut_Utils.cxx index b17e2b4d7..3a41721ca 100644 --- a/src/Tools/MeshCut/MeshCut_Utils.cxx +++ b/src/Tools/MeshCut/MeshCut_Utils.cxx @@ -589,7 +589,7 @@ med_geometry_type MESHCUT::InstanceMGE(TYPE_MAILLE TYPE) return typeBanaliseMED; } -int MESHCUT::chrono() +int MESHCUT::salome_chrono() { return clock() / CLOCKS_PER_SEC; } diff --git a/src/Tools/MeshCut/MeshCut_Utils.hxx b/src/Tools/MeshCut/MeshCut_Utils.hxx index df52ed3a9..7ac8e197b 100644 --- a/src/Tools/MeshCut/MeshCut_Utils.hxx +++ b/src/Tools/MeshCut/MeshCut_Utils.hxx @@ -57,7 +57,7 @@ namespace MESHCUT int copieFichier(std::string source, std::string cible); med_geometry_type InstanceMGE(TYPE_MAILLE TYPE); - int chrono(); + int salome_chrono(); TYPE_MAILLE typeMaille(std::string type); std::string MGE2string(med_geometry_type MGE); std::string TM2string(TYPE_MAILLE MGE); diff --git a/src/Tools/padder/meshjob/impl/MeshJobManager_i.cxx b/src/Tools/padder/meshjob/impl/MeshJobManager_i.cxx index 8986182c0..95c35adba 100644 --- a/src/Tools/padder/meshjob/impl/MeshJobManager_i.cxx +++ b/src/Tools/padder/meshjob/impl/MeshJobManager_i.cxx @@ -129,6 +129,7 @@ MeshJobManager_i::~MeshJobManager_i() { #include // to get _mkdir #else #include // to get basename +#include // to get basename - as per posix #include // to get mkdir #include // to get mkdir options #endif @@ -242,7 +243,7 @@ const char* MeshJobManager_i::_writeScriptFile(const char * dataFileName, const _splitpath( dataFileName, NULL, NULL, fname, NULL ); const char* bname = &fname[0]; #else - const char* bname = basename(dataFileName); + const char* bname = basename(const_cast(dataFileName)); #endif