]> SALOME platform Git repositories - plugins/blsurfplugin.git/commitdiff
Salome HOME
Merge from BR_V7_periodicity 03/10/2013:
authorbourcier <bourcier>
Thu, 3 Oct 2013 09:14:13 +0000 (09:14 +0000)
committerbourcier <bourcier>
Thu, 3 Oct 2013 09:14:13 +0000 (09:14 +0000)
Adding periodicity into the BLSURF Paramaters dialog box

32 files changed:
doc/salome/examples/test_periodicity.py [new file with mode: 0644]
doc/salome/examples/test_periodicity_precad.py [new file with mode: 0644]
doc/salome/examples/test_periodicity_reflexion_advanced.py [new file with mode: 0644]
doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters.png
doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_advanced.png
doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_enforced_vertices.png
doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_periodicity.png [new file with mode: 0644]
doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_sizemap1.png
doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_sizemap2.png
doc/salome/gui/BLSURFPLUGIN/images/blsurf_periodicity_2D.png [new file with mode: 0644]
doc/salome/gui/BLSURFPLUGIN/images/blsurf_periodicity_reflexion.png [new file with mode: 0644]
doc/salome/gui/BLSURFPLUGIN/images/blsurf_periodicity_translation.png [new file with mode: 0644]
doc/salome/gui/BLSURFPLUGIN/input/blsurf_hypo.doc
doc/salome/gui/BLSURFPLUGIN/input/blsurfplugin_python_interface.doc
idl/BLSURFPlugin_Algorithm.idl
src/BLSURFPlugin/BLSURFPluginBuilder.py
src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx
src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx
src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx
src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx
src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx
src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx
src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx
src/GUI/BLSURFPluginGUI_HypothesisCreator.h
src/GUI/BLSURFPlugin_msg_en.ts
src/GUI/BLSURFPlugin_msg_fr.ts
tests/test_periodicity.py
tests/test_periodicity_2D.py
tests/test_periodicity_2D_precad.py
tests/test_periodicity_reflexion.py
tests/test_periodicity_reflexion_2D.py
tests/test_periodicity_reflexion_precad.py

diff --git a/doc/salome/examples/test_periodicity.py b/doc/salome/examples/test_periodicity.py
new file mode 100644 (file)
index 0000000..b6e5de4
--- /dev/null
@@ -0,0 +1,187 @@
+# -*- coding: utf-8 -*-
+
+import salome
+
+import GEOM
+from salome.geom import geomBuilder
+geompy = geomBuilder.New(salome.myStudy)
+
+import math
+
+simple = False
+
+r = 10
+dist = 10
+
+p1 = geompy.MakeVertex(0., 0., 0.)
+p2 = geompy.MakeVertex(100., 100., 100.)
+box = geompy.MakeBoxTwoPnt(p1, p2)
+geompy.addToStudy(box, "box")
+
+p3 = geompy.MakeVertex(25., 5., 25.)
+sphere1 = geompy.MakeSpherePntR(p3, 15.)
+geompy.addToStudy(sphere1, "sphere1")
+
+sphere1_trans = geompy.MakeTranslation(sphere1, 0, 100, 0)
+geompy.addToStudy(sphere1_trans, "sphere1_trans")
+
+sphere1_trans = geompy.MakeTranslation(sphere1, 0, 100, 0)
+geompy.addToStudy(sphere1_trans, "sphere1_trans")
+
+p4 = geompy.MakeVertex(5, 50, 90)
+sphere2 = geompy.MakeSpherePntR(p4, 20.)
+
+sphere2_trans = geompy.MakeTranslation(sphere2, 100, 0, 0)
+geompy.addToStudy(sphere2_trans, "sphere2_trans")
+
+sphere2_trans2 = geompy.MakeTranslation(sphere2, 0, 0, -100)
+geompy.addToStudy(sphere2_trans2, "sphere2_trans2")
+
+sphere2_trans3 = geompy.MakeTranslation(sphere2, 100, 0, -100)
+geompy.addToStudy(sphere2_trans3, "sphere2_trans3")
+
+if simple:
+    part = box
+else:
+    part = geompy.MakePartition([box], [sphere1, sphere1_trans, sphere2, sphere2_trans, sphere2_trans2, sphere2_trans3])
+geompy.addToStudy(part, "part")
+
+Vx = geompy.MakeVectorDXDYDZ(1, 0, 0)
+Vy = geompy.MakeVectorDXDYDZ(0, 1, 0)
+Vz = geompy.MakeVectorDXDYDZ(0, 0, 1)
+
+left_faces = geompy.GetShapesOnPlane(part, geompy.ShapeType["FACE"], Vy, GEOM.ST_ON)
+left = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+geompy.UnionList(left, left_faces)
+geompy.addToStudyInFather(part, left, "left")
+
+right_faces = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["FACE"], Vy, p2, GEOM.ST_ON)
+right = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+geompy.UnionList(right, right_faces)
+geompy.addToStudyInFather(part, right, "right")
+
+back_faces = geompy.GetShapesOnPlane(part, geompy.ShapeType["FACE"], Vx, GEOM.ST_ON)
+back = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+geompy.UnionList(back, back_faces)
+geompy.addToStudyInFather(part, back, "back")
+
+front_faces = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["FACE"], Vx, p2, GEOM.ST_ON)
+front = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+geompy.UnionList(front, front_faces)
+geompy.addToStudyInFather(part, front, "front")
+
+bottom_faces = geompy.GetShapesOnPlane(part, geompy.ShapeType["FACE"], Vz, GEOM.ST_ON)
+bottom = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+geompy.UnionList(bottom, bottom_faces)
+geompy.addToStudyInFather(part, bottom, "bottom")
+
+top_faces = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["FACE"], Vz, p2, GEOM.ST_ON)
+top = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+geompy.UnionList(top, top_faces)
+geompy.addToStudyInFather(part, top, "top")
+
+sources = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+geompy.UnionList(sources, left_faces)
+geompy.UnionList(sources, back_faces)
+geompy.UnionList(sources, top_faces)
+geompy.addToStudyInFather(part, sources, "sources")
+
+
+# Mesh
+# ====
+
+import SMESH
+from salome.smesh import smeshBuilder
+smesh = smeshBuilder.New(salome.myStudy)
+
+Mesh = smesh.Mesh(part, "Mesh")
+
+algo2d = Mesh.Triangle(algo=smeshBuilder.BLSURF)
+algo2d.SetGeometricMesh( 1 )
+algo2d.SetAngleMesh( 4 )
+algo2d.SetPhySize( 8 )
+algo2d.SetOptionValue( 'periodic_tolerance', '1e-2' )
+
+def proj_x(shape1):
+    shape2 = geompy.MakeTranslation(shape1, 100, 0., 0)
+    return shape2
+    
+def proj_y(shape1):
+    shape2 = geompy.MakeTranslation(shape1, 0, 100., 0)
+    return shape2
+
+def proj_z(shape1):
+    shape2 = geompy.MakeTranslation(shape1, 0, 0, 100.)
+    return shape2
+
+def AddAdvancedFacesPeriodicity(faces1, faces2, f_transf):
+    # Periodicity left/right
+    source_faces = geompy.SubShapeAll(faces1, geompy.ShapeType["FACE"])
+    i = 0
+    j = 0
+    k = 0
+    for source_face in source_faces:
+        geompy.addToStudyInFather(faces1, source_face, "source_face_%i"%i)
+        p_source = geompy.MakeVertexInsideFace(source_face)
+        p_target = f_transf(p_source)
+        target_face = geompy.GetFaceNearPoint(faces2, p_target)
+        geompy.addToStudyInFather(faces2, target_face, "target_face_%i"%i)
+        algo2d.AddFacePeriodicity(source_face, target_face)
+        i += 1
+        
+        source_edges = geompy.SubShapeAll(source_face, geompy.ShapeType["EDGE"])
+        for source_edge in source_edges:
+            geompy.addToStudyInFather(faces1, source_edge, "source_edge_%i"%(j))
+            p_source = geompy.MakeVertexOnCurve(source_edge, 0.5)
+            p_target = f_transf(p_source)
+            target_edge = geompy.GetEdgeNearPoint(faces2, p_target)
+            geompy.addToStudyInFather(faces2, target_edge, "target_edge_%i"%(j))
+            algo2d.AddEdgePeriodicity(source_face, source_edge, target_face, target_edge)
+            j += 1
+            
+            source_vertices = geompy.SubShapeAll(source_edge, geompy.ShapeType["VERTEX"])
+            for source_vertex in source_vertices:
+                geompy.addToStudyInFather(faces1, source_vertex, "source_vertex_%i"%(k))
+                target_vertex_tmp = f_transf(source_vertex)
+                target_vertex = geompy.GetSame(faces2, target_vertex_tmp)
+                geompy.addToStudyInFather(faces2, target_vertex, "target_vertex_%i"%(k))
+                algo2d.AddVertexPeriodicity(source_edge, source_vertex, target_edge, target_vertex)
+                k += 1
+    pass
+
+AddAdvancedFacesPeriodicity(back, front, proj_x)
+AddAdvancedFacesPeriodicity(left, right, proj_y)
+AddAdvancedFacesPeriodicity(bottom, top, proj_z)
+
+gr_left = Mesh.Group(left)
+gr_right = Mesh.Group(right)
+gr_front = Mesh.Group(front)
+gr_back = Mesh.Group(back)
+gr_bottom = Mesh.Group(bottom)
+gr_top = Mesh.Group(top)
+
+Mesh.Compute()
+
+left_translated = Mesh.TranslateObjectMakeMesh( gr_left, SMESH.DirStruct( SMESH.PointStruct ( 0, 100, 0 )), 0, 'left_translated' )
+front_translated = Mesh.TranslateObjectMakeMesh( gr_front, SMESH.DirStruct( SMESH.PointStruct ( -100, 0, 0 )), 0, 'front_translated' )
+bottom_translated = Mesh.TranslateObjectMakeMesh( gr_bottom, SMESH.DirStruct( SMESH.PointStruct ( 0, 0, 100 )), 0, 'bottom_translated' )
+
+def checkProjection(gr, mesh_translated, tol=1e-7):
+    name = gr.GetName() + "_" + mesh_translated.GetName().split("_")[0]
+    mesh_source = smesh.CopyMesh(gr, gr.GetName())
+    mesh_check = smesh.Concatenate([mesh_source.GetMesh(), mesh_translated.GetMesh()], 0, name=name)
+    ll_coincident_nodes = mesh_check.FindCoincidentNodes(tol)
+    coincident_nodes = [item for sublist in ll_coincident_nodes for item in sublist]
+    mesh_check.MakeGroupByIds("coincident_nodes", SMESH.NODE, coincident_nodes)
+    mesh_nodes = mesh_check.GetNodesId()
+    if len(ll_coincident_nodes) != mesh_translated.NbNodes():
+        non_coincident_nodes = list(set(mesh_nodes) - set(coincident_nodes))
+        mesh_check.MakeGroupByIds("non_coincident_nodes", SMESH.NODE, non_coincident_nodes)
+        raise Exception("Projection failed for %s"%name)
+        
+checkProjection(gr_right, left_translated)
+checkProjection(gr_back, front_translated)
+checkProjection(gr_top, bottom_translated)
+
+salome.sg.updateObjBrowser(0)
+
diff --git a/doc/salome/examples/test_periodicity_precad.py b/doc/salome/examples/test_periodicity_precad.py
new file mode 100644 (file)
index 0000000..8a10dda
--- /dev/null
@@ -0,0 +1,140 @@
+# -*- coding: utf-8 -*-
+
+import salome
+import math
+
+import GEOM
+from salome.geom import geomBuilder
+geompy = geomBuilder.New(salome.myStudy)
+
+simple = False
+
+r = 10
+dist = 10
+
+p1 = geompy.MakeVertex(0., 0., 0.)
+p2 = geompy.MakeVertex(100., 100., 100.)
+box = geompy.MakeBoxTwoPnt(p1, p2)
+geompy.addToStudy(box, "box")
+
+p3 = geompy.MakeVertex(25., 5., 25.)
+sphere1 = geompy.MakeSpherePntR(p3, 15.)
+geompy.addToStudy(sphere1, "sphere1")
+
+sphere1_trans = geompy.MakeTranslation(sphere1, 0, 100, 0)
+geompy.addToStudy(sphere1_trans, "sphere1_trans")
+
+sphere1_trans = geompy.MakeTranslation(sphere1, 0, 100, 0)
+geompy.addToStudy(sphere1_trans, "sphere1_trans")
+
+p4 = geompy.MakeVertex(5, 50, 90)
+sphere2 = geompy.MakeSpherePntR(p4, 20.)
+
+sphere2_trans = geompy.MakeTranslation(sphere2, 100, 0, 0)
+geompy.addToStudy(sphere2_trans, "sphere2_trans")
+
+sphere2_trans2 = geompy.MakeTranslation(sphere2, 0, 0, -100)
+geompy.addToStudy(sphere2_trans2, "sphere2_trans2")
+
+sphere2_trans3 = geompy.MakeTranslation(sphere2, 100, 0, -100)
+geompy.addToStudy(sphere2_trans3, "sphere2_trans3")
+
+if simple:
+    part = box
+else:
+    part = geompy.MakePartition([box], [sphere1, sphere1_trans, sphere2, sphere2_trans, sphere2_trans2, sphere2_trans3])
+geompy.addToStudy(part, "part")
+
+Vx = geompy.MakeVectorDXDYDZ(1, 0, 0)
+Vy = geompy.MakeVectorDXDYDZ(0, 1, 0)
+Vz = geompy.MakeVectorDXDYDZ(0, 0, 1)
+
+left_faces = geompy.GetShapesOnPlane(part, geompy.ShapeType["FACE"], Vy, GEOM.ST_ON)
+left = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+geompy.UnionList(left, left_faces)
+geompy.addToStudyInFather(part, left, "left")
+
+right_faces = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["FACE"], Vy, p2, GEOM.ST_ON)
+right = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+geompy.UnionList(right, right_faces)
+geompy.addToStudyInFather(part, right, "right")
+
+back_faces = geompy.GetShapesOnPlane(part, geompy.ShapeType["FACE"], Vx, GEOM.ST_ON)
+back = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+geompy.UnionList(back, back_faces)
+geompy.addToStudyInFather(part, back, "back")
+
+front_faces = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["FACE"], Vx, p2, GEOM.ST_ON)
+front = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+geompy.UnionList(front, front_faces)
+geompy.addToStudyInFather(part, front, "front")
+
+bottom_faces = geompy.GetShapesOnPlane(part, geompy.ShapeType["FACE"], Vz, GEOM.ST_ON)
+bottom = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+geompy.UnionList(bottom, bottom_faces)
+geompy.addToStudyInFather(part, bottom, "bottom")
+
+top_faces = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["FACE"], Vz, p2, GEOM.ST_ON)
+top = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+geompy.UnionList(top, top_faces)
+geompy.addToStudyInFather(part, top, "top")
+
+sources = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+geompy.UnionList(sources, left_faces)
+geompy.UnionList(sources, back_faces)
+geompy.UnionList(sources, top_faces)
+geompy.addToStudyInFather(part, sources, "sources")
+
+# Mesh
+# ====
+
+import SMESH
+from salome.smesh import smeshBuilder
+smesh = smeshBuilder.New(salome.myStudy)
+
+Mesh = smesh.Mesh(part, "Mesh")
+
+algo2d = Mesh.Triangle(algo=smeshBuilder.BLSURF)
+algo2d.SetGeometricMesh( 1 )
+algo2d.SetAngleMesh( 4 )
+algo2d.SetPhySize( 8 )
+algo2d.SetVerbosity(1)
+
+# Periodicity
+#algo2d.SetPreCADOptionValue("periodic_tolerance", "1e-2")
+algo2d.AddPreCadFacesPeriodicity(left, right)
+algo2d.AddPreCadFacesPeriodicity(front, back)
+algo2d.AddPreCadFacesPeriodicity(bottom, top)
+
+gr_left = Mesh.Group(left)
+gr_right = Mesh.Group(right)
+gr_front = Mesh.Group(front)
+gr_back = Mesh.Group(back)
+gr_bottom = Mesh.Group(bottom)
+gr_top = Mesh.Group(top)
+
+Mesh.Compute()
+
+left_translated = Mesh.TranslateObjectMakeMesh( gr_left, SMESH.DirStruct( SMESH.PointStruct ( 0, 100, 0 )), 0, 'left_translated' )
+front_translated = Mesh.TranslateObjectMakeMesh( gr_front, SMESH.DirStruct( SMESH.PointStruct ( -100, 0, 0 )), 0, 'front_translated' )
+bottom_translated = Mesh.TranslateObjectMakeMesh( gr_bottom, SMESH.DirStruct( SMESH.PointStruct ( 0, 0, 100 )), 0, 'bottom_translated' )
+
+def checkProjection(gr, mesh_translated, tol=1e-7):
+    name = gr.GetName() + "_" + mesh_translated.GetName().split("_")[0]
+    mesh_source = smesh.CopyMesh(gr, gr.GetName())
+    mesh_check = smesh.Concatenate([mesh_source.GetMesh(), mesh_translated.GetMesh()], 0, name=name)
+    ll_coincident_nodes = mesh_check.FindCoincidentNodes(tol)
+    coincident_nodes = [item for sublist in ll_coincident_nodes for item in sublist]
+    mesh_check.MakeGroupByIds("coincident_nodes", SMESH.NODE, coincident_nodes)
+    mesh_nodes = mesh_check.GetNodesId()
+    if len(ll_coincident_nodes) != mesh_translated.NbNodes():
+        non_coincident_nodes = list(set(mesh_nodes) - set(coincident_nodes))
+        mesh_check.MakeGroupByIds("non_coincident_nodes", SMESH.NODE, non_coincident_nodes)
+        raise Exception("Projection failed for %s"%name)
+        
+checkProjection(gr_right, left_translated)
+checkProjection(gr_back, front_translated)
+checkProjection(gr_top, bottom_translated)
+
+salome.sg.updateObjBrowser(0)
+
diff --git a/doc/salome/examples/test_periodicity_reflexion_advanced.py b/doc/salome/examples/test_periodicity_reflexion_advanced.py
new file mode 100644 (file)
index 0000000..2ff31ad
--- /dev/null
@@ -0,0 +1,124 @@
+# -*- coding: utf-8 -*-
+
+import salome
+
+import GEOM
+from salome.geom import geomBuilder
+geompy = geomBuilder.New(salome.myStudy)
+
+import math
+
+simple = False
+
+r = 10
+dist = 10
+
+p1 = geompy.MakeVertex(0., 0., 0.)
+p2 = geompy.MakeVertex(100., 100., 100.)
+box = geompy.MakeBoxTwoPnt(p1, p2)
+geompy.addToStudy(box, "box")
+
+p3 = geompy.MakeVertex(25., 5., 25.)
+sphere1 = geompy.MakeSpherePntR(p3, 15.)
+geompy.addToStudy(sphere1, "sphere1")
+
+Vx = geompy.MakeVectorDXDYDZ(1, 0, 0)
+Vy = geompy.MakeVectorDXDYDZ(0, 1, 0)
+Vz = geompy.MakeVectorDXDYDZ(0, 0, 1)
+
+p4 = geompy.MakeVertex(100., 0., 0.)
+axe = geompy.MakePrismVecH(p4, Vz, 1)
+geompy.addToStudy(axe, "axe")
+
+sphere1_rota = geompy.MakeRotation(sphere1, axe, -math.pi/2.)
+geompy.addToStudy(sphere1_rota, "sphere1_rota")
+
+part = geompy.MakePartition([box], [sphere1, sphere1_rota])
+geompy.addToStudy(part, "part")
+
+left_faces = geompy.GetShapesOnPlane(part, geompy.ShapeType["FACE"], Vy, GEOM.ST_ON)
+left = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+geompy.UnionList(left, left_faces)
+geompy.addToStudyInFather(part, left, "left")
+
+right_faces = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["FACE"], Vy, p2, GEOM.ST_ON)
+right = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+geompy.UnionList(right, right_faces)
+geompy.addToStudyInFather(part, right, "right")
+
+back_faces = geompy.GetShapesOnPlane(part, geompy.ShapeType["FACE"], Vx, GEOM.ST_ON)
+back = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+geompy.UnionList(back, back_faces)
+geompy.addToStudyInFather(part, back, "back")
+
+front_faces = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["FACE"], Vx, p2, GEOM.ST_ON)
+front = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+geompy.UnionList(front, front_faces)
+geompy.addToStudyInFather(part, front, "front")
+
+bottom_faces = geompy.GetShapesOnPlane(part, geompy.ShapeType["FACE"], Vz, GEOM.ST_ON)
+bottom = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+geompy.UnionList(bottom, bottom_faces)
+geompy.addToStudyInFather(part, bottom, "bottom")
+
+top_faces = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["FACE"], Vz, p2, GEOM.ST_ON)
+top = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+geompy.UnionList(top, top_faces)
+geompy.addToStudyInFather(part, top, "top")
+
+sources = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+geompy.UnionList(sources, left_faces)
+geompy.UnionList(sources, back_faces)
+geompy.UnionList(sources, top_faces)
+geompy.addToStudyInFather(part, sources, "sources")
+
+
+# Mesh
+# ====
+
+import SMESH
+from salome.smesh import smeshBuilder
+smesh = smeshBuilder.New(salome.myStudy)
+
+Mesh = smesh.Mesh(part, "Mesh")
+
+algo2d = Mesh.Triangle(algo=smeshBuilder.BLSURF)
+algo2d.SetGeometricMesh( 1 )
+algo2d.SetAngleMesh( 4 )
+algo2d.SetPhySize( 8 )
+algo2d.SetOptionValue( 'periodic_tolerance', '1e-2' )
+
+def rota_z(shape1):
+    shape2 = geompy.MakeRotation(shape1, axe, -math.pi/2)
+    return shape2
+
+algo2d.AddAdvancedFacesPeriodicity(left, front, rota_z)
+
+gr_left = Mesh.Group(left)
+gr_right = Mesh.Group(right)
+gr_front = Mesh.Group(front)
+gr_back = Mesh.Group(back)
+gr_bottom = Mesh.Group(bottom)
+gr_top = Mesh.Group(top)
+
+Mesh.Compute()
+
+left_rotated = Mesh.RotateObjectMakeMesh( gr_left, axe, -math.pi/2, NewMeshName='left_rotated' )
+
+def checkProjection(gr, mesh_translated, tol=1e-7):
+    name = gr.GetName() + "_" + mesh_translated.GetName().split("_")[0]
+    mesh_source = smesh.CopyMesh(gr, gr.GetName())
+    mesh_check = smesh.Concatenate([mesh_source.GetMesh(), mesh_translated.GetMesh()], 0, name=name)
+    ll_coincident_nodes = mesh_check.FindCoincidentNodes(tol)
+    coincident_nodes = [item for sublist in ll_coincident_nodes for item in sublist]
+    mesh_check.MakeGroupByIds("coincident_nodes", SMESH.NODE, coincident_nodes)
+    mesh_nodes = mesh_check.GetNodesId()
+    if len(ll_coincident_nodes) != mesh_translated.NbNodes():
+        non_coincident_nodes = list(set(mesh_nodes) - set(coincident_nodes))
+        mesh_check.MakeGroupByIds("non_coincident_nodes", SMESH.NODE, non_coincident_nodes)
+        raise Exception("Projection failed for %s"%name)
+        
+checkProjection(gr_front, left_rotated)
+
+salome.sg.updateObjBrowser(0)
+
index 82c7e90a83b55b84fb312e6f0fa19dfd2d368c77..fb44312b90df3b0939f47536006ada50e3295c27 100644 (file)
Binary files a/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters.png and b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters.png differ
index 1f2b0eebcdb1d7a016abcac6a3009bd47672760d..b3cf06322433943e04547f05e2238af7d5633b26 100644 (file)
Binary files a/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_advanced.png and b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_advanced.png differ
index 33996a623ff5e9239418ca5442c9d5caa10f2672..55c871433921dea057f45cd3511243bfc5827865 100644 (file)
Binary files a/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_enforced_vertices.png and b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_enforced_vertices.png differ
diff --git a/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_periodicity.png b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_periodicity.png
new file mode 100644 (file)
index 0000000..3c8807c
Binary files /dev/null and b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_periodicity.png differ
index 4ae88c895024bdc85f0bf8c3b95e3dce6f4c4660..cb095f7b7ec1108533f18da2aa2e01711d8d6a2a 100644 (file)
Binary files a/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_sizemap1.png and b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_sizemap1.png differ
index e5e000d3211289e3b464c389154397b0e71f3429..809ef6add569ba21b7bebaa877ac29d4749ae17f 100644 (file)
Binary files a/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_sizemap2.png and b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_sizemap2.png differ
diff --git a/doc/salome/gui/BLSURFPLUGIN/images/blsurf_periodicity_2D.png b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_periodicity_2D.png
new file mode 100644 (file)
index 0000000..210a213
Binary files /dev/null and b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_periodicity_2D.png differ
diff --git a/doc/salome/gui/BLSURFPLUGIN/images/blsurf_periodicity_reflexion.png b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_periodicity_reflexion.png
new file mode 100644 (file)
index 0000000..4b2bc8c
Binary files /dev/null and b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_periodicity_reflexion.png differ
diff --git a/doc/salome/gui/BLSURFPLUGIN/images/blsurf_periodicity_translation.png b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_periodicity_translation.png
new file mode 100644 (file)
index 0000000..0001bec
Binary files /dev/null and b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_periodicity_translation.png differ
index 481510c14696430db33aa7bff661aca9768a0f88..a4e77ada817b0dc63037ea86afb9bbd6cd3efee8 100644 (file)
@@ -357,6 +357,68 @@ A group can optionnaly be defined on those enforced vertices.
 
 \ref blsurf_top "Back to top"
 
