Salome HOME
Update of CheckDone
[modules/smesh.git] / doc / examples / defining_hypotheses_ex12.py
1 # 1D Mesh with Fixed Points example
2
3 import salome
4 salome.salome_init_without_session()
5
6 from salome.geom import geomBuilder
7 from salome.smesh import smeshBuilder
8
9 geom_builder = geomBuilder.New()
10 smesh_builder = smeshBuilder.New()
11
12 # Create face and explode it on edges
13 face = geom_builder.MakeFaceHW(100, 100, 1)
14 edges = geom_builder.SubShapeAllSorted(face, geom_builder.ShapeType["EDGE"])
15 geom_builder.addToStudy( face, "Face" )
16
17 # get the first edge from exploded result
18 edge1 = geom_builder.GetSubShapeID(face, edges[0])
19
20 # Define Mesh on previously created face
21 Mesh_1 = smesh_builder.Mesh(face)
22
23 # Create Fixed Point 1D hypothesis and define parameters.
24 # Note: values greater than 1.0 and less than 0.0 are not taken into account;
25 # duplicated values are removed. Also, if not specified explicitly, values 0.0 and 1.0
26 # add added automatically.
27 # The number of segments should correspond to the number of points (NbSeg = NbPnt-1);
28 # extra values of segments splitting parameter are not taken into account,
29 # while missing values are considered to be equal to 1.
30 Fixed_points_1D_1 = smesh_builder.CreateHypothesis('FixedPoints1D')
31 Fixed_points_1D_1.SetPoints( [ 1.1, 0.9, 0.5, 0.0, 0.5, -0.3 ] )
32 Fixed_points_1D_1.SetNbSegments( [ 3, 1, 2 ] )
33 Fixed_points_1D_1.SetReversedEdges( [edge1] )
34
35 # Add hypothesis to mesh and define 2D parameters
36 Mesh_1.AddHypothesis(Fixed_points_1D_1)
37 Regular_1D = Mesh_1.Segment()
38 Quadrangle_2D = Mesh_1.Quadrangle()
39 # Compute mesh
40 if not Mesh_1.Compute(): raise Exception("Error when computing Mesh")