// 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
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 )
#include <iterator>
using namespace std;
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
#include <sys/sysinfo.h>
#endif
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 )
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)
}
}
-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)
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;
#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();
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;
#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();
#include <vector>
#include <set>
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
#include <sys/sysinfo.h>
#endif
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
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
{
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 )
*/
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
}
#include <process.h>
#else
#include <dlfcn.h>
+ #include <libgen.h> // for basename function
#endif
#ifdef WIN32
!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
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
}
}
_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;
_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 ) ) {
_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 ) ) {
//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
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
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;
<< 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
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;
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++)
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);
// 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;
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;
return typeBanaliseMED;
}
-int MESHCUT::chrono()
+int MESHCUT::salome_chrono()
{
return clock() / CLOCKS_PER_SEC;
}
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);
#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
_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