Salome HOME
0023360: [CEA 1963] Use salome.sg.updateObjBrowser(True) instead of salome.sg.updateO...
[plugins/blsurfplugin.git] / tests / test_precad_keep_gaps.py
1 # -*- coding: utf-8 -*-
2
3 import sys
4 import salome
5
6 salome.salome_init()
7 theStudy = salome.myStudy
8
9 ###
10 ### GEOM component
11 ###
12
13 import GEOM
14 from salome.geom import geomBuilder
15 geompy = geomBuilder.New(salome.myStudy)
16
17
18 geompy.init_geom(theStudy)
19
20 Face_1 = geompy.MakeFaceHW(10, 10, 1)
21 Translation_1 = geompy.MakeTranslation(Face_1, 10.0001, 0.0001, 0)
22 Translation_2 = geompy.MakeTranslation(Face_1, 5, -9.99995, 0)
23 Partition_1 = geompy.MakePartition([Face_1, Translation_1, Translation_2], [], [], [], geompy.ShapeType["FACE"], 0, [], 0)
24 geompy.addToStudy( Face_1, 'Face_1' )
25 geompy.addToStudy( Translation_1, 'Translation_1' )
26 geompy.addToStudy( Translation_2, 'Translation_2' )
27 geompy.addToStudy( Partition_1, 'Partition_1' )
28
29 p_axe = geompy.MakeVertex(5, -5, 0)
30 axe = geompy.MakePrismDXDYDZ(p_axe, 0, 0, 1)
31 vertices = geompy.GetShapesOnCylinder(Partition_1, geompy.ShapeType["VERTEX"], axe, 1e-3, GEOM.ST_IN)
32 gr_vertices = geompy.CreateGroup(Partition_1, geompy.ShapeType["VERTEX"])
33 geompy.UnionList(gr_vertices, vertices)
34 geompy.addToStudyInFather(Partition_1, gr_vertices, "vertices")
35
36 ###
37 ### SMESH component
38 ###
39
40 import SMESH
41 from salome.smesh import smeshBuilder
42 smesh = smeshBuilder.New(salome.myStudy)
43
44
45 Mesh_1 = smesh.Mesh(Partition_1)
46
47 BLSURF_1 = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf)
48 BLSURF_Parameters = BLSURF_1.Parameters()
49 BLSURF_Parameters.SetPhySize( 5 )
50
51 Mesh_1.Compute()
52
53 # Check that vertices are not merged by preCAD preprocessing
54 # when no preprocessing option has been explicitely called
55 nodes = []
56 for p in vertices:
57     x, y, z = geompy.PointCoordinates(p)
58     id_node = Mesh_1.FindNodeClosestTo(x, y, z)
59     nodes.append(id_node)
60
61 nodes = list(set(nodes))
62
63 Mesh_1.MakeGroupByIds("nodes", SMESH.NODE, nodes)
64
65 assert len(nodes) == 3, "We should have 3 nodes. We got %i. => The preprocessing has done something, but we did not ask him to."%len(nodes)
66
67 if salome.sg.hasDesktop():
68   salome.sg.updateObjBrowser(True)