Salome HOME
0020727: EDF 1276 SMESH : add a Method RadialQuadrangle to the Mesh class in smeshDC.py
[modules/smesh.git] / src / SMESH_SWIG / smeshDC.py
index 77e8459ab5a71ee995236a595cd7f1ab84ee378f..d0cfdf9a5343322d7f3606418363e998771a090e 100644 (file)
@@ -163,7 +163,7 @@ Hexa    = 8
 Hexotic = 9
 BLSURF  = 10
 GHS3DPRL = 11
-QUARDANGLE = 0
+QUADRANGLE = 0
 RADIAL_QUAD = 1
 
 # MirrorType enumeration
@@ -197,6 +197,10 @@ DefaultSize, DefaultGeom, Custom = 0,0,1
 
 PrecisionConfusion = 1e-07
 
+# TopAbs_State enumeration
+[TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
+
+
 ## Converts an angle from degrees to radians
 def DegreesToRadians(AngleInDegrees):
     from math import pi
@@ -1062,10 +1066,10 @@ class Mesh:
     #  If the optional \a geom parameter is not set, this algorithm is global.
     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
     #  @param geom If defined, the subshape to be meshed (GEOM_Object)
-    #  @param algo values are: smesh.QUARDANGLE || smesh.RADIAL_QUAD
+    #  @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
     #  @return an instance of Mesh_Quadrangle algorithm
     #  @ingroup l3_algos_basic
-    def Quadrangle(self, geom=0, algo=QUARDANGLE):
+    def Quadrangle(self, geom=0, algo=QUADRANGLE):
         if algo==RADIAL_QUAD:
             return Mesh_RadialQuadrangle1D2D(self,geom)
         else:
@@ -1314,7 +1318,7 @@ class Mesh:
         hyp_name = GetName( hyp )
         geom_name = ""
         if geom:
-            hyp_name = GetName( geom )
+            geom_name = GetName( geom )
         TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
         return status
 
@@ -1920,6 +1924,12 @@ class Mesh:
     def GetElementType(self, id, iselem):
         return self.mesh.GetElementType(id, iselem)
 
+    ## Returns the geometric type of mesh element
+    #  @return the value from SMESH::EntityType enumeration
+    #  @ingroup l1_meshinfo
+    def GetElementGeomType(self, id):
+        return self.mesh.GetElementGeomType(id)
+
     ## Returns the list of submesh elements IDs
     #  @param Shape a geom object(subshape) IOR
     #         Shape must be the subshape of a ShapeToMesh()
@@ -2285,6 +2295,11 @@ class Mesh:
     def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
         return self.editor.FindElementsByPoint(x, y, z, elementType)
         
+    # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
+    # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
+     
+    def GetPointState(self, x, y, z):
+        return self.editor.GetPointState(x, y, z)
 
     ## Finds the node closest to a point and moves it to a point location
     #  @param x  the X coordinate of a point
@@ -3271,6 +3286,51 @@ class Mesh:
         mesh.SetParameters(Parameters)
         return Mesh( self.smeshpyD, self.geompyD, mesh )
 
+
+
+    ## Scales the object
+    #  @param theObject - the object to translate (mesh, submesh, or group)
+    #  @param thePoint - base point for scale
+    #  @param theScaleFact - scale factors for axises
+    #  @param Copy - allows copying the translated elements
+    #  @param MakeGroups - forces the generation of new groups from existing
+    #                      ones (if Copy)
+    #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
+    #          empty list otherwise
+    def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
+        if ( isinstance( theObject, Mesh )):
+            theObject = theObject.GetMesh()
+        if ( isinstance( theObject, list )):
+            theObject = self.editor.MakeIDSource(theObject)
+
+        thePoint, Parameters = ParsePointStruct(thePoint)
+        self.mesh.SetParameters(Parameters)
+
+        if Copy and MakeGroups:
+            return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
+        self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
+        return []
+
+    ## 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 theScaleFact - scale factors for axises
+    #  @param MakeGroups - forces the generation of new groups from existing ones
+    #  @param NewMeshName - the name of the newly created mesh
+    #  @return instance of Mesh class
+    def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
+        if (isinstance(theObject, Mesh)):
+            theObject = theObject.GetMesh()
+        if ( isinstance( theObject, list )):
+            theObject = self.editor.MakeIDSource(theObject)
+
+        mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
+                                         MakeGroups, NewMeshName)
+        #mesh.SetParameters(Parameters)
+        return Mesh( self.smeshpyD, self.geompyD, mesh )
+
+
+
     ## Rotates the elements
     #  @param IDsOfElements list of elements ids
     #  @param Axis the axis of rotation (AxisStruct or geom line)
@@ -3729,6 +3789,7 @@ class Mesh_Algorithm:
             raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
         self.mesh = mesh
         piece = mesh.geom
+        name = ""
         if not geom:
             self.geom = piece
         else:
@@ -3744,7 +3805,7 @@ class Mesh_Algorithm:
 
         self.algo = algo
         status = mesh.mesh.AddHypothesis(self.geom, self.algo)
-        TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
+        TreatHypoStatus( status, algo.GetName(), name, True )
 
     def CompareHyp (self, hyp, args):
         print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()