This commit is contained in:
rnv 2018-07-13 09:51:25 +03:00
commit 32d14d3084
20 changed files with 362 additions and 406 deletions

View File

@ -1336,6 +1336,41 @@ bool SMESH_Mesh::HasModificationsToDiscard() const
return false; return false;
} }
//=============================================================================
/*!
* \brief Return true if all sub-meshes are computed OK - to update an icon
*/
//=============================================================================
bool SMESH_Mesh::IsComputedOK()
{
if ( NbNodes() == 0 )
return false;
if ( !HasShapeToMesh() )
return true;
if ( SMESH_subMesh* mainSM = GetSubMeshContaining( 1 ))
{
SMESH_subMeshIteratorPtr smIt = mainSM->getDependsOnIterator(/*includeSelf=*/true);
while ( smIt->more() )
{
const SMESH_subMesh* sm = smIt->next();
if ( !sm->IsAlwaysComputed() )
switch ( sm->GetComputeState() )
{
case SMESH_subMesh::NOT_READY:
case SMESH_subMesh::COMPUTE_OK:
continue; // ok
case SMESH_subMesh::FAILED_TO_COMPUTE:
case SMESH_subMesh::READY_TO_COMPUTE:
return false;
}
}
}
return true;
}
//================================================================================ //================================================================================
/*! /*!
* \brief Check if any groups of the same type have equal names * \brief Check if any groups of the same type have equal names

View File

@ -235,6 +235,11 @@ class SMESH_EXPORT SMESH_Mesh
*/ */
bool HasModificationsToDiscard() const; bool HasModificationsToDiscard() const;
/*!
* \brief Return true if all sub-meshes are computed OK - to update an icon
*/
bool IsComputedOK();
/*! /*!
* \brief Return data map of descendant to ancestor shapes * \brief Return data map of descendant to ancestor shapes
*/ */

View File

@ -261,7 +261,7 @@ public:
* none mesh entity is bound to it * none mesh entity is bound to it
*/ */
void SetIsAlwaysComputed(bool isAlCo); void SetIsAlwaysComputed(bool isAlCo);
bool IsAlwaysComputed() { return _alwaysComputed; } bool IsAlwaysComputed() const { return _alwaysComputed; }
bool SubMeshesComputed(bool * isFailedToCompute=0) const; bool SubMeshesComputed(bool * isFailedToCompute=0) const;

View File

@ -1942,10 +1942,6 @@ void SMESHGUI::OnEditDelete()
else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather(); SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
aMesh->RemoveSubMesh( aSubMesh ); aMesh->RemoveSubMesh( aSubMesh );
_PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
if (aMeshSO)
SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
} }
else { else {
Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
@ -3331,7 +3327,6 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
if ( aMesh->NbNodes() == 0 ) // imported mesh is not empty if ( aMesh->NbNodes() == 0 ) // imported mesh is not empty
SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true); SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
_PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh); _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
SMESH::ModifiedMesh( aMeshSObj, false, true);
// hide groups and submeshes // hide groups and submeshes
_PTR(ChildIterator) anIter = _PTR(ChildIterator) anIter =
SMESH::getStudy()->NewChildIterator( aMeshSObj ); SMESH::getStudy()->NewChildIterator( aMeshSObj );

View File

