1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2013-2024 CEA, EDF
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 from salome.geom import geomBuilder
26 geompy = geomBuilder.New()
30 p1 = geompy.MakeVertex(0., 0., 0.)
31 p2 = geompy.MakeVertex(100., 100., 100.)
32 box = geompy.MakeBoxTwoPnt(p1, p2)
33 geompy.addToStudy(box, "box")
35 p3 = geompy.MakeVertex(dist_coin, 0, dist_coin)
36 geompy.addToStudy(p3, "p3")
38 left = geompy.GetFaceNearPoint(box, p3)
39 geompy.addToStudyInFather(box, left, "left")
41 allEnforcedCoords = []
42 allEnforcedCoords.append(( dist_coin, 0, dist_coin ))
43 allEnforcedCoords.append(( 20, 0, 15.3 ))
44 allEnforcedCoords.append(( 25, 1, 25.3 ))
45 allEnforcedCoords.append(( 35, 1, 45.3 ))
46 allEnforcedCoords.append(( 35, 1, 55.3 ))
48 p4 = geompy.MakeVertex( *(allEnforcedCoords[1] ))
49 p5 = geompy.MakeVertex( *(allEnforcedCoords[2] ))
50 pp = geompy.MakeCompound( [p4,p5], theName="p4,p5" )
51 p6 = geompy.MakeVertex( *(allEnforcedCoords[3] ), theName="p6")
52 p7 = geompy.MakeVertex( *(allEnforcedCoords[4] ), theName="p7")
54 xyz7 = allEnforcedCoords[4]
60 from salome.smesh import smeshBuilder
61 smesh = smeshBuilder.New()
63 Mesh = smesh.Mesh(box, "Mesh")
66 algo2d = Mesh.Triangle(algo=smeshBuilder.MG_CADSurf)
67 algo2d.SetGeometricMesh( 1 )
68 algo2d.SetAngleMesh( 4 )
69 algo2d.SetPhySize( 8 )
71 algo2d.SetEnforcedVertex(left, dist_coin, 0, dist_coin)
72 algo2d.AddEnforcedVertexGeom( pp )
73 algo2d.AddEnforcedVertexGeom( p6 )
74 algo2d.AddEnforcedVertex( *xyz7 )
77 assert not Mesh.FindCoincidentNodes( 1e-7 )
79 for x,y,z in allEnforcedCoords:
81 id_node = Mesh.FindNodeClosestTo( x,y,z )
82 xn, yn, zn = Mesh.GetNodeXYZ( id_node )
85 assert "%.2f, %.2f"%(x, z) == "%.2f, %.2f"%( xn, zn ), \
86 "%.2f, %.2f, %.2f != %.2f, %.2f, %.2f"%( xn, yn, zn, x,y,z )
89 salome.sg.updateObjBrowser()