X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH_SWIG%2FsmeshBuilder.py;h=cec7eb822b0a6f608d7ecb4fbb38b067d94a0df4;hb=1a1b88b9cf10382f90a5e34f4ca8777b8b8550d8;hp=b4da6ea8e8495ff4ba537f1d8a372ec09e680303;hpb=5504d02a2237b17b8459bcd3b1fb2a89468598cd;p=modules%2Fsmesh.git diff --git a/src/SMESH_SWIG/smeshBuilder.py b/src/SMESH_SWIG/smeshBuilder.py index b4da6ea8e..cec7eb822 100644 --- a/src/SMESH_SWIG/smeshBuilder.py +++ b/src/SMESH_SWIG/smeshBuilder.py @@ -964,6 +964,10 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen): functor = aFilterMgr.CreateLength() elif theCriterion == FT_Length2D: functor = aFilterMgr.CreateLength2D() + elif theCriterion == FT_NodeConnectivityNumber: + functor = aFilterMgr.CreateNodeConnectivityNumber() + elif theCriterion == FT_BallDiameter: + functor = aFilterMgr.CreateBallDiameter() else: print "Error: given parameter is not numerical functor type." aFilterMgr.UnRegister() @@ -1497,11 +1501,12 @@ class Mesh: print allReasons pass if salome.sg.hasDesktop() and self.mesh.GetStudyId() >= 0: - smeshgui = salome.ImportComponentGUI("SMESH") - smeshgui.Init(self.mesh.GetStudyId()) - smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) ) - if refresh: salome.sg.updateObjBrowser(1) - pass + if not isinstance( refresh, list): # not a call from subMesh.Compute() + smeshgui = salome.ImportComponentGUI("SMESH") + smeshgui.Init(self.mesh.GetStudyId()) + smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) ) + if refresh: salome.sg.updateObjBrowser(True) + return ok ## Return a list of error messages (SMESH.ComputeError) of the last Compute() @@ -1619,7 +1624,7 @@ class Mesh: smeshgui = salome.ImportComponentGUI("SMESH") smeshgui.Init(self.mesh.GetStudyId()) smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True ) - if refresh: salome.sg.updateObjBrowser(1) + if refresh: salome.sg.updateObjBrowser(True) ## Removes all nodes and elements of indicated shape # @param refresh if @c True, Object browser is automatically updated (when running in GUI) @@ -1631,7 +1636,7 @@ class Mesh: smeshgui = salome.ImportComponentGUI("SMESH") smeshgui.Init(self.mesh.GetStudyId()) smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True ) - if refresh: salome.sg.updateObjBrowser(1) + if refresh: salome.sg.updateObjBrowser(True) ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + Tetrahedron # @param fineness [0.0,1.0] defines mesh fineness @@ -2259,6 +2264,8 @@ class Mesh: # idSrc.UnRegister() # @ingroup l1_auxiliary def GetIDSource(self, ids, elemType = SMESH.ALL): + if isinstance( ids, int ): + ids = [ids] return self.editor.MakeIDSource(ids, elemType) @@ -2823,10 +2830,11 @@ class Mesh: ## Creates a 0D element on a node with given number. # @param IDOfNode the ID of node for creation of the element. + # @param DuplicateElements to add one more 0D element to a node or not # @return the Id of the new 0D element # @ingroup l2_modif_add - def Add0DElement(self, IDOfNode): - return self.editor.Add0DElement(IDOfNode) + def Add0DElement( self, IDOfNode, DuplicateElements=True ): + return self.editor.Add0DElement( IDOfNode, DuplicateElements ) ## Create 0D elements on all nodes of the given elements except those # nodes on which a 0D element already exists. @@ -2835,18 +2843,19 @@ class Mesh: # of nodes IDs created by calling mesh.GetIDSource( nodes, SMESH.NODE ) # @param theGroupName optional name of a group to add 0D elements created # and/or found on nodes of \a theObject. + # @param DuplicateElements to add one more 0D element to a node or not # @return an object (a new group or a temporary SMESH_IDSource) holding # IDs of new and/or found 0D elements. IDs of 0D elements # can be retrieved from the returned object by calling GetIDs() # @ingroup l2_modif_add - def Add0DElementsToAllNodes(self, theObject, theGroupName=""): + def Add0DElementsToAllNodes(self, theObject, theGroupName="", DuplicateElements=False): unRegister = genObjUnRegister() if isinstance( theObject, Mesh ): theObject = theObject.GetMesh() - if isinstance( theObject, list ): + elif isinstance( theObject, list ): theObject = self.GetIDSource( theObject, SMESH.ALL ) unRegister.set( theObject ) - return self.editor.Create0DElementsOnAllNodes( theObject, theGroupName ) + return self.editor.Create0DElementsOnAllNodes( theObject, theGroupName, DuplicateElements ) ## Creates a ball element on a node with given ID. # @param IDOfNode the ID of node for creation of the element. @@ -4496,7 +4505,7 @@ class Mesh: ## Finds groups of ajacent nodes within Tolerance. # @param Tolerance the value of tolerance - # @param SubMeshOrGroup SubMesh or Group + # @param SubMeshOrGroup SubMesh, Group or Filter # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search # @param SeparateCornerAndMediumNodes if @c True, in quadratic mesh puts # corner and medium nodes in separate groups thus preventing @@ -5001,7 +5010,7 @@ class Mesh: pass # end of Mesh class -## class used to compensate change of CORBA API of SMESH_Mesh for backward compatibility +## Class used to compensate change of CORBA API of SMESH_Mesh for backward compatibility # with old dump scripts which call SMESH_Mesh directly and not via smeshBuilder.Mesh # class meshProxy(SMESH._objref_SMESH_Mesh): @@ -5017,7 +5026,40 @@ class meshProxy(SMESH._objref_SMESH_Mesh): pass omniORB.registerObjref(SMESH._objref_SMESH_Mesh._NP_RepositoryId, meshProxy) -## class used to compensate change of CORBA API of SMESH_MeshEditor for backward compatibility + +## Class wrapping SMESH_SubMesh in order to add Compute() +# +class submeshProxy(SMESH._objref_SMESH_subMesh): + def __init__(self): + SMESH._objref_SMESH_subMesh.__init__(self) + self.mesh = None + def __deepcopy__(self, memo=None): + new = self.__class__() + return new + + ## Computes the sub-mesh and returns the status of the computation + # @param refresh if @c True, Object browser is automatically updated (when running in GUI) + # @return True or False + # @ingroup l2_construct + def Compute(self,refresh=False): + if not self.mesh: + self.mesh = Mesh( smeshBuilder(), None, self.GetMesh()) + + ok = self.mesh.Compute( self.GetSubShape(),refresh=[] ) + + if salome.sg.hasDesktop() and self.mesh.GetStudyId() >= 0: + smeshgui = salome.ImportComponentGUI("SMESH") + smeshgui.Init(self.mesh.GetStudyId()) + smeshgui.SetMeshIcon( salome.ObjectToID( self ), ok, (self.GetNumberOfElements()==0) ) + if refresh: salome.sg.updateObjBrowser(True) + pass + + return ok + pass +omniORB.registerObjref(SMESH._objref_SMESH_subMesh._NP_RepositoryId, submeshProxy) + + +## Class used to compensate change of CORBA API of SMESH_MeshEditor for backward compatibility # with old dump scripts which call SMESH_MeshEditor directly and not via smeshBuilder.Mesh # class meshEditor(SMESH._objref_SMESH_MeshEditor): @@ -5129,7 +5171,7 @@ class algoCreator: raise RuntimeError, "No class found for algo type %s" % algoType return None -# Private class used to substitute and store variable parameters of hypotheses. +## Private class used to substitute and store variable parameters of hypotheses. # class hypMethodWrapper: def __init__(self, hyp, method): @@ -5160,7 +5202,8 @@ class hypMethodWrapper: return result pass -# A helper class that call UnRegister() of SALOME.GenericObj'es stored in it +## A helper class that call UnRegister() of SALOME.GenericObj'es stored in it +# class genObjUnRegister: def __init__(self, genObj=None): @@ -5181,6 +5224,9 @@ class genObjUnRegister: if genObj and hasattr( genObj, "UnRegister" ): genObj.UnRegister() + +## Bind methods creating mesher plug-ins to the Mesh class +# for pluginName in os.environ[ "SMESH_MeshersList" ].split( ":" ): # #print "pluginName: ", pluginName