-// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// Author : Paul RASCLE, EDF
// Module : SMESH
//
-
//#define CHRONODEF
-
+//
#include "SMESH_Gen.hxx"
#include "SMESH_DriverMesh.hxx"
#include "SMESHDS_Document.hxx"
#include "SMESH_HypoFilter.hxx"
#include "SMESH_Mesh.hxx"
+#include "SMESH_SequentialMesh.hxx"
+#include "SMESH_ParallelMesh.hxx"
#include "SMESH_MesherHelper.hxx"
#include "SMESH_subMesh.hxx"
#include <Basics_Utils.hxx>
+#ifndef WIN32
+#include <boost/asio.hpp>
+#endif
+
using namespace std;
+#ifndef WIN32
#include <boost/filesystem.hpp>
-#include <boost/asio.hpp>
namespace fs = boost::filesystem;
+#endif
// Environment variable separator
#ifdef WIN32
Unexpect aCatch(SalomeException);
// create a new SMESH_mesh object
- SMESH_Mesh *aMesh = new SMESH_Mesh(_localId++,
+ SMESH_Mesh *aMesh = new SMESH_SequentialMesh(
+ _localId++,
this,
theIsEmbeddedMode,
_studyContext->myDocument);
return aMesh;
}
+//=============================================================================
+/*!
+ * Creates a parallel mesh in a study.
+ * if (theIsEmbeddedMode) { mesh modification commands are not logged }
+ */
+//=============================================================================
+
+SMESH_Mesh* SMESH_Gen::CreateParallelMesh(bool theIsEmbeddedMode)
+{
+ Unexpect aCatch(SalomeException);
+
+ // create a new SMESH_mesh object
+ SMESH_Mesh *aMesh = new SMESH_ParallelMesh(
+ _localId++,
+ this,
+ theIsEmbeddedMode,
+ _studyContext->myDocument);
+ _studyContext->mapMesh[_localId-1] = aMesh;
+
+ return aMesh;
+}
//=============================================================================
/*!
continue;
// check for preview dimension limitations
- if ( aShapesId && GetShapeDim( shapeType ) > (int)aDim )
+ if ( aShapesId && SMESH_Gen::GetShapeDim( shapeType ) > (int)aDim )
{
// clear compute state not to show previous compute errors
// if preview invoked less dimension less than previous
bool,
TopTools_IndexedMapOfShape *,
TSetOfInt*)>
- compute_function([&] (SMESH_subMesh* sm,
+ compute_function([] (SMESH_subMesh* sm,
SMESH_subMesh::compute_event event,
SMESH_subMesh *shapeSM,
bool aShapeOnly,
});
+
//=============================================================================
/*!
* Algo to run the computation of all the submeshes of a mesh in parallel
const bool complexShapeFirst,
const bool aShapeOnly)
{
+#ifdef WIN32
+ throw SALOME_Exception("ParallelMesh is not working on Windows");
+#else
bool ret = true;
SMESH_subMeshIteratorPtr smIt;
SMESH_subMesh *shapeSM = aMesh.GetSubMesh(aShape);
- // Pool of thread for computation
- // TODO: move when parallelMesh created
- aMesh.InitPoolThreads();
-
TopAbs_ShapeEnum previousShapeType = TopAbs_VERTEX;
int nbThreads = aMesh.GetNbThreads();
MESSAGE("Compute submeshes with threads: " << nbThreads);
}
if(file_name != "")
{
- fs::path mesh_file = fs::path(aMesh.tmp_folder) / fs::path(file_name);
- exportMesh(mesh_file.string(), aMesh, "MESH");
-
+ fs::path mesh_file = fs::path(aMesh.GetTmpFolder()) / fs::path(file_name);
+ SMESH_DriverMesh::exportMesh(mesh_file.string(), aMesh, "MESH");
}
//Resetting threaded pool info
previousShapeType = shapeType;
}
// check for preview dimension limitations
- if ( aShapesId && GetShapeDim( shapeType ) > (int)aDim )
+ if ( aShapesId && SMESH_Gen::GetShapeDim( shapeType ) > (int)aDim )
{
// clear compute state not to show previous compute errors
// if preview invoked less dimension less than previous
smToCompute->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
continue;
}
- boost::asio::post(*(aMesh._pool), std::bind(compute_function, smToCompute, computeEvent,
+ boost::asio::post(*(aMesh.GetPool()), std::bind(compute_function, smToCompute, computeEvent,
shapeSM, aShapeOnly, allowedSubShapes,
aShapesId));
}
aMesh.GetMeshDS()->Modified();
return ret;
+#endif
};
-
//=============================================================================
/*
* Compute a mesh
// ===============================================
// Mesh all the sub-shapes starting from vertices
// ===============================================
- if (aMesh.IsParallel())
- ret = parallelComputeSubMeshes(
- aMesh, aShape, aDim,
- aShapesId, allowedSubShapes,
- computeEvent,
- includeSelf,
- complexShapeFirst,
- aShapeOnly);
- else
- ret = sequentialComputeSubMeshes(
- aMesh, aShape, aDim,
- aShapesId, allowedSubShapes,
- computeEvent,
- includeSelf,
- complexShapeFirst,
- aShapeOnly);
+ ret = aMesh.ComputeSubMeshes(
+ this,
+ aMesh, aShape, aDim,
+ aShapesId, allowedSubShapes,
+ computeEvent,
+ includeSelf,
+ complexShapeFirst,
+ aShapeOnly);
return ret;
}