From: bourcier Date: Wed, 21 Aug 2013 14:18:30 +0000 (+0000) Subject: Adding some Salome scripts as tests X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=17756969a91884a200747118b2732fa85a90f2fd;p=plugins%2Fblsurfplugin.git Adding some Salome scripts as tests --- diff --git a/Makefile.am b/Makefile.am index 2c52a4d..e88f1cf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,9 +37,9 @@ else !BLSURFPLUGIN_ENABLE_GUI -I ${SMESH_ROOT_DIR}/adm_local/unix/config_files endif -SUBDIRS = idl adm_local resources src bin doc +SUBDIRS = idl adm_local resources src bin doc tests -DIST_SUBDIRS = idl adm_local resources src bin doc +DIST_SUBDIRS = idl adm_local resources src bin doc tests DISTCLEANFILES = a.out aclocal.m4 configure local-install.sh hack_libtool diff --git a/configure.ac b/configure.ac index 8f119b7..fd469b9 100644 --- a/configure.ac +++ b/configure.ac @@ -442,6 +442,7 @@ AC_OUTPUT([ \ src/Makefile \ src/BLSURFPlugin/Makefile \ src/GUI/Makefile \ + tests/Makefile \ BLSURFPLUGIN_version.h \ Makefile \ ]) diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..7534495 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,42 @@ +# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +# =============================================================== +# Files to be installed +# =============================================================== +# + +# Scripts to be installed. +dist_salomescript_DATA = \ + test_enforced_internal_vertex.py \ + test_enforced_vertex.py \ + test_periodicity_2D_precad.py \ + test_periodicity_2D.py \ + test_periodicity_precad.py \ + test_periodicity.py \ + test_periodicity_reflexion_2D_precad.py \ + test_periodicity_reflexion_2D.py \ + test_periodicity_reflexion_precad.py \ + test_periodicity_reflexion.py \ + test_periodicity_with_points_2D_precad.py \ + test_precad_intersections.py + +mypkgpythondir = $(salomepythondir)/salome/BLSURFPlugin diff --git a/tests/test_enforced_internal_vertex.py b/tests/test_enforced_internal_vertex.py new file mode 100644 index 0000000..c7f3661 --- /dev/null +++ b/tests/test_enforced_internal_vertex.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- + +import salome +import math + +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +r = 10 +dist = 10 +dist_coin = 10.1 + +p1 = geompy.MakeVertex(0., 0., 0.) +p2 = geompy.MakeVertex(100., 100., 100.) +box = geompy.MakeBoxTwoPnt(p1, p2) +geompy.addToStudy(box, "box") + +p3 = geompy.MakeVertex(dist_coin, 0, dist_coin) +geompy.addToStudy(p3, "p3") + +part = geompy.MakePartition([box], [p3]) +geompy.addToStudy(part, "part") + +left = geompy.GetFaceNearPoint(box, p3) +geompy.addToStudyInFather(box, left, "left") + + +# 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.SetInternalEnforcedVertexAllFaces(True) + +Mesh.Compute() + +id_node = Mesh.FindNodeClosestTo(dist_coin, 0, dist_coin) + +x, y, z = Mesh.GetNodeXYZ(id_node) + +assert("%.2f, %.2f, %.2f"%(x, y, z) == "%.2f, %.2f, %.2f"%(dist_coin, 0, dist_coin)) + +salome.sg.updateObjBrowser(0) + diff --git a/tests/test_enforced_vertex.py b/tests/test_enforced_vertex.py new file mode 100644 index 0000000..f22b392 --- /dev/null +++ b/tests/test_enforced_vertex.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- + +import salome +import math + +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +r = 10 +dist = 10 +dist_coin = 10.1 + +p1 = geompy.MakeVertex(0., 0., 0.) +p2 = geompy.MakeVertex(100., 100., 100.) +box = geompy.MakeBoxTwoPnt(p1, p2) +geompy.addToStudy(box, "box") + +p3 = geompy.MakeVertex(dist_coin, 0, dist_coin) +geompy.addToStudy(p3, "p3") + +left = geompy.GetFaceNearPoint(box, p3) +geompy.addToStudyInFather(box, left, "left") + +# Mesh +# ==== + +import SMESH +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) + +Mesh = smesh.Mesh(box, "Mesh") + + +algo2d = Mesh.Triangle(algo=smeshBuilder.BLSURF) +algo2d.SetGeometricMesh( 1 ) +algo2d.SetAngleMesh( 4 ) +algo2d.SetPhySize( 8 ) + +algo2d.SetEnforcedVertex(left, dist_coin, 0, dist_coin) + +Mesh.Compute() + +id_node = Mesh.FindNodeClosestTo(dist_coin, 0, dist_coin) + +x, y, z = Mesh.GetNodeXYZ(id_node) + +assert("%.2f, %.2f, %.2f"%(x, y, z) == "%.2f, %.2f, %.2f"%(dist_coin, 0, dist_coin)) + + +salome.sg.updateObjBrowser(0) + diff --git a/tests/test_periodicity.py b/tests/test_periodicity.py new file mode 100644 index 0000000..b6e5de4 --- /dev/null +++ b/tests/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/tests/test_periodicity_2D.py b/tests/test_periodicity_2D.py new file mode 100644 index 0000000..405093e --- /dev/null +++ b/tests/test_periodicity_2D.py @@ -0,0 +1,137 @@ +# -*- coding: iso-8859-1 -*- + +import salome + +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import math + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) + +Face_1 = geompy.MakeFaceHW(10, 10, 1) +geomObj_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0) +Sketch_1 = geompy.MakeSketcherOnPlane("Sketcher:F -2.5209155082703 -1.4416453838348:TT -1.1105282306671 -2.9872753620148:TT 0.76354801654816 -2.3303825855255:TT 1.9614112377167 -3.0838770866394:TT 3.8354876041412 -1.2677619457245:TT 4.2218952178955 0.644955098629:TT 3.2751967906952 2.5576722621918:TT 0.58966463804245 3.5430111885071:TT -3.7380990982056 3.2338852882385:TT -4.433632850647 0.85747921466827:WW", Face_1 ) +vertices = geompy.ExtractShapes(Sketch_1, geompy.ShapeType["VERTEX"], True) +Curve_1 = geompy.MakeInterpol(vertices, True, True) + +part = geompy.MakePartition([Face_1], [Curve_1], Limit=geompy.ShapeType["FACE"]) +geompy.addToStudy(part, "part") + +Vx = geompy.MakeVectorDXDYDZ(1, 0, 0) +Vy = geompy.MakeVectorDXDYDZ(0, 1, 0) +Vz = geompy.MakeVectorDXDYDZ(0, 0, 1) + +p1 = geompy.MakeVertex(-5, -5, 0) +p2 = geompy.MakeVertex(5, 5, 0) +left_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p1, GEOM.ST_ON) +left = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) +geompy.UnionList(left, left_edges) +geompy.addToStudyInFather(part, left, "left") + +right_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p2, GEOM.ST_ON) +right = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) +geompy.UnionList(right, right_edges) +geompy.addToStudyInFather(part, right, "right") + +bottom_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p1, GEOM.ST_ON) +bottom = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) +geompy.UnionList(bottom, bottom_edges) +geompy.addToStudyInFather(part, bottom, "bottom") + +top_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p2, GEOM.ST_ON) +top = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) +geompy.UnionList(top, top_edges) +geompy.addToStudyInFather(part, top, "top") + + +# 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.SetVerbosity(10) +#algo2d.SetTopology(smesh.PreCAD) +algo2d.SetGeometricMesh( 1 ) +algo2d.SetAngleMesh( 4 ) +algo2d.SetPhySize( 8 ) +#algo2d.SetGradation(1.05) +algo2d.SetOptionValue( 'periodic_tolerance', '1e-2' ) + +# Periodicity + +def proj_x(shape1): + shape2 = geompy.MakeTranslation(shape1, 10, 0., 0) + return shape2 + +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) + +Mesh.Compute() + +gr_left = Mesh.Group(left) +gr_right = Mesh.Group(right) +gr_bottom = Mesh.Group(bottom) +gr_top = Mesh.Group(top) + +Mesh.Compute() + +left_translated = Mesh.TranslateObjectMakeMesh( gr_left, SMESH.DirStruct( SMESH.PointStruct ( 10, 0, 0 )), 0, 'left_translated' ) +bottom_translated = Mesh.TranslateObjectMakeMesh( gr_bottom, SMESH.DirStruct( SMESH.PointStruct ( 0, 10, 0 )), 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_top, bottom_translated) + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) diff --git a/tests/test_periodicity_2D_precad.py b/tests/test_periodicity_2D_precad.py new file mode 100644 index 0000000..f9806ce --- /dev/null +++ b/tests/test_periodicity_2D_precad.py @@ -0,0 +1,111 @@ +# -*- coding: iso-8859-1 -*- + +import sys +import salome + +### +### GEOM component +### + +import math + +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +Face_1 = geompy.MakeFaceHW(10, 10, 1) +geomObj_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0) +Sketch_1 = geompy.MakeSketcherOnPlane("Sketcher:F -2.5209155082703 -1.4416453838348:TT -1.1105282306671 -2.9872753620148:TT 0.76354801654816 -2.3303825855255:TT 1.9614112377167 -3.0838770866394:TT 3.8354876041412 -1.2677619457245:TT 4.2218952178955 0.644955098629:TT 3.2751967906952 2.5576722621918:TT 0.58966463804245 3.5430111885071:TT -3.7380990982056 3.2338852882385:TT -4.433632850647 0.85747921466827:WW", Face_1 ) +vertices = geompy.ExtractShapes(Sketch_1, geompy.ShapeType["VERTEX"], True) +Curve_1 = geompy.MakeInterpol(vertices, True, True) + +part = geompy.MakePartition([Face_1], [Curve_1], Limit=geompy.ShapeType["FACE"]) +geompy.addToStudy(part, "part") + +Vx = geompy.MakeVectorDXDYDZ(1, 0, 0) +Vy = geompy.MakeVectorDXDYDZ(0, 1, 0) +Vz = geompy.MakeVectorDXDYDZ(0, 0, 1) + +p1 = geompy.MakeVertex(-5, -5, 0) +p2 = geompy.MakeVertex(5, 5, 0) +left_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p1, GEOM.ST_ON) +left = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) +geompy.UnionList(left, left_edges) +geompy.addToStudyInFather(part, left, "left") + +right_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p2, GEOM.ST_ON) +right = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) +geompy.UnionList(right, right_edges) +geompy.addToStudyInFather(part, right, "right") + +bottom_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p1, GEOM.ST_ON) +bottom = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) +geompy.UnionList(bottom, bottom_edges) +geompy.addToStudyInFather(part, bottom, "bottom") + +top_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p2, GEOM.ST_ON) +top = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) +geompy.UnionList(top, top_edges) +geompy.addToStudyInFather(part, top, "top") + +source_face = geompy.GetFaceNearPoint(part, p1) +geompy.addToStudyInFather(part, source_face, "source_face") + + +# 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.SetGradation(1.05) + +# Periodicity +#algo2d.SetVerbosity(10) +algo2d.SetPreCADOptionValue("periodic_tolerance", "1e-2") +algo2d.AddPreCadEdgesPeriodicity(left, right) +algo2d.AddPreCadEdgesPeriodicity(bottom, top) + + +Mesh.Compute() + +gr_left = Mesh.Group(left) +gr_right = Mesh.Group(right) +gr_bottom = Mesh.Group(bottom) +gr_top = Mesh.Group(top) + +Mesh.Compute() + +left_translated = Mesh.TranslateObjectMakeMesh( gr_left, SMESH.DirStruct( SMESH.PointStruct ( 10, 0, 0 )), 0, 'left_translated' ) +bottom_translated = Mesh.TranslateObjectMakeMesh( gr_bottom, SMESH.DirStruct( SMESH.PointStruct ( 0, 10, 0 )), 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_top, bottom_translated) + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) + diff --git a/tests/test_periodicity_precad.py b/tests/test_periodicity_precad.py new file mode 100644 index 0000000..8a10dda --- /dev/null +++ b/tests/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/tests/test_periodicity_reflexion.py b/tests/test_periodicity_reflexion.py new file mode 100644 index 0000000..ed4f134 --- /dev/null +++ b/tests/test_periodicity_reflexion.py @@ -0,0 +1,159 @@ +# -*- 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 + +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) + +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/tests/test_periodicity_reflexion_2D.py b/tests/test_periodicity_reflexion_2D.py new file mode 100644 index 0000000..7405bad --- /dev/null +++ b/tests/test_periodicity_reflexion_2D.py @@ -0,0 +1,132 @@ +# -*- coding: iso-8859-1 -*- + +import salome + +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import math + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) + +Face_1 = geompy.MakeFaceHW(10, 10, 1) +geomObj_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0) +Sketch_1 = geompy.MakeSketcherOnPlane("Sketcher:F -2.5209155082703 -1.4416453838348:TT -1.1105282306671 -2.9872753620148:TT 0.76354801654816 -2.3303825855255:TT 1.9614112377167 -3.0838770866394:TT 3.8354876041412 -1.2677619457245:TT 4.2218952178955 0.644955098629:TT 3.2751967906952 2.5576722621918:TT 0.58966463804245 3.5430111885071:TT -3.7380990982056 3.2338852882385:TT -4.433632850647 0.85747921466827:WW", Face_1 ) +vertices = geompy.ExtractShapes(Sketch_1, geompy.ShapeType["VERTEX"], True) +Curve_1 = geompy.MakeInterpol(vertices, True, True) + +part = geompy.MakePartition([Face_1], [Curve_1], Limit=geompy.ShapeType["FACE"]) +geompy.addToStudy(part, "part") + +Vx = geompy.MakeVectorDXDYDZ(1, 0, 0) +Vy = geompy.MakeVectorDXDYDZ(0, 1, 0) +Vz = geompy.MakeVectorDXDYDZ(0, 0, 1) + +p1 = geompy.MakeVertex(-5, -5, 0) +p2 = geompy.MakeVertex(5, 5, 0) +left_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p1, GEOM.ST_ON) +left = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) +geompy.UnionList(left, left_edges) +geompy.addToStudyInFather(part, left, "left") + +right_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p2, GEOM.ST_ON) +right = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) +geompy.UnionList(right, right_edges) +geompy.addToStudyInFather(part, right, "right") + +bottom_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p1, GEOM.ST_ON) +bottom = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) +geompy.UnionList(bottom, bottom_edges) +geompy.addToStudyInFather(part, bottom, "bottom") + +top_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p2, GEOM.ST_ON) +top = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) +geompy.UnionList(top, top_edges) +geompy.addToStudyInFather(part, top, "top") + + +# 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.SetVerbosity(1) +#algo2d.SetTopology(smesh.PreCAD) +algo2d.SetGeometricMesh( 1 ) +algo2d.SetAngleMesh( 4 ) +algo2d.SetPhySize( 8 ) +#algo2d.SetGradation(1.05) +algo2d.SetOptionValue( 'periodic_tolerance', '1e-2' ) + +# Periodicity + +p_axe = geompy.MakeVertex(5, -5, 0) +axe = geompy.MakePrismVecH(p_axe, Vz, 1) +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) + +Mesh.Compute() + +gr_left = Mesh.Group(left) +gr_right = Mesh.Group(right) +gr_bottom = Mesh.Group(bottom) +gr_top = Mesh.Group(top) + +Mesh.Compute() + +bottom_rotated = Mesh.RotateObjectMakeMesh( gr_bottom, axe, -math.pi/2, NewMeshName='bottom_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_right, bottom_rotated) + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) diff --git a/tests/test_periodicity_reflexion_2D_precad.py b/tests/test_periodicity_reflexion_2D_precad.py new file mode 100644 index 0000000..5eed201 --- /dev/null +++ b/tests/test_periodicity_reflexion_2D_precad.py @@ -0,0 +1,126 @@ +# -*- coding: iso-8859-1 -*- + +import sys +import salome + +### +### GEOM component +### + +import math + +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +Face_1 = geompy.MakeFaceHW(10, 10, 1) +geomObj_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0) +Sketch_1 = geompy.MakeSketcherOnPlane("Sketcher:F -2.5209155082703 -1.4416453838348:TT -1.1105282306671 -2.9872753620148:TT 0.76354801654816 -2.3303825855255:TT 1.9614112377167 -3.0838770866394:TT 3.8354876041412 -1.2677619457245:TT 4.2218952178955 0.644955098629:TT 3.2751967906952 2.5576722621918:TT 0.58966463804245 3.5430111885071:TT -3.7380990982056 3.2338852882385:TT -4.433632850647 0.85747921466827:WW", Face_1 ) +vertices = geompy.ExtractShapes(Sketch_1, geompy.ShapeType["VERTEX"], True) +Curve_1 = geompy.MakeInterpol(vertices, True, True) + +part = geompy.MakePartition([Face_1], [Curve_1], Limit=geompy.ShapeType["FACE"]) +geompy.addToStudy(part, "part") + +Vx = geompy.MakeVectorDXDYDZ(1, 0, 0) +Vy = geompy.MakeVectorDXDYDZ(0, 1, 0) +Vz = geompy.MakeVectorDXDYDZ(0, 0, 1) + +p1 = geompy.MakeVertex(-5, -5, 0) +p2 = geompy.MakeVertex(5, 5, 0) +left_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p1, GEOM.ST_ON) +left = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) +geompy.UnionList(left, left_edges) +geompy.addToStudyInFather(part, left, "left") + +right_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p2, GEOM.ST_ON) +right = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) +geompy.UnionList(right, right_edges) +geompy.addToStudyInFather(part, right, "right") + +bottom_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p1, GEOM.ST_ON) +bottom = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) +geompy.UnionList(bottom, bottom_edges) +geompy.addToStudyInFather(part, bottom, "bottom") + +top_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p2, GEOM.ST_ON) +top = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) +geompy.UnionList(top, top_edges) +geompy.addToStudyInFather(part, top, "top") + +source_face = geompy.GetFaceNearPoint(part, p1) +geompy.addToStudyInFather(part, source_face, "source_face") + +# To define a rotation, we have to set at least 3 source vertices not aligned. +p_bas_gauche = geompy.MakeVertex(-5, -5, 0) +geompy.addToStudy(p_bas_gauche, "p_bas_gauche") +p_bas_mil = geompy.MakeVertex(0, -4, 0) +geompy.addToStudy(p_bas_mil, "p_bas_mil") +p_bas_droite = geompy.MakeVertex(5, -5, 0) +geompy.addToStudy(p_bas_droite, "p_bas_droite") + +# Target vertices +p_mil_droite = geompy.MakeVertex(4, 0, 0) +geompy.addToStudy(p_mil_droite, "p_mil_droite") +p_haut_droite = geompy.MakeVertex(5, 5, 0) +geompy.addToStudy(p_haut_droite, "p_haut_droite") + +# 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.SetGradation(1.05) + +#algo2d.SetOptionValue( 'debug', '1' ) +#algo2d.SetPreCADOptionValue( 'debug', '1' ) + +# Periodicity +#algo2d.SetVerbosity(10) +algo2d.SetPreCADOptionValue("periodic_tolerance", "1e-2") +algo2d.AddPreCadEdgesPeriodicity(bottom, right, [p_bas_droite, p_bas_mil, p_bas_gauche], [p_bas_droite, p_mil_droite, p_haut_droite]) + + +Mesh.Compute() + +gr_left = Mesh.Group(left) +gr_right = Mesh.Group(right) +gr_bottom = Mesh.Group(bottom) +gr_top = Mesh.Group(top) + +axe = geompy.MakePrismVecH(p_bas_droite, Vz, 1) +bottom_rotated = Mesh.RotateObjectMakeMesh( gr_bottom, axe, -math.pi/2, NewMeshName='bottom_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) + print "Projection failed for %s"%name + +checkProjection(gr_right, bottom_rotated) + +#salome.myStudyManager.SaveAs("test.hdf", salome.myStudy, 0) + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) + diff --git a/tests/test_periodicity_reflexion_precad.py b/tests/test_periodicity_reflexion_precad.py new file mode 100644 index 0000000..5da7dd9 --- /dev/null +++ b/tests/test_periodicity_reflexion_precad.py @@ -0,0 +1,121 @@ +# -*- 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(50., 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") + +p1_rota = geompy.MakeRotation(p1, axe, -math.pi/2.) +geompy.addToStudy(sphere1_rota, "sphere1_rota") + +p5 = geompy.MakeVertex(100, 0, 100) +geompy.addToStudy(p5, "p5") + +# 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 ) + +# Periodicity +#algo2d.SetVerbosity(10) +#algo2d.SetPreCADOptionValue("periodic_tolerance", "1e-2") +algo2d.AddPreCadFacesPeriodicity(left, front, [p1, p4, p5], [p1_rota, p4, p5]) + + +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/tests/test_periodicity_with_points_2D_precad.py b/tests/test_periodicity_with_points_2D_precad.py new file mode 100644 index 0000000..5322376 --- /dev/null +++ b/tests/test_periodicity_with_points_2D_precad.py @@ -0,0 +1,125 @@ +# -*- coding: iso-8859-1 -*- + +import sys +import salome + +### +### GEOM component +### + +import math + +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +Face_1 = geompy.MakeFaceHW(10, 10, 1) +geomObj_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0) +Sketch_1 = geompy.MakeSketcherOnPlane("Sketcher:F -2.5209155082703 -1.4416453838348:TT -1.1105282306671 -2.9872753620148:TT 0.76354801654816 -2.3303825855255:TT 1.9614112377167 -3.0838770866394:TT 3.8354876041412 -1.2677619457245:TT 4.2218952178955 0.644955098629:TT 3.2751967906952 2.5576722621918:TT 0.58966463804245 3.5430111885071:TT -3.7380990982056 3.2338852882385:TT -4.433632850647 0.85747921466827:WW", Face_1 ) +vertices = geompy.ExtractShapes(Sketch_1, geompy.ShapeType["VERTEX"], True) +Curve_1 = geompy.MakeInterpol(vertices, True, True) + +part = geompy.MakePartition([Face_1], [Curve_1], Limit=geompy.ShapeType["FACE"]) +geompy.addToStudy(part, "part") + +Vx = geompy.MakeVectorDXDYDZ(1, 0, 0) +Vy = geompy.MakeVectorDXDYDZ(0, 1, 0) +Vz = geompy.MakeVectorDXDYDZ(0, 0, 1) + +p1 = geompy.MakeVertex(-5, -5, 0) +p2 = geompy.MakeVertex(5, 5, 0) +left_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p1, GEOM.ST_ON) +left = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) +geompy.UnionList(left, left_edges) +geompy.addToStudyInFather(part, left, "left") + +right_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p2, GEOM.ST_ON) +right = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) +geompy.UnionList(right, right_edges) +geompy.addToStudyInFather(part, right, "right") + +bottom_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p1, GEOM.ST_ON) +bottom = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) +geompy.UnionList(bottom, bottom_edges) +geompy.addToStudyInFather(part, bottom, "bottom") + +top_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p2, GEOM.ST_ON) +top = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) +geompy.UnionList(top, top_edges) +geompy.addToStudyInFather(part, top, "top") + +source_face = geompy.GetFaceNearPoint(part, p1) +geompy.addToStudyInFather(part, source_face, "source_face") + +p_bas_gauche = geompy.MakeVertex(-5, -5, 0) +geompy.addToStudy(p_bas_gauche, "p_bas_gauche") +p_bas_mil = geompy.MakeVertex(0, -4, 0) +geompy.addToStudy(p_bas_mil, "p_bas_mil") +p_bas_droite = geompy.MakeVertex(5, -5, 0) +geompy.addToStudy(p_bas_droite, "p_bas_droite") +p_haut_gauche = geompy.MakeVertex(-5, 5, 0) +geompy.addToStudy(p_haut_gauche, "p_haut_gauche") +p_haut_mil = geompy.MakeVertex(0, 6, 0) +geompy.addToStudy(p_haut_mil, "p_haut_mil") +p_haut_droite = geompy.MakeVertex(5, 5, 0) +geompy.addToStudy(p_haut_droite, "p_haut_droite") + +# 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.SetGradation(1.05) + +# Periodicity +#algo2d.SetVerbosity(10) +algo2d.SetPreCADOptionValue("periodic_tolerance", "1e-2") +algo2d.AddPreCadEdgesPeriodicity(bottom, top, [p_bas_gauche, p_bas_mil, p_bas_droite], [p_haut_gauche, p_haut_mil, p_haut_droite]) + +# debug +#algo2d.SetOptionValue( 'debug', '1' ) +#algo2d.SetPreCADOptionValue( 'debug', '1' ) + +Mesh.Compute() + +gr_left = Mesh.Group(left) +gr_right = Mesh.Group(right) +gr_bottom = Mesh.Group(bottom) +gr_top = Mesh.Group(top) + +Mesh.Compute() + +left_translated = Mesh.TranslateObjectMakeMesh( gr_left, SMESH.DirStruct( SMESH.PointStruct ( 10, 0, 0 )), 0, 'left_translated' ) +bottom_translated = Mesh.TranslateObjectMakeMesh( gr_bottom, SMESH.DirStruct( SMESH.PointStruct ( 0, 10, 0 )), 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_top, bottom_translated) + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) + + diff --git a/tests/test_precad_intersections.py b/tests/test_precad_intersections.py new file mode 100644 index 0000000..544c71d --- /dev/null +++ b/tests/test_precad_intersections.py @@ -0,0 +1,82 @@ +# -*- coding: iso-8859-1 -*- + +### +### This file is generated automatically by SALOME v6.6.0 with dump python functionality +### + +import sys +import salome + +salome.salome_init() +theStudy = salome.myStudy + +import salome_notebook +notebook = salome_notebook.notebook +sys.path.insert( 0, r'/export/home/bourcier/salome/tests') + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + + +geompy.init_geom(theStudy) + +geomObj_1 = geompy.MakeBoxDXDYDZ(100, 100, 100) +geomObj_2 = geompy.MakeVertex(-2, 60, 40) +geomObj_3 = geompy.MakeSpherePntR(geomObj_2, 10) +geomObj_4 = geompy.MakeVertex(70, 20, 60) +geomObj_5 = geompy.MakeSpherePntR(geomObj_4, 15) +geomObj_6 = geompy.MakeCompound([geomObj_3, geomObj_5]) +geomObj_7 = geompy.GetInPlaceByHistory(geomObj_6, geomObj_3) +geomObj_8 = geompy.GetInPlaceByHistory(geomObj_6, geomObj_5) +Face_1 = geompy.MakeFaceHW(10, 10, 1) +Translation_1 = geompy.MakeTranslation(Face_1, 10.0001, 0.0001, 0) +Translation_2 = geompy.MakeTranslation(Face_1, 5, -9.99995, 0) +Partition_1 = geompy.MakePartition([Face_1, Translation_1, Translation_2], [], [], [], geompy.ShapeType["FACE"], 0, [], 0) +geompy.addToStudy( Face_1, 'Face_1' ) +geompy.addToStudy( Translation_1, 'Translation_1' ) +geompy.addToStudy( Translation_2, 'Translation_2' ) +geompy.addToStudy( Partition_1, 'Partition_1' ) + +p_axe = geompy.MakeVertex(5, -5, 0) +axe = geompy.MakePrismDXDYDZ(p_axe, 0, 0, 1) +vertices = geompy.GetShapesOnCylinder(Partition_1, geompy.ShapeType["VERTEX"], axe, 1e-3, GEOM.ST_IN) +gr_vertices = geompy.CreateGroup(Partition_1, geompy.ShapeType["VERTEX"]) +geompy.UnionList(gr_vertices, vertices) +geompy.addToStudyInFather(Partition_1, gr_vertices, "vertices") + +### +### SMESH component +### + +import SMESH +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) + + +Mesh_1 = smesh.Mesh(Partition_1) + +BLSURF_1 = Mesh_1.Triangle(algo=smeshBuilder.BLSURF) +BLSURF_Parameters = BLSURF_1.Parameters() +BLSURF_Parameters.SetPhySize( 5 ) +BLSURF_Parameters.SetTopology( 3 ) + +Mesh_1.Compute() + +# Check that vertices are merged by preCAD preprocessing +nodes = [] +for p in vertices: + x, y, z = geompy.PointCoordinates(p) + id_node = Mesh_1.FindNodeClosestTo(x, y, z) + nodes.append(id_node) + +nodes = set(nodes) + +assert(len(nodes) == 1) + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1)