Salome HOME
Fix up PressureValve test
[modules/smesh.git] / src / Tools / MacMesh / MacMesh / MacObject.py
index 8c24d560e4622e15834d4882454c5d874e0be742..e3a9c03fe9a2d78b90c3c29616032f98c00ffab1 100644 (file)
@@ -32,7 +32,7 @@ class MacObject:
         determines meshing parameters if necessary and finally launches the generation process.
         """
         import Config,GenFunctions
-        if Config.debug : print "Initializing object No. " + str(len(Config.ListObj)+1)
+        if Config.debug : print("Initializing object No. " + str(len(Config.ListObj)+1))
 
         if 'publish' in args :
             if args['publish']==0 : Config.publish = 0
@@ -46,7 +46,7 @@ class MacObject:
         else : self.GroupNames = [None, None, None, None]
 
         if ObjectType == 'NonOrtho':
-            if not(len(GeoParameters)==4): print "Error: trying to construct a non-ortho object but the 4 constitutive vertices are not given!"
+            if not(len(GeoParameters)==4): print("Error: trying to construct a non-ortho object but the 4 constitutive vertices are not given!")
             else :
                 Xmin = min([GeoParameters[i][0] for i in range(4)])
                 Xmax = max([GeoParameters[i][0] for i in range(4)])
@@ -69,7 +69,7 @@ class MacObject:
         self.MeshGroups = []
         self.CheckInterfaces()
         if 'auto' in MeshParameters : self.AutoParam()
-        if not(self.MeshPar[0]<0): self.Generate()
+        if isinstance(self.MeshPar[0], list) or not(self.MeshPar[0]<0): self.Generate()
         else :
             Config.ListObj.append(self)
             print("Aborting object creation\n ")
@@ -185,9 +185,11 @@ class MacObject:
         self.DirectionalMeshParams =  MeshPar
         self.MeshPar[0] = GenFunctions.CompatibilityTest(self)
 
+        if isinstance( self.MeshPar[0], list ):
+            return # OK
         if self.MeshPar[0] < 0 :
             Alarms.Message(4)
-            if self.MeshPar[0] == -1 : print ("Problem encountered with object(s) no. "+str(ObjectsInvolved))
+            if self.MeshPar[0] == -1 : print(("Problem encountered with object(s) no. "+str(ObjectsInvolved)))
             elif self.MeshPar[0] == -2 : print ("This object has no neighbours !!!")
 
     def Boundaries (self):
@@ -209,7 +211,7 @@ class MacObject:
         """
         PtCoor = self.PtCoor
         PtCoor.append(self.PtCoor[0])
-        if type(Direction) is str :
+        if isinstance(Direction, str) :
             Dir = { 'South'  : lambda : 0,
                     'North'  : lambda : 1,
                     'West'   : lambda : 2,
@@ -226,7 +228,7 @@ class MacObject:
         The interest in using this method is for non-orthogonal objects where the sides can be
         deviated from the orthogonal basis vectors
         """
-        if type(Direction) is str :
+        if isinstance(Direction, str) :
             Dir = { 'South'  : lambda : 0,
                     'North'  : lambda : 1,
                     'West'   : lambda : 2,
@@ -241,9 +243,9 @@ class MacObject:
         import GenFunctions, Config
 
         from salome.geom import geomBuilder
-        geompy = geomBuilder.New( Config.theStudy )
+        geompy = geomBuilder.New()
 
-        if type(Criterion) is str :
+        if isinstance(Criterion, str) :
             Crit = {'South'  : lambda : 0,
                     'North'  : lambda : 1,
                     'West'   : lambda : 2,
@@ -286,7 +288,7 @@ class MacObject:
         from itertools import combinations
         Boxes = []
         if self.Type == 'NonOrtho':
-            for combi in combinations(range(4),3):
+            for combi in combinations(list(range(4)),3):
                 Xmin = min([self.PtCoor[i][0] for i in combi])
                 Xmax = max([self.PtCoor[i][0] for i in combi])
                 Ymin = min([self.PtCoor[i][1] for i in combi])