return error( COMPERR_BAD_INPUT_MESH, "Mesh built on shape expected");
}
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+void SMESH_Algo::CancelCompute()
+{
+}
+#endif
+
//================================================================================
/*!
* \brief store error and comment and then return ( error == COMPERR_OK )
*/
virtual bool Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHelper);
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ virtual void CancelCompute();
+#endif
+
/*!
* \brief evaluates size of prospective mesh on a shape
* \param aMesh - the mesh
SMDS_Mesh::_meshList.clear();
MESSAGE(SMDS_Mesh::_meshList.size());
_counters = new counters(100);
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ _compute_canceled = false;
+ _sm_current = NULL;
+#endif
}
//=============================================================================
}
if (smToCompute->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE)
+ {
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ if (_compute_canceled)
+ return false;
+ _sm_current = smToCompute;
+#endif
smToCompute->ComputeStateEngine( SMESH_subMesh::COMPUTE );
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ _sm_current = NULL;
+#endif
+ }
// we check all the submeshes here and detect if any of them failed to compute
if (smToCompute->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE)
smWithAlgoSupportingSubmeshes.push_front( smToCompute );
else
{
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ if (_compute_canceled)
+ return false;
+ _sm_current = smToCompute;
+#endif
smToCompute->ComputeStateEngine( SMESH_subMesh::COMPUTE );
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ _sm_current = NULL;
+#endif
if ( aShapesId )
aShapesId->insert( smToCompute->GetId() );
}
if ( aShapesId && GetShapeDim( aShType ) > (int)aDim )
continue;
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ if (_compute_canceled)
+ return false;
+ _sm_current = sm;
+#endif
sm->ComputeStateEngine( SMESH_subMesh::COMPUTE );
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ _sm_current = NULL;
+#endif
if ( aShapesId )
aShapesId->insert( sm->GetId() );
}
}
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+//=============================================================================
+/*!
+ * Prepare Compute a mesh
+ */
+//=============================================================================
+void SMESH_Gen::PrepareCompute(SMESH_Mesh & aMesh,
+ const TopoDS_Shape & aShape)
+{
+ _compute_canceled = false;
+ _sm_current = NULL;
+}
+//=============================================================================
+/*!
+ * Cancel Compute a mesh
+ */
+//=============================================================================
+void SMESH_Gen::CancelCompute(SMESH_Mesh & aMesh,
+ const TopoDS_Shape & aShape)
+{
+ _compute_canceled = true;
+ if(_sm_current)
+ {
+ _sm_current->ComputeStateEngine( SMESH_subMesh::COMPUTE_CANCELED );
+ }
+}
+#endif
+
//=============================================================================
/*!
* Evaluate a mesh
const ::MeshDimension aDim=::MeshDim_3D,
TSetOfInt* aShapesId=0);
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ void PrepareCompute(::SMESH_Mesh & aMesh,
+ const TopoDS_Shape & aShape);
+ void CancelCompute(::SMESH_Mesh & aMesh,
+ const TopoDS_Shape & aShape);
+#endif
+
/*!
* \brief evaluates size of prospective mesh on a shape
* \param aMesh - the mesh
// default of segments
int _nbSegments;
counters *_counters;
+
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ volatile bool _compute_canceled;
+ SMESH_subMesh* _sm_current;
+#endif
};
#endif
break;
case COMPUTE: // nothing to do
break;
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ case COMPUTE_CANCELED: // nothing to do
+ break;
+#endif
case CLEAN:
CleanDependants();
RemoveSubMeshElementsAndNodes();
UpdateDependantsState( SUBMESH_COMPUTED ); // send event SUBMESH_COMPUTED
}
break;
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ case COMPUTE_CANCELED: // nothing to do
+ break;
+#endif
case CLEAN:
CleanDependants();
RemoveSubMeshElementsAndNodes();
break;
case COMPUTE: // nothing to do
break;
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ case COMPUTE_CANCELED: // nothing to do
+ break;
+#endif
case CLEAN:
CleanDependants(); // clean sub-meshes, dependant on this one, with event CLEAN
RemoveSubMeshElementsAndNodes();
break;
case COMPUTE: // nothing to do
break;
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ case COMPUTE_CANCELED:
+ {
+ algo = gen->GetAlgo((*_father), _subShape);
+ algo->CancelCompute();
+ }
+ break;
+#endif
case CLEAN:
CleanDependants(); // submeshes dependent on me should be cleaned as well
RemoveSubMeshElementsAndNodes();
enum compute_event
{
MODIF_ALGO_STATE, COMPUTE,
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ COMPUTE_CANCELED,
+#endif
CLEAN, SUBMESH_COMPUTED, SUBMESH_RESTORED,
MESH_ENTITY_REMOVED, CHECK_COMPUTE_STATE
};