+
+\section blsurf_periodicity Periodicity
+
+\subsection periodicity_introduction Introduction
+
+Periodicity is used to have the same discretization on two faces (in 3D) or two edges (in 2D).
+This is useful for instance for a Representative Volume Element so that the translated meshes share the same nodes on the common faces.
+
+In GUI, periodicity association uses PreCAD (optional BLSURF add-on). Be sure to have a PreCAD license to be able to use it. Otherwise, use \ref periodicity_tui_basic_api_usage "the basic API in TUI" or the \ref periodicity_tui_advanced_api_usage "the advanced API in TUI".
+
+\image html blsurf_periodicity_translation.png "Two periodic faces (translation)"
+
+\image html blsurf_periodicity_reflexion.png "Two periodic faces (reflexion)"
+
+\image html blsurf_periodicity_2D.png "Associations of edges in 2D (both red edges are associated with each other)"
+
+\subsection periodicity_gui_usage GUI usage
+
+\image html blsurf_parameters_periodicity.png
+
+The periodicity association can be defined:
+
+- on 2 groups of faces (in 3D)
+- on 2 groups of edges (in 2D)
+
+If the transformation is a translation, PreCAD makes the periodicity association with only this information.
+
+Otherwise, for instance a rotation, the user has to define 3 non-colinear vertices and their image by the transformation.
+
+\subsection periodicity_tui_precad_usage TUI PreCAD usage
+
+The two methods to define periodicity with PreCAD are:
+- BLSURFPluginBuilder.BLSURF_Algorithm.AddPreCadFacesPeriodicity 
+- BLSURFPluginBuilder.BLSURF_Algorithm.AddPreCadEdgesPeriodicity
+
+List of source and target vertices to define a transformation are optional.
+
+\sa Sample TUI Script of the definition of BLSurf periodicity \ref tui_blsurf_periodicity_preCAD "using preCAD".
+
+\subsection periodicity_tui_basic_api_usage TUI Basic API usage
+
+In the CADSurf basic API, only available in TUI, the periodicity must be defined face by face, edge by edge and vertex by vertex.
+
+The methods are:
+- BLSURFPluginBuilder.BLSURF_Algorithm.AddFacePeriodicity
+- BLSURFPluginBuilder.BLSURF_Algorithm.AddEdgePeriodicity
+- BLSURFPluginBuilder.BLSURF_Algorithm.AddEdgePeriodicityWithoutFaces
+- BLSURFPluginBuilder.BLSURF_Algorithm.AddVertexPeriodicity
+
+Sample TUI Script of the definition of BLSurf periodicity \ref tui_blsurf_periodicity_basic "using basic API (without preCAD)".
+
+\subsection periodicity_tui_advanced_api_usage TUI Advanced API usage
+
+To ease the periodicity description, the basic API methods can be called through two advanced methods, given two geom groups and a python geom transformation:
+
+- BLSURFPluginBuilder.BLSURF_Algorithm.AddAdvancedFacesPeriodicity (in 3D)
+- BLSURFPluginBuilder.BLSURF_Algorithm.AddAdvancedEdgesPeriodicity (in 2D)
+
+Sample TUI Script of the definition of BLSurf periodicity \ref tui_blsurf_periodicity_advanced "using advanced API (without preCAD)".
+
+\ref blsurf_top "Back to top"
+
 \section blsurf_limitations Limitations
 
 Currently BLSURF plugin has the following limitations.
index f6f83d412ed5551a41128c10a37a394bcc7f573e..f09654f35fd310d68feca3ce906d5abbc3d543b5 100644 (file)
@@ -16,4 +16,16 @@ Below you can see an example of usage of the BLSURFPluginBuilder Python API for
 <h2>Example of mesh generation with BLSurf algorithm:</h2>
 \tui_script{blsurfdemo.py}
 
+\anchor tui_blsurf_periodicity_preCAD
+<h2>Example of periodicity definition with preCAD</h2>
+\tui_script{test_periodicity_precad.py}
+
+\anchor tui_blsurf_periodicity_basic
+<h2>Example of basic periodicity definition (without preCAD)</h2>
+\tui_script{test_periodicity.py}
+
+\anchor tui_blsurf_periodicity_advanced
+<h2>Example of advanced periodicity definition (without preCAD)</h2>
+\tui_script{test_periodicity_reflexion_advanced.py}
+
 */
index fe664b1404601b4b2f62c2b9361615ae23b61d91..79b150dd0370246090b34c938dcc17f2fec868b3 100644 (file)
@@ -110,6 +110,16 @@ module BLSURFPlugin
   };
   typedef sequence<TAttractorParams> TAttParamsMap;
   
+  // Periodicity
+  struct TPreCadPeriodicity {
+    TEntry shape1Entry;
+    TEntry shape2Entry;
+    TEntryList theSourceVerticesEntries;
+    TEntryList theTargetVerticesEntries;
+  };
+  
+  typedef sequence<TPreCadPeriodicity> TPeriodicityList;
+  
   /*!
    * BLSURFPlugin_BLSURF: interface of BLSURF algorithm
    */
@@ -431,15 +441,19 @@ module BLSURFPlugin
     // PERIODICITY       //
     ///////////////////////
 
+    void ClearPreCadPeriodicityVectors();
     void AddPreCadFacesPeriodicity(in GEOM::GEOM_Object theFace1, in GEOM::GEOM_Object theFace2) raises (SALOME::SALOME_Exception);
     void AddPreCadFacesPeriodicityWithVertices(in GEOM::GEOM_Object theFace1, in GEOM::GEOM_Object theFace2, in GEOM::ListOfGO theSourceVertices, in GEOM::ListOfGO theTargetVertices) raises (SALOME::SALOME_Exception);
+    void AddPreCadFacesPeriodicityEntry(in TEntry theFace1, in TEntry theFace2, in TEntryList theSourceVertices, in TEntryList theTargetVertices)  raises (SALOME::SALOME_Exception);
     void AddPreCadEdgesPeriodicity(in GEOM::GEOM_Object theEdge1, in GEOM::GEOM_Object theEdge2) raises (SALOME::SALOME_Exception);
     void AddPreCadEdgesPeriodicityWithVertices(in GEOM::GEOM_Object theEdge1, in GEOM::GEOM_Object theEdge2, in GEOM::ListOfGO theSourceVertices, in GEOM::ListOfGO theTargetVertices) raises (SALOME::SALOME_Exception);
+    void AddPreCadEdgesPeriodicityEntry(in TEntry theEdge1, in TEntry theEdge2, in TEntryList theSourceVertices, in TEntryList theTargetVertices)  raises (SALOME::SALOME_Exception);
     void AddFacePeriodicity(in GEOM::GEOM_Object theFace1, in GEOM::GEOM_Object theFace2) raises (SALOME::SALOME_Exception);
     void AddEdgePeriodicity(in GEOM::GEOM_Object theFace1, in GEOM::GEOM_Object theEdge1, in GEOM::GEOM_Object theFace2, in GEOM::GEOM_Object theEdge2, in long edge_orientation) raises (SALOME::SALOME_Exception);
     void AddEdgePeriodicityWithoutFaces(in GEOM::GEOM_Object theEdge1, in GEOM::GEOM_Object theEdge2, in long edge_orientation) raises (SALOME::SALOME_Exception);
     void AddVertexPeriodicity(in GEOM::GEOM_Object theEdge1, in GEOM::GEOM_Object theVertex1, in GEOM::GEOM_Object theEdge2, in GEOM::GEOM_Object theVertex2) raises (SALOME::SALOME_Exception);
