Salome HOME
Prevent multithread test failing if only one CPU core is available
[plugins/blsurfplugin.git] / tests / attractor.py
1 # -*- coding: utf-8 -*-
2
3 import sys
4 import salome
5
6 salome.salome_init()
7 theStudy = salome.myStudy
8
9 import  SMESH, SALOMEDS
10
11 ## Compute the minimum area of the faces of the mesh
12 def getMinArea(mesh):
13   faces = mesh.GetElementsByType(SMESH.FACE)
14   areas = [mesh.GetArea(face) for face in faces]
15   return min(areas)
16
17 ###
18 ### GEOM component
19 ###
20
21 import GEOM
22 from salome.geom import geomBuilder
23 import math
24 import SALOMEDS
25
26
27 geompy = geomBuilder.New(theStudy)
28
29 O = geompy.MakeVertex(0, 0, 0)
30 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
31 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
32 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
33 Face_1 = geompy.MakeFaceHW(100, 100, 1)
34 Circle_1 = geompy.MakeCircle(None, None, 20)
35 geompy.addToStudy( O, 'O' )
36 geompy.addToStudy( OX, 'OX' )
37 geompy.addToStudy( OY, 'OY' )
38 geompy.addToStudy( OZ, 'OZ' )
39 geompy.addToStudy( Face_1, 'Face_1' )
40 geompy.addToStudy( Circle_1, 'Circle_1' )
41
42 ###
43 ### SMESH component
44 ###
45
46 from salome.smesh import smeshBuilder
47
48 smesh = smeshBuilder.New(theStudy)
49 Mesh_1 = smesh.Mesh(Face_1)
50 MG_CADSurf = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf)
51 MG_CADSurf_Parameters_1 = MG_CADSurf.Parameters()
52 MG_CADSurf_Parameters_1.SetPhySize( 14.1421 )
53 MG_CADSurf_Parameters_1.SetMinSize( 0.141421 )
54 MG_CADSurf_Parameters_1.SetMaxSize( 28.2843 )
55 MG_CADSurf_Parameters_1.SetChordalError( 7.07107 )
56 #MG_CADSurf_Parameters_1.SetAttractorGeom( Face_1, Circle_1, 1, 14.1421, 5, 5 )
57
58 Mesh_1.Compute()
59
60 min_area_without_attractor = getMinArea(Mesh_1)
61
62 print "min_area_without_attractor: ", min_area_without_attractor
63
64 MG_CADSurf_Parameters_1.SetAttractorGeom( Face_1, Circle_1, 1, 14.1421, 5, 5 )
65
66 Mesh_1.Compute()
67
68 min_area_with_attractor = getMinArea(Mesh_1)
69
70 print "min_area_with_attractor: ", min_area_with_attractor
71
72 assert min_area_with_attractor < min_area_without_attractor
73
74 assert min_area_with_attractor < 1
75
76 if salome.sg.hasDesktop():
77   salome.sg.updateObjBrowser(True)