_compatibleHypothesis.push_back("GHS3D_Parameters");
_compatibleHypothesis.push_back( StdMeshers_ViscousLayers::GetHypType() );
_requireShape = false; // can work without shape
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ _compute_canceled = false;
+#endif
}
//=============================================================================
static bool readResultFile(const int fileOpen,
#ifdef WNT
const char* fileName,
+#endif
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ GHS3DPlugin_GHS3D* theAlgo,
#endif
SMESH_Mesh& theMesh,
TopoDS_Shape tabShape[],
MESSAGE("nbEnforcedVertices: "<<nbEnforcedVertices);
// Reading the nodeCoor and update the nodeMap
for (int iNode=1; iNode <= nbNodes; iNode++) {
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ if(theAlgo->computeCanceled())
+ return false;
+#endif
for (int iCoor=0; iCoor < 3; iCoor++)
coord[ iCoor ] = strtod(ptr, &ptr);
nodeAssigne[ iNode ] = 1;
tabID = new int[nbTriangle];
for (int i=0; i < nbTriangle; i++) {
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ if(theAlgo->computeCanceled())
+ return false;
+#endif
tabID[i] = 0;
// find the solid corresponding to GHS3D sub-domain following
// the technique proposed in GHS3D manual in chapter
// Associating the tetrahedrons to the shapes
shapeID = compoundID;
for (int iElem = 0; iElem < nbElems; iElem++) {
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ if(theAlgo->computeCanceled())
+ return false;
+#endif
for (int iNode = 0; iNode < 4; iNode++) {
ID = strtol(tetraPtr, &tetraPtr, 10);
itOnNode = theGhs3dIdToNodeMap.find(ID);
static bool readResultFile(const int fileOpen,
#ifdef WNT
const char* fileName,
+#endif
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ GHS3DPlugin_GHS3D* theAlgo,
#endif
SMESH_Mesh& theMesh,
TopoDS_Shape aSolid,
// Reading the nodeCoord and update the nodeMap
shapeID = theMeshDS->ShapeToIndex( aSolid );
for (int iNode=0; iNode < nbNodes; iNode++) {
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ if(theAlgo->computeCanceled())
+ return false;
+#endif
for (int iCoor=0; iCoor < 3; iCoor++)
coord[ iCoor ] = strtod(ptr, &ptr);
if ((iNode+1) > (nbInputNodes-nbEnforcedVertices)) {
// Associating the tetrahedrons to the shapes
for (int iElem = 0; iElem < nbElems; iElem++) {
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ if(theAlgo->computeCanceled())
+ return false;
+#endif
for (int iNode = 0; iNode < 4; iNode++) {
ID = strtol(tetraPtr, &tetraPtr, 10);
node[ iNode ] = theNodeByGhs3dId[ ID-1 ];
std::cout << "Ghs3d execution..." << std::endl;
std::cout << cmd << std::endl;
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ _compute_canceled = false;
+#endif
+
system( cmd.ToCString() ); // run
std::cout << std::endl;
Ok = readResultFile( fileOpen,
#ifdef WNT
aResultFileName.ToCString(),
+#endif
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ this,
#endif
theMesh, tabShape, tabBox, _nbShape, aGhs3dIdToNodeMap,
toMeshHoles, nbEnforcedVertices );
}
if ( !_keepFiles ) {
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ if (! Ok)
+ if(_compute_canceled)
+ removeFile( aLogFileName );
+#endif
removeFile( aFacesFileName );
removeFile( aPointsFileName );
removeFile( aResultFileName );
cmd += TCollection_AsciiString(" -f ") + aGenericName; // file to read
cmd += TCollection_AsciiString(" 1>" ) + aLogFileName; // dump into file
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ _compute_canceled = false;
+#endif
+
system( cmd.ToCString() ); // run
// --------------
Ok = readResultFile( fileOpen,
#ifdef WNT
aResultFileName.ToCString(),
+#endif
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ this,
#endif
theMesh, theShape ,aNodeByGhs3dId, nbEnforcedVertices );
}
if ( !_keepFiles )
{
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ if (! Ok)
+ if(_compute_canceled)
+ removeFile( aLogFileName );
+#endif
removeFile( aFacesFileName );
removeFile( aPointsFileName );
removeFile( aResultFileName );
return Ok;
}
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+void GHS3DPlugin_GHS3D::CancelCompute()
+{
+ _compute_canceled = true;
+#ifdef WNT
+#else
+ TCollection_AsciiString aGenericName
+ = (char*) GHS3DPlugin_Hypothesis::GetFileName(_hyp).c_str();
+ TCollection_AsciiString cmd =
+ TCollection_AsciiString("ps ux | grep ") + aGenericName;
+ cmd += TCollection_AsciiString(" | grep -v grep | awk '{print $2}' | xargs kill -9 > /dev/null 2>&1");
+ system( cmd.ToCString() );
+#endif
+}
+#endif
+
//================================================================================
/*!
* \brief Provide human readable text by error code reported by ghs3d
bool GHS3DPlugin_GHS3D::storeErrorDescription(const TCollection_AsciiString& logFile,
const _Ghs2smdsConvertor & toSmdsConvertor )
{
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ if(_compute_canceled)
+ return error(SMESH_Comment("interruption initiated by user"));
+#endif
// open file
#ifdef WNT
int file = ::_open (logFile.ToCString(), _O_RDONLY|_O_BINARY);