-    
+    TPeriodicityList GetPreCadFacesPeriodicityVector();
+    TPeriodicityList GetPreCadEdgesPeriodicityVector();
     ///////////////////////
 
     /*!
index 7754191c57702d038f22d7f1ee8c9c267bf1bacb..5617b2dce488f71bc60ba2c2dd2b8c69ade3a6bf 100644 (file)
@@ -85,6 +85,7 @@ class BLSURF_Algorithm(Mesh_Algorithm):
       print "Warning: BLSURFPlugin module unavailable"
     self.Create(mesh, geom, BLSURF, "libBLSURFEngine.so")
     self.params=None
+    self.geompyD = mesh.geompyD
     #self.SetPhysicalMesh() - PAL19680
     pass
 
@@ -512,6 +513,77 @@ class BLSURF_Algorithm(Mesh_Algorithm):
     self.Parameters().AddVertexPeriodicity(theEdge1, theVertex1, theEdge2, theVertex2)
     pass
 
+  ## Define periodicity between two groups of faces, given a transformation function.
+  #  This uses the basic BLSURF API for each face, each edge, and each vertex.
+  #  @param theFace1 : GEOM face (or group, compound) to associate with theFace2
+  #  @param theFace2 : GEOM face (or group, compound) associated with theFace1
+  #  @param f_transf : python function defining the transformation between an object of theFace1
+  # into an object of theFace2
+  def AddAdvancedFacesPeriodicity(self, theFace1, theFace2, f_transf):
+    source_faces = self.geompyD.SubShapeAll(theFace1, self.geompyD.ShapeType["FACE"])
+    i = 0
+    j = 0
+    k = 0
+    for source_face in source_faces:
+      self.geompyD.addToStudyInFather(theFace1, source_face, "source_face_%i"%i)
+      p_source = self.geompyD.MakeVertexInsideFace(source_face)
+      p_target = f_transf(p_source)
+      target_face = self.geompyD.GetFaceNearPoint(theFace2, p_target)
+      self.geompyD.addToStudyInFather(theFace2, target_face, "target_face_%i"%i)
+      self.AddFacePeriodicity(source_face, target_face)
+      i += 1
+      
+      source_edges = self.geompyD.SubShapeAll(source_face, self.geompyD.ShapeType["EDGE"])
+      for source_edge in source_edges:
+        self.geompyD.addToStudyInFather(theFace1, source_edge, "source_edge_%i"%(j))
+        p_source = self.geompyD.MakeVertexOnCurve(source_edge, 0.5)
+        p_target = f_transf(p_source)
+        target_edge = self.geompyD.GetEdgeNearPoint(theFace2, p_target)
+        self.geompyD.addToStudyInFather(theFace2, target_edge, "target_edge_%i"%(j))
+        self.AddEdgePeriodicity(source_face, source_edge, target_face, target_edge)
+        j += 1
+        
+        source_vertices = self.geompyD.SubShapeAll(source_edge, self.geompyD.ShapeType["VERTEX"])
+        for source_vertex in source_vertices:
+          self.geompyD.addToStudyInFather(theFace1, source_vertex, "source_vertex_%i"%(k))
+          target_vertex_tmp = f_transf(source_vertex)
+          target_vertex = self.geompyD.GetSame(theFace2, target_vertex_tmp)
+          self.geompyD.addToStudyInFather(theFace2, target_vertex, "target_vertex_%i"%(k))
+          self.AddVertexPeriodicity(source_edge, source_vertex, target_edge, target_vertex)
+          k += 1
+      pass
+
+  ## Define periodicity between two groups of edges, without faces, given a transformation function.
+  #  This uses the basic BLSURF API for each edge and each vertex.
+  #  @param theFace1 : GEOM edge (or group, compound) to associate with theEdge2
+  #  @param theFace2 : GEOM edge (or group, compound) associated with theEdge1
+  #  @param f_transf : python function defining the transformation between an object of theEdge1
+  # into an object of theFace2
+  def AddAdvancedEdgesPeriodicity(self, theEdge1, theEdge2, f_transf):
+    source_edges = self.geompyD.SubShapeAll(theEdge1, self.geompyD.ShapeType["EDGE"])
+    j = 0
+    k = 0
+    for source_edge in source_edges:
+      self.geompyD.addToStudyInFather(theEdge1, source_edge, "source_edge_%i"%j)
+      p_source = self.geompyD.MakeVertexOnCurve(source_edge, 0.5)
+      p_target = f_transf(p_source)
+      target_edge = self.geompyD.GetEdgeNearPoint(theEdge2, p_target)
+      self.geompyD.addToStudyInFather(theEdge2, target_edge, "target_edge_%i"%j)
+      self.AddEdgePeriodicityWithoutFaces(source_edge, target_edge)
+      
+      j += 1
+      
+      source_vertices = self.geompyD.SubShapeAll(source_edge, self.geompyD.ShapeType["VERTEX"])
+      for source_vertex in source_vertices:
+        self.geompyD.addToStudyInFather(theEdge1, source_vertex, "source_vertex_%i"%k)
+        target_vertex_tmp = self.geompyD.MakeTranslation(source_vertex, 10, 0., 0)
+        target_vertex_tmp = f_transf(source_vertex)
+        target_vertex = self.geompyD.GetSame(theEdge2, target_vertex_tmp)
+        self.geompyD.addToStudyInFather(theEdge2, target_vertex, "target_vertex_%i"%k)
+        self.AddVertexPeriodicity(source_edge, source_vertex, target_edge, target_vertex)
+        
+        k += 1
+    pass
 
   #=====================
   # Obsolete methods
index 8dcdb4453668771060148f750be318278d7b7d88..f2157fbc4626d96c5bc2d3f09c584dfb0f93af28 100644 (file)
@@ -716,6 +716,17 @@ BLSURFPlugin_BLSURF::TListOfIDs _getSubShapeIDsInMainShape(TopoDS_Shape theMainS
   return face_ids;
 }
 
+void BLSURFPlugin_BLSURF::addCoordsFromVertices(const std::vector<std::string> &theVerticesEntries, std::vector<double> &theVerticesCoords)
+{
+  for (std::vector<std::string>::const_iterator it = theVerticesEntries.begin(); it != theVerticesEntries.end(); it++)
+    {
+      BLSURFPlugin_Hypothesis::TEntry theVertexEntry = *it;
+      MESSAGE("Vertex entry " << theVertexEntry);
+      addCoordsFromVertex(theVertexEntry, theVerticesCoords);
+    }
+}
+
+
 void BLSURFPlugin_BLSURF::addCoordsFromVertex(BLSURFPlugin_Hypothesis::TEntry theVertexEntry, std::vector<double> &theVerticesCoords)
 {
   if (theVertexEntry!="")
@@ -749,12 +760,14 @@ void BLSURFPlugin_BLSURF::createPreCadFacesPeriodicity(TopoDS_Shape theGeomShape
   preCadFacesPeriodicityIDs.shape1IDs = theFace1_ids;
   preCadFacesPeriodicityIDs.shape2IDs = theFace2_ids;
 
-  for (size_t i = 0; i<preCadPeriodicity.theSourceVerticesEntries.size(); i++)
-    addCoordsFromVertex(preCadPeriodicity.theSourceVerticesEntries[i], preCadFacesPeriodicityIDs.theSourceVerticesCoords);
+  MESSAGE("preCadPeriodicity.theSourceVerticesEntries.size(): " << preCadPeriodicity.theSourceVerticesEntries.size());
+  MESSAGE("preCadPeriodicity.theTargetVerticesEntries.size(): " << preCadPeriodicity.theTargetVerticesEntries.size());
 
-  for (size_t i = 0; i<preCadPeriodicity.theTargetVerticesEntries.size(); i++)
-    addCoordsFromVertex(preCadPeriodicity.theTargetVerticesEntries[i], preCadFacesPeriodicityIDs.theTargetVerticesCoords);
+  addCoordsFromVertices(preCadPeriodicity.theSourceVerticesEntries, preCadFacesPeriodicityIDs.theSourceVerticesCoords);
+  addCoordsFromVertices(preCadPeriodicity.theTargetVerticesEntries, preCadFacesPeriodicityIDs.theTargetVerticesCoords);
 
+  MESSAGE("preCadFacesPeriodicityIDs.theSourceVerticesCoords.size(): " << preCadFacesPeriodicityIDs.theSourceVerticesCoords.size());
+  MESSAGE("preCadFacesPeriodicityIDs.theTargetVerticesCoords.size(): " << preCadFacesPeriodicityIDs.theTargetVerticesCoords.size());
 
   _preCadFacesIDsPeriodicityVector.push_back(preCadFacesPeriodicityIDs);
   MESSAGE("_preCadFacesIDsPeriodicityVector.size() = " << _preCadFacesIDsPeriodicityVector.size());
@@ -777,12 +790,8 @@ void BLSURFPlugin_BLSURF::createPreCadEdgesPeriodicity(TopoDS_Shape theGeomShape
   preCadEdgesPeriodicityIDs.shape1IDs = theEdge1_ids;
   preCadEdgesPeriodicityIDs.shape2IDs = theEdge2_ids;
 
-  for (size_t i = 0; i<preCadPeriodicity.theSourceVerticesEntries.size(); i++)
-    addCoordsFromVertex(preCadPeriodicity.theSourceVerticesEntries[i], preCadEdgesPeriodicityIDs.theSourceVerticesCoords);
-
-  for (size_t i = 0; i<preCadPeriodicity.theTargetVerticesEntries.size(); i++)
-    addCoordsFromVertex(preCadPeriodicity.theTargetVerticesEntries[i], preCadEdgesPeriodicityIDs.theTargetVerticesCoords);
-
+  addCoordsFromVertices(preCadPeriodicity.theSourceVerticesEntries, preCadEdgesPeriodicityIDs.theSourceVerticesCoords);
+  addCoordsFromVertices(preCadPeriodicity.theTargetVerticesEntries, preCadEdgesPeriodicityIDs.theTargetVerticesCoords);
 
   _preCadEdgesIDsPeriodicityVector.push_back(preCadEdgesPeriodicityIDs);
   MESSAGE("_preCadEdgesIDsPeriodicityVector.size() = " << _preCadEdgesIDsPeriodicityVector.size());
index d3d5eee606d96b70ac2954c887482e0bb3b63ad6..5948bb185d9584dbe93361becd3174043373a06d 100644 (file)
@@ -151,6 +151,7 @@ class BLSURFPlugin_BLSURF: public SMESH_2D_Algo {
                    const char *       option_value);
 
     TopoDS_Shape entryToShape(std::string entry);
+    void addCoordsFromVertices(const std::vector<std::string> &theVerticesEntries, std::vector<double> &theVerticesCoords);
     void addCoordsFromVertex(BLSURFPlugin_Hypothesis::TEntry theVertexEntry, std::vector<double> &theVerticesCoords);
     void createEnforcedVertexOnFace(TopoDS_Shape FaceShape, BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList);
     void createPreCadFacesPeriodicity(TopoDS_Shape theGeomShape, const BLSURFPlugin_Hypothesis::TPreCadPeriodicity &preCadPeriodicity);
index 94a2695686484e5db790ac7a23ac0761df173533..50716f7aa3c39c40f1959b7a98e628669eaa1697 100644 (file)
@@ -1235,11 +1235,20 @@ BLSURFPlugin_Hypothesis::TVerticesPeriodicityVector BLSURFPlugin_Hypothesis::Get
   return hyp ? hyp->_GetVerticesPeriodicityVector() : GetDefaultVerticesPeriodicityVector();
 }
 
+//=======================================================================
+//function : ClearAllEnforcedVertices
+//=======================================================================
+void BLSURFPlugin_Hypothesis::ClearPreCadPeriodicityVectors() {
+  _preCadFacesPeriodicityVector.clear();
+  _preCadEdgesPeriodicityVector.clear();
+  NotifySubMeshesHypothesisModification();
+}
+
 //=======================================================================
 //function : AddPreCadFacesPeriodicity
 //=======================================================================
 void BLSURFPlugin_Hypothesis::AddPreCadFacesPeriodicity(TEntry theFace1Entry, TEntry theFace2Entry,
-    vector<TEntry> &theSourceVerticesEntries, vector<TEntry> &theTargetVerticesEntries) {
+    vector<string> &theSourceVerticesEntries, vector<string> &theTargetVerticesEntries) {
 
   TPreCadPeriodicity preCadFacesPeriodicity;
   preCadFacesPeriodicity.shape1Entry = theFace1Entry;
@@ -1256,7 +1265,7 @@ void BLSURFPlugin_Hypothesis::AddPreCadFacesPeriodicity(TEntry theFace1Entry, TE
 //function : AddPreCadEdgesPeriodicity
 //=======================================================================
 void BLSURFPlugin_Hypothesis::AddPreCadEdgesPeriodicity(TEntry theEdge1Entry, TEntry theEdge2Entry,
-    vector<TEntry> &theSourceVerticesEntries, vector<TEntry> &theTargetVerticesEntries) {
+    vector<string> &theSourceVerticesEntries, vector<string> &theTargetVerticesEntries) {
 
   TPreCadPeriodicity preCadEdgesPeriodicity;
   preCadEdgesPeriodicity.shape1Entry = theEdge1Entry;
@@ -1458,9 +1467,155 @@ std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) {
     save << " " << "__ENFORCED_VERTICES_END__";
   }
 
+  //PERIODICITY
+
+  SavePreCADPeriodicity(save, "FACES");
+  SavePreCADPeriodicity(save, "EDGES");
+
+  SaveFacesPeriodicity(save);
+  SaveEdgesPeriodicity(save);
+  SaveVerticesPeriodicity(save);
+
   return save;
 }
 
+void BLSURFPlugin_Hypothesis::SaveFacesPeriodicity(std::ostream & save){
+
+  TFacesPeriodicityVector::const_iterator it_faces_periodicity = _facesPeriodicityVector.begin();
+  if (it_faces_periodicity != _facesPeriodicityVector.end()) {
+    MESSAGE("__FACES_PERIODICITY_BEGIN__");
+    save << " " << "__FACES_PERIODICITY_BEGIN__";
+    for (; it_faces_periodicity != _facesPeriodicityVector.end(); ++it_faces_periodicity) {
+      TFacesPeriodicity periodicity_i = (*it_faces_periodicity);
+      save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
+      save << " " << "__BEGIN_ENTRY1__";
+      save << " " << periodicity_i.first;
+      save << " " << "__END_ENTRY1__";
+      save << " " << "__BEGIN_ENTRY2__";
+      save << " " << periodicity_i.second;
+      save << " " << "__END_ENTRY2__";
+      save << " " << "__END_PERIODICITY_DESCRIPTION__";
+    }
+    save << " " << "__FACES_PERIODICITY_END__";
+    MESSAGE("__FACES_PERIODICITY_END__");
+  }
+}
+
+void BLSURFPlugin_Hypothesis::SaveEdgesPeriodicity(std::ostream & save){
+
+  TEdgesPeriodicityVector::const_iterator it_edges_periodicity = _edgesPeriodicityVector.begin();
+  if (it_edges_periodicity != _edgesPeriodicityVector.end()) {
+    save << " " << "__EDGES_PERIODICITY_BEGIN__";
+    MESSAGE("__EDGES_PERIODICITY_BEGIN__");
+    for (; it_edges_periodicity != _edgesPeriodicityVector.end(); ++it_edges_periodicity) {
+      TEdgePeriodicity periodicity_i = (*it_edges_periodicity);
+      save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
+      if (not periodicity_i.theFace1Entry.empty()){
+        save << " " << "__BEGIN_FACE1__";
+        save << " " << periodicity_i.theFace1Entry;
+        save << " " << "__END_FACE1__";
+      }
+      save << " " << "__BEGIN_EDGE1__";
+      save << " " << periodicity_i.theEdge1Entry;
+      save << " " << "__END_EDGE1__";
+      if (not periodicity_i.theFace2Entry.empty()){
+        save << " " << "__BEGIN_FACE2__";
+        save << " " << periodicity_i.theFace2Entry;
+        save << " " << "__END_FACE2__";
+      }
+      save << " " << "__BEGIN_EDGE2__";
+      save << " " << periodicity_i.theEdge2Entry;
+      save << " " << "__END_EDGE2__";
+      save << " " << "__BEGIN_EDGE_ORIENTATION__";
+      save << " " << periodicity_i.edge_orientation;
+      save << " " << "__END_EDGE_ORIENTATION__";
+      save << " " << "__END_PERIODICITY_DESCRIPTION__";
+    }
+    save << " " << "__EDGES_PERIODICITY_END__";
+    MESSAGE("__EDGES_PERIODICITY_END__");
+  }
+}
+
+void BLSURFPlugin_Hypothesis::SaveVerticesPeriodicity(std::ostream & save){
+
+  TVerticesPeriodicityVector::const_iterator it_vertices_periodicity = _verticesPeriodicityVector.begin();
+  if (it_vertices_periodicity != _verticesPeriodicityVector.end()) {
+    MESSAGE("__VERTICES_PERIODICITY_BEGIN__");
+    save << " " << "__VERTICES_PERIODICITY_BEGIN__";
+    for (; it_vertices_periodicity != _verticesPeriodicityVector.end(); ++it_vertices_periodicity) {
+      TVertexPeriodicity periodicity_i = (*it_vertices_periodicity);
+      save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
+      save << " " << "__BEGIN_EDGE1__";
+      save << " " << periodicity_i.theEdge1Entry;
+      save << " " << "__END_EDGE1__";
+      save << " " << "__BEGIN_VERTEX1__";
+      save << " " << periodicity_i.theVertex1Entry;
+      save << " " << "__END_VERTEX1__";
+      save << " " << "__BEGIN_EDGE2__";
+      save << " " << periodicity_i.theEdge2Entry;
+      save << " " << "__END_EDGE2__";
+      save << " " << "__BEGIN_VERTEX2__";
+      save << " " << periodicity_i.theVertex2Entry;
+      save << " " << "__END_VERTEX2__";
+      save << " " << "__END_PERIODICITY_DESCRIPTION__";
+    }
+    save << " " << "__VERTICES_PERIODICITY_END__";
+    MESSAGE("__VERTICES_PERIODICITY_END__");
+  }
+}
+
+void BLSURFPlugin_Hypothesis::SavePreCADPeriodicity(std::ostream & save, const char* shapeType) {
+  TPreCadPeriodicityVector precad_periodicity;
+  if (shapeType == "FACES")
+    precad_periodicity = _preCadFacesPeriodicityVector;
+  else
+    precad_periodicity = _preCadEdgesPeriodicityVector;
+  TPreCadPeriodicityVector::const_iterator it_precad_periodicity = precad_periodicity.begin();
+  if (it_precad_periodicity != precad_periodicity.end()) {
+    save << " " << "__PRECAD_" << shapeType << "_PERIODICITY_BEGIN__";
+    for (; it_precad_periodicity != precad_periodicity.end(); ++it_precad_periodicity) {
+      TPreCadPeriodicity periodicity_i = (*it_precad_periodicity);
+      save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
+      if (!periodicity_i.shape1Entry.empty()) {
+        save << " " << "__BEGIN_ENTRY1__";
+        save << " " << periodicity_i.shape1Entry;
+        save << " " << "__END_ENTRY1__";
+      }
+      if (!periodicity_i.shape2Entry.empty()) {
+        save << " " << "__BEGIN_ENTRY2__";
+        save << " " << periodicity_i.shape2Entry;
+        save << " " << "__END_ENTRY2__";
+      }
+
+      std::vector<std::string>::const_iterator sourceVerticesEntriesIt = periodicity_i.theSourceVerticesEntries.begin();
+      bool hasSourceVertices = false;
+      if (sourceVerticesEntriesIt != periodicity_i.theSourceVerticesEntries.end()) {
+        hasSourceVertices = true;
+        save << " " << "__BEGIN_SOURCE_VERTICES_LIST__";
+      }
+      for (; sourceVerticesEntriesIt != periodicity_i.theSourceVerticesEntries.end(); ++sourceVerticesEntriesIt)
+        save << " " << (*sourceVerticesEntriesIt);
+      if (hasSourceVertices)
+        save << " " << "__END_SOURCE_VERTICES_LIST__";
+
+      std::vector<std::string>::const_iterator targetVerticesEntriesIt = periodicity_i.theTargetVerticesEntries.begin();
+      bool hasTargetVertices = false;
+      if (targetVerticesEntriesIt != periodicity_i.theTargetVerticesEntries.end()) {
+        hasTargetVertices = true;
+        save << " " << "__BEGIN_TARGET_VERTICES_LIST__";
+      }
+      for (; targetVerticesEntriesIt != periodicity_i.theTargetVerticesEntries.end(); ++targetVerticesEntriesIt)
+        save << " " << (*targetVerticesEntriesIt);
+      if (hasTargetVertices)
+        save << " " << "__END_TARGET_VERTICES_LIST__";
+
+      save << " " << "__END_PERIODICITY_DESCRIPTION__";
+    }
+    save << " " << "__PRECAD_" << shapeType << "_PERIODICITY_END__";
+  }
+
+}
+
 //=============================================================================
 std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
   bool isOK = true;
@@ -1610,6 +1765,11 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
   bool hasAttractor = false;
   bool hasNewAttractor = false;
   bool hasEnforcedVertex = false;
+  bool hasPreCADFacesPeriodicity = false;
+  bool hasPreCADEdgesPeriodicity = false;
+  bool hasFacesPeriodicity = false;
+  bool hasEdgesPeriodicity = false;
+  bool hasVerticesPeriodicity = false;
 
   isOK = (load >> option_or_sm);
   if (isOK)
@@ -1630,6 +1790,16 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
       hasNewAttractor = true;
     else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
       hasEnforcedVertex = true;
+    else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
+      hasPreCADFacesPeriodicity = true;
+    else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
+      hasPreCADEdgesPeriodicity = true;
+    else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
+      hasFacesPeriodicity = true;
+    else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
+      hasEdgesPeriodicity = true;
+    else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
+      hasVerticesPeriodicity = true;
 
   if (isOK && hasCADSurfOptions) {
     isOK = (load >> i);
@@ -1722,6 +1892,16 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
         hasNewAttractor = true;
       else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
         hasEnforcedVertex = true;
+      else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
+        hasPreCADFacesPeriodicity = true;
+      else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
+        hasPreCADEdgesPeriodicity = true;
+      else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
+        hasFacesPeriodicity = true;
+      else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
+        hasEdgesPeriodicity = true;
+      else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
+        hasVerticesPeriodicity = true;
   }
   
   std::string optName, optValue;
@@ -1764,6 +1944,16 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
         hasNewAttractor = true;
       else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
         hasEnforcedVertex = true;
+      else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
+        hasPreCADFacesPeriodicity = true;
+      else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
+        hasPreCADEdgesPeriodicity = true;
+      else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
+        hasFacesPeriodicity = true;
+      else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
+        hasEdgesPeriodicity = true;
+      else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
+        hasVerticesPeriodicity = true;
   }
 
   while (isOK && hasPreCADOptions) {
@@ -1803,6 +1993,16 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
         hasNewAttractor = true;
       else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
         hasEnforcedVertex = true;
+      else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
+        hasPreCADFacesPeriodicity = true;
+      else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
+        hasPreCADEdgesPeriodicity = true;
+      else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
+        hasFacesPeriodicity = true;
+      else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
+        hasEdgesPeriodicity = true;
+      else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
+        hasVerticesPeriodicity = true;
   }
   
   std::string smEntry, smValue;
@@ -1841,6 +2041,16 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
         hasNewAttractor = true;
       else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
         hasEnforcedVertex = true;
+      else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
+        hasPreCADFacesPeriodicity = true;
+      else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
+        hasPreCADEdgesPeriodicity = true;
+      else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
+        hasFacesPeriodicity = true;
+      else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
+        hasEdgesPeriodicity = true;
+      else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
+        hasVerticesPeriodicity = true;
   }
 
   std::string atEntry, atValue;
@@ -1877,6 +2087,16 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
         hasNewAttractor = true;
       else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
         hasEnforcedVertex = true;
+      else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
+        hasPreCADFacesPeriodicity = true;
+      else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
+        hasPreCADEdgesPeriodicity = true;
+      else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
+        hasFacesPeriodicity = true;
+      else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
+        hasEdgesPeriodicity = true;
+      else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
+        hasVerticesPeriodicity = true;
   }
 
   std::string newAtFaceEntry, atTestString;
@@ -1911,6 +2131,16 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
     if (isOK)
       if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
         hasEnforcedVertex = true;
+      else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
+        hasPreCADFacesPeriodicity = true;
+      else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
+        hasPreCADEdgesPeriodicity = true;
+      else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
+        hasFacesPeriodicity = true;
+      else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
+        hasEdgesPeriodicity = true;
+      else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
+        hasVerticesPeriodicity = true;
   }
 
 
@@ -2047,9 +2277,377 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
     }
   }
 
+  // PERIODICITY
+
+  if (hasPreCADFacesPeriodicity){
+    LoadPreCADPeriodicity(load, "FACES");
+
+    isOK = (load >> option_or_sm);
+    if (isOK)
+      if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
+        hasPreCADEdgesPeriodicity = true;
+      else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
+        hasFacesPeriodicity = true;
+      else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
+        hasEdgesPeriodicity = true;
+      else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
+        hasVerticesPeriodicity = true;
+  }
+
+  if (hasPreCADEdgesPeriodicity){
+    LoadPreCADPeriodicity(load, "EDGES");
+
+    isOK = (load >> option_or_sm);
+    if (isOK)
+      if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
+        hasFacesPeriodicity = true;
+      else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
+        hasEdgesPeriodicity = true;
+      else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
+        hasVerticesPeriodicity = true;
+  }
+
+  if (hasFacesPeriodicity){
+      LoadFacesPeriodicity(load);
+
+    isOK = (load >> option_or_sm);
+    if (isOK)
+      if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
+        hasEdgesPeriodicity = true;
+      else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
+        hasVerticesPeriodicity = true;
+  }
+
+  if (hasEdgesPeriodicity){
+      LoadEdgesPeriodicity(load);
+
+    isOK = (load >> option_or_sm);
+    if (isOK)
+      if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
+        hasVerticesPeriodicity = true;
+  }
+
+  if (hasVerticesPeriodicity)
+      LoadVerticesPeriodicity(load);
+
   return load;
 }
 
+void BLSURFPlugin_Hypothesis::LoadFacesPeriodicity(std::istream & load){
+
+  bool isOK = true;
+
+  std::string periodicitySeparator;
+  TEntry shape1Entry;
+  TEntry shape2Entry;
+
+  _facesPeriodicityVector.clear();
+
+  while (isOK) {
+    isOK = (load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
+    MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
+    TFacesPeriodicity *periodicity_i = new TFacesPeriodicity();
+    if (periodicitySeparator == "__FACES_PERIODICITY_END__")
+      break; // __FACES_PERIODICITY_END__
+    if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
+      MESSAGE("//" << periodicitySeparator << "//");
+      throw std::exception();
+    }
+
+    while (isOK) {
+      isOK = (load >> periodicitySeparator);
+      MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
+      if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
+
+        periodicity_i->first = shape1Entry;
+        periodicity_i->second = shape2Entry;
+
+        _facesPeriodicityVector.push_back(*periodicity_i);
+
+        break; // __END_PERIODICITY_DESCRIPTION__
+      }
+
+      if (periodicitySeparator == "__BEGIN_ENTRY1__") {  // __BEGIN_ENTRY1__
+        isOK = (load >> shape1Entry);
+        isOK = (load >> periodicitySeparator); // __END_ENTRY1__
+        if (periodicitySeparator != "__END_ENTRY1__")
+          throw std::exception();
+        MESSAGE("shape1Entry: " <<shape1Entry);
+      }
+
+      if (periodicitySeparator == "__BEGIN_ENTRY2__") {  // __BEGIN_ENTRY2__
+        isOK = (load >> shape2Entry);
+        isOK = (load >> periodicitySeparator); // __END_ENTRY2__
+        if (periodicitySeparator != "__END_ENTRY2__")
+          throw std::exception();
+        MESSAGE("shape2Entry: " <<shape2Entry);
+      }
+    }
+  }
+}
+
+
+void BLSURFPlugin_Hypothesis::LoadEdgesPeriodicity(std::istream & load){
+
+  bool isOK = true;
+
+  std::string periodicitySeparator;
+  TEntry theFace1Entry;
+  TEntry theEdge1Entry;
+  TEntry theFace2Entry;
+  TEntry theEdge2Entry;
+  int edge_orientation = 0;
+
+  _edgesPeriodicityVector.clear();
+
+  while (isOK) {
+    isOK = (load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
+    MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
+    TEdgePeriodicity *periodicity_i = new TEdgePeriodicity();
+    if (periodicitySeparator == "__EDGES_PERIODICITY_END__")
+      break; // __EDGES_PERIODICITY_END__
+    if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
+      MESSAGE("//" << periodicitySeparator << "//");
+      throw std::exception();
+    }
+
+    while (isOK) {
+      isOK = (load >> periodicitySeparator);
+      MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
+      if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
+
+        periodicity_i->theFace1Entry = theFace1Entry;
+        periodicity_i->theEdge1Entry = theEdge1Entry;
+        periodicity_i->theFace2Entry = theFace2Entry;
+        periodicity_i->theEdge2Entry = theEdge2Entry;
+        periodicity_i->edge_orientation = edge_orientation;
+
+        _edgesPeriodicityVector.push_back(*periodicity_i);
+
+        break; // __END_PERIODICITY_DESCRIPTION__
+      }
+
+      if (periodicitySeparator == "__BEGIN_FACE1__") {  // __BEGIN_FACE1__
+        isOK = (load >> theFace1Entry);
+        MESSAGE("//" << theFace1Entry << "//");
+        isOK = (load >> periodicitySeparator); // __END_FACE1__
+        if (periodicitySeparator != "__END_FACE1__"){
+          MESSAGE("//" << periodicitySeparator << "//");
+          throw std::exception();
+        }
+        MESSAGE("theFace1Entry: " <<theFace1Entry);
+      }
+
+      if (periodicitySeparator == "__BEGIN_EDGE1__") {  // __BEGIN_EDGE1__
+        isOK = (load >> theEdge1Entry);
+        isOK = (load >> periodicitySeparator); // __END_EDGE1__
+        if (periodicitySeparator != "__END_EDGE1__")
+          throw std::exception();
+        MESSAGE("theEdge1Entry: " <<theEdge1Entry);
+      }
+
+      if (periodicitySeparator == "__BEGIN_FACE2__") {  // __BEGIN_FACE2__
+        isOK = (load >> theFace2Entry);
+        isOK = (load >> periodicitySeparator); // __END_FACE2__
+        if (periodicitySeparator != "__END_FACE2__")
+          throw std::exception();
+        MESSAGE("theFace2Entry: " <<theFace2Entry);
+      }
+
+      if (periodicitySeparator == "__BEGIN_EDGE2__") {  // __BEGIN_EDGE2__
+        isOK = (load >> theEdge2Entry);
+        isOK = (load >> periodicitySeparator); // __END_EDGE2__
+        if (periodicitySeparator != "__END_EDGE2__")
+          throw std::exception();
+        MESSAGE("theEdge2Entry: " <<theEdge2Entry);
+      }
+
+      if (periodicitySeparator == "__BEGIN_EDGE_ORIENTATION__") {  // __BEGIN_EDGE_ORIENTATION__
+        isOK = (load >> edge_orientation);
+        isOK = (load >> periodicitySeparator); // __END_EDGE_ORIENTATION__
+        if (periodicitySeparator != "__END_EDGE_ORIENTATION__")
+          throw std::exception();
+        MESSAGE("edge_orientation: " <<edge_orientation);
+      }
+    }
+  }
+}
+
+void BLSURFPlugin_Hypothesis::LoadVerticesPeriodicity(std::istream & load){
+
+  bool isOK = true;
+
+  std::string periodicitySeparator;
+  TEntry theEdge1Entry;
+  TEntry theVertex1Entry;
+  TEntry theEdge2Entry;
+  TEntry theVertex2Entry;
+
+  _verticesPeriodicityVector.clear();
+
+  while (isOK) {
+    isOK = (load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
+    MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
+    TVertexPeriodicity *periodicity_i = new TVertexPeriodicity();
+    if (periodicitySeparator == "__VERTICES_PERIODICITY_END__")
+      break; // __VERTICES_PERIODICITY_END__
+    if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
+      MESSAGE("//" << periodicitySeparator << "//");
+      throw std::exception();
+    }
+
+    while (isOK) {
+      isOK = (load >> periodicitySeparator);
+      MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
+      if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
+
+        periodicity_i->theEdge1Entry = theEdge1Entry;
+        periodicity_i->theVertex1Entry = theVertex1Entry;
+        periodicity_i->theEdge2Entry = theEdge2Entry;
+        periodicity_i->theVertex2Entry = theVertex2Entry;
+
+        _verticesPeriodicityVector.push_back(*periodicity_i);
+
+        break; // __END_PERIODICITY_DESCRIPTION__
+      }
+
+      if (periodicitySeparator == "__BEGIN_EDGE1__") {  // __BEGIN_EDGE1__
+        isOK = (load >> theEdge1Entry);
+        isOK = (load >> periodicitySeparator); // __END_EDGE1__
+        if (periodicitySeparator != "__END_EDGE1__")
+          throw std::exception();
+        MESSAGE("theEdge1Entry: " <<theEdge1Entry);
+      }
+
+      if (periodicitySeparator == "__BEGIN_VERTEX1__") {  // __BEGIN_VERTEX1__
+        isOK = (load >> theVertex1Entry);
+        isOK = (load >> periodicitySeparator); // __END_VERTEX1__
+        if (periodicitySeparator != "__END_VERTEX1__")
+          throw std::exception();
+        MESSAGE("theVertex1Entry: " <<theVertex1Entry);
+      }
+
+      if (periodicitySeparator == "__BEGIN_EDGE2__") {  // __BEGIN_EDGE2__
+        isOK = (load >> theEdge2Entry);
+        isOK = (load >> periodicitySeparator); // __END_EDGE2__
+        if (periodicitySeparator != "__END_EDGE2__")
+          throw std::exception();
+        MESSAGE("theEdge2Entry: " <<theEdge2Entry);
+      }
+
+      if (periodicitySeparator == "__BEGIN_VERTEX2__") {  // __BEGIN_VERTEX2__
+        isOK = (load >> theVertex2Entry);
+        isOK = (load >> periodicitySeparator); // __END_VERTEX2__
+        if (periodicitySeparator != "__END_VERTEX2__")
+          throw std::exception();
+        MESSAGE("theVertex2Entry: " <<theVertex2Entry);
+      }
+    }
+  }
+}
+
+void BLSURFPlugin_Hypothesis::LoadPreCADPeriodicity(std::istream & load, const char* shapeType) {
+
+  bool isOK = true;
+
+  std::string periodicitySeparator;
+  TEntry shape1Entry;
+  TEntry shape2Entry;
+  std::vector<std::string> theSourceVerticesEntries;
+  std::vector<std::string> theTargetVerticesEntries;
+
+  bool hasSourceVertices = false;
+  bool hasTargetVertices = false;
+
+  if (shapeType == "FACES")
+    _preCadFacesPeriodicityVector.clear();
+  else
+    _preCadEdgesPeriodicityVector.clear();
+
+
+  while (isOK) {
+    isOK = (load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
+    MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
+    TPreCadPeriodicity *periodicity_i = new TPreCadPeriodicity();
+//     MESSAGE("periodicitySeparator: " <<periodicitySeparator);
+    std::string endSeparator = "__PRECAD_" + std::string(shapeType) + "_PERIODICITY_END__";
+    if (periodicitySeparator == endSeparator)
+      break; // __PRECAD_FACES_PERIODICITY_END__
+    if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
+      MESSAGE("//" << endSeparator << "//");
+      MESSAGE("//" << periodicitySeparator << "//");
+      throw std::exception();
+    }
+
+    while (isOK) {
+      isOK = (load >> periodicitySeparator);
+      MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
+      if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
+
+        periodicity_i->shape1Entry = shape1Entry;
+        periodicity_i->shape2Entry = shape2Entry;
+
+        MESSAGE("theSourceVerticesEntries.size(): " << theSourceVerticesEntries.size());
+        MESSAGE("theTargetVerticesEntries.size(): " << theTargetVerticesEntries.size());
+
+        if (hasSourceVertices)
+          periodicity_i->theSourceVerticesEntries = theSourceVerticesEntries;
+        if (hasTargetVertices)
+          periodicity_i->theTargetVerticesEntries = theTargetVerticesEntries;
+
+        if (shapeType == "FACES")
+          _preCadFacesPeriodicityVector.push_back(*periodicity_i);
+        else
+          _preCadEdgesPeriodicityVector.push_back(*periodicity_i);
+
+        theSourceVerticesEntries.clear();
+        theTargetVerticesEntries.clear();
+        hasSourceVertices = false;
+        hasTargetVertices = false;
+        break; // __END_PERIODICITY_DESCRIPTION__
+      }
+
+      if (periodicitySeparator == "__BEGIN_ENTRY1__") {  // __BEGIN_ENTRY1__
+        isOK = (load >> shape1Entry);
+        isOK = (load >> periodicitySeparator); // __END_ENTRY1__
+        if (periodicitySeparator != "__END_ENTRY1__")
+          throw std::exception();
+        MESSAGE("shape1Entry: " <<shape1Entry);
+      }
+
+      if (periodicitySeparator == "__BEGIN_ENTRY2__") {  // __BEGIN_ENTRY2__
+        isOK = (load >> shape2Entry);
+        isOK = (load >> periodicitySeparator); // __END_ENTRY2__
+        if (periodicitySeparator != "__END_ENTRY2__")
+          throw std::exception();
+        MESSAGE("shape2Entry: " <<shape2Entry);
+      }
+
+      if (periodicitySeparator == "__BEGIN_SOURCE_VERTICES_LIST__") {  // __BEGIN_SOURCE_VERTICES_LIST__
+        hasSourceVertices = true;
+        while (isOK && (periodicitySeparator != "__END_SOURCE_VERTICES_LIST__")) {
+          isOK = (load >> periodicitySeparator);
+          if (periodicitySeparator != "__END_SOURCE_VERTICES_LIST__") {
+            theSourceVerticesEntries.push_back(periodicitySeparator);
+            MESSAGE("theSourceVerticesEntries: " <<periodicitySeparator);
+          }
+        }
+      }
+
+      if (periodicitySeparator == "__BEGIN_TARGET_VERTICES_LIST__") {  // __BEGIN_TARGET_VERTICES_LIST__
+        hasTargetVertices = true;
+        while (isOK && (periodicitySeparator != "__END_TARGET_VERTICES_LIST__")) {
+          isOK = (load >> periodicitySeparator);
+          if (periodicitySeparator != "__END_TARGET_VERTICES_LIST__") {
+            theTargetVerticesEntries.push_back(periodicitySeparator);
+            MESSAGE("theTargetVerticesEntries: " <<periodicitySeparator);
+          }
+        }
+      }
+    }
+  }
+}
+
 //=============================================================================
 std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp) {
   return hyp.SaveTo(save);
index ae1f40c8acf4b5d98ddc7cd5bdbcafeb7a3ba387..b6f9eee9591ab1efd3122571b34d80192c0ae665 100644 (file)
@@ -220,8 +220,8 @@ public:
   struct TPreCadPeriodicity {
     TEntry shape1Entry;
     TEntry shape2Entry;
-    std::vector<TEntry> theSourceVerticesEntries;
-    std::vector<TEntry> theTargetVerticesEntries;
+    std::vector<std::string> theSourceVerticesEntries;
+    std::vector<std::string> theTargetVerticesEntries;
   };
 
   // Edge periodicity
@@ -387,6 +387,8 @@ public:
   static TEnfVertexGroupNameMap     GetDefaultEnfVertexGroupNameMap() { return TEnfVertexGroupNameMap(); }
   */
 
