From 9afcd890f59bc3177fa74c7c0a454cc618f713bf Mon Sep 17 00:00:00 2001 From: Yoann Audouin Date: Tue, 28 Mar 2023 08:45:16 +0200 Subject: [PATCH] Replace WIN32 by DISABLE_PSMESH --- src/SMESH/SMESH_DriverShape.cxx | 6 +++--- src/SMESH/SMESH_Gen.cxx | 6 +++--- src/SMESH/SMESH_Mesh.hxx | 6 ++++-- src/SMESH/SMESH_ParallelMesh.cxx | 12 ++++++++---- src/SMESH/SMESH_ParallelMesh.hxx | 19 +++++++++++++++++++ 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/SMESH/SMESH_DriverShape.cxx b/src/SMESH/SMESH_DriverShape.cxx index 8efa1943f..9c3088ee4 100644 --- a/src/SMESH/SMESH_DriverShape.cxx +++ b/src/SMESH/SMESH_DriverShape.cxx @@ -40,7 +40,7 @@ //Occ include #include -#ifndef WIN32 +#ifndef DISABLE_PSMESH #include #include namespace fs = boost::filesystem; @@ -148,7 +148,7 @@ int exportBREPShape(const std::string shape_file, const TopoDS_Shape& aShape){ * @return error code */ int SMESH_DriverShape::importShape(const std::string shape_file, TopoDS_Shape& aShape){ -#ifndef WIN32 +#ifndef DISABLE_PSMESH std::string type = fs::path(shape_file).extension().string(); boost::algorithm::to_lower(type); if (type == ".brep"){ @@ -172,7 +172,7 @@ int SMESH_DriverShape::importShape(const std::string shape_file, TopoDS_Shape& a * @return error code */ int SMESH_DriverShape::exportShape(const std::string shape_file, const TopoDS_Shape& aShape){ -#ifndef WIN32 +#ifndef DISABLE_PSMESH std::string type = fs::path(shape_file).extension().string(); boost::algorithm::to_lower(type); if (type == ".brep"){ diff --git a/src/SMESH/SMESH_Gen.cxx b/src/SMESH/SMESH_Gen.cxx index 4a020890e..a1e6a816c 100644 --- a/src/SMESH/SMESH_Gen.cxx +++ b/src/SMESH/SMESH_Gen.cxx @@ -57,12 +57,12 @@ #include -#ifndef WIN32 +#ifndef DISABLE_PSMESH #include #endif using namespace std; -#ifndef WIN32 +#ifndef DISABLE_PSMESH #include namespace fs = boost::filesystem; #endif @@ -307,7 +307,7 @@ bool SMESH_Gen::parallelComputeSubMeshes( const bool complexShapeFirst, const bool aShapeOnly) { -#ifdef WIN32 +#ifdef DISABLE_PSMESH throw SALOME_Exception("ParallelMesh is not working on Windows"); #else diff --git a/src/SMESH/SMESH_Mesh.hxx b/src/SMESH/SMESH_Mesh.hxx index c0cbb37b6..d889e1d99 100644 --- a/src/SMESH/SMESH_Mesh.hxx +++ b/src/SMESH/SMESH_Mesh.hxx @@ -49,7 +49,7 @@ #include #include -#ifndef WIN32 +#ifndef DISABLE_PSMESH #include #include #endif @@ -404,8 +404,10 @@ class SMESH_EXPORT SMESH_Mesh virtual bool IsParallel(){std::cout << "Should not pass here: IsParallel" << std::endl;return false;}; +#ifndef DISABLE_PSMESH virtual boost::filesystem::path GetTmpFolder() {return "";}; virtual boost::asio::thread_pool* GetPool() {return NULL;}; +#endif virtual bool ComputeSubMeshes( SMESH_Gen* gen, @@ -466,7 +468,7 @@ protected: TCallUp* _callUp; // Mutex for multhitreading write in SMESH_Mesh -#ifndef WIN32 +#ifndef DISABLE_PSMESH boost::mutex _my_lock; #endif int _NbThreads=-1; diff --git a/src/SMESH/SMESH_ParallelMesh.cxx b/src/SMESH/SMESH_ParallelMesh.cxx index 4b9f83ce5..a56658892 100644 --- a/src/SMESH/SMESH_ParallelMesh.cxx +++ b/src/SMESH/SMESH_ParallelMesh.cxx @@ -32,12 +32,12 @@ #include #endif -#ifndef WIN32 +#ifndef DISABLE_PSMESH #include namespace fs=boost::filesystem; #endif -#ifndef WIN32 +#ifndef DISABLE_PSMESH #include #endif @@ -58,7 +58,11 @@ SMESH_ParallelMesh::SMESH_ParallelMesh(int theLocalId, theDocument) { MESSAGE("SMESH_ParallelMesh::SMESH_ParallelMesh(int localId)"); +#ifndef DISABLE_PSMESH _NbThreads = std::thread::hardware_concurrency(); +#else + _NbThreads = 0; +#endif CreateTmpFolder(); }; @@ -78,7 +82,7 @@ SMESH_ParallelMesh::~SMESH_ParallelMesh() //============================================================================= void SMESH_ParallelMesh::CreateTmpFolder() { -#ifndef WIN32 +#ifndef DISABLE_PSMESH // Temporary folder that will be used by parallel computation tmp_folder = fs::temp_directory_path()/fs::unique_path(fs::path("SMESH_%%%%-%%%%")); fs::create_directories(tmp_folder); @@ -92,7 +96,7 @@ void SMESH_ParallelMesh::CreateTmpFolder() //============================================================================= void SMESH_ParallelMesh::DeleteTmpFolder() { -#ifndef WIN32 +#ifndef DISABLE_PSMESH fs::remove_all(tmp_folder); #endif } diff --git a/src/SMESH/SMESH_ParallelMesh.hxx b/src/SMESH/SMESH_ParallelMesh.hxx index 09a520681..361d7fba1 100644 --- a/src/SMESH/SMESH_ParallelMesh.hxx +++ b/src/SMESH/SMESH_ParallelMesh.hxx @@ -42,6 +42,7 @@ class SMESH_EXPORT SMESH_ParallelMesh: public SMESH_Mesh virtual ~SMESH_ParallelMesh(); +#ifndef DISABLE_PSMESH void Lock() override {_my_lock.lock();}; void Unlock() override {_my_lock.unlock();}; @@ -60,6 +61,22 @@ class SMESH_EXPORT SMESH_ParallelMesh: public SMESH_Mesh boost::filesystem::path GetTmpFolder() override {return tmp_folder;}; boost::asio::thread_pool* GetPool() override {return _pool;}; +#else + void Lock() override {}; + void Unlock() override {}; + + int GetNbThreads() override {return 0;}; + void SetNbThreads(long nbThreads) {(void) nbThreads;}; + + void InitPoolThreads() override {}; + void DeletePoolThreads() override {}; + void wait() override {}; + + bool IsParallel() override {return false;}; + + void CreateTmpFolder(); + void DeleteTmpFolder(); +#endif bool ComputeSubMeshes( SMESH_Gen* gen, @@ -77,7 +94,9 @@ class SMESH_EXPORT SMESH_ParallelMesh: public SMESH_Mesh SMESH_ParallelMesh():SMESH_Mesh() {}; SMESH_ParallelMesh(const SMESH_ParallelMesh& aMesh):SMESH_Mesh(aMesh) {}; private: +#ifndef DISABLE_PSMESH boost::filesystem::path tmp_folder; boost::asio::thread_pool * _pool = nullptr; //thread pool for computation +#endif }; #endif -- 2.39.2