Salome HOME
Bug 0020072: GHS3DPRLPLUGIN update. Integrating the attached patch.
[modules/smesh.git] / src / SMESH_SWIG / smeshDC.py
index d5e8661d6315a5724f0389693a04eb8556634e0a..db8a34ccd929a4e40eed1366d45a9464810d2fe8 100644 (file)
@@ -1,4 +1,6 @@
-#  Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+#  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+#
+#  Copyright (C) 2003-2007  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
@@ -20,7 +22,7 @@
 #  File   : smesh.py
 #  Author : Francis KLOSS, OCC
 #  Module : SMESH
-
+#
 """
  \namespace smesh
  \brief Module smesh
@@ -126,6 +128,7 @@ NETGEN_FULL   = FULL_NETGEN
 Hexa    = 8
 Hexotic = 9
 BLSURF  = 10
+GHS3DPRL = 11
 
 # MirrorType enumeration
 POINT = SMESH_MeshEditor.POINT
@@ -174,6 +177,10 @@ def GetName(obj):
 
 ## Sets a name to the object
 def SetName(obj, name):
+    if isinstance( obj, Mesh ):
+        obj = obj.GetMesh()
+    elif isinstance( obj, Mesh_Algorithm ):
+        obj = obj.GetAlgorithm()
     ior  = salome.orb.object_to_string(obj)
     sobj = salome.myStudy.FindObjectIOR(ior)
     if not sobj is None:
@@ -233,9 +240,7 @@ class smeshDC(SMESH._objref_SMESH_Gen):
     ## Sets the current study and Geometry component
     #  @ingroup l1_auxiliary
     def init_smesh(self,theStudy,geompyD):
-        self.geompyD=geompyD
-        self.SetGeomEngine(geompyD)
-        self.SetCurrentStudy(theStudy)
+        self.SetCurrentStudy(theStudy,geompyD)
 
     ## Creates an empty Mesh. This mesh can have an underlying geometry.
     #  @param obj the Geometrical object on which the mesh is built. If not defined,
@@ -326,8 +331,14 @@ class smeshDC(SMESH._objref_SMESH_Gen):
 
     ## Sets the current study
     #  @ingroup l1_auxiliary
-    def SetCurrentStudy( self, theStudy ):
+    def SetCurrentStudy( self, theStudy, geompyD = None ):
         #self.SetCurrentStudy(theStudy)
+        if not geompyD:
+            import geompy
+            geompyD = geompy.geom
+            pass
+        self.geompyD=geompyD
+        self.SetGeomEngine(geompyD)
         SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
 
     ## Gets the current study
@@ -363,6 +374,24 @@ class smeshDC(SMESH._objref_SMESH_Gen):
         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
         return aMesh
 
+    ## Concatenate the given meshes into one mesh.
+    #  @return an instance of Mesh class
+    #  @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 mergeTolerance tolerance for merging nodes
+    #  @param allGroups forces creation of groups of all elements
+    def Concatenate( self, meshes, uniteIdenticalGroups,
+                     mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
+        if allGroups:
+            aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
+                self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
+        else:
+            aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
+                self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
+        aMesh = Mesh(self, self.geompyD, aSmeshMesh)
+        return aMesh
+
     ## From SMESH_Gen interface
     #  @return the list of integer values
     #  @ingroup l1_auxiliary
@@ -749,7 +778,7 @@ class Mesh:
     #  The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
     #  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 algo values are: smesh.NETGEN, smesh.GHS3D, smesh.FULL_NETGEN
+    #  @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
     #  @param geom If defined, the subshape to be meshed (GEOM_Object)
     #  @return an instance of Mesh_Tetrahedron algorithm
     #  @ingroup l3_algos_basic
@@ -3094,7 +3123,7 @@ class Mesh_Segment(Mesh_Algorithm):
 # --------------------------
 
 ## Defines a segment 1D algorithm for discretization
-#  
+#
 #  @ingroup l3_algos_basic
 class Mesh_CompositeSegment(Mesh_Segment):
 
@@ -3489,6 +3518,11 @@ class Mesh_Tetrahedron(Mesh_Algorithm):
             self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
             pass
 
+        elif algoType == GHS3DPRL:
+            import GHS3DPRLPlugin
+            self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
+            pass
+
         self.algoType = algoType
 
     ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
@@ -3516,6 +3550,7 @@ class Mesh_Tetrahedron(Mesh_Algorithm):
     def Parameters(self, which=SOLE):
         if self.params:
             return self.params
+
         if self.algoType == FULL_NETGEN:
             if which == SIMPLE:
                 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
@@ -3524,11 +3559,17 @@ class Mesh_Tetrahedron(Mesh_Algorithm):
                 self.params = self.Hypothesis("NETGEN_Parameters", [],
                                               "libNETGENEngine.so", UseExisting=0)
             return self.params
+
         if self.algoType == GHS3D:
             self.params = self.Hypothesis("GHS3D_Parameters", [],
                                           "libGHS3DEngine.so", UseExisting=0)
             return self.params
-        
+
+        if self.algoType == GHS3DPRL:
+            self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
+                                          "libGHS3DPRLEngine.so", UseExisting=0)
+            return self.params
+
         print "Algo supports no multi-parameter hypothesis"
         return None
 
@@ -3645,7 +3686,7 @@ class Mesh_Tetrahedron(Mesh_Algorithm):
     ## To keep working files or remove them. Log file remains in case of errors anyway.
     #  @ingroup l3_hypos_ghs3dh
     def SetKeepFiles(self, toKeep):
-        #  Advanced parameter of GHS3D
+        #  Advanced parameter of GHS3D and GHS3DPRL
         self.Parameters().SetKeepFiles(toKeep)
 
     ## To set verbose level [0-10]. <ul>
@@ -3674,12 +3715,24 @@ class Mesh_Tetrahedron(Mesh_Algorithm):
         #  Advanced parameter of GHS3D
         self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
 
-    ## Sets command line option as text. 
+    ## Sets command line option as text.
     #  @ingroup l3_hypos_ghs3dh
     def SetTextOption(self, option):
         #  Advanced parameter of GHS3D
         self.Parameters().SetTextOption(option)
 
+    ## Sets MED files name and path.
+    def SetMEDName(self, value):
+        self.Parameters().SetMEDName(value)
+
+    ## Sets the number of partition of the initial mesh
+    def SetNbPart(self, value):
+        self.Parameters().SetNbPart(value)
+
+    ## When big mesh, start tepal in background
+    def SetBackground(self, value):
+        self.Parameters().SetBackground(value)
+
 # Public class: Mesh_Hexahedron
 # ------------------------------
 
@@ -3855,7 +3908,7 @@ class Mesh_Projection3D(Mesh_Algorithm):
         Mesh_Algorithm.__init__(self)
         self.Create(mesh, geom, "Projection_3D")
 
-    ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where 
+    ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
     #  the mesh pattern is taken, and, optionally, the  association of vertices
     #  between the source and the target solid  (to which a hipothesis is assigned)
     #  @param solid from where the mesh pattern is taken