@ -925,10 +925,6 @@ void SMESHGUI_BaseComputeOp::computeMesh()
// NPAL16631: if ( !memoryLack ) // NPAL16631: if ( !memoryLack )
{ {
_PTR(SObject) sobj = SMESH::getStudy()->FindObjectID(myIObject->getEntry());
SMESH::ModifiedMesh( sobj,
!computeFailed && aHypErrors.isEmpty(),
myMesh->NbNodes() == 0);
update( UF_ObjBrowser | UF_Model ); update( UF_ObjBrowser | UF_Model );
// SHOW MESH // SHOW MESH

View File

@ -317,7 +317,6 @@ void SMESHGUI_GenericHypothesisCreator::onDialogFinished( int result )
if( !aSubMesh->_is_nil() ) if( !aSubMesh->_is_nil() )
aMesh = aSubMesh->GetFather(); aMesh = aSubMesh->GetFather();
_PTR(SObject) meshSO = SMESH::FindSObject( aMesh ); _PTR(SObject) meshSO = SMESH::FindSObject( aMesh );
SMESH::ModifiedMesh( meshSO, false, aMesh->NbNodes()==0);
SMESH_Actor* actor = SMESH::FindActorByEntry( meshSO->GetID().c_str() ); SMESH_Actor* actor = SMESH::FindActorByEntry( meshSO->GetID().c_str() );
if( actor && actor->GetVisibility() ) if( actor && actor->GetVisibility() )
actor->Update(); actor->Update();

View File

@ -631,12 +631,6 @@ namespace SMESH
try { try {
CORBA::String_var error; CORBA::String_var error;
res = aMesh->AddHypothesis(aShapeObject, aHyp, error.out()); res = aMesh->AddHypothesis(aShapeObject, aHyp, error.out());
if (res < SMESH::HYP_UNKNOWN_FATAL) {
_PTR(SObject) aSH = SMESH::FindSObject(aHyp);
if (SM && aSH) {
SMESH::ModifiedMesh(SM, false, aMesh->NbNodes()==0);
}
}
if (res > SMESH::HYP_OK) { if (res > SMESH::HYP_OK) {
wc.suspend(); wc.suspend();
processHypothesisStatus(res, aHyp, true, error.in() ); processHypothesisStatus(res, aHyp, true, error.in() );
@ -668,11 +662,6 @@ namespace SMESH
{ {
CORBA::String_var error; CORBA::String_var error;
res = aMesh->AddHypothesis( aShapeObject, aHyp, error.out() ); res = aMesh->AddHypothesis( aShapeObject, aHyp, error.out() );
if (res < SMESH::HYP_UNKNOWN_FATAL) {
_PTR(SObject) meshSO = SMESH::FindSObject(aMesh);
if (meshSO)
SMESH::ModifiedMesh(meshSO, false, aMesh->NbNodes()==0);
}
if (res > SMESH::HYP_OK) { if (res > SMESH::HYP_OK) {
wc.suspend(); wc.suspend();
processHypothesisStatus( res, aHyp, true, error.in() ); processHypothesisStatus( res, aHyp, true, error.in() );
@ -763,9 +752,6 @@ namespace SMESH
} }
if ( _PTR(SObject) meshSO = SMESH::FindSObject(aMesh) ) if ( _PTR(SObject) meshSO = SMESH::FindSObject(aMesh) )
{ {
if ( res < SMESH::HYP_UNKNOWN_FATAL )
SMESH::ModifiedMesh(meshSO, false, aMesh->NbNodes()==0);
if ( SMESH_Actor* actor = SMESH::FindActorByEntry( meshSO->GetID().c_str() )) if ( SMESH_Actor* actor = SMESH::FindActorByEntry( meshSO->GetID().c_str() ))
if( actor->GetVisibility() ) if( actor->GetVisibility() )
actor->Update(); actor->Update();

View File

@ -24,6 +24,7 @@
#include "SMESHGUI.h" #include "SMESHGUI.h"
#include "SMESHGUI_Utils.h" #include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_MeshUtils.h"
// SALOME GUI includes // SALOME GUI includes
@ -139,7 +140,10 @@ bool SMESHGUI_MeshOrderOp::onApply()
bool res = myMgr ? myMgr->SetMeshOrder() : false; bool res = myMgr ? myMgr->SetMeshOrder() : false;
if( res ) if( res )
{
SMESHGUI::Modified(); SMESHGUI::Modified();
SMESH::UpdateView();
}
delete myMgr; delete myMgr;
myMgr = 0; myMgr = 0;
@ -300,11 +304,6 @@ bool SMESHGUI_MeshOrderMgr::SetMeshOrder( const ListListId& theListListIds )
} }
} }
// is it enough to set modified attribute on root mesh objects only?
// it is seems that modifcation flag will be set on child submeshes
// automatically (see SMESH::ModifiedMesh for details)
SMESH::ModifiedMesh( aMeshSObj, false, false );
SMESH::submesh_array_array_var meshOrder = new SMESH::submesh_array_array(); SMESH::submesh_array_array_var meshOrder = new SMESH::submesh_array_array();
meshOrder->length(theListListIds.count() ); meshOrder->length(theListListIds.count() );
ListListId::const_iterator it = theListListIds.constBegin(); ListListId::const_iterator it = theListListIds.constBegin();

View File

@ -257,83 +257,6 @@ namespace SMESH
return theSObject->GetFather(); return theSObject->GetFather();
} }
void ModifiedMesh (_PTR(SObject) theSObject, bool theIsNotModif, bool isEmptyMesh)
{
_PTR(Study) aStudy = getStudy();
if ( !aStudy || aStudy->GetProperties()->IsLocked())
return;
_PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
_PTR(GenericAttribute) anAttr =
aBuilder->FindOrCreateAttribute(theSObject,"AttributePixMap");
_PTR(AttributePixMap) aPixmap = anAttr;
std::string pmName;
if (theIsNotModif)
pmName = "ICON_SMESH_TREE_MESH";
else if ( isEmptyMesh )
pmName = "ICON_SMESH_TREE_MESH_WARN";
else
pmName = "ICON_SMESH_TREE_MESH_PARTIAL";
aPixmap->SetPixMap( pmName );
_PTR(ChildIterator) anIter = aStudy->NewChildIterator(theSObject);
for ( ; anIter->More(); anIter->Next() ) {
_PTR(SObject) aSObj = anIter->Value();
if ( aSObj->Tag() >= SMESH::Tag_FirstSubMesh )
{
_PTR(ChildIterator) anIter1 = aStudy->NewChildIterator(aSObj);
for ( ; anIter1->More(); anIter1->Next())
{
_PTR(SObject) aSObj1 = anIter1->Value();
_PTR(SObject) aSObjectRef;
if (aSObj1->ReferencedObject(aSObjectRef))
continue; // reference to an object
anAttr = aBuilder->FindOrCreateAttribute(aSObj1, "AttributePixMap");
aPixmap = anAttr;
std::string entry = aSObj1->GetID();
int objType = SMESHGUI_Selection::type( entry.c_str() );
if ( objType == SMESH::HYPOTHESIS || objType == SMESH::ALGORITHM )
continue;
SMESH::SMESH_IDSource_var idSrc = SObjectToInterface<SMESH::SMESH_IDSource>( aSObj1 );
if ( !idSrc->_is_nil() )
{
SMESH::SMESH_GroupOnFilter_var gof =
SObjectToInterface<SMESH::SMESH_GroupOnFilter>( aSObj1 );
const bool isGroupOnFilter = !gof->_is_nil();
bool isEmpty = false;
if ( !isGroupOnFilter ) // GetTypes() can be very long on GroupOnFilter!
{
SMESH::array_of_ElementType_var elemTypes = idSrc->GetTypes();
isEmpty = ( elemTypes->length() == 0 );
}
if ( isEmpty )
aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_WARN");
else if ( objType != GROUP )
aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH" );
else if ( isGroupOnFilter )
aPixmap->SetPixMap( "ICON_SMESH_TREE_GROUP_ON_FILTER" );
else
aPixmap->SetPixMap( "ICON_SMESH_TREE_GROUP" );
}
else // is it necessary?
{
if ( !theIsNotModif )
aPixmap->SetPixMap( pmName );
else if ( objType == GROUP )
aPixmap->SetPixMap( "ICON_SMESH_TREE_GROUP" );
else
aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH" );
}
}
}
}
}
void ShowHelpFile (const QString& theHelpFileName) void ShowHelpFile (const QString& theHelpFileName)
{ {
LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());

View File

@ -158,9 +158,6 @@ SMESHGUI_EXPORT
SMESHGUI_EXPORT SMESHGUI_EXPORT
_PTR(SObject) GetMeshOrSubmesh( _PTR(SObject) ); _PTR(SObject) GetMeshOrSubmesh( _PTR(SObject) );
SMESHGUI_EXPORT
void ModifiedMesh( _PTR(SObject), bool, bool = false );
SMESHGUI_EXPORT SMESHGUI_EXPORT
void ShowHelpFile( const QString& ); void ShowHelpFile( const QString& );

View File

@ -1947,6 +1947,7 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
bool ok = myGen.Compute( myLocMesh, myLocShape, how ); bool ok = myGen.Compute( myLocMesh, myLocShape, how );
meshServant->CreateGroupServants(); // algos can create groups (issue 0020918) meshServant->CreateGroupServants(); // algos can create groups (issue 0020918)
myLocMesh.GetMeshDS()->Modified(); myLocMesh.GetMeshDS()->Modified();
UpdateIcons( theMesh );
return ok; return ok;
} }
} }

View File

@ -58,7 +58,7 @@ class SMESH_Mesh_i;
class SALOME_LifeCycleCORBA; class SALOME_LifeCycleCORBA;
// =========================================================== // ===========================================================
// Study context - stores study-connected objects references // Study context - store study-connected objects references
// ========================================================== // ==========================================================
class SMESH_I_EXPORT StudyContext class SMESH_I_EXPORT StudyContext
{ {
@ -67,58 +67,22 @@ class SMESH_I_EXPORT StudyContext
public: public:
// constructor // constructor
StudyContext() {} StudyContext() {}
// register object in the internal map and return its id // register object in the internal map and return its id
int addObject( std::string theIOR ) int addObject( const std::string& theIOR );
{
int nextId = getNextId();
mapIdToIOR.Bind( nextId, theIOR );
return nextId;
}
// find the object id in the internal map by the IOR // find the object id in the internal map by the IOR
int findId( std::string theIOR ) int findId( const std::string& theIOR );
{
TInt2StringMap::iterator imap;
for ( imap = mapIdToIOR.begin(); imap != mapIdToIOR.end(); ++imap ) {
if ( *imap == theIOR )
return imap.Iterator().Key();
}
return 0;
}
// get object's IOR by id // get object's IOR by id
std::string getIORbyId( const int theId ) std::string getIORbyId( const int theId );
{
if ( mapIdToIOR.IsBound( theId ) )
return mapIdToIOR( theId );
return std::string();
}
// get object's IOR by old id // get object's IOR by old id
std::string getIORbyOldId( const int theOldId ) std::string getIORbyOldId( const int theOldId );
{
if ( mapIdToId.IsBound( theOldId ) )
return getIORbyId( mapIdToId( theOldId ));
return std::string();
}
// maps old object id to the new one (used when restoring data) // maps old object id to the new one (used when restoring data)
void mapOldToNew( const int oldId, const int newId ) { void mapOldToNew( const int oldId, const int newId );
mapIdToId.Bind( oldId, newId );
}
// get old id by a new one // get old id by a new one
int getOldId( const int newId ) { int getOldId( const int newId );
TInt2IntMap::iterator imap;
for ( imap = mapIdToId.begin(); imap != mapIdToId.end(); ++imap ) {
if ( *imap == newId )
return imap.Iterator().Key();
}
return 0;
}
private: private:
// get next free object identifier // get next free object identifier
int getNextId() int getNextId() { return mapIdToIOR.Extent() + 1; }
{
return mapIdToIOR.Extent() + 1;
}
TInt2StringMap mapIdToIOR; // persistent-to-transient map TInt2StringMap mapIdToIOR; // persistent-to-transient map
TInt2IntMap mapIdToId; // to translate object from persistent to transient form TInt2IntMap mapIdToId; // to translate object from persistent to transient form
@ -151,7 +115,7 @@ public:
// Get the SALOMEDS::SObject corresponding to a CORBA object // Get the SALOMEDS::SObject corresponding to a CORBA object
static SALOMEDS::SObject_ptr ObjectToSObject(CORBA::Object_ptr theObject); static SALOMEDS::SObject_ptr ObjectToSObject(CORBA::Object_ptr theObject);
// Get the SALOMEDS::Study from naming service // Get the SALOMEDS::Study from naming service
static SALOMEDS::Study_ptr getStudyServant(); static SALOMEDS::Study_var getStudyServant();
// Get GEOM Object corresponding to TopoDS_Shape // Get GEOM Object corresponding to TopoDS_Shape
GEOM::GEOM_Object_ptr ShapeToGeomObject (const TopoDS_Shape& theShape ); GEOM::GEOM_Object_ptr ShapeToGeomObject (const TopoDS_Shape& theShape );
// Get TopoDS_Shape corresponding to GEOM_Object // Get TopoDS_Shape corresponding to GEOM_Object
@ -534,6 +498,7 @@ public:
SMESH::SMESH_GroupBase_ptr theGroup, SMESH::SMESH_GroupBase_ptr theGroup,
GEOM::GEOM_Object_ptr theShapeObject, GEOM::GEOM_Object_ptr theShapeObject,
const char* theName = 0); const char* theName = 0);
void UpdateIcons(SMESH::SMESH_Mesh_ptr theMesh);
bool AddHypothesisToShape(SMESH::SMESH_Mesh_ptr theMesh, bool AddHypothesisToShape(SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theShapeObject, GEOM::GEOM_Object_ptr theShapeObject,
SMESH::SMESH_Hypothesis_ptr theHyp); SMESH::SMESH_Hypothesis_ptr theHyp);

View File

@ -208,7 +208,7 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::ObjectToSObject(CORBA::Object_ptr theObject)
//function : GetStudyPtr //function : GetStudyPtr
//purpose : Get study from naming service //purpose : Get study from naming service
//======================================================================= //=======================================================================
SALOMEDS::Study_ptr SMESH_Gen_i::getStudyServant() SALOMEDS::Study_var SMESH_Gen_i::getStudyServant()
{ {
return SALOMEDS::Study::_duplicate(KERNEL::getStudyServant()); return SALOMEDS::Study::_duplicate(KERNEL::getStudyServant());
} }
@ -396,7 +396,7 @@ void SMESH_Gen_i::SetName(SALOMEDS::SObject_ptr theSObject,
void SMESH_Gen_i::SetPixMap(SALOMEDS::SObject_ptr theSObject, void SMESH_Gen_i::SetPixMap(SALOMEDS::SObject_ptr theSObject,
const char* thePixMap) const char* thePixMap)
{ {
if ( !theSObject->_is_nil() && thePixMap && strlen( thePixMap )) if ( !theSObject->_is_nil() && thePixMap && thePixMap && thePixMap[0] )
{ {
SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder(); SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
SALOMEDS::GenericAttribute_wrap anAttr = SALOMEDS::GenericAttribute_wrap anAttr =
@ -859,6 +859,79 @@ SALOMEDS::SObject_ptr
return aHypSO._retn(); return aHypSO._retn();
} }
//=======================================================================
//function : UpdateIcons
//purpose : update icons of a mesh and its children upon mesh modification
//=======================================================================
void SMESH_Gen_i::UpdateIcons( SMESH::SMESH_Mesh_ptr theMesh )
{
SMESH_Mesh_i* mesh_i = SMESH::DownCast< SMESH_Mesh_i* >( theMesh );
if ( ! mesh_i )
return;
SALOMEDS::SObject_wrap so = ObjectToSObject( theMesh );
if ( so->_is_nil() )
return;
// set icon of the mesh
if ( mesh_i->NbNodes() == 0 )
SetPixMap( so, "ICON_SMESH_TREE_MESH_WARN" );
else if ( mesh_i->IsComputedOK() )
SetPixMap( so, "ICON_SMESH_TREE_MESH" );
else
SetPixMap( so, "ICON_SMESH_TREE_MESH_PARTIAL" );
// set icons of sub-objects
SALOMEDS::Study_var study = getStudyServant();
SALOMEDS::ChildIterator_wrap iter = study->NewChildIterator( so );
for ( ; iter->More(); iter->Next() )
{
so = iter->Value(); // 1st level child - root of algos, hyps, sub-meshes or groups
if ( so->Tag() < SMESH::Tag_FirstSubMesh )
continue;
SALOMEDS::ChildIterator_wrap subIter = study->NewChildIterator( so );
for ( ; subIter->More(); subIter->Next() )
{
so = subIter->Value(); // 2nd level child - a sub-mesh or group
CORBA::Object_var obj = SObjectToObject( so );
SMESH::SMESH_IDSource_var idSrc = SMESH::SMESH_IDSource::_narrow( obj );
if ( idSrc->_is_nil() )
continue;
SMESH::SMESH_GroupBase_var grp = SMESH::SMESH_GroupBase::_narrow( obj );
SMESH::SMESH_GroupOnFilter_var gof = SMESH::SMESH_GroupOnFilter::_narrow( obj );
const bool isGroup = !grp->_is_nil();
const bool isGroupOnFilter = !gof->_is_nil();
bool isEmpty = ( mesh_i->NbNodes() == 0 );
if ( !isEmpty )
{
if ( isGroupOnFilter ) // GetTypes() can be very long on GroupOnFilter!
{
SMESH::long_array_var nbByType = mesh_i->GetNbElementsByType();
isEmpty = ( nbByType[ grp->GetType() ] == 0 );
}
else
{
SMESH::array_of_ElementType_var elemTypes = idSrc->GetTypes();
isEmpty = ( elemTypes->length() == 0 );
}
}
if ( isEmpty )
SetPixMap( so, "ICON_SMESH_TREE_MESH_WARN");
else if ( !isGroup )
SetPixMap( so, "ICON_SMESH_TREE_MESH" );
else if ( isGroupOnFilter )
SetPixMap( so, "ICON_SMESH_TREE_GROUP_ON_FILTER" );
else
SetPixMap( so, "ICON_SMESH_TREE_GROUP" );
}
}
}
//======================================================================= //=======================================================================
//function : GetMeshOrSubmeshByShape //function : GetMeshOrSubmeshByShape
//purpose : //purpose :
@ -1232,3 +1305,85 @@ char* SMESH_Gen_i::GetParameters(CORBA::Object_ptr theObject)
} }
return aResult._retn(); return aResult._retn();
} }
// ==============
// Study context
// ==============
//=======================================================================
//function : addObject
//purpose : register object in the internal map and return its id
//=======================================================================
int StudyContext::addObject( const std::string& theIOR )
{
int nextId = getNextId();
mapIdToIOR.Bind( nextId, theIOR );
return nextId;
}
//=======================================================================
//function : findId
//purpose : find the object id in the internal map by the IOR
//=======================================================================
int StudyContext::findId( const std::string& theIOR )
{
TInt2StringMap::iterator imap;
for ( imap = mapIdToIOR.begin(); imap != mapIdToIOR.end(); ++imap ) {
if ( *imap == theIOR )
return imap.Iterator().Key();
}
return 0;
}
//=======================================================================
//function : getIORbyId
//purpose : get object's IOR by id
//=======================================================================
std::string StudyContext::getIORbyId( const int theId )
{
if ( mapIdToIOR.IsBound( theId ) )
return mapIdToIOR( theId );
return std::string();
}
//=======================================================================
//function : getIORbyOldId
//purpose : get object's IOR by old id
//=======================================================================
std::string StudyContext::getIORbyOldId( const int theOldId )
{
if ( mapIdToId.IsBound( theOldId ) )
return getIORbyId( mapIdToId( theOldId ));
return std::string();
}
//=======================================================================
//function : mapOldToNew
//purpose : maps old object id to the new one (used when restoring data)
//=======================================================================
void StudyContext::mapOldToNew( const int oldId, const int newId )
{
mapIdToId.Bind( oldId, newId );
}
//=======================================================================
//function : getOldId
//purpose : get old id by a new one
//=======================================================================
int StudyContext::getOldId( const int newId )
{
TInt2IntMap::iterator imap;
for ( imap = mapIdToId.begin(); imap != mapIdToId.end(); ++imap ) {
if ( *imap == newId )
return imap.Iterator().Key();
}
return 0;
}

