1 # -*- coding: utf-8 -*-
7 from salome.geom import geomBuilder
8 geompy = geomBuilder.New(salome.myStudy)
12 p1 = geompy.MakeVertex(0., 0., 0.)
13 p2 = geompy.MakeVertex(100., 100., 100.)
14 box = geompy.MakeBoxTwoPnt(p1, p2)
15 geompy.addToStudy(box, "box")
17 p3 = geompy.MakeVertex(dist_coin, 0, dist_coin)
18 geompy.addToStudy(p3, "p3")
20 left = geompy.GetFaceNearPoint(box, p3)
21 geompy.addToStudyInFather(box, left, "left")
23 allEnforcedCoords = []
24 allEnforcedCoords.append(( dist_coin, 0, dist_coin ))
25 allEnforcedCoords.append(( 20, 0, 15.3 ))
26 allEnforcedCoords.append(( 25, 1, 25.3 ))
27 allEnforcedCoords.append(( 35, 1, 45.3 ))
28 allEnforcedCoords.append(( 35, 1, 55.3 ))
30 p4 = geompy.MakeVertex( *(allEnforcedCoords[1] ))
31 p5 = geompy.MakeVertex( *(allEnforcedCoords[2] ))
32 pp = geompy.MakeCompound( [p4,p5], theName="p4,p5" )
33 p6 = geompy.MakeVertex( *(allEnforcedCoords[3] ), theName="p6")
34 p7 = geompy.MakeVertex( *(allEnforcedCoords[4] ), theName="p7")
36 xyz7 = allEnforcedCoords[4]
42 from salome.smesh import smeshBuilder
43 smesh = smeshBuilder.New(salome.myStudy)
45 Mesh = smesh.Mesh(box, "Mesh")
48 algo2d = Mesh.Triangle(algo=smeshBuilder.MG_CADSurf)
49 algo2d.SetGeometricMesh( 1 )
50 algo2d.SetAngleMesh( 4 )
51 algo2d.SetPhySize( 8 )
53 algo2d.SetEnforcedVertex(left, dist_coin, 0, dist_coin)
54 algo2d.AddEnforcedVertexGeom( pp )
55 algo2d.AddEnforcedVertexGeom( p6 )
56 algo2d.AddEnforcedVertex( *xyz7 )
59 assert not Mesh.FindCoincidentNodes( 1e-7 )
61 for x,y,z in allEnforcedCoords:
63 id_node = Mesh.FindNodeClosestTo( x,y,z )
64 xn, yn, zn = Mesh.GetNodeXYZ( id_node )
67 assert "%.2f, %.2f"%(x, z) == "%.2f, %.2f"%( xn, zn ), \
68 "%.2f, %.2f, %.2f != %.2f, %.2f, %.2f"%( xn, yn, zn, x,y,z )
71 salome.sg.updateObjBrowser(True)