+//  const TPreCadPeriodicityEntriesVector _GetPreCadFacesPeriodicityEntries() const { return _preCadFacesPeriodicityEntriesVector; }
+
   static TPreCadPeriodicityVector GetDefaultPreCadFacesPeriodicityVector() { return TPreCadPeriodicityVector(); }
   const TPreCadPeriodicityVector  _GetPreCadFacesPeriodicityVector() const { return _preCadFacesPeriodicityVector; }
   static TPreCadPeriodicityVector GetPreCadFacesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp);
@@ -407,6 +409,8 @@ public:
   const TVerticesPeriodicityVector  _GetVerticesPeriodicityVector() const { return _verticesPeriodicityVector; }
   static TVerticesPeriodicityVector GetVerticesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp);
 
+  void ClearPreCadPeriodicityVectors();
+
   void AddPreCadFacesPeriodicity(TEntry theFace1Entry, TEntry theFace2Entry,
       std::vector<std::string> &theSourceVerticesEntries, std::vector<std::string> &theTargetVerticesEntries);
   void AddPreCadEdgesPeriodicity(TEntry theEdge1Entry, TEntry theEdge2Entry,
@@ -520,6 +524,30 @@ private:
   TEdgesPeriodicityVector _edgesPeriodicityVector;
   TVerticesPeriodicityVector _verticesPeriodicityVector;
 
+  // Called by SaveTo to store content of _preCadFacesPeriodicityVector and _preCadEdgesPeriodicityVector
+  void SavePreCADPeriodicity(std::ostream & save, const char* shapeType);
+
+  // Called by LoadFrom to fill _preCadFacesPeriodicityVector and _preCadEdgesPeriodicityVector
+  void LoadPreCADPeriodicity(std::istream & load, const char* shapeType);
+
+  // Called by LoadFrom to fill _facesPeriodicityVector
+  void LoadFacesPeriodicity(std::istream & load);
+
+  // Called by LoadFrom to fill _edgesPeriodicityVector
+  void LoadEdgesPeriodicity(std::istream & load);
+
+  // Called by LoadFrom to fill _verticesPeriodicityVector
+  void LoadVerticesPeriodicity(std::istream & load);
+
+  // Called by SaveTo to store content of _facesPeriodicityVector
+  void SaveFacesPeriodicity(std::ostream & save);
+
+  // Called by SaveTo to store content of _edgesPeriodicityVector
+  void SaveEdgesPeriodicity(std::ostream & save);
+
+  // Called by SaveTo to store content of _verticesPeriodicityVector
+  void SaveVerticesPeriodicity(std::ostream & save);
+
   std::string     _GMFFileName;
 //   bool            _GMFFileMode;
 
index 58d275ae1a2f6df413ff0e60a914a8e4bfb352fa..ffb5b15c250b8e33ddacc9da692bb49b15bb412c 100644 (file)
@@ -2668,25 +2668,103 @@ std::string BLSURFPlugin_Hypothesis_i::FormatVerticesEntries(vector<string> &the
   if (!theSourceVerticesEntries.empty())
     {
       listEntriesTxt << ", [" ;
-      for (size_t i = 0; i<theSourceVerticesEntries.size(); i++)
+      size_t i =0;
+      for (std::vector<std::string>::const_iterator it = theSourceVerticesEntries.begin(); it != theSourceVerticesEntries.end(); it++, i++)
         {
           if (i>0)
             listEntriesTxt << ", ";
-          listEntriesTxt << theSourceVerticesEntries[i];
+          listEntriesTxt << *it;
         }
 
       listEntriesTxt << "], [" ;
-      for (size_t i = 0; i<theTargetVerticesEntries.size(); i++)
+      i =0;
+      for (std::vector<std::string>::const_iterator it = theTargetVerticesEntries.begin(); it != theTargetVerticesEntries.end(); it++, i++)
         {
           if (i>0)
             listEntriesTxt << ", ";
-          listEntriesTxt << theTargetVerticesEntries[i];
+          listEntriesTxt << *it;
         }
       listEntriesTxt << "]" ;
     }
   return listEntriesTxt.str();
 }
 
+/**
+ * Erase all PreCad periodicity associations
+ */
+void BLSURFPlugin_Hypothesis_i::ClearPreCadPeriodicityVectors() {
+  ASSERT(myBaseImpl);
+  this->GetImpl()->ClearPreCadPeriodicityVectors();
+  SMESH::TPythonDump() << _this() << ".ClearPreCadPeriodicityVectors()";
+}
+
+BLSURFPlugin::TPeriodicityList* BLSURFPlugin_Hypothesis_i::GetPreCadFacesPeriodicityVector()
+{
+  MESSAGE("BLSURFPlugin_Hypothesis_i::GetPreCadFacesPeriodicityVector");
+  const ::BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector preCadPeriodicityVector =
+      this->GetImpl()->_GetPreCadFacesPeriodicityVector();
+
+  BLSURFPlugin::TPeriodicityList_var periodicityList = PreCadVectorToSequence(preCadPeriodicityVector);
+
+  MESSAGE("BLSURFPlugin_Hypothesis_i::GetPreCadFacesPeriodicityVector end");
+  return periodicityList._retn();
+}
+
+BLSURFPlugin::TPeriodicityList* BLSURFPlugin_Hypothesis_i::GetPreCadEdgesPeriodicityVector()
+{
+  MESSAGE("BLSURFPlugin_Hypothesis_i::GetPreCadEdgesPeriodicityVector");
+  const ::BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector preCadPeriodicityVector =
+      this->GetImpl()->_GetPreCadEdgesPeriodicityVector();
+
+  BLSURFPlugin::TPeriodicityList_var periodicityList = PreCadVectorToSequence(preCadPeriodicityVector);
+
+  MESSAGE("BLSURFPlugin_Hypothesis_i::GetPreCadEdgesPeriodicityVector end");
+  return periodicityList._retn();
+}
+
+// convert a vector preCadPeriodicityVector into TPeriodicityList Corba sequence
+BLSURFPlugin::TPeriodicityList* BLSURFPlugin_Hypothesis_i::PreCadVectorToSequence(const ::BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector& preCadPeriodicityVector)
+{
+  MESSAGE("BLSURFPlugin_Hypothesis_i::PreCadVectorToSequence");
+  BLSURFPlugin::TPeriodicityList_var periodicityList = new BLSURFPlugin::TPeriodicityList();
+
+    periodicityList->length(preCadPeriodicityVector.size());
+
+    for (size_t i = 0; i<preCadPeriodicityVector.size(); i++)
+      {
+        ::BLSURFPlugin_Hypothesis::TPreCadPeriodicity preCadPeriodicityVector_i = preCadPeriodicityVector[i];
+
+        BLSURFPlugin::TPreCadPeriodicity_var myPreCadPeriodicity = new BLSURFPlugin::TPreCadPeriodicity();
+        myPreCadPeriodicity->shape1Entry = CORBA::string_dup(preCadPeriodicityVector_i.shape1Entry.c_str());
+        myPreCadPeriodicity->shape2Entry = CORBA::string_dup(preCadPeriodicityVector_i.shape2Entry.c_str());
+
+        BLSURFPlugin::TEntryList_var sourceVertices = new BLSURFPlugin::TEntryList();
+        if (not preCadPeriodicityVector_i.theSourceVerticesEntries.empty())
+          {
+            sourceVertices->length(preCadPeriodicityVector_i.theSourceVerticesEntries.size());
+            for (size_t j=0; j<preCadPeriodicityVector_i.theSourceVerticesEntries.size(); j++)
+              sourceVertices[j]=CORBA::string_dup(preCadPeriodicityVector_i.theSourceVerticesEntries[j].c_str());
+          }
+
+        myPreCadPeriodicity->theSourceVerticesEntries = sourceVertices;
+
+        BLSURFPlugin::TEntryList_var targetVertices = new BLSURFPlugin::TEntryList();
+        if (not preCadPeriodicityVector_i.theTargetVerticesEntries.empty())
+           {
+            targetVertices->length(preCadPeriodicityVector_i.theTargetVerticesEntries.size());
+             for (size_t j=0; j<preCadPeriodicityVector_i.theTargetVerticesEntries.size(); j++)
+               targetVertices[j]=CORBA::string_dup(preCadPeriodicityVector_i.theTargetVerticesEntries[j].c_str());
+           }
+
+        myPreCadPeriodicity->theTargetVerticesEntries = targetVertices;
+
+        periodicityList[i] = myPreCadPeriodicity;
+      }
+
+
+  return periodicityList._retn();
+}
+
 
 void BLSURFPlugin_Hypothesis_i::AddPreCadFacesPeriodicity(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
 throw (SALOME::SALOME_Exception)
@@ -2703,6 +2781,7 @@ void BLSURFPlugin_Hypothesis_i::AddPreCadFacesPeriodicityWithVertices(GEOM::GEOM
 throw (SALOME::SALOME_Exception)
 {
   ASSERT(myBaseImpl);
+  MESSAGE("BLSURFPlugin_Hypothesis_i::AddPreCadFacesPeriodicityWithVertices");
 
   size_t theLength = theSourceVertices.length();
   if (theLength != theTargetVertices.length())
@@ -2721,21 +2800,23 @@ throw (SALOME::SALOME_Exception)
   string theFace2Entry = PublishIfNeeded(theFace2, GEOM::FACE, prefix2);
 
   string prefix3 = "Source_vertex_";
-  vector<string> theSourceVerticesEntries (theLength) ;
+  BLSURFPlugin::TEntryList_var theSourceVerticesEntries = new BLSURFPlugin::TEntryList();
+  theSourceVerticesEntries->length(theLength);
   GEOM::GEOM_Object_ptr theVtx_i;
   string theEntry_i;
   for (size_t ind = 0; ind < theLength; ind++) {
       theVtx_i = theSourceVertices[ind];
       theEntry_i = PublishIfNeeded(theVtx_i, GEOM::VERTEX, prefix3);
-      theSourceVerticesEntries[ind] = theEntry_i;
+      theSourceVerticesEntries[ind] = CORBA::string_dup(theEntry_i.c_str());
   }
 
   string prefix4 = "Target_vertex_";
-  vector<string> theTargetVerticesEntries (theLength) ;
+  BLSURFPlugin::TEntryList_var theTargetVerticesEntries = new BLSURFPlugin::TEntryList();
+  theTargetVerticesEntries->length(theLength);
   for (size_t ind = 0; ind < theLength; ind++) {
       theVtx_i = theTargetVertices[ind];
       theEntry_i = PublishIfNeeded(theVtx_i, GEOM::VERTEX, prefix4);
-      theTargetVerticesEntries[ind] = theEntry_i;
+      theTargetVerticesEntries[ind] = CORBA::string_dup(theEntry_i.c_str());
   }
 
   string theFace2Name = theFace2->GetName();
@@ -2752,12 +2833,19 @@ throw (SALOME::SALOME_Exception)
 
 
 void BLSURFPlugin_Hypothesis_i::AddPreCadFacesPeriodicityEntry(const char* theFace1Entry, const char* theFace2Entry,
-    vector<string> &theSourceVerticesEntries, vector<string> &theTargetVerticesEntries)
+    const BLSURFPlugin::TEntryList& theSourceVerticesEntriesCorba, const BLSURFPlugin::TEntryList& theTargetVerticesEntriesCorba)
     throw (SALOME::SALOME_Exception)
 {
 
   ASSERT(myBaseImpl);
 
+  // Convert BLSURFPlugin::TEntryList to vector<string>
+  vector<string> theSourceVerticesEntries, theTargetVerticesEntries;
+  for (size_t ind = 0; ind < theSourceVerticesEntriesCorba.length(); ind++) {
+      theSourceVerticesEntries.push_back(theSourceVerticesEntriesCorba[ind].in());
+      theTargetVerticesEntries.push_back(theTargetVerticesEntriesCorba[ind].in());
+  }
+
   string listEntriesTxt = FormatVerticesEntries(theSourceVerticesEntries, theTargetVerticesEntries);
 
   MESSAGE("IDL : AddPreCadFacesPeriodicityEntry(" << theFace1Entry << ", " << theFace2Entry << listEntriesTxt.c_str() << ")");
@@ -2790,6 +2878,7 @@ void BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicityWithVertices(GEOM::GEOM
     const GEOM::ListOfGO& theSourceVertices, const GEOM::ListOfGO& theTargetVertices)
       throw (SALOME::SALOME_Exception)
 {
+  MESSAGE("BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicityWithVertices");
   ASSERT(myBaseImpl);
 
   size_t theLength = theSourceVertices.length();
@@ -2809,21 +2898,23 @@ void BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicityWithVertices(GEOM::GEOM
   string theEdge2Entry = PublishIfNeeded(theEdge2, GEOM::EDGE, prefix2);
 
   string prefix3 = "Source_vertex_";
-  vector<string> theSourceVerticesEntries (theLength) ;
+  BLSURFPlugin::TEntryList_var theSourceVerticesEntries = new BLSURFPlugin::TEntryList();
+  theSourceVerticesEntries->length(theLength);
   GEOM::GEOM_Object_ptr theVtx_i;
   string theEntry_i;
   for (size_t ind = 0; ind < theLength; ind++) {
       theVtx_i = theSourceVertices[ind];
       theEntry_i = PublishIfNeeded(theVtx_i, GEOM::VERTEX, prefix3);
-      theSourceVerticesEntries[ind] = theEntry_i;
+      theSourceVerticesEntries[ind] = CORBA::string_dup(theEntry_i.c_str());
   }
 
   string prefix4 = "Target_vertex_";
-  vector<string> theTargetVerticesEntries (theLength) ;
+  BLSURFPlugin::TEntryList_var theTargetVerticesEntries = new BLSURFPlugin::TEntryList();
+  theTargetVerticesEntries->length(theLength);
   for (size_t ind = 0; ind < theLength; ind++) {
       theVtx_i = theTargetVertices[ind];
       theEntry_i = PublishIfNeeded(theVtx_i, GEOM::VERTEX, prefix4);
-      theTargetVerticesEntries[ind] = theEntry_i;
+      theTargetVerticesEntries[ind] = CORBA::string_dup(theEntry_i.c_str());
   }
 
   string theEdge2Name = theEdge2->GetName();
@@ -2840,12 +2931,19 @@ void BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicityWithVertices(GEOM::GEOM
 
 
 void BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicityEntry(const char* theEdge1Entry, const char* theEdge2Entry,
-    vector<string> &theSourceVerticesEntries, vector<string> &theTargetVerticesEntries)
+    const BLSURFPlugin::TEntryList& theSourceVerticesEntriesCorba, const BLSURFPlugin::TEntryList& theTargetVerticesEntriesCorba)
     throw (SALOME::SALOME_Exception)
 {
 
   ASSERT(myBaseImpl);
 
+  // Convert BLSURFPlugin::TEntryList to vector<string>
+  vector<string> theSourceVerticesEntries, theTargetVerticesEntries;
+  for (size_t ind = 0; ind < theSourceVerticesEntriesCorba.length(); ind++) {
+      theSourceVerticesEntries.push_back(theSourceVerticesEntriesCorba[ind].in());
+      theTargetVerticesEntries.push_back(theTargetVerticesEntriesCorba[ind].in());
+  }
+
   string listEntriesTxt = FormatVerticesEntries(theSourceVerticesEntries, theTargetVerticesEntries);
 
   MESSAGE("IDL : AddPreCadEdgesPeriodicityEntry(" << theEdge1Entry << ", " << theEdge2Entry << listEntriesTxt.c_str() << ")");
index 904f6261966fa5b6976533fe0af92afbd40cab33..9d26a59a3ebbfc1b8909eeb6de8f83dc2784a3a8 100644 (file)
@@ -258,6 +258,13 @@ public:
   // PERIODICITY       //
   ///////////////////////
 
+  void ClearPreCadPeriodicityVectors();
+
+  BLSURFPlugin::TPeriodicityList* GetPreCadFacesPeriodicityVector();
+  BLSURFPlugin::TPeriodicityList* GetPreCadEdgesPeriodicityVector();
+
+  BLSURFPlugin::TPeriodicityList* PreCadVectorToSequence(const ::BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector& preCadPeriodicityVector);
+
   void AddPreCadFacesPeriodicity(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
       throw (SALOME::SALOME_Exception);
 
@@ -266,7 +273,7 @@ public:
       throw (SALOME::SALOME_Exception);
 
   void AddPreCadFacesPeriodicityEntry(const char* theFace1Entry, const char* theFace2Entry,
-      vector<string> &theSourceVerticesEntries, vector<string> &theTargetVerticesEntries)
+      const BLSURFPlugin::TEntryList& theSourceVerticesEntries, const BLSURFPlugin::TEntryList& theTargetVerticesEntries)
       throw (SALOME::SALOME_Exception);
 
   void AddPreCadEdgesPeriodicity(GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2)
@@ -277,7 +284,7 @@ public:
       throw (SALOME::SALOME_Exception);
 
   void AddPreCadEdgesPeriodicityEntry(const char* theEdge1Entry, const char* theEdge2Entry,
-      vector<string> &theSourceVerticesEntries, vector<string> &theTargetVerticesEntries)
+      const BLSURFPlugin::TEntryList& theSourceVerticesEntries, const BLSURFPlugin::TEntryList& theTargetVerticesEntries)
       throw (SALOME::SALOME_Exception);
 
   void AddFacePeriodicity(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
index 0e6a11c1d7c27ee609f3c4fe69a404cda2d97b5b..832119156e3b432c371b80652768e7f74cea594d 100644 (file)
@@ -58,6 +58,7 @@
 #include <QTableWidget>
 #include <QTabWidget>
 #include <QVBoxLayout>
+#include <QSplitter>
 
 #include <QStandardItemModel>
 #include <QStandardItem>
@@ -86,6 +87,7 @@ enum {
   ADV_TAB,
   SMP_TAB,
   ENF_TAB,
+  PERIODICITY_TAB,
   SMP_NAME_COLUMN =0,
   SMP_SIZEMAP_COLUMN,
   SMP_ENTRY_COLUMN,
@@ -99,7 +101,36 @@ enum {
   ENF_VER_Z_COLUMN,
   ENF_VER_ENTRY_COLUMN,
   ENF_VER_GROUP_COLUMN,
-  ENF_VER_NB_COLUMNS
+  ENF_VER_NB_COLUMNS,
+// Periodicity
+  PERIODICITY_OBJ_SOURCE_COLUMN = 0,
+  PERIODICITY_OBJ_TARGET_COLUMN,
+  PERIODICITY_P1_SOURCE_COLUMN,
+  PERIODICITY_P2_SOURCE_COLUMN,
+  PERIODICITY_P3_SOURCE_COLUMN,
+  PERIODICITY_P1_TARGET_COLUMN,
+  PERIODICITY_P2_TARGET_COLUMN,
+  PERIODICITY_P3_TARGET_COLUMN,
+  PERIODICITY_SHAPE_TYPE,
+
+//  PERIODICITY_OBJ_SOURCE_COLUMN = 0,
+//  PERIODICITY_ENTRY_SOURCE_COLUMN,
+//  PERIODICITY_OBJ_TARGET_COLUMN,
+//  PERIODICITY_ENTRY_TARGET_COLUMN,
+//  PERIODICITY_P1_SOURCE_COLUMN,
+//  PERIODICITY_P1_ENTRY_SOURCE_COLUMN,
+//  PERIODICITY_P2_SOURCE_COLUMN,
+//  PERIODICITY_P2_ENTRY_SOURCE_COLUMN,
+//  PERIODICITY_P3_SOURCE_COLUMN,
+//  PERIODICITY_P3_ENTRY_SOURCE_COLUMN,
+//  PERIODICITY_P1_TARGET_COLUMN,
+//  PERIODICITY_P1_ENTRY_TARGET_COLUMN,
+//  PERIODICITY_P2_TARGET_COLUMN,
+//  PERIODICITY_P2_ENTRY_TARGET_COLUMN,
+//  PERIODICITY_P3_TARGET_COLUMN,
+//  PERIODICITY_P3_ENTRY_TARGET_COLUMN,
+
+  PERIODICITY_NB_COLUMN
 };
 
 enum {
@@ -455,6 +486,31 @@ GEOM::GEOM_Gen_var BLSURFPluginGUI_HypothesisCreator::getGeomEngine()
   return GeometryGUI::GetGeomGen();
 }
 
+void BLSURFPluginGUI_HypothesisCreator::avoidSimultaneousSelection(ListOfWidgets &selectionWidgets) const
+{
+  StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
+  ListOfWidgets::const_iterator anIt = selectionWidgets.begin();
+  for ( ; anIt != selectionWidgets.end(); anIt++)
+    {
+      if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
+        {
+          StdMeshersGUI_ObjectReferenceParamWdg * w1 =
+              ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
+          ListOfWidgets::const_iterator anIt2 = anIt;
+          for ( ++anIt2; anIt2 != selectionWidgets.end(); anIt2++)
+            if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
+              {
+                StdMeshersGUI_ObjectReferenceParamWdg * w2 =
+                    ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
+                w1->AvoidSimultaneousSelection( w2 );
+              }
+          if ( !widgetToActivate )
+            widgetToActivate = w1;
+        }
+    }
+  if ( widgetToActivate )
+    widgetToActivate->activateSelection();
+}
 
 bool BLSURFPluginGUI_HypothesisCreator::checkParams(QString& msg) const
 {
@@ -864,11 +920,199 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
   anEnfLayout->addLayout(anEnfLayout2, 0,1,ENF_VER_NB_LINES+1,2);
 //   anEnfLayout->setRowStretch(1, 1);
 
+  // ---
+  // Periodicity parameters
+  myPeriodicityGroup = new QWidget();
+  aPeriodicityLayout1 = new QGridLayout(myPeriodicityGroup);
+
+  myPeriodicitySplitter = new QSplitter(myPeriodicityGroup);
+  myPeriodicitySplitter->setOrientation(Qt::Horizontal);
+  aPeriodicityLayout1->addWidget(myPeriodicitySplitter, 0, 0, 1, 1);
+
+  myPeriodicityTreeWidget = new QTreeWidget(myPeriodicitySplitter);
+
+  QStringList myPeriodicityTreeHeaders;
+  myPeriodicityTreeHeaders << tr("BLSURF_PERIODICITY_OBJ_SOURCE_COLUMN")
+                           << tr("BLSURF_PERIODICITY_OBJ_TARGET_COLUMN")
+                           << tr("BLSURF_PERIODICITY_P1_SOURCE_COLUMN")
+                           << tr("BLSURF_PERIODICITY_P2_SOURCE_COLUMN")
+                           << tr("BLSURF_PERIODICITY_P3_SOURCE_COLUMN")
+                           << tr("BLSURF_PERIODICITY_P1_TARGET_COLUMN")
+                           << tr("BLSURF_PERIODICITY_P2_TARGET_COLUMN")
+                           << tr("BLSURF_PERIODICITY_P3_TARGET_COLUMN")
+                           << tr("BLSURF_PERIODICITY_SHAPE_TYPE");
+  myPeriodicityTreeWidget->setHeaderLabels(myPeriodicityTreeHeaders);
+
+  // Hide the vertex name to make the widget more readable
+  myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_SOURCE_COLUMN);
+  myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_SOURCE_COLUMN);
+  myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_SOURCE_COLUMN);
+  myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_TARGET_COLUMN);
+  myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_TARGET_COLUMN);
+  myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_TARGET_COLUMN);
+  myPeriodicityTreeWidget->hideColumn(PERIODICITY_SHAPE_TYPE);
+
+
+  myPeriodicityTreeWidget->setColumnCount(PERIODICITY_NB_COLUMN);
+  myPeriodicityTreeWidget->setSortingEnabled(true);
+
+  myPeriodicityTreeWidget->setAlternatingRowColors(true);
+  myPeriodicityTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
+  myPeriodicityTreeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
+  
+  int periodicityVisibleColumns = 2;
+  for (size_t column = 0; column < periodicityVisibleColumns; ++column) {
+      myPeriodicityTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive);
+      myPeriodicityTreeWidget->resizeColumnToContents(column);
+  }
+  myPeriodicityTreeWidget->header()->setStretchLastSection(true);
+
+  myPeriodicitySplitter->addWidget(myPeriodicityTreeWidget);
+
+  myPeriodicityRightWidget = new QWidget(myPeriodicitySplitter);
+
+  myPeriodicityRightGridLayout = new QGridLayout(myPeriodicityRightWidget);
+  myPeriodicityGroupBox1 = new QGroupBox(tr("BLSURF_PRECAD_PERIODICITY"), myPeriodicityRightWidget);
+  myPeriodicityGroupBox1Layout = new QGridLayout(myPeriodicityGroupBox1);
+
+  myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox1, 0, 0, 1, 2);
+
+  myPeriodicityOnFaceRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_FACE"), myPeriodicityGroupBox1);
+  myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnFaceRadioButton, 0, 0, 1, 2);
+
+  myPeriodicityOnFaceRadioButton->setChecked(true);
+
+  myPeriodicityOnEdgeRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_EDGE"), myPeriodicityGroupBox1);
+  myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnEdgeRadioButton, 0, 2, 1, 2);
+
+
+  // FACE, EDGE AND VERTEX SELECTION
+  TColStd_MapOfInteger shapeTypesFace, shapeTypesEdge;
+  shapeTypesFace.Add( TopAbs_FACE );
+  shapeTypesFace.Add( TopAbs_EDGE );
+  shapeTypesFace.Add( TopAbs_COMPOUND );
+  shapeTypesEdge.Add( TopAbs_EDGE );
+  shapeTypesEdge.Add( TopAbs_COMPOUND );
+
+//  myPeriodicityEdgeFilter = new SMESH_NumberFilter("GEOM", TopAbs_EDGE, 0, shapeTypesEdge);
+
+  myPeriodicityMainSourceLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_SOURCE"), myPeriodicityGroupBox1);
+  myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainSourceLabel, 1, 0, 1, 1);
+
+  SMESH_NumberFilter* myPeriodicitySourceFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
+  myPeriodicitySourceFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicitySourceFaceFilter, 0, /*multiSel=*/false, /*stretch=*/false);
+//  myPeriodicitySourceFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
+  myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceFaceWdg, 1, 1, 1, 1);
+
+//  myPeriodicitySourceEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false, /*stretch=*/false);
+//  myPeriodicitySourceEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
+//  myPeriodicitySourceEdgeWdg->hide();
+//  myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceEdgeWdg, 1, 1, 1, 1);
+
+  myPeriodicityMainTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_TARGET"), myPeriodicityGroupBox1);
+  myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainTargetLabel, 1, 2, 1, 1);
+
+  SMESH_NumberFilter* myPeriodicityTargetFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
+  myPeriodicityTargetFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityTargetFaceFilter, 0, /*multiSel=*/false, /*stretch=*/false);
+//  myPeriodicityTargetFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
+  myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetFaceWdg, 1, 3, 1, 1);
+
+//  myPeriodicityTargetEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false, /*stretch=*/false);
+//  myPeriodicityTargetEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
+//  myPeriodicityTargetEdgeWdg->hide();
+//  myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetEdgeWdg, 1, 3, 1, 1);
+
+  myPeriodicityGroupBox2 = new QGroupBox(tr("BLSURF_PERIODICITY_WITH_VERTICES"), myPeriodicityRightWidget);
+  myPeriodicityGroupBox2Layout = new QGridLayout(myPeriodicityGroupBox2);
+  myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox2, 1, 0, 1, 2);
+
+  myPeriodicityGroupBox2->setCheckable(true);
+  myPeriodicityGroupBox2->setChecked(false);
+
+  myPeriodicitySourceLabel = new QLabel(tr("BLSURF_PERIODICITY_SOURCE"), myPeriodicityGroupBox2);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicitySourceLabel, 0, 0, 1, 2);
+
+  myPeriodicityTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_TARGET"), myPeriodicityGroupBox2);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityTargetLabel, 0, 2, 1, 2);
+
+  // P1
+  myPeriodicityP1SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_SOURCE"), myPeriodicityGroupBox2);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceLabel, 1, 0, 1, 1);
+
+
+  SMESH_NumberFilter* myPeriodicityP1SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
+  myPeriodicityP1SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1SourceFilter, 0, /*multiSel=*/false, /*stretch=*/false);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceWdg, 1, 1, 1, 1);
+
+  // P2
+  myPeriodicityP2SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_SOURCE"), myPeriodicityGroupBox2);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceLabel, 2, 0, 1, 1);
+
+  SMESH_NumberFilter* myPeriodicityP2SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
+  myPeriodicityP2SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2SourceFilter, 0, /*multiSel=*/false, /*stretch=*/false);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceWdg, 2, 1, 1, 1);
+
+  // P3
+  myPeriodicityP3SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_SOURCE"), myPeriodicityGroupBox2);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceLabel, 3, 0, 1, 1);
+
+  SMESH_NumberFilter* myPeriodicityP3SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
+  myPeriodicityP3SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3SourceFilter, 0, /*multiSel=*/false, /*stretch=*/false);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceWdg, 3, 1, 1, 1);
+
+  // P1
+  myPeriodicityP1TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_TARGET"), myPeriodicityGroupBox2);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetLabel, 1, 2, 1, 1);
+
+  SMESH_NumberFilter* myPeriodicityP1TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
+  myPeriodicityP1TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1TargetFilter, 0, /*multiSel=*/false, /*stretch=*/false);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetWdg, 1, 3, 1, 1);
+
+  // P2
+  myPeriodicityP2TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_TARGET"), myPeriodicityGroupBox2);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetLabel, 2, 2, 1, 1);
+
+  SMESH_NumberFilter* myPeriodicityP2TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
+  myPeriodicityP2TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2TargetFilter, 0, /*multiSel=*/false, /*stretch=*/false);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetWdg, 2, 3, 1, 1);
+
+  // P3
+  myPeriodicityP3TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_TARGET"), myPeriodicityGroupBox2);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetLabel, 3, 2, 1, 1);
+
+  SMESH_NumberFilter* myPeriodicityP3TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
+  myPeriodicityP3TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3TargetFilter, 0, /*multiSel=*/false, /*stretch=*/false);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetWdg, 3, 3, 1, 1);
+
+  myPeriodicityVerticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
+  myPeriodicityGroupBox2Layout->addItem(myPeriodicityVerticalSpacer, 7, 1, 1, 1);
+
+
+  myPeriodicityAddButton = new QPushButton(tr("BLSURF_PERIODICITY_ADD"),myPeriodicityRightWidget);
+  myPeriodicityRightGridLayout->addWidget(myPeriodicityAddButton, 2, 0, 1, 1);
+
+  myPeriodicityRemoveButton = new QPushButton(tr("BLSURF_PERIODICITY_REMOVE"),myPeriodicityRightWidget);
+  myPeriodicityRightGridLayout->addWidget(myPeriodicityRemoveButton, 2, 1, 1, 1);
+
+  myPeriodicitySplitter->addWidget(myPeriodicityRightWidget);
+
+  myPeriodicitySelectionWidgets.clear();
+  myPeriodicitySelectionWidgets.append(myPeriodicitySourceFaceWdg);
+  myPeriodicitySelectionWidgets.append(myPeriodicityTargetFaceWdg);
+  myPeriodicitySelectionWidgets.append(myPeriodicityP1SourceWdg);
+  myPeriodicitySelectionWidgets.append(myPeriodicityP2SourceWdg);
+  myPeriodicitySelectionWidgets.append(myPeriodicityP3SourceWdg);
+  myPeriodicitySelectionWidgets.append(myPeriodicityP1TargetWdg);
+  myPeriodicitySelectionWidgets.append(myPeriodicityP2TargetWdg);
+  myPeriodicitySelectionWidgets.append(myPeriodicityP3TargetWdg);
+  avoidSimultaneousSelection(myPeriodicitySelectionWidgets);
+
   // ---
   myTabWidget->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
   myTabWidget->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) );
   myTabWidget->insertTab( SMP_TAB, mySmpGroup, tr( "LOCAL_SIZE" ) );
   myTabWidget->insertTab( ENF_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) );