View File

@ -299,6 +299,9 @@ void SMESH_Mesh_i::Clear() throw (SALOME::SALOME_Exception)
} }
TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".Clear()"; TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".Clear()";
SMESH::SMESH_Mesh_var mesh = _this();
_gen_i->UpdateIcons( mesh );
} }
//================================================================================ //================================================================================
@ -594,6 +597,7 @@ SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Object_ptr aSubShape,
if ( !SMESH_Hypothesis::IsStatusFatal(status) ) if ( !SMESH_Hypothesis::IsStatusFatal(status) )
{ {
_gen_i->AddHypothesisToShape( mesh, aSubShape, anHyp ); _gen_i->AddHypothesisToShape( mesh, aSubShape, anHyp );
_gen_i->UpdateIcons( mesh );
} }
if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status ); if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status );
@ -679,6 +683,7 @@ SMESH::Hypothesis_Status SMESH_Mesh_i::RemoveHypothesis(GEOM::GEOM_Object_ptr aS
if ( !SMESH_Hypothesis::IsStatusFatal(status) ) if ( !SMESH_Hypothesis::IsStatusFatal(status) )
{ {
_gen_i->RemoveHypothesisFromShape( mesh, aSubShape, anHyp ); _gen_i->RemoveHypothesisFromShape( mesh, aSubShape, anHyp );
_gen_i->UpdateIcons( mesh );
} }
// Update Python script // Update Python script
if(_impl->HasShapeToMesh()) if(_impl->HasShapeToMesh())
@ -2705,6 +2710,9 @@ void SMESH_Mesh_i::onHypothesisModified()
{ {
if ( _preMeshInfo ) if ( _preMeshInfo )
_preMeshInfo->ForgetOrLoad(); _preMeshInfo->ForgetOrLoad();
SMESH::SMESH_Mesh_var mesh = _this();
_gen_i->UpdateIcons( mesh );
} }
//============================================================================= //=============================================================================
@ -4991,6 +4999,17 @@ void SMESH_Mesh_i::CreateGroupServants()
} }
} }
//=============================================================================
/*!
* \brief Return true if all sub-meshes are computed OK - to update an icon
*/
//=============================================================================
bool SMESH_Mesh_i::IsComputedOK()
{
return _impl->IsComputedOK();
}
//============================================================================= //=============================================================================
/*! /*!
* \brief Return groups cantained in _mapGroups by their IDs * \brief Return groups cantained in _mapGroups by their IDs
@ -5968,6 +5987,9 @@ TListOfListOfInt SMESH_Mesh_i::findConcurrentSubMeshes()
mesh.SetMeshOrder( subMeshOrder ); mesh.SetMeshOrder( subMeshOrder );
res = true; res = true;
SMESH::SMESH_Mesh_var me = _this();
_gen_i->UpdateIcons( me );
return res; return res;
} }

View File

@ -396,8 +396,11 @@ public:
const char* theGroupName) const char* theGroupName)
throw (SALOME::SALOME_Exception); throw (SALOME::SALOME_Exception);
// ===================================================
// Internal methods not available through CORBA // Internal methods not available through CORBA
// They are called by corresponding interface methods // They are called by corresponding interface methods
// ===================================================
SMESH_Hypothesis::Hypothesis_Status addHypothesis(GEOM::GEOM_Object_ptr aSubShape, SMESH_Hypothesis::Hypothesis_Status addHypothesis(GEOM::GEOM_Object_ptr aSubShape,
SMESH::SMESH_Hypothesis_ptr anHyp, SMESH::SMESH_Hypothesis_ptr anHyp,
std::string* anErrorText=0); std::string* anErrorText=0);
@ -455,6 +458,16 @@ public:
*/ */
void CreateGroupServants(); void CreateGroupServants();
/*!
* \brief Return true if all sub-meshes are computed OK - to update an icon
*/
bool IsComputedOK();
// ====================================
// SMESH_Mesh interface (continuation)
// ====================================
/*! /*!
* \brief Return groups cantained in _mapGroups by their IDs * \brief Return groups cantained in _mapGroups by their IDs
*/ */
@ -654,6 +667,7 @@ public:
*/ */
virtual SALOMEDS::TMPFile* GetVtkUgStream(); virtual SALOMEDS::TMPFile* GetVtkUgStream();
std::map<int, SMESH_subMesh_i*> _mapSubMesh_i; //NRI std::map<int, SMESH_subMesh_i*> _mapSubMesh_i; //NRI
std::map<int, ::SMESH_subMesh*> _mapSubMesh; //NRI std::map<int, ::SMESH_subMesh*> _mapSubMesh; //NRI

