X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_SWIG%2FsmeshBuilder.py;h=b4f79d7356e2ed27ff664744de29fc9be4ef4236;hp=77481578f21ba152fe2820dc5776aa8ddd3569b9;hb=fd1943809d016d0223da20a2a492b157cb17146a;hpb=ee4749bf4c09bcdf042d119912d8db447ece5a26 diff --git a/src/SMESH_SWIG/smeshBuilder.py b/src/SMESH_SWIG/smeshBuilder.py index 77481578f..b4f79d735 100644 --- a/src/SMESH_SWIG/smeshBuilder.py +++ b/src/SMESH_SWIG/smeshBuilder.py @@ -1,4 +1,4 @@ -# Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -520,7 +520,8 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen): #return self.IsEmbeddedMode() return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self) - ## Sets the current study + ## Sets the current study. Calling SetCurrentStudy( None ) allows to + # switch OFF automatic pubilishing in the Study of mesh objects. # @ingroup l1_auxiliary def SetCurrentStudy( self, theStudy, geompyD = None ): #self.SetCurrentStudy(theStudy) @@ -536,6 +537,12 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen): notebook = salome_notebook.NoteBook( theStudy ) else: notebook = salome_notebook.NoteBook( salome_notebook.PseudoStudyForNoteBook() ) + if theStudy: + sb = theStudy.NewBuilder() + sc = theStudy.FindComponent("SMESH") + if sc: sb.LoadWith(sc, self) + pass + pass ## Gets the current study # @ingroup l1_auxiliary @@ -595,14 +602,15 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen): if error.comment: print "*** CreateMeshesFromGMF() errors:\n", error.comment return Mesh(self, self.geompyD, aSmeshMesh), error - ## Concatenate the given meshes into one mesh. - # @return an instance of Mesh class + ## Concatenate the given meshes into one mesh. All groups of input meshes will be + # present in the new mesh. # @param meshes the meshes to combine into one mesh # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed - # @param mergeNodesAndElements if true, equal nodes and elements aremerged + # @param mergeNodesAndElements if true, equal nodes and elements are merged # @param mergeTolerance tolerance for merging nodes - # @param allGroups forces creation of groups of all elements + # @param allGroups forces creation of groups corresponding to every input mesh # @param name name of a new mesh + # @return an instance of Mesh class def Concatenate( self, meshes, uniteIdenticalGroups, mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False, name = ""): @@ -627,7 +635,7 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen): # pass result of Mesh.GetIDSource( list_of_ids, type ) as meshPart # @param meshName a name of the new mesh # @param toCopyGroups to create in the new mesh groups the copied elements belongs to - # @param toKeepIDs to preserve IDs of the copied elements or not + # @param toKeepIDs to preserve order of the copied elements or not # @return an instance of Mesh class def CopyMesh( self, meshPart, meshName, toCopyGroups=False, toKeepIDs=False): if (isinstance( meshPart, Mesh )): @@ -1369,9 +1377,10 @@ class Mesh: # @param discardModifs if True and the mesh has been edited since # a last total re-compute and that may prevent successful partial re-compute, # then the mesh is cleaned before Compute() + # @param refresh if @c True, Object browser is automatically updated (when running in GUI) # @return True or False # @ingroup l2_construct - def Compute(self, geom=0, discardModifs=False): + def Compute(self, geom=0, discardModifs=False, refresh=False): if geom == 0 or not isinstance(geom, geomBuilder.GEOM._objref_GEOM_Object): if self.geom == 0: geom = self.mesh.GetShapeToMesh() @@ -1499,7 +1508,7 @@ class Mesh: smeshgui = salome.ImportComponentGUI("SMESH") smeshgui.Init(self.mesh.GetStudyId()) smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) ) - salome.sg.updateObjBrowser(1) + if refresh: salome.sg.updateObjBrowser(1) pass return ok @@ -1516,25 +1525,28 @@ class Mesh: return self.mesh.SetMeshOrder(submeshes) ## Removes all nodes and elements + # @param refresh if @c True, Object browser is automatically updated (when running in GUI) # @ingroup l2_construct - def Clear(self): + def Clear(self, refresh=False): self.mesh.Clear() if ( salome.sg.hasDesktop() and - salome.myStudyManager.GetStudyByID( self.mesh.GetStudyId() )): + salome.myStudyManager.GetStudyByID( self.mesh.GetStudyId() ) ): smeshgui = salome.ImportComponentGUI("SMESH") smeshgui.Init(self.mesh.GetStudyId()) smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True ) - salome.sg.updateObjBrowser(1) + if refresh: salome.sg.updateObjBrowser(1) ## Removes all nodes and elements of indicated shape + # @param refresh if @c True, Object browser is automatically updated (when running in GUI) + # @param geomId the ID of a sub-shape to remove elements on # @ingroup l2_construct - def ClearSubMesh(self, geomId): + def ClearSubMesh(self, geomId, refresh=False): self.mesh.ClearSubMesh(geomId) if salome.sg.hasDesktop(): smeshgui = salome.ImportComponentGUI("SMESH") smeshgui.Init(self.mesh.GetStudyId()) smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True ) - salome.sg.updateObjBrowser(1) + if refresh: salome.sg.updateObjBrowser(1) ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + Tetrahedron # @param fineness [0.0,1.0] defines mesh fineness @@ -3387,11 +3399,11 @@ class Mesh: # them with quadratic with the same id. # @param theForce3d new node creation method: # 0 - the medium node lies at the geometrical entity from which the mesh element is built - # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element + # 1 - the medium node lies at the middle of the line segments connecting two nodes of a mesh element # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal # @param theToBiQuad If True, converts the mesh to bi-quadratic # @ingroup l2_modif_tofromqu - def ConvertToQuadratic(self, theForce3d, theSubMesh=None, theToBiQuad=False): + def ConvertToQuadratic(self, theForce3d=False, theSubMesh=None, theToBiQuad=False): if isinstance( theSubMesh, Mesh ): theSubMesh = theSubMesh.mesh if theToBiQuad: @@ -3477,12 +3489,12 @@ class Mesh: if mesh: mesh = self.smeshpyD.Mesh(mesh) return nb, mesh, group - ## Renumber mesh nodes + ## Renumber mesh nodes (Obsolete, does nothing) # @ingroup l2_modif_renumber def RenumberNodes(self): self.editor.RenumberNodes() - ## Renumber mesh elements + ## Renumber mesh elements (Obsole, does nothing) # @ingroup l2_modif_renumber def RenumberElements(self): self.editor.RenumberElements() @@ -3662,6 +3674,44 @@ class Mesh: ExtrFlags, SewTolerance) return [] + ## Generates new elements by extrusion along the normal to a discretized surface or wire + # @param Elements container of elements to extrude; + # it can be Mesh, Group, Sub-mesh, Filter or list of IDs; + # Only faces can be extruded so far. Sub-mesh sould be a sub-mesh on geom faces. + # @param StepSize length of one extrusion step (the total extrusion + # length will be \a NbOfSteps * \a StepSize ). + # @param NbOfSteps number of extrusion steps. + # @param ByAverageNormal if True each node is translated by \a StepSize + # along the average of the normal vectors to the faces sharing the node; + # else each node is translated along the same average normal till + # intersection with the plane got by translation of the face sharing + # the node along its own normal by \a StepSize. + # @param UseInputElemsOnly to use only \a Elements when computing extrusion direction + # for every node of \a Elements. + # @param MakeGroups forces generation of new groups from existing ones. + # @param Dim dimension of elements to extrude: 2 - faces or 1 - edges. Extrusion of edges + # is not yet implemented. This parameter is used if \a Elements contains + # both faces and edges, i.e. \a Elements is a Mesh. + # @return the list of created groups (SMESH_GroupBase) if \a MakeGroups=True, + # empty list otherwise. + # @ingroup l2_modif_extrurev + def ExtrusionByNormal(self, Elements, StepSize, NbOfSteps, + ByAverageNormal=False, UseInputElemsOnly=True, MakeGroups=False, Dim = 2): + unRegister = genObjUnRegister() + if isinstance( Elements, Mesh ): + Elements = Elements.GetMesh() + if isinstance( Elements, list ): + if not Elements: + raise RuntimeError, "List of element IDs is empty!" + if not isinstance( Elements[0], int ): + raise RuntimeError, "List must contain element IDs and not %s"% Elements[0] + Elements = self.GetIDSource( Elements, SMESH.ALL ) + unRegister.set( Elements ) + StepSize,NbOfSteps,Parameters,hasVars = ParseParameters(StepSize,NbOfSteps) + self.mesh.SetParameters(Parameters) + return self.editor.ExtrusionByNormal(Elements, StepSize, NbOfSteps, + UseInputElemsOnly, ByAverageNormal, MakeGroups, Dim) + ## Generates new elements by extrusion of the elements which belong to the object # @param theObject the object which elements should be processed. # It can be a mesh, a sub mesh or a group. @@ -4131,7 +4181,7 @@ class Mesh: ## Scales the object # @param theObject - the object to translate (mesh, submesh, or group) - # @param thePoint - base point for scale + # @param thePoint - base point for scale (SMESH.PointStruct or list of 3 coordinates) # @param theScaleFact - list of 1-3 scale factors for axises # @param Copy - allows copying the translated elements # @param MakeGroups - forces the generation of new groups from existing @@ -4145,6 +4195,8 @@ class Mesh: if ( isinstance( theObject, list )): theObject = self.GetIDSource(theObject, SMESH.ALL) unRegister.set( theObject ) + if ( isinstance( thePoint, list )): + thePoint = PointStruct( thePoint[0], thePoint[1], thePoint[2] ) if ( isinstance( theScaleFact, float )): theScaleFact = [theScaleFact] if ( isinstance( theScaleFact, int )): @@ -4159,7 +4211,7 @@ class Mesh: ## Creates a new mesh from the translated object # @param theObject - the object to translate (mesh, submesh, or group) - # @param thePoint - base point for scale + # @param thePoint - base point for scale (SMESH.PointStruct or list of 3 coordinates) # @param theScaleFact - list of 1-3 scale factors for axises # @param MakeGroups - forces the generation of new groups from existing ones # @param NewMeshName - the name of the newly created mesh @@ -4171,6 +4223,8 @@ class Mesh: if ( isinstance( theObject, list )): theObject = self.GetIDSource(theObject,SMESH.ALL) unRegister.set( theObject ) + if ( isinstance( thePoint, list )): + thePoint = PointStruct( thePoint[0], thePoint[1], thePoint[2] ) if ( isinstance( theScaleFact, float )): theScaleFact = [theScaleFact] if ( isinstance( theScaleFact, int )):