+  myTabWidget->insertTab( PERIODICITY_TAB, myPeriodicityGroup, tr( "BLSURF_PERIODICITY" ) );
 
   myTabWidget->setCurrentIndex( STD_TAB );
 
@@ -902,6 +1146,20 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
 //   connect( myEnfVertexWdg,     SIGNAL( selectionActivated()),         this,         SLOT( onVertexSelectionActivated() ) );
 //   connect( myEnfFaceWdg,       SIGNAL( selectionActivated()),         this,         SLOT( onFaceSelectionActivated() ) );
 
+  // Periodicity
+  connect( myPeriodicityAddButton,     SIGNAL( clicked()),                    this,   SLOT( onAddPeriodicity() ) );
+  connect( myPeriodicityRemoveButton,  SIGNAL( clicked()),                    this,   SLOT( onRemovePeriodicity() ) );
+  connect( myPeriodicityTreeWidget,    SIGNAL( itemClicked(QTreeWidgetItem*, int)), this, SLOT( onPeriodicityTreeClicked(QTreeWidgetItem *, int) ) );
+  connect( myPeriodicityGroupBox2,     SIGNAL(toggled(bool)),                 this,   SLOT(onPeriodicityByVerticesChecked(bool)));
+
+  ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
+  for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
+    {
+      StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
+      connect( w1,     SIGNAL(contentModified ()),                 this,   SLOT(onPeriodicityContentModified()));
+
+    }
+//  connect( myPeriodicitySourceFaceWdg,     SIGNAL(contentModified()),    this,   SLOT(onPeriodicityContentModified()));
   return fr;
 }
 
