+ case COMPUTE:
+ {
+ algo = gen->GetAlgo((*_father), _subShape);
+ ASSERT(algo);
+ ret = algo->CheckHypothesis((*_father), _subShape, hyp_status);
+ if (!ret)
+ {
+ MESSAGE("***** verify compute state *****");
+ _computeState = NOT_READY;
+ SetAlgoState(MISSING_HYP);
+ break;
+ }
+ TopoDS_Shape shape = _subShape;
+ // check submeshes needed
+ if (_father->HasShapeToMesh() ) {
+ bool subComputed = false;
+ if (!algo->OnlyUnaryInput())
+ shape = GetCollection( gen, algo, subComputed );
+ else
+ subComputed = SubMeshesComputed();
+ ret = ( algo->NeedDescretBoundary() ? subComputed :
+ algo->SupportSubmeshes() ? true :
+ ( !subComputed || _father->IsNotConformAllowed() ));
+ if (!ret) {
+ _computeState = FAILED_TO_COMPUTE;
+ if ( !algo->NeedDescretBoundary() )
+ _computeError =
+ SMESH_ComputeError::New(COMPERR_BAD_INPUT_MESH,
+ "Unexpected computed submesh",algo);
+ break;
+ }
+ }
+ // compute
+// CleanDependants(); for "UseExisting_*D" algos
+// RemoveSubMeshElementsAndNodes();
+ ret = false;
+ _computeState = FAILED_TO_COMPUTE;
+ _computeError = SMESH_ComputeError::New(COMPERR_OK,"",algo);
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+ algo->InitComputeError();
+ MemoryReserve aMemoryReserve;
+ SMDS_Mesh::CheckMemory();
+ if ( !_father->HasShapeToMesh() ) // no shape
+ {
+ SMESH_MesherHelper helper( *_father );
+ helper.SetSubShape( shape );
+ helper.SetElementsOnShape( true );
+ ret = algo->Compute(*_father, &helper );
+ }
+ else
+ {
+ ret = algo->Compute((*_father), shape);
+ }
+ if ( !ret && _computeError->IsOK() ) // algo can set _computeError of submesh
+ _computeError = algo->GetComputeError();
+ }
+ catch ( std::bad_alloc& exc ) {
+ MESSAGE("std::bad_alloc thrown inside algo->Compute()");
+ if ( _computeError ) {
+ _computeError->myName = COMPERR_MEMORY_PB;
+ //_computeError->myComment = exc.what();
+ }
+ cleanSubMesh( this );
+ throw exc;
+ }
+ catch ( Standard_OutOfMemory& exc ) {
+ MESSAGE("Standard_OutOfMemory thrown inside algo->Compute()");
+ if ( _computeError ) {
+ _computeError->myName = COMPERR_MEMORY_PB;
+ //_computeError->myComment = exc.what();
+ }
+ cleanSubMesh( this );
+ throw std::bad_alloc();
+ }
+ catch (Standard_Failure& ex) {
+ if ( !_computeError ) _computeError = SMESH_ComputeError::New();
+ _computeError->myName = COMPERR_OCC_EXCEPTION;
+ _computeError->myComment += ex.DynamicType()->Name();
+ if ( ex.GetMessageString() && strlen( ex.GetMessageString() )) {
+ _computeError->myComment += ": ";
+ _computeError->myComment += ex.GetMessageString();
+ }
+ }
+ catch ( SALOME_Exception& S_ex ) {
+ if ( !_computeError ) _computeError = SMESH_ComputeError::New();
+ _computeError->myName = COMPERR_SLM_EXCEPTION;
+ _computeError->myComment = S_ex.what();
+ }
+ catch ( std::exception& exc ) {
+ if ( !_computeError ) _computeError = SMESH_ComputeError::New();
+ _computeError->myName = COMPERR_STD_EXCEPTION;
+ _computeError->myComment = exc.what();
+ }
+ catch ( ... ) {
+ if ( _computeError )
+ _computeError->myName = COMPERR_EXCEPTION;
+ else
+ ret = false;
+ }
+ if (ret && !_alwaysComputed && shape == _subShape) { // check if anything was built
+ ret = ( GetSubMeshDS() && ( GetSubMeshDS()->NbElements() || GetSubMeshDS()->NbNodes() ));
+ }
+ bool isComputeErrorSet = !CheckComputeError( algo, shape );
+ if (!ret && !isComputeErrorSet)
+ {
+ // Set _computeError
+ if ( !_computeError )
+ _computeError = SMESH_ComputeError::New();
+ if ( _computeError->IsOK() )
+ _computeError->myName = COMPERR_ALGO_FAILED;
+ _computeState = FAILED_TO_COMPUTE;
+ }
+ if (ret)
+ {
+ _computeError.reset();
+ }
+ UpdateDependantsState( SUBMESH_COMPUTED ); // send event SUBMESH_COMPUTED
+ }
+ break;
+ case CLEAN:
+ CleanDependants();
+ RemoveSubMeshElementsAndNodes();
+ _computeState = NOT_READY;
+ algo = gen->GetAlgo((*_father), _subShape);
+ if (algo)
+ {
+ ret = algo->CheckHypothesis((*_father), _subShape, hyp_status);
+ if (ret)
+ _computeState = READY_TO_COMPUTE;
+ else
+ SetAlgoState(MISSING_HYP);
+ }
+ break;
+ case SUBMESH_COMPUTED: // nothing to do
+ break;
+ case SUBMESH_RESTORED:
+ // check if a mesh is already computed that may
+ // happen after retrieval from a file
+ ComputeStateEngine( CHECK_COMPUTE_STATE );
+ ComputeSubMeshStateEngine( SUBMESH_RESTORED );
+ algo = gen->GetAlgo(*_father, _subShape);
+ if (algo) algo->SubmeshRestored( this );
+ break;
+ case MESH_ENTITY_REMOVED:
+ break;
+ case CHECK_COMPUTE_STATE:
+ if ( IsMeshComputed() )
+ _computeState = COMPUTE_OK;
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+ break;