Salome HOME
Merge branch 'master' of https://codev-tuleap.cea.fr/plugins/git/salome/smesh
[modules/smesh.git] / src / SMESH_SWIG / smeshBuilder.py
index 6a1a4e1dffe12512924952abfda148165ba284fd..bd9966d40f171d4387c7768332265cfa5b6f17e6 100644 (file)
@@ -1155,6 +1155,18 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen):
         aMeasurements.UnRegister()
         return value
 
+    ## Get gravity center of all nodes of the mesh object.
+    #  @param obj mesh, submesh or group
+    #  @return three components of the gravity center: x,y,z
+    #  @ingroup l1_measurements
+    def GetGravityCenter(self, obj):
+        if isinstance(obj, Mesh): obj = obj.mesh
+        if isinstance(obj, Mesh_Algorithm): obj = obj.GetSubMesh()
+        aMeasurements = self.CreateMeasurements()
+        pointStruct = aMeasurements.GravityCenter(obj)
+        aMeasurements.UnRegister()
+        return pointStruct.x, pointStruct.y, pointStruct.z
+
     pass # end of class smeshBuilder
 
 import omniORB
@@ -1171,11 +1183,12 @@ omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshBuilder)
 #    from salome.smesh import smeshBuilder
 #    smesh = smeshBuilder.New(salome.myStudy)
 #  \endcode
-#  @param  study     SALOME study, generally obtained by salome.myStudy.
-#  @param  instance  CORBA proxy of SMESH Engine. If None, the default Engine is used.
+#  @param  study         SALOME study, generally obtained by salome.myStudy.
+#  @param  instance      CORBA proxy of SMESH Engine. If None, the default Engine is used.
+#  @param  instanceGeom  CORBA proxy of GEOM  Engine. If None, the default Engine is used.
 #  @return smeshBuilder instance
 
-def New( study, instance=None):
+def New( study, instance=None, instanceGeom=None):
     """
     Create a new smeshBuilder instance.The smeshBuilder class provides the Python
     interface to create or load meshes.
@@ -1187,8 +1200,9 @@ def New( study, instance=None):
         smesh = smeshBuilder.New(salome.myStudy)
 
     Parameters:
-        study     SALOME study, generally obtained by salome.myStudy.
-        instance  CORBA proxy of SMESH Engine. If None, the default Engine is used.
+        study         SALOME study, generally obtained by salome.myStudy.
+        instance      CORBA proxy of SMESH Engine. If None, the default Engine is used.
+        instanceGeom  CORBA proxy of GEOM  Engine. If None, the default Engine is used.
     Returns:
         smeshBuilder instance
     """
@@ -1200,7 +1214,7 @@ def New( study, instance=None):
       doLcc = True
     smeshInst = smeshBuilder()
     assert isinstance(smeshInst,smeshBuilder), "Smesh engine class is %s but should be smeshBuilder.smeshBuilder. Import salome.smesh.smeshBuilder before creating the instance."%smeshInst.__class__
-    smeshInst.init_smesh(study)
+    smeshInst.init_smesh(study, instanceGeom)
     return smeshInst
 
 
@@ -4571,6 +4585,24 @@ class Mesh:
         self.mesh.SetParameters(Parameters)
         return Mesh( self.smeshpyD, self.geompyD, mesh )
 
+    ## Create an offset mesh from the given 2D object
+    #  @param theObject the source object (mesh, submesh, group or filter)
+    #  @param theValue signed offset size
+    #  @param MakeGroups forces the generation of new groups from existing ones
+    #  @param NewMeshName the name of a mesh to create. If empty, offset elements are added
+    #         to this mesh
+    #  @return a tuple (mesh, list_of_groups)
+    #  @ingroup l2_modif_trsf
+    def Offset(self, theObject, theValue, MakeGroups=False, NewMeshName=''):
+        if isinstance( theObject, Mesh ):
+            theObject = theObject.GetMesh()
+        theValue,Parameters,hasVars = ParseParameters(theValue)
+        mesh_groups = self.editor.Offset(theObject, theValue, MakeGroups, NewMeshName )
+        self.mesh.SetParameters(Parameters)
+        # if mesh_groups[0]:
+        #     return Mesh( self.smeshpyD, self.geompyD, mesh_groups[0] ), mesh_groups[1]
+        return mesh_groups
+
     ## Find groups of adjacent nodes within Tolerance.
     #  @param Tolerance the value of tolerance
     #  @param SeparateCornerAndMediumNodes if @c True, in quadratic mesh puts
@@ -4782,7 +4814,7 @@ class Mesh:
     #         a Mesh, elements of highest dimension are duplicated
     #  @param theGroupName - a name of group to contain the generated elements.
     #                    If a group with such a name already exists, the new elements
-    #                    are added to the existng group, else a new group is created.
+    #                    are added to the existing group, else a new group is created.
     #                    If \a theGroupName is empty, new elements are not added 
     #                    in any group.
     # @return a group where the new elements are added. None if theGroupName == "".