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
*/
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
*/
* none mesh entity is bound to it
*/
void SetIsAlwaysComputed(bool isAlCo);
- bool IsAlwaysComputed() { return _alwaysComputed; }
+ bool IsAlwaysComputed() const { return _alwaysComputed; }
bool SubMeshesComputed(bool * isFailedToCompute=0) const;
else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
aMesh->RemoveSubMesh( aSubMesh );
-
- _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
- if (aMeshSO)
- SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
}
else {
Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
if ( aMesh->NbNodes() == 0 ) // imported mesh is not empty
SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
_PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
- SMESH::ModifiedMesh( aMeshSObj, false, true);
// hide groups and submeshes
_PTR(ChildIterator) anIter =
SMESH::getStudy()->NewChildIterator( aMeshSObj );
// 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 );
// SHOW MESH
if( !aSubMesh->_is_nil() )
aMesh = aSubMesh->GetFather();
_PTR(SObject) meshSO = SMESH::FindSObject( aMesh );
- SMESH::ModifiedMesh( meshSO, false, aMesh->NbNodes()==0);
SMESH_Actor* actor = SMESH::FindActorByEntry( meshSO->GetID().c_str() );
if( actor && actor->GetVisibility() )
actor->Update();
try {
CORBA::String_var error;
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) {
wc.suspend();
processHypothesisStatus(res, aHyp, true, error.in() );
{
CORBA::String_var error;
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) {
wc.suspend();
processHypothesisStatus( res, aHyp, true, error.in() );
}
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( actor->GetVisibility() )
actor->Update();
#include "SMESHGUI.h"
#include "SMESHGUI_Utils.h"
+#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_MeshUtils.h"
// SALOME GUI includes
bool res = myMgr ? myMgr->SetMeshOrder() : false;
if( res )
+ {
SMESHGUI::Modified();
+ SMESH::UpdateView();
+ }
delete myMgr;
myMgr = 0;
}
}
- // 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();
meshOrder->length(theListListIds.count() );
ListListId::const_iterator it = theListListIds.constBegin();
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)
{
LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
SMESHGUI_EXPORT
_PTR(SObject) GetMeshOrSubmesh( _PTR(SObject) );
-SMESHGUI_EXPORT
- void ModifiedMesh( _PTR(SObject), bool, bool = false );
-
SMESHGUI_EXPORT
void ShowHelpFile( const QString& );
bool ok = myGen.Compute( myLocMesh, myLocShape, how );
meshServant->CreateGroupServants(); // algos can create groups (issue 0020918)
myLocMesh.GetMeshDS()->Modified();
+ UpdateIcons( theMesh );
return ok;
}
}
class SALOME_LifeCycleCORBA;
// ===========================================================
-// Study context - stores study-connected objects references
+// Study context - store study-connected objects references
// ==========================================================
class SMESH_I_EXPORT StudyContext
{
public:
// constructor
StudyContext() {}
-
// register object in the internal map and return its id
- int addObject( std::string theIOR )
- {
- int nextId = getNextId();
- mapIdToIOR.Bind( nextId, theIOR );
- return nextId;
- }
+ int addObject( const std::string& theIOR );
// find the object id in the internal map by the IOR
- int findId( std::string theIOR )
- {
- TInt2StringMap::iterator imap;
- for ( imap = mapIdToIOR.begin(); imap != mapIdToIOR.end(); ++imap ) {
- if ( *imap == theIOR )
- return imap.Iterator().Key();
- }
- return 0;
- }
+ int findId( const std::string& theIOR );
// get object's IOR by id
- std::string getIORbyId( const int theId )
- {
- if ( mapIdToIOR.IsBound( theId ) )
- return mapIdToIOR( theId );
- return std::string();
- }
+ std::string getIORbyId( const int theId );
// get object's IOR by old id
- std::string getIORbyOldId( const int theOldId )
- {
- if ( mapIdToId.IsBound( theOldId ) )
- return getIORbyId( mapIdToId( theOldId ));
- return std::string();
- }
+ std::string getIORbyOldId( const int theOldId );
// maps old object id to the new one (used when restoring data)
- void mapOldToNew( const int oldId, const int newId ) {
- mapIdToId.Bind( oldId, newId );
- }
+ void mapOldToNew( const int oldId, const int newId );
// get old id by a new one
- 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;
- }
+ int getOldId( const int newId );
private:
// get next free object identifier
- int getNextId()
- {
- return mapIdToIOR.Extent() + 1;
- }
+ int getNextId() { return mapIdToIOR.Extent() + 1; }
TInt2StringMap mapIdToIOR; // persistent-to-transient map
TInt2IntMap mapIdToId; // to translate object from persistent to transient form
// Get the SALOMEDS::SObject corresponding to a CORBA object
static SALOMEDS::SObject_ptr ObjectToSObject(CORBA::Object_ptr theObject);
// Get the SALOMEDS::Study from naming service
- static SALOMEDS::Study_ptr getStudyServant();
+ static SALOMEDS::Study_var getStudyServant();
// Get GEOM Object corresponding to TopoDS_Shape
GEOM::GEOM_Object_ptr ShapeToGeomObject (const TopoDS_Shape& theShape );
// Get TopoDS_Shape corresponding to GEOM_Object
SMESH::SMESH_GroupBase_ptr theGroup,
GEOM::GEOM_Object_ptr theShapeObject,
const char* theName = 0);
+ void UpdateIcons(SMESH::SMESH_Mesh_ptr theMesh);
bool AddHypothesisToShape(SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theShapeObject,
SMESH::SMESH_Hypothesis_ptr theHyp);
//function : GetStudyPtr
//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());
}
void SMESH_Gen_i::SetPixMap(SALOMEDS::SObject_ptr theSObject,
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::GenericAttribute_wrap anAttr =
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
//purpose :
//=======================================================================
SALOMEDS::SObject_ptr
- SMESH_Gen_i::GetMeshOrSubmeshByShape (SMESH::SMESH_Mesh_ptr theMesh,
- GEOM::GEOM_Object_ptr theShape)
+SMESH_Gen_i::GetMeshOrSubmeshByShape (SMESH::SMESH_Mesh_ptr theMesh,
+ GEOM::GEOM_Object_ptr theShape)
{
if(MYDEBUG) MESSAGE("GetMeshOrSubmeshByShape")
SALOMEDS::SObject_wrap aMeshOrSubMesh;
}
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;
+}
}
TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".Clear()";
+
+ SMESH::SMESH_Mesh_var mesh = _this();
+ _gen_i->UpdateIcons( mesh );
}
//================================================================================
if ( !SMESH_Hypothesis::IsStatusFatal(status) )
{
_gen_i->AddHypothesisToShape( mesh, aSubShape, anHyp );
+ _gen_i->UpdateIcons( mesh );
}
if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status );
if ( !SMESH_Hypothesis::IsStatusFatal(status) )
{
_gen_i->RemoveHypothesisFromShape( mesh, aSubShape, anHyp );
+ _gen_i->UpdateIcons( mesh );
}
// Update Python script
if(_impl->HasShapeToMesh())
{
if ( _preMeshInfo )
_preMeshInfo->ForgetOrLoad();
+
+ SMESH::SMESH_Mesh_var mesh = _this();
+ _gen_i->UpdateIcons( mesh );
}
//=============================================================================
}
}
+//=============================================================================
+/*!
+ * \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
mesh.SetMeshOrder( subMeshOrder );
res = true;
+ SMESH::SMESH_Mesh_var me = _this();
+ _gen_i->UpdateIcons( me );
+
return res;
}
const char* theGroupName)
throw (SALOME::SALOME_Exception);
+ // ===================================================
// Internal methods not available through CORBA
// They are called by corresponding interface methods
+ // ===================================================
+
SMESH_Hypothesis::Hypothesis_Status addHypothesis(GEOM::GEOM_Object_ptr aSubShape,
SMESH::SMESH_Hypothesis_ptr anHyp,
std::string* anErrorText=0);
*/
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
*/
* happen if mesh data is not yet fully loaded from the file of study.
*/
bool IsMeshInfoCorrect();
- /*!
- * Returns mesh unstructed grid information.
- */
- virtual SALOMEDS::TMPFile* GetVtkUgStream();
+ /*!
+ * Returns mesh unstructed grid information.
+ */
+ virtual SALOMEDS::TMPFile* GetVtkUgStream();
+
std::map<int, SMESH_subMesh_i*> _mapSubMesh_i; //NRI
std::map<int, ::SMESH_subMesh*> _mapSubMesh; //NRI
{
if ( CORBA::is_nil( theArg ) )
return *this << "None";
- SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
if(!aSObject->_is_nil())
{
# scripts / static
SET(_bin_SCRIPTS
- smesh.py
ex00_all.py
ex01_cube2build.py
ex02_cube2primitive.py
+++ /dev/null
-# -*- 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!
-
-===============================================================================
-""")
pass
if salome.sg.hasDesktop():
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()
return ok
self.mesh.Clear()
if ( salome.sg.hasDesktop() ):
- smeshgui = salome.ImportComponentGUI("SMESH")
- smeshgui.Init()
- smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
if refresh: salome.sg.updateObjBrowser()
def ClearSubMesh(self, geomId, refresh=False):
self.mesh.ClearSubMesh(geomId)
if salome.sg.hasDesktop():
- smeshgui = salome.ImportComponentGUI("SMESH")
- smeshgui.Init()
- smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
if refresh: salome.sg.updateObjBrowser()
def AutomaticTetrahedralization(self, fineness=0):
ok = self.mesh.Compute( self.GetSubShape(),refresh=[] )
if salome.sg.hasDesktop():
- smeshgui = salome.ImportComponentGUI("SMESH")
- smeshgui.Init()
- smeshgui.SetMeshIcon( salome.ObjectToID( self ), ok, (self.GetNumberOfElements()==0) )
if refresh: salome.sg.updateObjBrowser()
pass
_PTR(Study) study = SMESH::getStudy();
if ( study )
{
- sobject = study->FindObjectID( uid );
- if ( !sobject )
- sobject = study->FindObjectIOR( uid );
+ sobject = study->FindObjectID( uid );
+ if ( !sobject )
+ sobject = study->FindObjectIOR( uid );
}
}
return sobject;
{
if ( uid )
{
- ViewManagerList vms = app->viewManagers();
- for ( int i = 0; i < vms.count() && !window; i++ )
- {
- SUIT_ViewManager* vm = vms[i];
- QVector<SUIT_ViewWindow*> vws = vm->getViews();
- for ( int j = 0; j < vws.count() && !window; j++)
- {
- SUIT_ViewWindow* vw = vws[0];
- if ( uid == vw->getId() )
- window = dynamic_cast<SALOME_View*>( vm->getViewModel() );
- }
- }
+ ViewManagerList vms = app->viewManagers();
+ for ( int i = 0; i < vms.count() && !window; i++ )
+ {
+ SUIT_ViewManager* vm = vms[i];
+ QVector<SUIT_ViewWindow*> vws = vm->getViews();
+ for ( int j = 0; j < vws.count() && !window; j++)
+ {
+ SUIT_ViewWindow* vw = vws[0];
+ if ( uid == vw->getId() )
+ window = dynamic_cast<SALOME_View*>( vm->getViewModel() );
+ }
+ }
}
else
{
- SUIT_ViewManager* vm = app->getViewManager( SVTK_Viewer::Type(), create );
- if ( vm )
- {
- window = dynamic_cast<SALOME_View*>( vm->getViewModel() );
- }
+ SUIT_ViewManager* vm = app->getViewManager( SVTK_Viewer::Type(), create );
+ if ( vm )
+ {
+ window = dynamic_cast<SALOME_View*>( vm->getViewModel() );
+ }
}
}
return window;
foreach( SUIT_ViewManager* vm, vms )
{
if ( vm && vm->getType() == SVTK_Viewer::Type() )
- {
+ {
SALOME_View* view = dynamic_cast<SALOME_View*>( vm->getViewModel() );
if ( view )
- views << view;
- }
+ views << view;
+ }
}
}
return views;
if ( actor )
{
actor->GetNodeColor( props.nodeColor.r,
- props.nodeColor.g,
- props.nodeColor.b );
+ props.nodeColor.g,
+ props.nodeColor.b );
props.markerType = actor->GetMarkerType();
props.markerScale = actor->GetMarkerScale();
actor->GetEdgeColor( props.edgeColor.r,
- props.edgeColor.g,
- props.edgeColor.b );
+ props.edgeColor.g,
+ props.edgeColor.b );
props.edgeWidth = qMax( (int)actor->GetLineWidth(), 1 );
actor->GetSufaceColor( props.surfaceColor.r,
- props.surfaceColor.g,
- props.surfaceColor.b,
- props.surfaceColor.delta );
+ props.surfaceColor.g,
+ props.surfaceColor.b,
+ props.surfaceColor.delta );
actor->GetVolumeColor( props.volumeColor.r,
- props.volumeColor.g,
- props.volumeColor.b,
- props.volumeColor.delta );
+ props.volumeColor.g,
+ props.volumeColor.b,
+ props.volumeColor.delta );
actor->Get0DColor( props.elem0dColor.r,
- props.elem0dColor.g,
- props.elem0dColor.b );
+ props.elem0dColor.g,
+ props.elem0dColor.b );
props.elem0dSize = qMax( (int)actor->Get0DSize(), 1 );
actor->GetBallColor( props.ballColor.r,
- props.ballColor.g,
- props.ballColor.b );
+ props.ballColor.g,
+ props.ballColor.b );
props.ballScale = qMax( actor->GetBallScale(), 1e-2 );
actor->GetOutlineColor( props.outlineColor.r,
- props.outlineColor.g,
- props.outlineColor.b );
+ props.outlineColor.g,
+ props.outlineColor.b );
props.outlineWidth = qMax( (int)actor->GetOutlineWidth(), 1 );
actor->GetFacesOrientationColor( props.orientationColor.r,
- props.orientationColor.g,
- props.orientationColor.b );
+ props.orientationColor.g,
+ props.orientationColor.b );
props.orientationScale = actor->GetFacesOrientationScale();
props.orientation3d = actor->GetFacesOrientation3DVectors();
if ( actor )
{
actor->SetNodeColor( props.nodeColor.r,
- props.nodeColor.g,
- props.nodeColor.b );
+ props.nodeColor.g,
+ props.nodeColor.b );
if ( props.markerType != VTK::MT_USER )
- actor->SetMarkerStd( props.markerType, props.markerScale );
+ actor->SetMarkerStd( props.markerType, props.markerScale );
actor->SetEdgeColor( props.edgeColor.r,
- props.edgeColor.g,
- props.edgeColor.b );
+ props.edgeColor.g,
+ props.edgeColor.b );
actor->SetLineWidth( qMax( (double)props.edgeWidth, 1. ) );
actor->SetSufaceColor( props.surfaceColor.r,
- props.surfaceColor.g,
- props.surfaceColor.b,
- props.surfaceColor.delta );
+ props.surfaceColor.g,
+ props.surfaceColor.b,
+ props.surfaceColor.delta );
actor->SetVolumeColor( props.volumeColor.r,
- props.volumeColor.g,
- props.volumeColor.b,
- props.volumeColor.delta );
+ props.volumeColor.g,
+ props.volumeColor.b,
+ props.volumeColor.delta );
actor->Set0DColor( props.elem0dColor.r,
- props.elem0dColor.g,
- props.elem0dColor.b );
+ props.elem0dColor.g,
+ props.elem0dColor.b );
actor->Set0DSize( qMax( (double)props.elem0dSize, 1. ) );
actor->SetBallColor( props.ballColor.r,
- props.ballColor.g,
- props.ballColor.b );
+ props.ballColor.g,
+ props.ballColor.b );
actor->SetBallScale( qMax( props.ballScale, 1e-2 ) );
actor->SetOutlineColor( props.outlineColor.r,
- props.outlineColor.g,
- props.outlineColor.b );
+ props.outlineColor.g,
+ props.outlineColor.b );
actor->SetOutlineWidth( qMax( (double)props.outlineWidth, 1. ) );
actor->SetFacesOrientationColor( props.orientationColor.r,
- props.orientationColor.g,
- props.orientationColor.b );
+ props.orientationColor.g,
+ props.orientationColor.b );
actor->SetFacesOrientationScale( props.orientationScale );
actor->SetFacesOrientation3DVectors( props.orientation3d );
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
if ( !SMESHGUI::GetSMESHGUI() )
- app->loadModule( "Mesh" );
+ app->loadModule( "Mesh" );
}
};
if ( !CORBA::is_nil( object ) )
{
SALOMEDS::SObject_var sobject =
- SMESHGUI::GetSMESHGen()->PublishInStudy( SALOMEDS::SObject::_nil(),
- object.in(),
- name );
+ SMESHGUI::GetSMESHGen()->PublishInStudy( SALOMEDS::SObject::_nil(),
+ object.in(),
+ name );
if ( !CORBA::is_nil( sobject ) )
- {
- uid = sobject->GetID();
- }
+ {
+ uid = sobject->GetID();
+ }
sobject->UnRegister();
}
{
SALOME_View* view = uid2wnd( myViewUid, true ); // create view if it's not present
if ( view )
- LightApp_Displayer::FindDisplayer( "Mesh", true )->Display( myUid, myIsUpdate, view );
+ LightApp_Displayer::FindDisplayer( "Mesh", true )->Display( myUid, myIsUpdate, view );
}
};
{
if ( myViewUid == -1 )
{
- QList<SALOME_View*> views = windows();
- foreach( SALOME_View* view, views )
- LightApp_Displayer::FindDisplayer( "Mesh", true )->Erase( myUid, true, myIsUpdate, view );
+ QList<SALOME_View*> views = windows();
+ foreach( SALOME_View* view, views )
+ LightApp_Displayer::FindDisplayer( "Mesh", true )->Erase( myUid, true, myIsUpdate, view );
}
else
{
- SALOME_View* view = uid2wnd( myViewUid );
- if ( view )
- LightApp_Displayer::FindDisplayer( "Mesh", true )->Erase( myUid, true, myIsUpdate, view );
+ SALOME_View* view = uid2wnd( myViewUid );
+ if ( view )
+ LightApp_Displayer::FindDisplayer( "Mesh", true )->Erase( myUid, true, myIsUpdate, view );
}
}
};
virtual void Execute()
{
Handle(SALOME_InteractiveObject) io =
- new SALOME_InteractiveObject( myUid, "SMESH", "" );
+ new SALOME_InteractiveObject( myUid, "SMESH", "" );
SMESH::Update( io, true );
}
};
QList<SALOME_View*> views = windows();
foreach( SALOME_View* view, views )
{
- setProperties( view, myUid, myProps );
+ setProperties( view, myUid, myProps );
}
}
else
{
actor->SetPointsLabeled( myNumbering );
if ( view )
- view->Repaint();
+ view->Repaint();
}
}
};
{
actor->SetCellsLabeled( myNumbering );
if ( view )
- view->Repaint();
+ view->Repaint();
}
}
};
{
actor->SetRepresentation( myMode );
if ( view )
- view->Repaint();
+ view->Repaint();
}
}
};
if ( actor )
{
if ( myShrink )
- actor->SetShrink();
+ actor->SetShrink();
else
- actor->UnShrink();
+ actor->UnShrink();
if ( view )
- view->Repaint();
+ view->Repaint();
}
}
};
{
actor->SetOpacity( myOpacity );
if ( view )
- view->Repaint();
+ view->Repaint();
}
}
};
{
actor->SetFacesOriented( myShown );
if ( view )
- view->Repaint();
+ view->Repaint();
}
}
};
{
actor->SetEntityMode( myEntities );
if ( view )
- view->Repaint();
+ view->Repaint();
}
}
};
const char* SMESH_Swig::AddSubMesh(const char* /*meshUid*/,
const char* ior,
int /*shapeType*/,
- const char* name)
+ const char* name)
{
deprecated("SMESH_Swig::AddSubMesh", "SMESH_Swig::publish");
return publish( ior, name );
const char* /*shapeUid*/,
const char* ior,
int /*shapeType*/,
- const char* name)
+ const char* name)
{
deprecated("SMESH_Swig::AddSubMeshOnShape", "SMESH_Swig::publish");
return publish( ior, name );
{
SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( model->getViewManager()->getActiveView() );
if ( vw )
- myResult = (SelectionMode)vw->SelectionMode();
+ myResult = (SelectionMode)vw->SelectionMode();
}
}
};
SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( model->getViewManager()->getActiveView() );
if ( vw )
{
- SelectionMode previousMode = (SelectionMode)vw->SelectionMode();
- bool switchPointMode = ( previousMode == Node && mySelectionMode != Node ) ||
- ( previousMode != Node && mySelectionMode == Node );
- if ( switchPointMode )
- {
- vtkRenderer* renderer = vw->getRenderer();
- VTK::ActorCollectionCopy actors( renderer->GetActors() );
- vtkActorCollection* collection = actors.GetActors();
- collection->InitTraversal();
- while ( vtkActor* vtkActor = collection->GetNextActor() )
- {
- if ( SMESH_Actor* actor = dynamic_cast<SMESH_Actor*>( vtkActor ) )
- {
- if ( actor->GetVisibility() )
- actor->SetPointRepresentation( mySelectionMode == Node );
- }
- }
- }
- vw->SetSelectionMode( mySelectionMode );
+ SelectionMode previousMode = (SelectionMode)vw->SelectionMode();
+ bool switchPointMode = ( previousMode == Node && mySelectionMode != Node ) ||
+ ( previousMode != Node && mySelectionMode == Node );
+ if ( switchPointMode )
+ {
+ vtkRenderer* renderer = vw->getRenderer();
+ VTK::ActorCollectionCopy actors( renderer->GetActors() );
+ vtkActorCollection* collection = actors.GetActors();
+ collection->InitTraversal();
+ while ( vtkActor* vtkActor = collection->GetNextActor() )
+ {
+ if ( SMESH_Actor* actor = dynamic_cast<SMESH_Actor*>( vtkActor ) )
+ {
+ if ( actor->GetVisibility() )
+ actor->SetPointRepresentation( mySelectionMode == Node );
+ }
+ }
+ }
+ vw->SetSelectionMode( mySelectionMode );
}
}
}