# Copyright (C) 2005 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. # # 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org # # File : smesh.py # Author : Francis KLOSS, OCC # Module : SMESH """ \namespace smesh \brief Module smesh """ import salome import geompy import StdMeshers import SMESH # Public variables # ---------------- REGULAR = 1 PYTHON = 2 NETGEN = 3 GHS3D = 4 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") smesh.SetCurrentStudy(salome.myStudy) # Private functions # ----------------- def GetName(obj): ior = salome.orb.object_to_string(obj) sobj = salome.myStudy.FindObjectIOR(ior) attr = sobj.FindAttribute("AttributeName")[1] return attr.Value() def SetName(obj, name): ior = salome.orb.object_to_string(obj) sobj = salome.myStudy.FindObjectIOR(ior) attr = sobj.FindAttribute("AttributeName")[1] attr.SetValue(name) # Algorithms and hypothesis # ========================= # Private class: Mesh_Algorithm # ----------------------------- class Mesh_Algorithm: """ Mother class to define algorithm, recommended to don't use directly """ mesh = 0 geom = 0 subm = 0 def GetSubMesh(self): """ If the algorithm is global, return 0 else return the submesh associated to this algorithm """ return self.subm def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"): """ Private method """ self.mesh = mesh piece = mesh.geom if geom==0: self.geom = piece name = GetName(piece) else: self.geom = geom name = geompy.SubShapeName(geom, piece) geompy.addToStudyInFather(piece, geom, name) self.subm = mesh.mesh.GetSubMesh(geom, hypo) algo = smesh.CreateHypothesis(hypo, so) SetName(algo, name + "/" + hypo) mesh.mesh.AddHypothesis(self.geom, algo) def Hypothesis(self, hyp, args=[], so="libStdMeshersEngine.so"): """ Private method """ hypo = smesh.CreateHypothesis(hyp, so) a = "" s = "=" i = 0 n = len(args) while i