@@ -1290,6 +1548,204 @@ void BLSURFPluginGUI_HypothesisCreator::onInternalVerticesClicked(int state)
   myInternalEnforcedVerticesAllFacesGroup->setEnabled(state == Qt::Checked);
 }
 
+/** BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity()
+This method is called when a item is added into the periodicity table widget
+*/
+void BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity() {
+//   MESSAGE("BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices");
+
+  BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
+
+  that->getGeomSelectionTool()->selectionMgr()->clearFilters();
+  ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
+  for ( ; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
+    {
+          StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
+          w1->deactivateSelection();
+    }
+
+
+  // Source-Target selection
+  int selSource = myPeriodicitySourceFaceWdg->NbObjects();
+  int selTarget = myPeriodicityTargetFaceWdg->NbObjects();
+
+  if (selSource == 0 or selTarget == 0)
+    return;
+
+  // Vertices selection
+  if (myPeriodicityGroupBox2->isChecked())
+    {
+      int P1Ssel = myPeriodicityP1SourceWdg->NbObjects();
+      int P2Ssel = myPeriodicityP2SourceWdg->NbObjects();
+      int P3Ssel = myPeriodicityP3SourceWdg->NbObjects();
+      int P1Tsel = myPeriodicityP1TargetWdg->NbObjects();
+      int P2Tsel = myPeriodicityP2TargetWdg->NbObjects();
+      int P3Tsel = myPeriodicityP3TargetWdg->NbObjects();
+
+      if (P1Ssel!=1 or P2Ssel!=1 or P3Ssel!=1 or P1Tsel!=1 or P3Tsel!=1 or P3Tsel!=1)
+        {
+          QString msg = tr("BLSURF_PERIODICITY_WRONG_NUMBER_OF_VERTICES");
+          SUIT_MessageBox::critical( dlg(),"Error" , msg );
+          return;
+        }
+    }
+
+  // Add Source-Target in table
+  string shapeEntry, sourceEntry, targetEntry;
+  string shapeName, sourceName, targetName;
+  GEOM::GEOM_Object_var shape;
+
+  QTreeWidgetItem* item = new QTreeWidgetItem();
+  myPeriodicityTreeWidget->addTopLevelItem(item);
+
+  item->setFlags( Qt::ItemIsSelectable   |Qt::ItemIsEnabled );
+
+
+  size_t k=0;
+  for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
+    {
+      StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
+      shape = w1->GetObject< GEOM::GEOM_Object >(0);
+      shapeName = shape->GetName();
+      shapeEntry = shape->GetStudyEntry();
+      item->setData(k, Qt::EditRole, shapeName.c_str() );
+      item->setData(k, Qt::UserRole, shapeEntry.c_str() );
+      if (not myPeriodicityGroupBox2->isChecked() and k==1)
+        break;
+    }
+
+  // Add shape type in tree
+  string onFace = (myPeriodicityOnFaceRadioButton->isChecked()) ? "1" : "0";
+  item->setData(PERIODICITY_SHAPE_TYPE, Qt::UserRole, onFace.c_str());
+
+  // Blank input fields
+  for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++)
+    {
+      StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
+      w1->SetObject(GEOM::GEOM_Object::_nil());
+    }
+
+//  for (int column = 0; column < myPeriodicityTreeWidget->columnCount(); ++column)
+//    myPeriodicityTreeWidget->resizeColumnToContents(column);
+
+}
+
+/** BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity()
+This method is called when a item is removed from the periodicity tree widget
+*/
+void BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity() {
+//   MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex");
+  QList<QTreeWidgetItem *> selectedItems = myPeriodicityTreeWidget->selectedItems();
+  QTreeWidgetItem* item;
+
+  foreach(item,selectedItems) {
+     MESSAGE("Remove " << item->text(0).toStdString());
+    delete item;
+  }
+
+  myEnforcedTreeWidget->selectionModel()->clearSelection();
+}
+
+/** BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked()
+This method enable clears the field for periodicity by vertices
+*/
+void BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked(bool checked)
+{
+  if (not checked)
+    {
+      for (size_t k=2; k<myPeriodicitySelectionWidgets.size(); k++)
+        {
+          StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k] );
+          w1->deactivateSelection();
+          w1->SetObject(CORBA::Object::_nil());
+        }
+    }
+}
+
+/** BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
+This method enable the proper shape selection widget to Face or Edge shapes
+*/
+//void BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
+//{
+//  if (myPeriodicityOnFaceRadioButton->isChecked())
+//    {
+//      MESSAGE("Show Face");
+//      myPeriodicitySourceEdgeWdg->hide();
+//      myPeriodicityTargetEdgeWdg->hide();
+//      myPeriodicitySourceFaceWdg->show();
+//      myPeriodicityTargetFaceWdg->show();
+//    }
+//  else
+//    {
+//      MESSAGE("Show Edge");
+//      myPeriodicitySourceFaceWdg->hide();
+//      myPeriodicityTargetFaceWdg->hide();
+//      myPeriodicitySourceEdgeWdg->show();
+//      myPeriodicityTargetEdgeWdg->show();
+//    }
+//}
+
+void BLSURFPluginGUI_HypothesisCreator::onPeriodicityTreeClicked(QTreeWidgetItem* item, int row)
+{
+  QString shapeName, shapeEntry;
+  CORBA::Object_var shape;
+  size_t k=0;
+  ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
+  for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
+    {
+      StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
+
+      shapeName = item->data(k, Qt::EditRole).toString();
+      shapeEntry = item->data(k, Qt::UserRole).toString();
+      if (not shapeEntry.isEmpty())
+        {
+          shape = entryToObject(shapeEntry);
+          w1->SetObject(shape);
+          w1->deactivateSelection();
+          if (k==2)
+            myPeriodicityGroupBox2->setChecked(1);
+        }
+      else if(k==2)
+        myPeriodicityGroupBox2->setChecked(0);
+    }
+
+  if (item->data(PERIODICITY_SHAPE_TYPE, Qt::UserRole) == "1")
+    myPeriodicityOnFaceRadioButton->setChecked(true);
+  else
+    myPeriodicityOnEdgeRadioButton->setChecked(true);
+
+
+}
+
+/** BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
+This method gives the focus to the next selection widget when a content is modified in a selection widget.
+*/
+void BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
+{
+  BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
+
+  ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
+  size_t k=0;
+  // find wich selection widget is activated
+  for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
+    {
+      StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
+      if (w1->IsSelectionActivated() and k<(myPeriodicitySelectionWidgets.size()-1))
+        {
+          // don't activate vertex selection if the group box is not checked
+          if (k==1 and not myPeriodicityGroupBox2->isChecked())
+            break;
+          // clear the selection, to avoid to put the same object in the other widget
+          that->getGeomSelectionTool()->selectionMgr()->clearSelected();
+          // activate the next widget
+          StdMeshersGUI_ObjectReferenceParamWdg * w2 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k+1] );
+          w2->activateSelection();
+          break;
+        }
+    }
+}
+
+
 /** BLSURFPluginGUI_HypothesisCreator::retrieveParams()
 This method updates the GUI widgets with the hypothesis data
 */
