Salome HOME
Correction because of 'geompyDC' refactoring.
[modules/smesh.git] / src / SMESH_SWIG / smeshBuilder.py
index 25bf8e9e0e1d0393af5ba052ecd1d4b30cc98277..78089201d2099facc7cdee6f100b041a1380e2c9 100644 (file)
@@ -259,15 +259,15 @@ def AssureGeomPublished(mesh, geom, name=''):
     return
 
 ## Return the first vertex of a geometrical edge by ignoring orientation
-def FirstVertexOnCurve(edge):
-    vv = geomBuilder.SubShapeAll( edge, geomBuilder.geomBuilder.ShapeType["VERTEX"])
+def FirstVertexOnCurve(mesh, edge):
+    vv = mesh.geompyD.SubShapeAll( edge, geomBuilder.geomBuilder.ShapeType["VERTEX"])
     if not vv:
         raise TypeError, "Given object has no vertices"
     if len( vv ) == 1: return vv[0]
-    v0   = geomBuilder.MakeVertexOnCurve(edge,0.)
-    xyz  = geomBuilder.PointCoordinates( v0 ) # coords of the first vertex
-    xyz1 = geomBuilder.PointCoordinates( vv[0] )
-    xyz2 = geomBuilder.PointCoordinates( vv[1] )
+    v0   = mesh.geompyD.MakeVertexOnCurve(edge,0.)
+    xyz  = mesh.geompyD.PointCoordinates( v0 ) # coords of the first vertex
+    xyz1 = mesh.geompyD.PointCoordinates( vv[0] )
+    xyz2 = mesh.geompyD.PointCoordinates( vv[1] )
     dist1, dist2 = 0,0
     for i in range(3):
         dist1 += abs( xyz[i] - xyz1[i] )
@@ -285,6 +285,7 @@ def FirstVertexOnCurve(edge):
 smeshInst = None
 engine = None
 doLcc = False
+created = False
 
 ## This class allows to create, load or manipulate meshes
 #  It has a set of methods to create load or copy meshes, to combine several meshes.
@@ -312,7 +313,7 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen):
         global engine
         global smeshInst
         global doLcc
-        #print "__new__", engine, smeshInst, doLcc
+        #print "==== __new__", engine, smeshInst, doLcc
 
         if smeshInst is None:
             # smesh engine is either retrieved from engine, or created
@@ -327,26 +328,30 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen):
                     # FindOrLoadComponent called:
                     # 1. CORBA resolution of server
                     # 2. the __new__ method is called again
-                    #print "smeshInst = lcc.FindOrLoadComponent ", engine, smeshInst, doLcc
+                    #print "==== smeshInst = lcc.FindOrLoadComponent ", engine, smeshInst, doLcc
                     smeshInst = salome.lcc.FindOrLoadComponent( "FactoryServer", "SMESH" )
             else:
                 # FindOrLoadComponent not called
                 if smeshInst is None:
                     # smeshBuilder instance is created from lcc.FindOrLoadComponent
-                    #print "smeshInst = super(smeshBuilder,cls).__new__(cls) ", engine, smeshInst, doLcc
+                    #print "==== smeshInst = super(smeshBuilder,cls).__new__(cls) ", engine, smeshInst, doLcc
                     smeshInst = super(smeshBuilder,cls).__new__(cls)
                 else:
                     # smesh engine not created: existing engine found
-                    #print "existing ", engine, smeshInst, doLcc
+                    #print "==== existing ", engine, smeshInst, doLcc
                     pass
-
+            #print "====1 ", smeshInst
             return smeshInst
 
+        #print "====2 ", smeshInst
         return smeshInst
 
     def __init__(self):
-        #print "__init__"
-        SMESH._objref_SMESH_Gen.__init__(self)
+        global created
+        #print "--------------- smeshbuilder __init__ ---", created
+        if not created:
+          created = True
+          SMESH._objref_SMESH_Gen.__init__(self)
 
     ## Dump component to the Python script
     #  This method overrides IDL function to allow default values for the parameters.