#ifndef WIN32
#include <boost/thread/thread.hpp>
#include <boost/bind.hpp>
-#else
+#else
#include <pthread.h>
#endif
+#include <boost/filesystem.hpp>
+namespace fs=boost::filesystem;
+
// maximum stored group name length in MED file
#define MAX_MED_GROUP_NAME_LENGTH 80
#ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
#else
static int MYDEBUG = 0;
#endif
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
_callUp = NULL;
_meshDS->ShapeToMesh( PseudoShape() );
_subMeshHolder = new SubMeshHolder;
+ // 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);
// assure unique persistent ID
if ( _document->NbMeshes() > 1 )
#ifndef WIN32
void deleteMeshDS(SMESHDS_Mesh* meshDS)
{
- //cout << "deleteMeshDS( " << meshDS << endl;
delete meshDS;
}
#else
static void* deleteMeshDS(void* meshDS)
{
- //cout << "deleteMeshDS( " << meshDS << endl;
SMESHDS_Mesh* m = (SMESHDS_Mesh*)meshDS;
if(m) {
delete m;
int result=pthread_create(&thread, NULL, deleteMeshDS, (void*)_meshDS);
#endif
}
+
+ if(_pool)
+ DeletePoolThreads();
+ if (!MYDEBUG)
+ fs::remove_all(tmp_folder);
}
//================================================================================
Driver_Mesh::Status status = myReader.Perform();
#ifdef _DEBUG_
SMESH_ComputeErrorPtr er = myReader.GetError();
- if ( er && !er->IsOK() ) std::cout << er->myComment << std::endl;
+ if ( er && !er->IsOK() ) MESSAGE(er->myComment);
#endif
// Reading groups (sub-meshes are out of scope of MED import functionality)
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
while ( smIt->more() ) {
SMESH_subMesh* sm = smIt->next();
if ( sm->IsApplicableHypothesis( anHyp )) {
- ret2 = sm->CheckConcurrentHypothesis( anHyp->GetType() );
+ ret2 = sm->CheckConcurrentHypothesis( anHyp );
if (ret2 > ret) {
ret = ret2;
break;
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId];
if(MYDEBUG) { SCRUTE(anHyp->GetType()); }
- // shape
+ // shape
bool isAlgo = ( !anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO );
SMESH_subMesh::algo_event event = isAlgo ? SMESH_subMesh::REMOVE_ALGO : SMESH_subMesh::REMOVE_HYP;
// there may appear concurrent hyps that were covered by the removed hyp
if (ret < SMESH_Hypothesis::HYP_CONCURRENT &&
subMesh->IsApplicableHypothesis( anHyp ) &&
- subMesh->CheckConcurrentHypothesis( anHyp->GetType() ) != SMESH_Hypothesis::HYP_OK)
+ subMesh->CheckConcurrentHypothesis( anHyp ) != SMESH_Hypothesis::HYP_OK)
ret = SMESH_Hypothesis::HYP_CONCURRENT;
// sub-shapes
while ( smIt->more() ) {
SMESH_subMesh* sm = smIt->next();
if ( sm->IsApplicableHypothesis( anHyp )) {
- ret2 = sm->CheckConcurrentHypothesis( anHyp->GetType() );
+ ret2 = sm->CheckConcurrentHypothesis( anHyp );
if (ret2 > ret) {
ret = ret2;
break;
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
const_cast< std::vector< SMESH_subMesh * > & > ( aSubMesh->GetAncestors() );
SortByMeshOrder( ancestors );
- std::vector<SMESH_subMesh*>::const_iterator smIt = ancestors.begin();
+ std::vector<SMESH_subMesh*>::const_iterator smIt = ancestors.begin();
for ( ; smIt != ancestors.end(); smIt++ )
{
const TopoDS_Shape& curSh = (*smIt)->GetSubShape();
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
void SMESH_Mesh::ClearLog()
const SMESH_subMesh* curSM = _gen->GetCurrentSubMesh();
// get progress of a current algo
- TColStd_MapOfInteger currentSubIds;
+ TColStd_MapOfInteger currentSubIds;
if ( curSM )
if ( SMESH_Algo* algo = curSM->GetAlgo() )
{
rate = algo->GetProgressByTic();
computedCost += algoDoneCost + rate * algoNotDoneCost;
}
- // cout << "rate: "<<rate << " algoNotDoneCost: " << algoNotDoneCost << endl;
}
// get cost of already treated sub-meshes
}
}
}
- // cout << "Total: " << totalCost
- // << " computed: " << computedCost << " progress: " << computedCost / totalCost
- // << " nbElems: " << GetMeshDS()->GetMeshInfo().NbElements() << endl;
return computedCost / totalCost;
}
//=======================================================================
//function : IsMainShape
-//purpose :
+//purpose :
//=======================================================================
bool SMESH_Mesh::IsMainShape(const TopoDS_Shape& theShape) const
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
std::map<int, SMESH_Group*>::const_iterator it = _mapGroup.begin();
for ( ; it != _mapGroup.end(); it++ )
anIds.push_back( it->first );
-
+
return anIds;
}
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
}
}
return true; // no order imposed to given sub-meshes
-}
+}
//=============================================================================
/*!