@@ -1488,6 +1944,26 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
   myInternalEnforcedVerticesAllFacesGroup->setText(QString(data.myInternalEnforcedVerticesAllFacesGroup.c_str()));
   myInternalEnforcedVerticesAllFacesGroup->setEnabled(data.myInternalEnforcedVerticesAllFaces);
 
+  // Periodicity
+  MESSAGE("retrieveParams(): periodicity ");
+
+
+  // Add an item in the tree widget for each association
+  for (size_t i=0 ; i<data.preCadPeriodicityVector.size() ; i++)
+    {
+      QTreeWidgetItem* item = new QTreeWidgetItem();
+      myPeriodicityTreeWidget->addTopLevelItem(item);
+      item->setFlags( Qt::ItemIsSelectable   |Qt::ItemIsEnabled );
+      TPreCadPeriodicity periodicity_i = data.preCadPeriodicityVector[i];
+      for (size_t k=0; k<periodicity_i.size(); k++)
+        {
+          string shapeEntry = periodicity_i[k];
+          string shapeName = myGeomToolSelected->getNameFromEntry(shapeEntry);
+          item->setData(k, Qt::EditRole, shapeName.c_str() );
+          item->setData(k, Qt::UserRole, shapeEntry.c_str() );
+        }
+    }
+
   // update widgets
   that->myStdWidget->onPhysicalMeshChanged();
   that->myStdWidget->onGeometricMeshChanged();
@@ -1498,6 +1974,7 @@ This method updates the hypothesis data with the GUI widgets content.
 */
 QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
 {
+  MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParams");
   BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
 
   BlsurfHypothesisData data;
@@ -1625,7 +2102,7 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData
   }
   
   // attractor new version
-  MESSAGE("retrieveParams, Attractors")
+  MESSAGE("readParamsFromHypo, Attractors")
   BLSURFPlugin::TAttParamsMap_var allMyAttractorParams = h->GetAttractorParams();
   for ( int i = 0;i<allMyAttractorParams->length(); ++i ) {
     BLSURFPlugin::TAttractorParams myAttractorParams =  allMyAttractorParams[i];
@@ -1688,9 +2165,55 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData
   h_data.myInternalEnforcedVerticesAllFaces = h->GetInternalEnforcedVertexAllFaces();
   h_data.myInternalEnforcedVerticesAllFacesGroup = h->GetInternalEnforcedVertexAllFacesGroup();
 
+  // Periodicity
+  MESSAGE("readParamsFromHypo, Periodicity")
+
+  h_data.preCadPeriodicityVector.clear();
+
+  BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector = h->GetPreCadFacesPeriodicityVector();
+  AddPreCadSequenceToVector(h_data, preCadFacePeriodicityVector, true);
+
+  BLSURFPlugin::TPeriodicityList_var preCadEdgePeriodicityVector = h->GetPreCadEdgesPeriodicityVector();
+  AddPreCadSequenceToVector(h_data, preCadEdgePeriodicityVector, false);
   return true;
 }
 
+void BLSURFPluginGUI_HypothesisCreator::AddPreCadSequenceToVector(BlsurfHypothesisData& h_data,
+    BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector, bool onFace) const
+{
+
+  for (size_t i=0; i<preCadFacePeriodicityVector->length(); i++ )
+    {
+      TPreCadPeriodicity periodicity_i(PERIODICITY_NB_COLUMN);
+      periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN] = preCadFacePeriodicityVector[i].shape1Entry.in();
+      periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN] = preCadFacePeriodicityVector[i].shape2Entry.in();
+
+      BLSURFPlugin::TEntryList sourceVertices = preCadFacePeriodicityVector[i].theSourceVerticesEntries;
+      BLSURFPlugin::TEntryList targetVertices = preCadFacePeriodicityVector[i].theTargetVerticesEntries;
+
+      if (sourceVertices.length()!=0)
+        {
+          periodicity_i[PERIODICITY_P1_SOURCE_COLUMN] = sourceVertices[0].in();
+          periodicity_i[PERIODICITY_P2_SOURCE_COLUMN] = sourceVertices[1].in();
+          periodicity_i[PERIODICITY_P3_SOURCE_COLUMN] = sourceVertices[2].in();
+        }
+
+      if (targetVertices.length()!=0)
+        {
+          periodicity_i[PERIODICITY_P1_TARGET_COLUMN] = targetVertices[0].in();
+          periodicity_i[PERIODICITY_P2_TARGET_COLUMN] = targetVertices[1].in();
+          periodicity_i[PERIODICITY_P3_TARGET_COLUMN] = targetVertices[2].in();
+        }
+
+      if (onFace)
+        periodicity_i[PERIODICITY_SHAPE_TYPE] = "1";
+      else
+        periodicity_i[PERIODICITY_SHAPE_TYPE] = "0";
+
+      h_data.preCadPeriodicityVector.push_back(periodicity_i);
+    }
+}
+
 /** BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo(h_data)
 Saves the hypothesis data to hypothesis values.
 */
@@ -1870,6 +2393,47 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi
     if ( h->GetInternalEnforcedVertexAllFacesGroup() != h_data.myInternalEnforcedVerticesAllFacesGroup )
       h->SetInternalEnforcedVertexAllFacesGroup( h_data.myInternalEnforcedVerticesAllFacesGroup.c_str() );
 
+    // Periodicity
+    if ( h->GetPreCadFacesPeriodicityVector()->length() > 0 or h->GetPreCadEdgesPeriodicityVector()->length() > 0 )
+          h->ClearPreCadPeriodicityVectors();
+
+    MESSAGE("h_data.preCadPeriodicityVector.size(): " << h_data.preCadPeriodicityVector.size());
+    TPreCadPeriodicityVector::const_iterator pIt = h_data.preCadPeriodicityVector.begin();
+    for ( ; pIt != h_data.preCadPeriodicityVector.end() ; ++pIt)
+      {
+        TPreCadPeriodicity periodicity_i = *pIt;
+        TEntry source = periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN];
+        TEntry target = periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN];
+        TEntry p1Source = periodicity_i[PERIODICITY_P1_SOURCE_COLUMN];
+        TEntry p2Source = periodicity_i[PERIODICITY_P2_SOURCE_COLUMN];
+        TEntry p3Source = periodicity_i[PERIODICITY_P3_SOURCE_COLUMN];
+        TEntry p1Target = periodicity_i[PERIODICITY_P1_TARGET_COLUMN];
+        TEntry p2Target = periodicity_i[PERIODICITY_P2_TARGET_COLUMN];
+        TEntry p3Target = periodicity_i[PERIODICITY_P3_TARGET_COLUMN];
+        bool onFace = (periodicity_i[PERIODICITY_SHAPE_TYPE]=="1") ? true : false;
+
+        BLSURFPlugin::TEntryList_var sourceVertices = new BLSURFPlugin::TEntryList();
+        sourceVertices->length(3);
+        sourceVertices[0]=CORBA::string_dup(p1Source.c_str());
+        sourceVertices[1]=CORBA::string_dup(p2Source.c_str());
+        sourceVertices[2]=CORBA::string_dup(p3Source.c_str());
+
+
+        BLSURFPlugin::TEntryList_var targetVertices = new BLSURFPlugin::TEntryList();
+        targetVertices->length(3);
+        targetVertices[0]=CORBA::string_dup(p1Target.c_str());
+        targetVertices[1]=CORBA::string_dup(p2Target.c_str());
+        targetVertices[2]=CORBA::string_dup(p3Target.c_str());
+
+        if (onFace)
+          h->AddPreCadFacesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
+        else
+          h->AddPreCadEdgesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
+      }
+
+    MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo end periodicity");
+
+
   } // try
   catch(const std::exception& ex) {
     std::cout << "Exception: " << ex.what() << std::endl;
@@ -1881,6 +2445,7 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi
 // //     SalomeApp_Tools::QtCatchCorbaException(ex);
 // //     ok = false;
 //   }
+  MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo end");
   return ok;
 }
 
@@ -2042,6 +2607,26 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes
   h_data.myInternalEnforcedVerticesAllFaces      = myInternalEnforcedVerticesAllFaces->isChecked();
   h_data.myInternalEnforcedVerticesAllFacesGroup = myInternalEnforcedVerticesAllFacesGroup->text().toStdString();
 
+  // Periodicity
+  h_data.preCadPeriodicityVector.clear();
+  // For each tree item, store each value. Shapes are stored as entries.
+  int nbPeriodicityDescriptions = myPeriodicityTreeWidget->topLevelItemCount();
+  for (size_t i=0 ; i<nbPeriodicityDescriptions ; i++) {
+    QTreeWidgetItem* item = myPeriodicityTreeWidget->topLevelItem(i);
+    TPreCadPeriodicity periodicity_i;
+    if (item) {
+        for (size_t k=0; k<myPeriodicityTreeWidget->columnCount(); ++k)
+          {
+            MESSAGE(k);
+            std::string entry = item->data(k, Qt::UserRole).toString().toStdString();
+            MESSAGE(entry);
+            periodicity_i.push_back(entry);
+          }
+        h_data.preCadPeriodicityVector.push_back(periodicity_i);
+    }
+    guiHyp += "PERIODICITY = yes; ";
+  }
+
   MESSAGE("guiHyp : " << guiHyp.toLatin1().data());
   return guiHyp;
 }
index 349e275ed8e37d70fc67dc0e2ce8772a666d07d8..b43af772ea8b451b1b0a5181142ff55d62db6d61 100644 (file)
@@ -85,8 +85,13 @@ class QAction;
 class QTreeWidgetItem;
 class QTableWidgetItem;
 class QObject;
+class QSplitter;
+class QGridLayout;
+class QVBoxLayout;
+class QSpacerItem;
 
 class SMESHGUI_SpinBox;
+class SMESH_NumberFilter;
 class LightApp_SelectionMgr;
 class BLSURFPluginGUI_StdWidget;
 class BLSURFPluginGUI_AdvWidget;
@@ -133,6 +138,10 @@ typedef std::map< TEntry, TEnfVertexList > TFaceEntryEnfVertexListMap;
 // Map Face Entry / InternalEnforcedVertices
 typedef std::map< TEntry, bool > TFaceEntryInternalVerticesMap;
 
+// PreCad Face and Edge periodicity
+typedef std::vector<std::string> TPreCadPeriodicity;
+typedef std::vector< TPreCadPeriodicity > TPreCadPeriodicityVector;
+
 typedef struct
 {
   int     myTopology, myVerbosity;
@@ -153,6 +162,7 @@ typedef struct
   /* TODO GROUPS
   TGroupNameEnfVertexListMap groupNameEnfVertexListMap;
   */
+  TPreCadPeriodicityVector preCadPeriodicityVector;
   QString myName;
 } BlsurfHypothesisData;
 
@@ -207,6 +217,13 @@ protected slots:
 //   void                deactivateSelection(QWidget*, QWidget*);
   void                clearEnforcedVertexWidgets();
   void                onInternalVerticesClicked(int);
