2012-08-09 16:03:55 +06:00
|
|
|
# -*- coding: iso-8859-1 -*-
|
2015-02-13 13:38:35 +05:00
|
|
|
# Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
|
2009-02-17 10:27:49 +05:00
|
|
|
#
|
2012-08-09 16:03:55 +06:00
|
|
|
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
|
|
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
2005-03-21 13:38:22 +05:00
|
|
|
#
|
2012-08-09 16:03:55 +06:00
|
|
|
# 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
|
2014-02-20 18:25:37 +06:00
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
2005-03-21 13:38:22 +05:00
|
|
|
#
|
2012-08-09 16:03:55 +06:00
|
|
|
# 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.
|
2005-03-21 13:38:22 +05:00
|
|
|
#
|
2012-08-09 16:03:55 +06:00
|
|
|
# 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
|
2005-03-21 13:38:22 +05:00
|
|
|
#
|
2012-08-09 16:03:55 +06:00
|
|
|
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2005-03-21 13:38:22 +05:00
|
|
|
#
|
2012-08-09 16:03:55 +06:00
|
|
|
|
2005-03-21 13:38:22 +05:00
|
|
|
# File : smesh.py
|
|
|
|
# Author : Francis KLOSS, OCC
|
|
|
|
# Module : SMESH
|
2009-02-17 10:27:49 +05:00
|
|
|
#
|
2008-03-07 12:47:05 +05:00
|
|
|
"""@package smesh
|
2005-03-21 13:38:22 +05:00
|
|
|
\brief Module smesh
|
|
|
|
"""
|
|
|
|
|
|
|
|
import salome
|
2008-03-07 12:47:05 +05:00
|
|
|
from salome import *
|
2005-03-21 13:38:22 +05:00
|
|
|
|
2013-12-18 21:08:18 +06:00
|
|
|
import geompy
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
import SMESH, SALOMEDS
|
|
|
|
from salome.smesh import smeshBuilder
|
2005-03-21 13:38:22 +05:00
|
|
|
|
2012-10-08 17:56:59 +06:00
|
|
|
# retrieve SMESH engine in try/except block
|
|
|
|
# to avoid problems in some cases, e.g. when generating documentation
|
|
|
|
try:
|
2013-04-04 13:08:19 +06:00
|
|
|
# get instance of class smeshBuilder
|
|
|
|
engineSmesh = salome.lcc.FindOrLoadComponent( "FactoryServer", "SMESH" )
|
|
|
|
smesh = smeshBuilder.New(salome.myStudy, engineSmesh)
|
2012-10-08 17:56:59 +06:00
|
|
|
except:
|
2013-04-09 22:47:57 +06:00
|
|
|
print "exception in smesh.py: instance creation failed"
|
2012-10-08 17:56:59 +06:00
|
|
|
smesh = None
|
|
|
|
pass
|
2005-03-21 13:38:22 +05:00
|
|
|
|
2012-10-08 17:56:59 +06:00
|
|
|
# load plugins and add dynamically generated methods to Mesh class,
|
|
|
|
# the same for for global variables declared by plug-ins
|
2013-04-09 22:47:57 +06:00
|
|
|
from salome.smesh.smeshBuilder import *
|
2013-04-04 13:08:19 +06:00
|
|
|
from salome.smesh.smeshBuilder import Mesh, algoCreator
|
2012-10-08 17:56:59 +06:00
|
|
|
for pluginName in os.environ[ "SMESH_MeshersList" ].split( ":" ):
|
|
|
|
#
|
2013-04-04 13:08:19 +06:00
|
|
|
#print "pluginName: ", pluginName
|
|
|
|
pluginBuilderName = pluginName + "Builder"
|
2012-10-08 17:56:59 +06:00
|
|
|
try:
|
2013-04-04 13:08:19 +06:00
|
|
|
exec( "from salome.%s.%s import *" % (pluginName, pluginBuilderName))
|
2012-10-08 17:56:59 +06:00
|
|
|
except Exception, e:
|
2013-12-18 21:08:18 +06:00
|
|
|
from salome_utils import verbose
|
|
|
|
if verbose(): print "Exception while loading %s: %s" % ( pluginBuilderName, e )
|
2012-10-08 17:56:59 +06:00
|
|
|
continue
|
2013-04-04 13:08:19 +06:00
|
|
|
exec( "from salome.%s import %s" % (pluginName, pluginBuilderName))
|
|
|
|
plugin = eval( pluginBuilderName )
|
2012-08-09 16:03:55 +06:00
|
|
|
|
2012-10-08 17:56:59 +06:00
|
|
|
# add methods creating algorithms to Mesh
|
|
|
|
for k in dir( plugin ):
|
|
|
|
if k[0] == '_': continue
|
|
|
|
algo = getattr( plugin, k )
|
|
|
|
if type( algo ).__name__ == 'classobj' 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
|
2012-08-09 16:03:55 +06:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
# export the methods of smeshBuilder
|
2012-10-08 17:56:59 +06:00
|
|
|
if smesh:
|
|
|
|
for k in dir( smesh ):
|
|
|
|
if k[0] == '_': continue
|
|
|
|
globals()[k] = getattr( smesh, k )
|
|
|
|
del k
|
|
|
|
pass
|
2013-04-04 13:08:19 +06:00
|
|
|
|
|
|
|
print """
|
|
|
|
===============================================================================
|
2013-04-10 22:33:43 +06:00
|
|
|
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
|
|
|
|
-------
|
|
|
|
|
2013-04-24 18:13:36 +06:00
|
|
|
import smesh, SMESH
|
2013-04-10 22:33:43 +06:00
|
|
|
smesh.SetCurrentStudy(theStudy)
|
|
|
|
|
|
|
|
with
|
|
|
|
----
|
|
|
|
|
2013-04-24 18:13:36 +06:00
|
|
|
import SMESH
|
2013-04-10 22:33:43 +06:00
|
|
|
from salome.smesh import smeshBuilder
|
2013-04-16 19:50:10 +06:00
|
|
|
smesh = smeshBuilder.New(salome.myStudy)
|
2013-04-10 22:33:43 +06:00
|
|
|
|
|
|
|
you also need to modify some lines where smeshBuilder is used instead of smesh
|
|
|
|
|
2013-04-24 18:13:36 +06:00
|
|
|
algo=smesh.xxxx ==> algo=smeshBuilder.xxxx
|
2013-04-10 22:33:43 +06:00
|
|
|
|
2013-04-16 19:50:10 +06:00
|
|
|
See also SMESH User's Guide for more details
|
|
|
|
|
2014-05-14 16:53:24 +06:00
|
|
|
WARNING:
|
|
|
|
The smesh.py module works correctly only in the first created study.
|
|
|
|
It does not work in the second, third, etc studies!
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
===============================================================================
|
|
|
|
"""
|