]> SALOME platform Git repositories - modules/smesh.git/blob - src/SMESH_SWIG/SMESH_hexaedre.py
Salome HOME
PAL10872. Image for aspect ratio of a quadrangle
[modules/smesh.git] / src / SMESH_SWIG / SMESH_hexaedre.py
1 #==============================================================================
2 #  Info.
3 #  Bug (from script, bug)   : hexaedre_modified.py, PAL6194, PAL7153
4 #  Modified                 : 25/11/2004
5 #  Author                   : Kovaltchuk Alexey
6 #  Project                  : PAL/SALOME
7 #==============================================================================
8
9 import salome
10 from salome import sg
11
12 import geompy
13
14 import math
15
16 # -----------------------------------------------------------------------------
17
18 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
19 myBuilder = salome.myStudy.NewBuilder()
20 gg = salome.ImportComponentGUI("GEOM")
21 from salome import sg
22
23 ShapeTypeCompSolid = 1
24 ShapeTypeSolid     = 2
25 ShapeTypeShell     = 3
26 ShapeTypeFace      = 4
27 ShapeTypeWire      = 5
28 ShapeTypeEdge      = 6
29 ShapeTypeVertex    = 7
30
31 Boolop_common = 1
32 Boolop_cut = 2
33 Boolop_fuse = 3
34 Boolop_section = 4
35
36 p0 = geompy.MakeVertex(0., 0., 0.)
37 px = geompy.MakeVertex(100., 0., 0.)
38 py = geompy.MakeVertex(0., 100., 0.)
39 pz = geompy.MakeVertex(0., 0., 100.)
40 vx = geompy.MakeVector(p0, px)
41 vy = geompy.MakeVector(p0, py)
42 vz = geompy.MakeVector(p0, pz)
43
44 sphereExt = geompy.MakeSphere(    0.,  0.,  0., 400.)
45 sphereInt = geompy.MakeSphere(    0.,-50.,  0., 350.)
46 sphereA   = geompy.MakeSphere( -400., 50., 50., 400.)
47 sphereB   = geompy.MakeSphere(  350.,-50.,-50., 350.)
48 ptcyle    = geompy.MakeVertex(0., -300., -450.)
49 cylindre  = geompy.MakeCylinder(ptcyle,vz,500.,900.)
50
51 vol1=geompy.MakeCut(sphereExt,sphereA)
52 vol2=geompy.MakeCut(vol1,sphereB)
53 vol3=geompy.MakeCut(vol2,cylindre)
54 blob=geompy.MakeCut(vol3,sphereInt)
55
56 idblob = geompy.addToStudy(blob,"blob")
57
58 aretes = []
59 aretes = geompy.SubShapeAllSorted(blob, ShapeTypeEdge)
60 eid=0
61
62 # -------------------------------
63 # --- numerotation des aretes
64 ##for edge in aretes:
65 ##    edname="arete%d"%eid
66 ##    idedge=geompy.addToStudy(edge,edname)
67 ##    eid=eid+1
68
69 salome.sg.updateObjBrowser(1)
70
71 # --- epaisseur 0 2 8 10
72 # --- hauteur   1 3 9 11
73 # --- largeur   4 5 6 7
74
75 # -----------------------------------------------------------------------------
76
77 print "-------------------------- mesh"
78
79 import SMESH
80 import StdMeshers
81 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
82 smesh.SetCurrentStudy(salome.myStudy)
83
84 # ---- create Hypothesis
85 print "-------------------------- create Hypothesis"
86 numberOfSegments = 4
87 hypNbSegA=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
88 hypNbSegA.SetNumberOfSegments(numberOfSegments)
89 numberOfSegments = 10
90 hypNbSegB=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
91 hypNbSegB.SetNumberOfSegments(numberOfSegments)
92 numberOfSegments = 15
93 hypNbSegC=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
94 hypNbSegC.SetNumberOfSegments(numberOfSegments)
95
96 # ---- create Algorithms
97 print "-------------------------- create Algorithms"
98 regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
99 quad2D=smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
100 hexa3D=smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
101
102 # ---- init a Mesh with the geom shape
103 shape_mesh = blob
104 myMesh=smesh.CreateMesh(shape_mesh)
105
106 # ---- add hypothesis and algorithms to mesh
107 print "-------------------------- add hypothesis to mesh"
108 myMesh.AddHypothesis(shape_mesh,regular1D)
109 myMesh.AddHypothesis(shape_mesh,quad2D)
110 myMesh.AddHypothesis(shape_mesh,hexa3D)
111
112 #myMesh.AddHypothesis(shape_mesh,hypNbSeg)
113
114 myMesh.AddHypothesis(aretes[0],hypNbSegA)
115 myMesh.AddHypothesis(aretes[2],hypNbSegA)
116 myMesh.AddHypothesis(aretes[8],hypNbSegA)
117 myMesh.AddHypothesis(aretes[10],hypNbSegA)
118
119 myMesh.AddHypothesis(aretes[1],hypNbSegC)
120 myMesh.AddHypothesis(aretes[3],hypNbSegC)
121 myMesh.AddHypothesis(aretes[9],hypNbSegC)
122 myMesh.AddHypothesis(aretes[11],hypNbSegC)
123
124 myMesh.AddHypothesis(aretes[4],hypNbSegB)
125 myMesh.AddHypothesis(aretes[5],hypNbSegB)
126 myMesh.AddHypothesis(aretes[6],hypNbSegB)
127 myMesh.AddHypothesis(aretes[7],hypNbSegB)
128
129 # ---- compute mesh
130
131 print "-------------------------- compute mesh"
132 ret=smesh.Compute(myMesh, shape_mesh)
133 print ret
134 if ret != 0:
135     #log=myMesh.GetLog(0) # no erase trace
136     #for linelog in log:
137     #    print linelog
138     print "Information about the Mesh:"
139     print "Number of nodes       : ", myMesh.NbNodes()
140     print "Number of edges       : ", myMesh.NbEdges()
141     print "Number of faces       : ", myMesh.NbFaces()
142     print "Number of quadrangles : ", myMesh.NbQuadrangles()
143     print "Number of volumes     : ", myMesh.NbVolumes()
144     print "Number of hexahedrons : ", myMesh.NbHexas()
145 else:
146     print "problem when Computing the mesh"
147
148 salome.sg.updateObjBrowser(1)