View File

@ -349,7 +349,6 @@ namespace SMESH
{ {
if ( CORBA::is_nil( theArg ) ) if ( CORBA::is_nil( theArg ) )
return *this << "None"; return *this << "None";
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg); SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
if(!aSObject->_is_nil()) if(!aSObject->_is_nil())
{ {

View File

@ -21,7 +21,6 @@
# scripts / static # scripts / static
SET(_bin_SCRIPTS SET(_bin_SCRIPTS
smesh.py
ex00_all.py ex00_all.py
ex01_cube2build.py ex01_cube2build.py
ex02_cube2primitive.py ex02_cube2primitive.py

View File

@ -1,122 +0,0 @@
# -*- coding: iso-8859-1 -*-
# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
# File : smesh.py
# Author : Francis KLOSS, OCC
# Module : SMESH
#
"""@package smesh
\brief Module smesh
"""
import inspect
import salome
from salome import *
import geompy
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
# retrieve SMESH engine in try/except block
# to avoid problems in some cases, e.g. when generating documentation
try:
# get instance of class smeshBuilder
engineSmesh = salome.lcc.FindOrLoadComponent( "FactoryServer", "SMESH" )
smesh = smeshBuilder.New(True,engineSmesh)
except:
print("exception in smesh.py: instance creation failed")
smesh = None
pass
# load plugins and add dynamically generated methods to Mesh class,
# the same for global variables declared by plug-ins
from salome.smesh.smeshBuilder import *
from salome.smesh.smeshBuilder import Mesh, algoCreator
for pluginName in os.environ[ "SMESH_MeshersList" ].split( ":" ):
#
#print "pluginName: ", pluginName
pluginBuilderName = pluginName + "Builder"
try:
exec( "from salome.%s.%s import *" % (pluginName, pluginBuilderName))
except Exception as e:
from salome_utils import verbose
if verbose(): print("Exception while loading %s: %s" % ( pluginBuilderName, e ))
continue
exec( "from salome.%s import %s" % (pluginName, pluginBuilderName))
plugin = eval( pluginBuilderName )
# add methods creating algorithms to Mesh
for k in dir( plugin ):
if k[0] == '_': continue
algo = getattr( plugin, k )
if inspect.isclass(algo) and hasattr(algo, "meshMethod"):
if not hasattr( Mesh, algo.meshMethod ):
setattr( Mesh, algo.meshMethod, algoCreator() )
pass
getattr( Mesh, algo.meshMethod ).add( algo )
pass
pass
pass
del pluginName
# export the methods of smeshBuilder
if smesh:
for k in dir( smesh ):
if k[0] == '_': continue
globals()[k] = getattr( smesh, k )
del k
pass
print("""
===============================================================================
WARNING:
Usage of smesh.py is deprecated in SALOME V7.2!
smesh.py will be removed in a future version!
TODO:
The following changes in your scripts are required to avoid this message:
replace
-------
import smesh, SMESH
with
----
import SMESH
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New()
you also need to modify some lines where smeshBuilder is used instead of smesh
algo=smesh.xxxx ==> algo=smeshBuilder.xxxx
See also SMESH User's Guide for more details
WARNING:
The smesh.py module works correctly only in the first created study.
It does not work in the second, third, etc studies!
===============================================================================
""")

View File

@ -1823,9 +1823,6 @@ class Mesh(metaclass = MeshMeta):
pass pass
if salome.sg.hasDesktop(): if salome.sg.hasDesktop():
if not isinstance( refresh, list): # not a call from subMesh.Compute() if not isinstance( refresh, list): # not a call from subMesh.Compute()
smeshgui = salome.ImportComponentGUI("SMESH")
smeshgui.Init()
smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
if refresh: salome.sg.updateObjBrowser() if refresh: salome.sg.updateObjBrowser()
return ok return ok
@ -1971,9 +1968,6 @@ class Mesh(metaclass = MeshMeta):
self.mesh.Clear() self.mesh.Clear()
if ( salome.sg.hasDesktop() ): if ( salome.sg.hasDesktop() ):
smeshgui = salome.ImportComponentGUI("SMESH")
smeshgui.Init()
smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
if refresh: salome.sg.updateObjBrowser() if refresh: salome.sg.updateObjBrowser()
def ClearSubMesh(self, geomId, refresh=False): def ClearSubMesh(self, geomId, refresh=False):
@ -1987,9 +1981,6 @@ class Mesh(metaclass = MeshMeta):
self.mesh.ClearSubMesh(geomId) self.mesh.ClearSubMesh(geomId)
if salome.sg.hasDesktop(): if salome.sg.hasDesktop():
smeshgui = salome.ImportComponentGUI("SMESH")
smeshgui.Init()
smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
if refresh: salome.sg.updateObjBrowser() if refresh: salome.sg.updateObjBrowser()
def AutomaticTetrahedralization(self, fineness=0): def AutomaticTetrahedralization(self, fineness=0):
@ -6903,9 +6894,6 @@ class submeshProxy(SMESH._objref_SMESH_subMesh):
ok = self.mesh.Compute( self.GetSubShape(),refresh=[] ) ok = self.mesh.Compute( self.GetSubShape(),refresh=[] )
if salome.sg.hasDesktop(): if salome.sg.hasDesktop():
smeshgui = salome.ImportComponentGUI("SMESH")
smeshgui.Init()
smeshgui.SetMeshIcon( salome.ObjectToID( self ), ok, (self.GetNumberOfElements()==0) )
if refresh: salome.sg.updateObjBrowser() if refresh: salome.sg.updateObjBrowser()
pass pass