Disabling boost::filesystem for windows

This commit is contained in:
Yoann Audouin 2022-11-04 17:22:45 +01:00
parent e749ba3f4e
commit 3c51726026
6 changed files with 30 additions and 17 deletions

View File

@ -24,7 +24,6 @@
// Author : Yoann AUDOUIN, EDF
// Module : SMESH
//
#include <utilities.h>
#include <Utils_SALOME_Exception.hxx>
#include "SMESH_DriverShape.hxx"
@ -41,9 +40,11 @@
//Occ include
#include <TopoDS.hxx>
#ifndef WIN32
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
namespace fs = boost::filesystem;
#endif
/**
* @brief Import the content of a shape file (STEP) into a TopDS_Shape object
@ -147,6 +148,7 @@ int exportBREPShape(const std::string shape_file, const TopoDS_Shape& aShape){
* @return error code
*/
int importShape(const std::string shape_file, TopoDS_Shape& aShape){
#ifndef WIN32
std::string type = fs::path(shape_file).extension().string();
boost::algorithm::to_lower(type);
if (type == ".brep"){
@ -156,6 +158,7 @@ int importShape(const std::string shape_file, TopoDS_Shape& aShape){
} else {
throw SALOME_Exception("Unknow format for importShape: " + type);
}
#endif
}
/**
@ -167,6 +170,7 @@ int importShape(const std::string shape_file, TopoDS_Shape& aShape){
* @return error code
*/
int exportShape(const std::string shape_file, const TopoDS_Shape& aShape){
#ifndef WIN32
std::string type = fs::path(shape_file).extension().string();
boost::algorithm::to_lower(type);
if (type == ".brep"){
@ -176,4 +180,5 @@ int exportShape(const std::string shape_file, const TopoDS_Shape& aShape){
} else {
throw SALOME_Exception("Unknow format for exportShape: " + type);
}
#endif
}

View File

@ -25,7 +25,6 @@
// Author : Paul RASCLE, EDF
// Module : SMESH
//
//#define CHRONODEF
//
#ifndef WIN32
@ -60,8 +59,10 @@
#include <Basics_Utils.hxx>
using namespace std;
#ifndef WIN32
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
#endif
// Environment variable separator
#ifdef WIN32
@ -280,6 +281,9 @@ bool SMESH_Gen::parallelComputeSubMeshes(
const bool complexShapeFirst,
const bool aShapeOnly)
{
#ifdef WIN32
throw SALOME_Exception("ParallelMesh is not working on Windows");
#else
bool ret = true;
@ -351,15 +355,9 @@ bool SMESH_Gen::parallelComputeSubMeshes(
smToCompute->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
continue;
}
#ifdef WIN32
compute_function(smToCompute, computeEvent,
shapeSM, aShapeOnly, allowedSubShapes,
aShapesId);
#else
boost::asio::post(*(aMesh._pool), std::bind(compute_function, smToCompute, computeEvent,
shapeSM, aShapeOnly, allowedSubShapes,
aShapesId));
#endif
}
// Waiting for the thread for Solids to finish
@ -369,6 +367,7 @@ bool SMESH_Gen::parallelComputeSubMeshes(
aMesh.DeleteTmpFolder();
return ret;
#endif
};
//=============================================================================

View File

@ -80,8 +80,10 @@
#include <pthread.h>
#endif
#ifndef WIN32
#include <boost/filesystem.hpp>
namespace fs=boost::filesystem;
#endif
// maximum stored group name length in MED file
#define MAX_MED_GROUP_NAME_LENGTH 80
@ -236,10 +238,8 @@ SMESH_Mesh::~SMESH_Mesh()
int result=pthread_create(&thread, NULL, deleteMeshDS, (void*)_meshDS);
#endif
}
#ifndef WIN32
if(_pool)
DeletePoolThreads();
#endif
}
//================================================================================
@ -2578,9 +2578,11 @@ void SMESH_Mesh::getAncestorsSubMeshes (const TopoDS_Shape& theSubSha
//=============================================================================
void SMESH_Mesh::CreateTmpFolder()
{
#ifndef WIN32
// 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);
#endif
}
//
//=============================================================================
@ -2590,7 +2592,7 @@ void SMESH_Mesh::CreateTmpFolder()
//=============================================================================
void SMESH_Mesh::DeleteTmpFolder()
{
#ifndef _DEBUG_
#ifndef WIN32
fs::remove_all(tmp_folder);
#endif
}

View File

@ -29,7 +29,6 @@
#include "SMESH_SMESH.hxx"
#include "SMDSAbs_ElementType.hxx"
#include "SMESH_ComputeError.hxx"
#include "SMESH_Controls.hxx"
@ -49,11 +48,11 @@
#include <vector>
#include <ostream>
#include <boost/filesystem.hpp>
#ifndef WIN32
#include <boost/filesystem.hpp>
#include <boost/asio/thread_pool.hpp>
#include <boost/thread.hpp>
#endif
#include <boost/thread.hpp>
#ifdef WIN32
#pragma warning(disable:4251) // Warning DLL Interface ...
@ -422,10 +421,13 @@ class SMESH_EXPORT SMESH_Mesh
void DeleteTmpFolder();
// Temporary folder used during parallel Computation
#ifndef WIN32
boost::filesystem::path tmp_folder;
#ifndef WIN32
boost::asio::thread_pool * _pool = nullptr; //thread pool for computation
#endif
#else
std::string tmp_folder;
bool _pool = false;
#endif
private:

View File

@ -123,9 +123,11 @@ def run_test(nbox=2, boxsize=100):
print("Time elapsed (seq, par): ", time_seq, time_par)
def main():
if sys.platform == "win32":
print("Test disabled on Windows")
return
nbox = 2
boxsize = 100
run_test(nbox, boxsize)
main()

View File

@ -126,4 +126,7 @@ def test_netgen3d():
assert nb_tetras > 0
if __name__ == "__main__":
if sys.platform == "win32":
print("Disabled on windows")
sys.exit(0)
test_netgen3d()