Salome HOME
updated copyright message
[plugins/blsurfplugin.git] / tests / prepro_intersections.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2013-2023  CEA/DEN, EDF R&D
3 #
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.
8 #
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.
13 #
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
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 import sys
22 import salome
23
24 salome.salome_init()
25
26 ###
27 ### GEOM component
28 ###
29
30 import GEOM
31 from salome.geom import geomBuilder
32 geompy = geomBuilder.New()
33
34
35 geompy.init_geom()
36
37 Face_1 = geompy.MakeFaceHW(10, 10, 1)
38 Translation_1 = geompy.MakeTranslation(Face_1, 10.0001, 0.0001, 0)
39 Translation_2 = geompy.MakeTranslation(Face_1, 5, -9.99995, 0)
40 Partition_1 = geompy.MakePartition([Face_1, Translation_1, Translation_2], [], [], [], geompy.ShapeType["FACE"], 0, [], 0)
41 geompy.addToStudy( Face_1, 'Face_1' )
42 geompy.addToStudy( Translation_1, 'Translation_1' )
43 geompy.addToStudy( Translation_2, 'Translation_2' )
44 geompy.addToStudy( Partition_1, 'Partition_1' )
45
46 p_axe = geompy.MakeVertex(5, -5, 0)
47 axe = geompy.MakePrismDXDYDZ(p_axe, 0, 0, 1)
48 vertices = geompy.GetShapesOnCylinder(Partition_1, geompy.ShapeType["VERTEX"], axe, 1e-3, GEOM.ST_IN)
49 gr_vertices = geompy.CreateGroup(Partition_1, geompy.ShapeType["VERTEX"])
50 geompy.UnionList(gr_vertices, vertices)
51 geompy.addToStudyInFather(Partition_1, gr_vertices, "vertices")
52
53 ###
54 ### SMESH component
55 ###
56
57 import SMESH
58 from salome.smesh import smeshBuilder
59 smesh = smeshBuilder.New()
60
61
62 Mesh_1 = smesh.Mesh(Partition_1)
63
64 BLSURF_1 = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf)
65 BLSURF_Parameters = BLSURF_1.Parameters()
66 BLSURF_Parameters.SetPhySize( 5 )
67 BLSURF_Parameters.SetPreCADMergeEdges( True )
68 BLSURF_Parameters.SetPreCADProcess3DTopology( True )
69 BLSURF_Parameters.SetPreCADOptionValue( 'remove_tiny_uv_edges', 'yes' )
70
71 Mesh_1.Compute()
72
73 # Check that vertices are merged by preCAD preprocessing
74 nodes = []
75 for p in vertices:
76     x, y, z = geompy.PointCoordinates(p)
77     id_node = Mesh_1.FindNodeClosestTo(x, y, z)
78     nodes.append(id_node)
79
80 nodes = list(set(nodes))
81
82 nodesGroup = Mesh_1.MakeGroupByIds("nodes", SMESH.NODE, nodes)
83
84 assert nodesGroup.Size() == 1, nodesGroup.GetIDs()
85
86 if salome.sg.hasDesktop():
87   salome.sg.updateObjBrowser()