]> SALOME platform Git repositories - modules/smesh.git/blob - src/SMESH_SWIG/ex09_grid4build.py
Salome HOME
Fix for bug IPAL10431 ( It is impossible create/edit mesh using GUI ).
[modules/smesh.git] / src / SMESH_SWIG / ex09_grid4build.py
1 # CEA/LGLS 2004-2005, Francis KLOSS (OCC)
2 # =======================================
3
4 from geompy import *
5
6 import smesh
7
8 import math
9
10 # Geometry
11 # ========
12
13 # Element of a grid compound by a square with a cylinder on each vertex build by points, edges, faces and solids
14
15 # Values
16 # ------
17
18 ox = 0
19 oy = 0
20 oz = 0
21
22 arete   =  50
23 hauteur = 100
24
25 rayon = 10
26
27 demi = rayon/2
28 r3   = demi*math.sqrt(3)
29
30 # Points
31 # ------
32
33 piecePoint111 = MakeVertex(ox+rayon      , oy, oz)
34 piecePoint211 = MakeVertex(ox+arete-rayon, oy, oz)
35 piecePoint112 = MakeVertex(ox            , oy, oz+rayon)
36 piecePoint212 = MakeVertex(ox+arete      , oy, oz+rayon)
37 piecePoint113 = MakeVertex(ox            , oy, oz+arete-rayon)
38 piecePoint213 = MakeVertex(ox+arete      , oy, oz+arete-rayon)
39 piecePoint114 = MakeVertex(ox+rayon      , oy, oz+arete)
40 piecePoint214 = MakeVertex(ox+arete-rayon, oy, oz+arete)
41
42 pieceCenter1  = MakeVertex(ox            , oy, oz)
43 pieceCenter2  = MakeVertex(ox+arete      , oy, oz)
44 pieceCenter3  = MakeVertex(ox            , oy, oz+arete)
45 pieceCenter4  = MakeVertex(ox+arete      , oy, oz+arete)
46
47 piecePass1    = MakeVertex(ox+demi       , oy, oz+r3)
48 piecePass2    = MakeVertex(ox+arete-demi , oy, oz+r3)
49 piecePass3    = MakeVertex(ox+arete-demi , oy, oz+arete-r3)
50 piecePass4    = MakeVertex(ox+demi       , oy, oz+arete-r3)
51
52 # Edges
53 # -----
54
55 pieceEdgeSquare1   = MakeEdge(piecePoint111, piecePoint211)
56 pieceEdgeSquare2   = MakeEdge(piecePoint114, piecePoint214)
57 pieceEdgeSquare3   = MakeEdge(piecePoint112, piecePoint113)
58 pieceEdgeSquare4   = MakeEdge(piecePoint212, piecePoint213)
59
60 pieceEdgeDiagonal1 = MakeEdge(piecePoint111, piecePoint213)
61 pieceEdgeDiagonal2 = MakeEdge(piecePoint112, piecePoint214)
62
63 pieceEdgeArc1 = MakeArc(piecePoint111, piecePass1, piecePoint112)
64 pieceEdgeArc2 = MakeArc(piecePoint211, piecePass2, piecePoint212)
65 pieceEdgeArc3 = MakeArc(piecePoint213, piecePass3, piecePoint214)
66 pieceEdgeArc4 = MakeArc(piecePoint113, piecePass4, piecePoint114)
67
68 # Faces
69 # -----
70
71 pieceFace1 = MakeQuad(pieceEdgeSquare1, pieceEdgeArc2, pieceEdgeSquare4, pieceEdgeDiagonal1)
72 pieceFace2 = MakeQuad(pieceEdgeSquare2, pieceEdgeArc4, pieceEdgeSquare3, pieceEdgeDiagonal2)
73
74 pieceFace3 = MakeQuad(pieceEdgeArc1, pieceEdgeDiagonal1, pieceEdgeArc3, pieceEdgeDiagonal2)
75
76 # Solids
77 # ------
78
79 pieceVector = MakeVectorDXDYDZ(0, 1, 0)
80
81 pieceSolid1 = MakePrismVecH(pieceFace1, pieceVector, hauteur)
82 pieceSolid2 = MakePrismVecH(pieceFace2, pieceVector, hauteur)
83 pieceSolid3 = MakePrismVecH(pieceFace3, pieceVector, hauteur)
84
85 # Compound and glue
86 # -----------------
87
88 c_cpd = MakeCompound([pieceSolid1, pieceSolid2, pieceSolid3])
89
90 piece = MakeGlueFaces(c_cpd, 1.e-5)
91
92 # Add in study
93 # ------------
94
95 piece_id = addToStudy(piece, "ex09_grid4build")
96
97 # Meshing
98 # =======
99
100 # Create a hexahedral mesh
101 # ------------------------
102
103 hexa = smesh.Mesh(piece, "ex09_grid4build:hexa")
104
105 algo = hexa.Segment()
106 algo.NumberOfSegments(6)
107
108 hexa.Quadrangle()
109
110 hexa.Hexahedron()
111
112 # Mesh calculus
113 # -------------
114
115 hexa.Compute()