+  // Periodicity tab
+  void                onPeriodicityByVerticesChecked(bool);
+  void                onPeriodicityRadioButtonChanged();
+  void                onAddPeriodicity();
+  void                onRemovePeriodicity();
+  void                onPeriodicityTreeClicked(QTreeWidgetItem*, int);
+  void                onPeriodicityContentModified();
 
 private:
   bool                readParamsFromHypo( BlsurfHypothesisData& ) const;
@@ -223,6 +240,8 @@ private:
   int                 findRowFromEntry(QString entry);
   CORBA::Object_var   entryToObject(QString entry);
   static LightApp_SelectionMgr* selectionMgr();
+  void                avoidSimultaneousSelection(ListOfWidgets &myCustomWidgets) const;
+  void                AddPreCadSequenceToVector(BlsurfHypothesisData& h_data, BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector, bool onFace) const;
 
 private:
   
@@ -299,6 +318,46 @@ private:
   GeomSelectionTools*             GeomToolSelected;
   LightApp_SelectionMgr*          aSel;
 
+  // Periodicity
+  QWidget* myPeriodicityGroup;
+  QSplitter* myPeriodicitySplitter;
+  QTreeWidget* myPeriodicityTreeWidget;
+  QWidget* myPeriodicityRightWidget;
+  QGridLayout* myPeriodicityRightGridLayout;
+  QGroupBox* myPeriodicityGroupBox1;
+  QGroupBox* myPeriodicityGroupBox2;
+  QGridLayout* aPeriodicityLayout1;
+  QGridLayout* myPeriodicityGroupBox1Layout;
+  QGridLayout* myPeriodicityGroupBox2Layout;
+  QRadioButton* myPeriodicityOnFaceRadioButton;
+  QRadioButton* myPeriodicityOnEdgeRadioButton;
+  QLabel* myPeriodicityMainSourceLabel;
+  QLabel* myPeriodicityMainTargetLabel;
+  QLabel* myPeriodicitySourceLabel;
+  QLabel* myPeriodicityTargetLabel;
+  StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicitySourceFaceWdg;
+//  StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicitySourceEdgeWdg;
+  GEOM::GEOM_Object_var myPeriodicityFace;
+  StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityTargetFaceWdg;
+//  StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityTargetEdgeWdg;
+  GEOM::GEOM_Object_var myPeriodicityEdge;
+  QLabel* myPeriodicityP1SourceLabel;
+  QLabel* myPeriodicityP2SourceLabel;
+  QLabel* myPeriodicityP3SourceLabel;
+  QLabel* myPeriodicityP1TargetLabel;
+  QLabel* myPeriodicityP2TargetLabel;
+  QLabel* myPeriodicityP3TargetLabel;
+  StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP1SourceWdg;
+  StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP2SourceWdg;
+  StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP3SourceWdg;
+  StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP1TargetWdg;
+  StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP2TargetWdg;
+  StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP3TargetWdg;
+  ListOfWidgets myPeriodicitySelectionWidgets;
+  QPushButton* myPeriodicityAddButton;
+  QPushButton* myPeriodicityRemoveButton;
+  QSpacerItem* myPeriodicityVerticalSpacer;
+
   BLSURFPlugin::string_array_var myOptions, myPreCADOptions;
 
   PyObject *          main_mod;
index 6d24616ab182dd08dd7548de33f8dd7742bcdc64..86cb3e619c0cc1ba1e8e33681631504c0d1c4dcd 100644 (file)
@@ -434,5 +434,117 @@ The smaller this distance is, the closer the mesh is to the exact surface (only
         <source>ZERO_VALUE_OF</source>
         <translation>Invalid value (zero) of "%1"</translation>
     </message>
+    <message>
+        <source>BLSURF_PERIODICITY</source>
+        <translation>Periodicity</translation>
+    </message>
+    <message>
+        <source>BLSURF_PRECAD_PERIODICITY</source>
+        <translation>Periodicity association (using PreCAD)</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_ON_FACE</source>
+        <translation>On face</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_ON_EDGE</source>
+        <translation>On edge only</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_OBJ_SOURCE_COLUMN</source>
+        <translation>Source</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_OBJ_TARGET_COLUMN</source>
+        <translation>Target</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P1_SOURCE_COLUMN</source>
+        <translation>P1</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P2_SOURCE_COLUMN</source>
+        <translation>P2</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P3_SOURCE_COLUMN</source>
+        <translation>P3</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P1_TARGET_COLUMN</source>
+        <translation>P1</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P2_TARGET_COLUMN</source>
+        <translation>P2</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P3_TARGET_COLUMN</source>
+        <translation>P3</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_MAIN_SOURCE</source>
+        <translation>Source</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_MAIN_TARGET</source>
+        <translation>Target</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_SOURCE</source>
+        <translation>Source</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_TARGET</source>
+        <translation>Target</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_WITH_VERTICES</source>
+        <translation>Transformation vertices</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P1_SOURCE</source>
+        <translation>P1</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P2_SOURCE</source>
+        <translation>P2</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P3_SOURCE</source>
+        <translation>P3</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P1_TARGET</source>
+        <translation>P1</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P2_TARGET</source>
+        <translation>P2</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P3_TARGET</source>
+        <translation>P3</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_ADD</source>
+        <translation>Add</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_REMOVE</source>
+        <translation>Remove</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_WRONG_NUMBER_OF_VERTICES</source>
+        <translation>Wrong number of vertices provided</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_SELECT_FACE</source>
+        <translation>Face</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_SELECT_EDGE</source>
+        <translation>Edge</translation>
+    </message>
 </context>
 </TS>
index db53724bfc2c5a9081568a68d66e00c3e579b5d7..6094b0be8b30b3890a032989f7dc073e3a14023a 100755 (executable)
@@ -434,5 +434,117 @@ Plus la distance est petite, plus le maillage sera proche de la surface (disponi
         <source>BLSURF_ENF_VER_INTERNAL_VERTICES</source>
         <translation>Utiliser les points internes de toutes les faces</translation>
     </message>
+        <message>
+        <source>BLSURF_PERIODICITY</source>
+        <translation>Periodicité</translation>
+    </message>
+    <message>
+        <source>BLSURF_PRECAD_PERIODICITY</source>
+        <translation>Association périodique (utilise PreCAD)</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_ON_FACE</source>
+        <translation>Sur les faces</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_ON_EDGE</source>
+        <translation>Sur les arêtes uniquement</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_OBJ_SOURCE_COLUMN</source>
+        <translation>Source</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_OBJ_TARGET_COLUMN</source>
+        <translation>Cible</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P1_SOURCE_COLUMN</source>
+        <translation>P1</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P2_SOURCE_COLUMN</source>
+        <translation>P2</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P3_SOURCE_COLUMN</source>
+        <translation>P3</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P1_TARGET_COLUMN</source>
+        <translation>P1</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P2_TARGET_COLUMN</source>
+        <translation>P2</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P3_TARGET_COLUMN</source>
+        <translation>P3</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_MAIN_SOURCE</source>
+        <translation>Source</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_MAIN_TARGET</source>
+        <translation>Cible</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_SOURCE</source>
+        <translation>Source</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_TARGET</source>
+        <translation>Cible</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_WITH_VERTICES</source>
+        <translation>Points définissant la transformation</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P1_SOURCE</source>
+        <translation>P1</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P2_SOURCE</source>
+        <translation>P2</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P3_SOURCE</source>
+        <translation>P3</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P1_TARGET</source>
+        <translation>P1</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P2_TARGET</source>
+        <translation>P2</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_P3_TARGET</source>
+        <translation>P3</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_ADD</source>
+        <translation>Ajouter</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_REMOVE</source>
+        <translation>Supprimer</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_WRONG_NUMBER_OF_VERTICES</source>
+        <translation>Le nombre de points fournis n'est pas correct</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_SELECT_FACE</source>
+        <translation>Face</translation>
+    </message>
+    <message>
+        <source>BLSURF_PERIODICITY_SELECT_EDGE</source>
+        <translation>Arête</translation>
+    </message>
 </context>
 </TS>
index b6e5de4d9f5735cb3f8836b69724d20d9a206e01..5fb0085fd664fdd0dde5cc6ef9c7e951661f84c1 100644 (file)
@@ -114,44 +114,9 @@ def proj_z(shape1):
     shape2 = geompy.MakeTranslation(shape1, 0, 0, 100.)
     return shape2
 
-def AddAdvancedFacesPeriodicity(faces1, faces2, f_transf):
-    # Periodicity left/right
-    source_faces = geompy.SubShapeAll(faces1, geompy.ShapeType["FACE"])
-    i = 0
-    j = 0
-    k = 0
-    for source_face in source_faces:
-        geompy.addToStudyInFather(faces1, source_face, "source_face_%i"%i)
-        p_source = geompy.MakeVertexInsideFace(source_face)
-        p_target = f_transf(p_source)
-        target_face = geompy.GetFaceNearPoint(faces2, p_target)
-        geompy.addToStudyInFather(faces2, target_face, "target_face_%i"%i)
-        algo2d.AddFacePeriodicity(source_face, target_face)
-        i += 1
-        
-        source_edges = geompy.SubShapeAll(source_face, geompy.ShapeType["EDGE"])
-        for source_edge in source_edges:
-            geompy.addToStudyInFather(faces1, source_edge, "source_edge_%i"%(j))
-            p_source = geompy.MakeVertexOnCurve(source_edge, 0.5)
-            p_target = f_transf(p_source)
-            target_edge = geompy.GetEdgeNearPoint(faces2, p_target)
-            geompy.addToStudyInFather(faces2, target_edge, "target_edge_%i"%(j))
-            algo2d.AddEdgePeriodicity(source_face, source_edge, target_face, target_edge)
-            j += 1
-            
-            source_vertices = geompy.SubShapeAll(source_edge, geompy.ShapeType["VERTEX"])
-            for source_vertex in source_vertices:
-                geompy.addToStudyInFather(faces1, source_vertex, "source_vertex_%i"%(k))
-                target_vertex_tmp = f_transf(source_vertex)
-                target_vertex = geompy.GetSame(faces2, target_vertex_tmp)
-                geompy.addToStudyInFather(faces2, target_vertex, "target_vertex_%i"%(k))
-                algo2d.AddVertexPeriodicity(source_edge, source_vertex, target_edge, target_vertex)
-                k += 1
-    pass
-
-AddAdvancedFacesPeriodicity(back, front, proj_x)
-AddAdvancedFacesPeriodicity(left, right, proj_y)
-AddAdvancedFacesPeriodicity(bottom, top, proj_z)
+algo2d.AddAdvancedFacesPeriodicity(back, front, proj_x)
+algo2d.AddAdvancedFacesPeriodicity(left, right, proj_y)
+algo2d.AddAdvancedFacesPeriodicity(bottom, top, proj_z)
 
 gr_left = Mesh.Group(left)
 gr_right = Mesh.Group(right)
index 405093efa73c202484679a4f78cb62c7606d0b33..13c7fcd36c7d1957b30f2b516b5f29a7a8072bd8 100644 (file)
@@ -77,33 +77,8 @@ def proj_y(shape1):
     shape2 = geompy.MakeTranslation(shape1, 0, 10., 0)
     return shape2
 
-def AddAdvancedEdgesPeriodicity(edges1, edges2, f_transf):
-    source_edges = geompy.SubShapeAll(edges1, geompy.ShapeType["EDGE"])
-    j = 0
-    k = 0
-    for source_edge in source_edges:
-        geompy.addToStudyInFather(edges1, source_edge, "source_edge_%i"%j)
-        p_source = geompy.MakeVertexOnCurve(source_edge, 0.5)
-        p_target = f_transf(p_source)
-        target_edge = geompy.GetEdgeNearPoint(part, p_target)
-        geompy.addToStudyInFather(edges2, target_edge, "target_edge_%i"%j)
-        algo2d.AddEdgePeriodicityWithoutFaces(source_edge, target_edge)
-        
-        j += 1
-        
-        source_vertices = geompy.SubShapeAll(source_edge, geompy.ShapeType["VERTEX"])
-        for source_vertex in source_vertices:
-            geompy.addToStudyInFather(edges1, source_vertex, "source_vertex_%i"%k)
-            target_vertex_tmp = geompy.MakeTranslation(source_vertex, 10, 0., 0)
-            target_vertex_tmp = f_transf(source_vertex)
-            target_vertex = geompy.GetSame(part, target_vertex_tmp)
-            geompy.addToStudyInFather(edges2, target_vertex, "target_vertex_%i"%k)
-            algo2d.AddVertexPeriodicity(source_edge, source_vertex, target_edge, target_vertex)
-            
-            k += 1
-    
-AddAdvancedEdgesPeriodicity(left, right, proj_x)
-AddAdvancedEdgesPeriodicity(bottom, top, proj_y)
+algo2d.AddAdvancedEdgesPeriodicity(left, right, proj_x)
+algo2d.AddAdvancedEdgesPeriodicity(bottom, top, proj_y)
 
 Mesh.Compute()
 
index f9806ce7d679e67f8432c889e3a7af6b202c2844..93821710eff333cdb71342e99b9b2ca9ad7b4de1 100644 (file)
@@ -108,4 +108,3 @@ checkProjection(gr_top, bottom_translated)
 
 if salome.sg.hasDesktop():
   salome.sg.updateObjBrowser(1)
-  
index ed4f13496331f5dc02ce5899e41a1c54c878c256..2ff31adbe6a032c883395940372d6fb19484b0ec 100644 (file)
@@ -92,42 +92,7 @@ def rota_z(shape1):
     shape2 = geompy.MakeRotation(shape1, axe, -math.pi/2)
     return shape2
 
-def AddAdvancedFacesPeriodicity(faces1, faces2, f_transf):
-    # Periodicity left/right
-    source_faces = geompy.SubShapeAll(faces1, geompy.ShapeType["FACE"])
-    i = 0
-    j = 0
-    k = 0
-    for source_face in source_faces:
-        geompy.addToStudyInFather(faces1, source_face, "source_face_%i"%i)
-        p_source = geompy.MakeVertexInsideFace(source_face)
-        p_target = f_transf(p_source)
-        target_face = geompy.GetFaceNearPoint(faces2, p_target)
-        geompy.addToStudyInFather(faces2, target_face, "target_face_%i"%i)
-        algo2d.AddFacePeriodicity(source_face, target_face)
-        i += 1
-        
-        source_edges = geompy.SubShapeAll(source_face, geompy.ShapeType["EDGE"])
-        for source_edge in source_edges:
-            geompy.addToStudyInFather(faces1, source_edge, "source_edge_%i"%(j))
-            p_source = geompy.MakeVertexOnCurve(source_edge, 0.5)
-            p_target = f_transf(p_source)
-            target_edge = geompy.GetEdgeNearPoint(faces2, p_target)
-            geompy.addToStudyInFather(faces2, target_edge, "target_edge_%i"%(j))
-            algo2d.AddEdgePeriodicity(source_face, source_edge, target_face, target_edge)
-            j += 1
-            
-            source_vertices = geompy.SubShapeAll(source_edge, geompy.ShapeType["VERTEX"])
-            for source_vertex in source_vertices:
-                geompy.addToStudyInFather(faces1, source_vertex, "source_vertex_%i"%(k))
-                target_vertex_tmp = f_transf(source_vertex)
-                target_vertex = geompy.GetSame(faces2, target_vertex_tmp)
-                geompy.addToStudyInFather(faces2, target_vertex, "target_vertex_%i"%(k))
-                algo2d.AddVertexPeriodicity(source_edge, source_vertex, target_edge, target_vertex)
-                k += 1
-    pass
-
-AddAdvancedFacesPeriodicity(left, front, rota_z)
+algo2d.AddAdvancedFacesPeriodicity(left, front, rota_z)
 
 gr_left = Mesh.Group(left)
 gr_right = Mesh.Group(right)
index 7405bad3e34b8134d81bec57de790ed4ef747322..8bc95c894068f484a538ab367d91322817b102ee 100644 (file)
@@ -75,32 +75,7 @@ def rota_z(shape1):
     shape2 = geompy.MakeRotation(shape1, axe, -math.pi/2)
     return shape2
 
-def AddAdvancedEdgesPeriodicity(edges1, edges2, f_transf):
-    source_edges = geompy.SubShapeAll(edges1, geompy.ShapeType["EDGE"])
-    j = 0
-    k = 0
-    for source_edge in source_edges:
-        geompy.addToStudyInFather(edges1, source_edge, "source_edge_%i"%j)
-        p_source = geompy.MakeVertexOnCurve(source_edge, 0.5)
-        p_target = f_transf(p_source)
-        target_edge = geompy.GetEdgeNearPoint(part, p_target)
-        geompy.addToStudyInFather(edges2, target_edge, "target_edge_%i"%j)
-        algo2d.AddEdgePeriodicityWithoutFaces(source_edge, target_edge)
-        
-        j += 1
-        
-        source_vertices = geompy.SubShapeAll(source_edge, geompy.ShapeType["VERTEX"])
-        for source_vertex in source_vertices:
-            geompy.addToStudyInFather(edges1, source_vertex, "source_vertex_%i"%k)
-            target_vertex_tmp = geompy.MakeTranslation(source_vertex, 10, 0., 0)
-            target_vertex_tmp = f_transf(source_vertex)
-            target_vertex = geompy.GetSame(part, target_vertex_tmp)
-            geompy.addToStudyInFather(edges2, target_vertex, "target_vertex_%i"%k)
-            algo2d.AddVertexPeriodicity(source_edge, source_vertex, target_edge, target_vertex)
-            
-            k += 1
-    
-AddAdvancedEdgesPeriodicity(bottom, right, rota_z)
+algo2d.AddAdvancedEdgesPeriodicity(bottom, right, rota_z)
 
 Mesh.Compute()
 
index 5da7dd962675413a6ae57dab377e27ad07e69b93..efaee7c45aa4812e38d2d28e80c552cd34b6c1c9 100644 (file)
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 import salome