From: bourcier Date: Wed, 2 Oct 2013 14:18:41 +0000 (+0000) Subject: Adding PreCAD periodicity in Parameters Hypothesis dialog box X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FBR_V7_periodicity;p=plugins%2Fblsurfplugin.git Adding PreCAD periodicity in Parameters Hypothesis dialog box --- diff --git a/doc/salome/examples/test_periodicity.py b/doc/salome/examples/test_periodicity.py new file mode 100644 index 0000000..b6e5de4 --- /dev/null +++ b/doc/salome/examples/test_periodicity.py @@ -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 index 0000000..8a10dda --- /dev/null +++ b/doc/salome/examples/test_periodicity_precad.py @@ -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 index 0000000..2ff31ad --- /dev/null +++ b/doc/salome/examples/test_periodicity_reflexion_advanced.py @@ -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) + diff --git a/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters.png b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters.png index 82c7e90..fb44312 100644 Binary files a/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters.png and b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters.png differ diff --git a/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_advanced.png b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_advanced.png index 1f2b0ee..b3cf063 100644 Binary files a/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_advanced.png and b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_advanced.png differ diff --git a/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_enforced_vertices.png b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_enforced_vertices.png index 33996a6..55c8714 100644 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 index 0000000..3c8807c Binary files /dev/null and b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_periodicity.png differ diff --git a/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_sizemap1.png b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_sizemap1.png index 4ae88c8..cb095f7 100644 Binary files a/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_sizemap1.png and b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_sizemap1.png differ diff --git a/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_sizemap2.png b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_parameters_sizemap2.png index e5e000d..809ef6a 100644 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 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 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 index 0000000..0001bec Binary files /dev/null and b/doc/salome/gui/BLSURFPLUGIN/images/blsurf_periodicity_translation.png differ diff --git a/doc/salome/gui/BLSURFPLUGIN/input/blsurf_hypo.doc b/doc/salome/gui/BLSURFPLUGIN/input/blsurf_hypo.doc index 481510c..a4e77ad 100644 --- a/doc/salome/gui/BLSURFPLUGIN/input/blsurf_hypo.doc +++ b/doc/salome/gui/BLSURFPLUGIN/input/blsurf_hypo.doc @@ -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. diff --git a/doc/salome/gui/BLSURFPLUGIN/input/blsurfplugin_python_interface.doc b/doc/salome/gui/BLSURFPLUGIN/input/blsurfplugin_python_interface.doc index f6f83d4..f09654f 100644 --- a/doc/salome/gui/BLSURFPLUGIN/input/blsurfplugin_python_interface.doc +++ b/doc/salome/gui/BLSURFPLUGIN/input/blsurfplugin_python_interface.doc @@ -16,4 +16,16 @@ Below you can see an example of usage of the BLSURFPluginBuilder Python API for

Example of mesh generation with BLSurf algorithm:

\tui_script{blsurfdemo.py} +\anchor tui_blsurf_periodicity_preCAD +

Example of periodicity definition with preCAD

+\tui_script{test_periodicity_precad.py} + +\anchor tui_blsurf_periodicity_basic +

Example of basic periodicity definition (without preCAD)

+\tui_script{test_periodicity.py} + +\anchor tui_blsurf_periodicity_advanced +

Example of advanced periodicity definition (without preCAD)

