From 53fcb605c1cf0adcb3b3099ae881db40751e2d11 Mon Sep 17 00:00:00 2001 From: eap Date: Fri, 14 Feb 2014 16:05:31 +0400 Subject: [PATCH] 0022367: EDF SMESH: Notification on concurrent algorithms/hypotheses --- idl/SMESH_Mesh.idl | 5 ++ src/SMESHGUI/SMESHGUI_MeshOrderOp.cxx | 3 +- src/SMESH_I/SMESH_Mesh_i.cxx | 73 +++++++++++++++++++++++---- src/SMESH_I/SMESH_Mesh_i.hxx | 9 ++++ 4 files changed, 78 insertions(+), 12 deletions(-) diff --git a/idl/SMESH_Mesh.idl b/idl/SMESH_Mesh.idl index abce2bb25..527a79475 100644 --- a/idl/SMESH_Mesh.idl +++ b/idl/SMESH_Mesh.idl @@ -827,6 +827,11 @@ module SMESH * Methods to set meshing order of submeshes */ + /*! + * \brief Return \c true if a meshing order not yet set for a concurrent sub-mesh + */ + boolean IsUnorderedSubMesh(in long submeshID); + /*! * \brief Return submesh objects list in meshing order */ diff --git a/src/SMESHGUI/SMESHGUI_MeshOrderOp.cxx b/src/SMESHGUI/SMESHGUI_MeshOrderOp.cxx index 96caaa581..12235d531 100644 --- a/src/SMESHGUI/SMESHGUI_MeshOrderOp.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshOrderOp.cxx @@ -295,7 +295,8 @@ bool SMESHGUI_MeshOrderMgr::SetMeshOrder( const ListListId& theListListIds ) _PTR(SObject) aSmObj = smIter->Value(); SMESH::SMESH_subMesh_var sm = SMESH::SObjectToInterface( aSmObj ); - mapOfSubMesh[ sm->GetId() ] = SMESH::SMESH_subMesh::_duplicate(sm); + if ( !sm->_is_nil() ) + mapOfSubMesh[ sm->GetId() ] = SMESH::SMESH_subMesh::_duplicate(sm); } } diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 139262a6f..c539c3061 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -5100,8 +5100,37 @@ void findCommonSubMesh (list& theSubMeshList, //theCommon.insert( theSubMesh ); } +//----------------------------------------------------------------------------- +bool isSubMeshInList ( int smID, const TListOfListOfInt& smLists ) +{ + TListOfListOfInt::const_iterator listsIt = smLists.begin(); + for ( ; listsIt != smLists.end(); ++listsIt ) + { + const TListOfInt& smIDs = *listsIt; + if ( std::find( smIDs.begin(), smIDs.end(), smID ) != smIDs.end() ) + return true; + } + return false; +} + } // namespace +//============================================================================= +/*! + * \brief Return \c true if a meshing order not yet set for a concurrent sub-mesh + */ +//============================================================================= + +CORBA::Boolean SMESH_Mesh_i::IsUnorderedSubMesh(CORBA::Long submeshID) +{ + TListOfListOfInt anOrder = GetImpl().GetMeshOrder(); // already defined order + if ( isSubMeshInList( submeshID, anOrder )) + return false; + + TListOfListOfInt allConurrent = findConcurrentSubMeshes(); + return isSubMeshInList( submeshID, allConurrent ); +} + //============================================================================= /*! * \brief Return submesh objects list in meshing order @@ -5115,14 +5144,37 @@ SMESH::submesh_array_array* SMESH_Mesh_i::GetMeshOrder() SMESHDS_Mesh* aMeshDS = _impl->GetMeshDS(); if ( !aMeshDS ) return aResult._retn(); - - ::SMESH_Mesh& mesh = GetImpl(); - TListOfListOfInt anOrder = mesh.GetMeshOrder(); // is there already defined order? - if ( !anOrder.size() ) { + TListOfListOfInt anOrder = GetImpl().GetMeshOrder(); // already defined order + TListOfListOfInt allConurrent = findConcurrentSubMeshes(); + anOrder.splice( anOrder.end(), allConurrent ); + + int listIndx = 0; + TListOfListOfInt::iterator listIt = anOrder.begin(); + for(; listIt != anOrder.end(); listIt++, listIndx++ ) + unionLists( *listIt, anOrder, listIndx + 1 ); + + // convert submesh ids into interface instances + // and dump command into python + convertMeshOrder( anOrder, aResult, false ); + + return aResult._retn(); +} + +//============================================================================= +/*! + * \brief Finds concurrent sub-meshes + */ +//============================================================================= + +TListOfListOfInt SMESH_Mesh_i::findConcurrentSubMeshes() +{ + TListOfListOfInt anOrder; + ::SMESH_Mesh& mesh = GetImpl(); + { // collect submeshes and detect concurrent algorithms and hypothesises TDimHypList dimHypListArr[4]; // dimHyp list for each shape dimension - + map::iterator i_sm = _mapSubMesh.begin(); for ( ; i_sm != _mapSubMesh.end(); i_sm++ ) { ::SMESH_subMesh* sm = (*i_sm).second; @@ -5194,11 +5246,8 @@ SMESH::submesh_array_array* SMESH_Mesh_i::GetMeshOrder() for(; listIt != anOrder.end(); listIt++, listIndx++ ) unionLists( *listIt, anOrder, listIndx + 1 ); } - // convert submesh ids into interface instances - // and dump command into python - convertMeshOrder( anOrder, aResult, false ); - return aResult._retn(); + return anOrder; } //============================================================================= @@ -5287,7 +5336,8 @@ void SMESH_Mesh_i::convertMeshOrder (const TListOfListOfInt& theIdsOrder, SMESH::submesh_array_var aResSubSet = new SMESH::submesh_array(); aResSubSet->length(aSubOrder.size()); TListOfInt::const_iterator subIt = aSubOrder.begin(); - for( int j = 0; subIt != aSubOrder.end(); subIt++ ) { + int j; + for( j = 0; subIt != aSubOrder.end(); subIt++ ) { if ( _mapSubMeshIor.find(*subIt) == _mapSubMeshIor.end() ) continue; SMESH::SMESH_subMesh_var subMesh = @@ -5301,7 +5351,8 @@ void SMESH_Mesh_i::convertMeshOrder (const TListOfListOfInt& theIdsOrder, } if ( theIsDump ) aPythonDump << " ]"; - theResOrder[ listIndx++ ] = aResSubSet; + if ( j > 1 ) + theResOrder[ listIndx++ ] = aResSubSet; } // correct number of lists theResOrder.length( listIndx ); diff --git a/src/SMESH_I/SMESH_Mesh_i.hxx b/src/SMESH_I/SMESH_Mesh_i.hxx index f83347539..f63c51d23 100644 --- a/src/SMESH_I/SMESH_Mesh_i.hxx +++ b/src/SMESH_I/SMESH_Mesh_i.hxx @@ -585,6 +585,10 @@ public: */ SMESH::string_array* GetLastParameters(); + /*! + * \brief Return \c true if a meshing order not yet set for a concurrent sub-mesh + */ + CORBA::Boolean IsUnorderedSubMesh(CORBA::Long submeshID); /*! * \brief Return submesh objects list in meshing order */ @@ -653,6 +657,11 @@ private: SMESH::submesh_array_array& theSubMeshOrder, const bool theIsDump); + /*! + * \brief Finds concurrent sub-meshes + */ + TListOfListOfInt findConcurrentSubMeshes(); + private: static int _idGenerator;