mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-26 09:20:34 +05:00
Patch for MacOS (from SALOME forum)
This commit is contained in:
parent
41b3e44333
commit
21af9b3a2c
@ -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 <sys/sysinfo.h>
|
||||
#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 )
|
||||
|
@ -56,7 +56,7 @@
|
||||
#include <iterator>
|
||||
using namespace std;
|
||||
|
||||
#ifndef WIN32
|
||||
#if !defined WIN32 && !defined __APPLE__
|
||||
#include <sys/sysinfo.h>
|
||||
#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<SMDS_MeshElementIDFactory&>(fact) ),
|
||||
myID(1), myMaxID( myIDFact.GetMaxID() ),myNbFound(0), myTotalNb( totalNb ),
|
||||
myType( type ),
|
||||
myElem(0)
|
||||
|
@ -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)
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
|
@ -20,14 +20,18 @@
|
||||
#ifndef _MEMOIRE_H_
|
||||
#define _MEMOIRE_H_
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include <iostream>
|
||||
|
||||
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();
|
||||
|
@ -102,7 +102,7 @@
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
#ifndef WIN32
|
||||
#if !defined WIN32 && !defined __APPLE__
|
||||
#include <sys/sysinfo.h>
|
||||
#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 )
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include <process.h>
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#include <libgen.h> // 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<char *>(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<char *>(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<char *>(theFileName) );
|
||||
#endif
|
||||
// publish mesh in the study
|
||||
if ( CanPublishInStudy( aMesh ) ) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -129,6 +129,7 @@ MeshJobManager_i::~MeshJobManager_i() {
|
||||
#include <direct.h> // to get _mkdir
|
||||
#else
|
||||
#include <unistd.h> // to get basename
|
||||
#include <libgen.h> // to get basename - as per posix
|
||||
#include <sys/stat.h> // to get mkdir
|
||||
#include <sys/types.h> // 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<char *>(dataFileName));
|
||||
#endif
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user