Salome HOME
Add full-quadrangles support, available since MeshGems v2.5
[plugins/blsurfplugin.git] / tests / test_enforced_vertex.py
1 # -*- coding: utf-8 -*-
2
3 import salome
4 import math
5
6 import GEOM
7 from salome.geom import geomBuilder
8 geompy = geomBuilder.New(salome.myStudy)
9
10 dist_coin = 10.1
11
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")
16
17 p3 = geompy.MakeVertex(dist_coin, 0, dist_coin)
18 geompy.addToStudy(p3, "p3")
19
20 left = geompy.GetFaceNearPoint(box, p3)
21 geompy.addToStudyInFather(box, left, "left")
22
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 ))
29
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")
35
36 xyz7 = allEnforcedCoords[4]
37
38 # Mesh
39 # ====
40
41 import SMESH
42 from salome.smesh import smeshBuilder
43 smesh = smeshBuilder.New(salome.myStudy)
44
45 Mesh = smesh.Mesh(box, "Mesh")
46
47
48 algo2d = Mesh.Triangle(algo=smeshBuilder.MG_CADSurf)
49 algo2d.SetGeometricMesh( 1 )
50 algo2d.SetAngleMesh( 4 )
51 algo2d.SetPhySize( 8 )
52
53 algo2d.SetEnforcedVertex(left, dist_coin, 0, dist_coin)
54 algo2d.AddEnforcedVertexGeom( pp )
55 algo2d.AddEnforcedVertexGeom( p6 )
56 algo2d.AddEnforcedVertex( *xyz7 )
57
58 assert Mesh.Compute()
59 assert not Mesh.FindCoincidentNodes( 1e-7 )
60
61 for x,y,z in allEnforcedCoords:
62
63     id_node = Mesh.FindNodeClosestTo( x,y,z )
64     xn, yn, zn = Mesh.GetNodeXYZ( id_node )
65
66     # compare X and Z
67     assert "%.2f, %.2f"%(x, z) == "%.2f, %.2f"%( xn, zn ), \
68         "%.2f, %.2f, %.2f != %.2f, %.2f, %.2f"%( xn, yn, zn, x,y,z )
69
70
71 salome.sg.updateObjBrowser(True)