+\tui_script{test_periodicity_reflexion_advanced.py} + */ diff --git a/idl/BLSURFPlugin_Algorithm.idl b/idl/BLSURFPlugin_Algorithm.idl index fe664b1..79b150d 100644 --- a/idl/BLSURFPlugin_Algorithm.idl +++ b/idl/BLSURFPlugin_Algorithm.idl @@ -110,6 +110,16 @@ module BLSURFPlugin }; typedef sequence TAttParamsMap; + // Periodicity + struct TPreCadPeriodicity { + TEntry shape1Entry; + TEntry shape2Entry; + TEntryList theSourceVerticesEntries; + TEntryList theTargetVerticesEntries; + }; + + typedef sequence 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(); /////////////////////// /*! diff --git a/src/BLSURFPlugin/BLSURFPluginBuilder.py b/src/BLSURFPlugin/BLSURFPluginBuilder.py index 7754191..5617b2d 100644 --- a/src/BLSURFPlugin/BLSURFPluginBuilder.py +++ b/src/BLSURFPlugin/BLSURFPluginBuilder.py @@ -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 diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index c7b098b..a994049 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -716,6 +716,17 @@ BLSURFPlugin_BLSURF::TListOfIDs _getSubShapeIDsInMainShape(TopoDS_Shape theMainS return face_ids; } +void BLSURFPlugin_BLSURF::addCoordsFromVertices(const std::vector &theVerticesEntries, std::vector &theVerticesCoords) +{ + for (std::vector::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 &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::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::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); + MESSAGE("periodicitySeparator 2: " <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: " <> shape2Entry); + isOK = (load >> periodicitySeparator); // __END_ENTRY2__ + if (periodicitySeparator != "__END_ENTRY2__") + throw std::exception(); + MESSAGE("shape2Entry: " <> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__ + MESSAGE("periodicitySeparator 1: " <> periodicitySeparator); + MESSAGE("periodicitySeparator 2: " <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: " <> theEdge1Entry); + isOK = (load >> periodicitySeparator); // __END_EDGE1__ + if (periodicitySeparator != "__END_EDGE1__") + throw std::exception(); + MESSAGE("theEdge1Entry: " <> theFace2Entry); + isOK = (load >> periodicitySeparator); // __END_FACE2__ + if (periodicitySeparator != "__END_FACE2__") + throw std::exception(); + MESSAGE("theFace2Entry: " <> theEdge2Entry); + isOK = (load >> periodicitySeparator); // __END_EDGE2__ + if (periodicitySeparator != "__END_EDGE2__") + throw std::exception(); + MESSAGE("theEdge2Entry: " <> edge_orientation); + isOK = (load >> periodicitySeparator); // __END_EDGE_ORIENTATION__ + if (periodicitySeparator != "__END_EDGE_ORIENTATION__") + throw std::exception(); + MESSAGE("edge_orientation: " <> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__ + MESSAGE("periodicitySeparator 1: " <> periodicitySeparator); + MESSAGE("periodicitySeparator 2: " <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: " <> theVertex1Entry); + isOK = (load >> periodicitySeparator); // __END_VERTEX1__ + if (periodicitySeparator != "__END_VERTEX1__") + throw std::exception(); + MESSAGE("theVertex1Entry: " <> theEdge2Entry); + isOK = (load >> periodicitySeparator); // __END_EDGE2__ + if (periodicitySeparator != "__END_EDGE2__") + throw std::exception(); + MESSAGE("theEdge2Entry: " <> theVertex2Entry); + isOK = (load >> periodicitySeparator); // __END_VERTEX2__ + if (periodicitySeparator != "__END_VERTEX2__") + throw std::exception(); + MESSAGE("theVertex2Entry: " < theSourceVerticesEntries; + std::vector 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); + MESSAGE("periodicitySeparator 2: " <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: " <> shape2Entry); + isOK = (load >> periodicitySeparator); // __END_ENTRY2__ + if (periodicitySeparator != "__END_ENTRY2__") + throw std::exception(); + MESSAGE("shape2Entry: " <> periodicitySeparator); + if (periodicitySeparator != "__END_SOURCE_VERTICES_LIST__") { + theSourceVerticesEntries.push_back(periodicitySeparator); + MESSAGE("theSourceVerticesEntries: " <> periodicitySeparator); + if (periodicitySeparator != "__END_TARGET_VERTICES_LIST__") { + theTargetVerticesEntries.push_back(periodicitySeparator); + MESSAGE("theTargetVerticesEntries: " < theSourceVerticesEntries; - std::vector theTargetVerticesEntries; + std::vector theSourceVerticesEntries; + std::vector 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 &theSourceVerticesEntries, std::vector &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; diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx index 066021e..22c3fe5 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx @@ -29,8 +29,6 @@ #include #include -#include - #include #include #include @@ -2670,25 +2668,103 @@ std::string BLSURFPlugin_Hypothesis_i::FormatVerticesEntries(vector &the if (!theSourceVerticesEntries.empty()) { listEntriesTxt << ", [" ; - for (size_t i = 0; i::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::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; ishape1Entry = 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; jtheSourceVerticesEntries = 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; jtheTargetVerticesEntries = 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) @@ -2705,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()) @@ -2723,21 +2800,23 @@ throw (SALOME::SALOME_Exception) string theFace2Entry = PublishIfNeeded(theFace2, GEOM::FACE, prefix2); string prefix3 = "Source_vertex_"; - vector 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 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(); @@ -2754,12 +2833,19 @@ throw (SALOME::SALOME_Exception) void BLSURFPlugin_Hypothesis_i::AddPreCadFacesPeriodicityEntry(const char* theFace1Entry, const char* theFace2Entry, - vector &theSourceVerticesEntries, vector &theTargetVerticesEntries) + const BLSURFPlugin::TEntryList& theSourceVerticesEntriesCorba, const BLSURFPlugin::TEntryList& theTargetVerticesEntriesCorba) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); + // Convert BLSURFPlugin::TEntryList to vector + vector 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() << ")"); @@ -2792,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(); @@ -2811,21 +2898,23 @@ void BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicityWithVertices(GEOM::GEOM string theEdge2Entry = PublishIfNeeded(theEdge2, GEOM::EDGE, prefix2); string prefix3 = "Source_vertex_"; - vector 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 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(); @@ -2842,12 +2931,19 @@ void BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicityWithVertices(GEOM::GEOM void BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicityEntry(const char* theEdge1Entry, const char* theEdge2Entry, - vector &theSourceVerticesEntries, vector &theTargetVerticesEntries) + const BLSURFPlugin::TEntryList& theSourceVerticesEntriesCorba, const BLSURFPlugin::TEntryList& theTargetVerticesEntriesCorba) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); + // Convert BLSURFPlugin::TEntryList to vector + vector 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() << ")"); diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx index c34d82a..af5e4b0 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx @@ -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 &theSourceVerticesEntries, vector &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 &theSourceVerticesEntries, vector &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) diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index 0e6a11c..8321191 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -58,6 +58,7 @@ #include #include #include +#include #include #include @@ -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 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; kdeactivateSelection(); + 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 ; iaddTopLevelItem(item); + item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled ); + TPreCadPeriodicity periodicity_i = data.preCadPeriodicityVector[i]; + for (size_t k=0; kgetNameFromEntry(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;ilength(); ++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; ilength(); 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 ; itopLevelItem(i); + TPreCadPeriodicity periodicity_i; + if (item) { + for (size_t k=0; kcolumnCount(); ++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; } diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h index 349e275..b43af77 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h @@ -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 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; diff --git a/src/GUI/BLSURFPlugin_msg_en.ts b/src/GUI/BLSURFPlugin_msg_en.ts index 6d24616..86cb3e6 100644 --- a/src/GUI/BLSURFPlugin_msg_en.ts +++ b/src/GUI/BLSURFPlugin_msg_en.ts @@ -434,5 +434,117 @@ The smaller this distance is, the closer the mesh is to the exact surface (only ZERO_VALUE_OF Invalid value (zero) of "%1" + + BLSURF_PERIODICITY + Periodicity + + + BLSURF_PRECAD_PERIODICITY + Periodicity association (using PreCAD) + + + BLSURF_PERIODICITY_ON_FACE + On face + + + BLSURF_PERIODICITY_ON_EDGE + On edge only + + + BLSURF_PERIODICITY_OBJ_SOURCE_COLUMN + Source + + + BLSURF_PERIODICITY_OBJ_TARGET_COLUMN + Target + + + BLSURF_PERIODICITY_P1_SOURCE_COLUMN + P1 + + + BLSURF_PERIODICITY_P2_SOURCE_COLUMN + P2 + + + BLSURF_PERIODICITY_P3_SOURCE_COLUMN + P3 + + + BLSURF_PERIODICITY_P1_TARGET_COLUMN + P1 + + + BLSURF_PERIODICITY_P2_TARGET_COLUMN + P2 + + + BLSURF_PERIODICITY_P3_TARGET_COLUMN + P3 + + + BLSURF_PERIODICITY_MAIN_SOURCE + Source + + + BLSURF_PERIODICITY_MAIN_TARGET + Target + + + BLSURF_PERIODICITY_SOURCE + Source + + + BLSURF_PERIODICITY_TARGET + Target + + + BLSURF_PERIODICITY_WITH_VERTICES + Transformation vertices + + + BLSURF_PERIODICITY_P1_SOURCE + P1 + + + BLSURF_PERIODICITY_P2_SOURCE + P2 + + + BLSURF_PERIODICITY_P3_SOURCE + P3 + + + BLSURF_PERIODICITY_P1_TARGET + P1 + + + BLSURF_PERIODICITY_P2_TARGET + P2 + + + BLSURF_PERIODICITY_P3_TARGET + P3 + + + BLSURF_PERIODICITY_ADD + Add + + + BLSURF_PERIODICITY_REMOVE + Remove + + + BLSURF_PERIODICITY_WRONG_NUMBER_OF_VERTICES + Wrong number of vertices provided + + + BLSURF_PERIODICITY_SELECT_FACE + Face + + + BLSURF_PERIODICITY_SELECT_EDGE + Edge + diff --git a/src/GUI/BLSURFPlugin_msg_fr.ts b/src/GUI/BLSURFPlugin_msg_fr.ts index db53724..6094b0b 100755 --- a/src/GUI/BLSURFPlugin_msg_fr.ts +++ b/src/GUI/BLSURFPlugin_msg_fr.ts @@ -434,5 +434,117 @@ Plus la distance est petite, plus le maillage sera proche de la surface (disponi BLSURF_ENF_VER_INTERNAL_VERTICES Utiliser les points internes de toutes les faces + + BLSURF_PERIODICITY + Periodicité + + + BLSURF_PRECAD_PERIODICITY + Association périodique (utilise PreCAD) + + + BLSURF_PERIODICITY_ON_FACE + Sur les faces + + + BLSURF_PERIODICITY_ON_EDGE + Sur les arêtes uniquement + + + BLSURF_PERIODICITY_OBJ_SOURCE_COLUMN + Source + + + BLSURF_PERIODICITY_OBJ_TARGET_COLUMN + Cible + + + BLSURF_PERIODICITY_P1_SOURCE_COLUMN + P1 + + + BLSURF_PERIODICITY_P2_SOURCE_COLUMN + P2 + + + BLSURF_PERIODICITY_P3_SOURCE_COLUMN + P3 + + + BLSURF_PERIODICITY_P1_TARGET_COLUMN + P1 + + + BLSURF_PERIODICITY_P2_TARGET_COLUMN + P2 + + + BLSURF_PERIODICITY_P3_TARGET_COLUMN + P3 + + + BLSURF_PERIODICITY_MAIN_SOURCE + Source + + + BLSURF_PERIODICITY_MAIN_TARGET + Cible + + + BLSURF_PERIODICITY_SOURCE + Source + + + BLSURF_PERIODICITY_TARGET + Cible + + + BLSURF_PERIODICITY_WITH_VERTICES + Points définissant la transformation + + + BLSURF_PERIODICITY_P1_SOURCE + P1 + + + BLSURF_PERIODICITY_P2_SOURCE + P2 + + + BLSURF_PERIODICITY_P3_SOURCE + P3 + + + BLSURF_PERIODICITY_P1_TARGET + P1 + + + BLSURF_PERIODICITY_P2_TARGET + P2 + + + BLSURF_PERIODICITY_P3_TARGET + P3 + + + BLSURF_PERIODICITY_ADD + Ajouter + + + BLSURF_PERIODICITY_REMOVE + Supprimer + + + BLSURF_PERIODICITY_WRONG_NUMBER_OF_VERTICES + Le nombre de points fournis n'est pas correct + + + BLSURF_PERIODICITY_SELECT_FACE + Face + + + BLSURF_PERIODICITY_SELECT_EDGE + Arête + diff --git a/tests/test_periodicity.py b/tests/test_periodicity.py index b6e5de4..5fb0085 100644 --- a/tests/test_periodicity.py +++ b/tests/test_periodicity.py @@ -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) diff --git a/tests/test_periodicity_2D.py b/tests/test_periodicity_2D.py index 405093e..13c7fcd 100644 --- a/tests/test_periodicity_2D.py +++ b/tests/test_periodicity_2D.py @@ -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() diff --git a/tests/test_periodicity_2D_precad.py b/tests/test_periodicity_2D_precad.py index f9806ce..9382171 100644 --- a/tests/test_periodicity_2D_precad.py +++ b/tests/test_periodicity_2D_precad.py @@ -108,4 +108,3 @@ checkProjection(gr_top, bottom_translated) if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1) - diff --git a/tests/test_periodicity_reflexion.py b/tests/test_periodicity_reflexion.py index ed4f134..2ff31ad 100644 --- a/tests/test_periodicity_reflexion.py +++ b/tests/test_periodicity_reflexion.py @@ -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) diff --git a/tests/test_periodicity_reflexion_2D.py b/tests/test_periodicity_reflexion_2D.py index 7405bad..8bc95c8 100644 --- a/tests/test_periodicity_reflexion_2D.py +++ b/tests/test_periodicity_reflexion_2D.py @@ -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() diff --git a/tests/test_periodicity_reflexion_precad.py b/tests/test_periodicity_reflexion_precad.py index 5da7dd9..efaee7c 100644 --- a/tests/test_periodicity_reflexion_precad.py +++ b/tests/test_periodicity_reflexion_precad.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python # -*- coding: utf-8 -*- import salome