Salome HOME
NPAL18084: add a new simple sample of GEOM/SMESH.
authorjfa <jfa@opencascade.com>
Thu, 13 Dec 2007 11:41:17 +0000 (11:41 +0000)
committerjfa <jfa@opencascade.com>
Thu, 13 Dec 2007 11:41:17 +0000 (11:41 +0000)
doc/salome/gui/SMESH/doxyfile.in
doc/salome/gui/SMESH/images/mesh_cylinder_hexa.png [new file with mode: 0644]
doc/salome/gui/SMESH/input/introduction_to_mesh_python.doc
doc/salome/gui/SMESH/input/tui_creating_meshes.doc
src/SMESH_SWIG/Makefile.am
src/SMESH_SWIG/ex24_cylinder.py [new file with mode: 0644]

index 53d07c1176b210091f3edef886ab3e1ddf47f712..37ef2d45fa52f6136d2df38ac2966229c743f721 100755 (executable)
@@ -19,7 +19,7 @@ WARNINGS          = YES
 INPUT             = @srcdir@/input               
 FILE_PATTERNS     = *.doc
 IMAGE_PATH        = @srcdir@/images
-
+EXAMPLE_PATH      = ../../../share/salome/src/SMESH_SWIG
 #---------------------------------------------------------------------------
 #HTML related options
 #---------------------------------------------------------------------------
diff --git a/doc/salome/gui/SMESH/images/mesh_cylinder_hexa.png b/doc/salome/gui/SMESH/images/mesh_cylinder_hexa.png
new file mode 100644 (file)
index 0000000..f95dc67
Binary files /dev/null and b/doc/salome/gui/SMESH/images/mesh_cylinder_hexa.png differ
index eb475e48a36be9f119e6881463f2376529c4f05e..2fcc329a2340a809f2e417e52438f785772035da 100644 (file)
@@ -74,4 +74,4 @@
 <b># Create a groupe of faces</b>
 \n tetra.Group(group)
 
-*/
\ No newline at end of file
+*/
index 087b2de259071156ec3d23ba543d44649629cee9..25bf50268374945cbb0151688e1e2df4652f36b5 100644 (file)
@@ -2,7 +2,7 @@
 
 \page tui_creating_meshes_page Creating Meshes
 
-\n First of all see \ref tui_creating_meshes_page "Example of 3d mesh generation",
+\n First of all see \ref introduction_to_mesh_python_page "Example of 3d mesh generation",
  which is an example of good python script style for Mesh module.
 
 <br>
@@ -172,4 +172,13 @@ tetra.Compute()
 tetra.ExportMED("/tmp/meshMED.med", 0)
 \endcode
 
+<br>
+<h2>How to mesh a cylinder with hexahedrons?</h2>
+Here you can see an example of python script, creating a hexahedral
+mesh on a cylinder. And a picture below the source code of the script,
+demonstrating the resulting mesh.
+\include /dn20/salome/jfa/V4/SRC/SMESH_SRC/src/SMESH_SWIG/ex24_cylinder.py
+
+\image html mesh_cylinder_hexa.png
+
 */
index 09ab5553d3e233bee9d930792c7505c8f25c3818..c46bde084df57fac278f2497a69ed165b4f0790c 100644 (file)
@@ -55,6 +55,7 @@ dist_salomescript_DATA= \
        ex18_dome2.py \
        ex19_sphereINcube.py \
        ex21_lamp.py \
+       ex24_cylinder.py \
        SMESH_test.py\
        SMESH_test0.py\
        SMESH_test1.py \
diff --git a/src/SMESH_SWIG/ex24_cylinder.py b/src/SMESH_SWIG/ex24_cylinder.py
new file mode 100644 (file)
index 0000000..25a1e96
--- /dev/null
@@ -0,0 +1,104 @@
+# CEA/LGLS 2007, Francis KLOSS (OCC)
+# ==================================
+
+import math
+
+import geompy
+import smesh
+
+geo = geompy
+
+# Parameters
+# ----------
+
+radius =  50
+height = 200
+
+# Build a cylinder
+# ----------------
+
+base = geo.MakeVertex(0, 0, 0)
+direction = geo.MakeVectorDXDYDZ(0, 0, 1)
+
+cylinder = geo.MakeCylinder(base, direction, radius, height)
+
+geo.addToStudy(cylinder, "cylinder")
+
+# Build blocks
+# ------------
+
+size = radius/2.0
+
+box_rot = geo.MakeBox(-size, -size, 0,  +size, +size, height)
+box_axis = geo.MakeLine(base, direction)
+box = geo.MakeRotation(box_rot, box_axis, math.pi/4)
+
+hole = geo.MakeCut(cylinder, box)
+
+plane_trim = 2000
+
+plane_a = geo.MakePlane(base, geo.MakeVectorDXDYDZ(1, 0, 0), plane_trim)
+plane_b = geo.MakePlane(base, geo.MakeVectorDXDYDZ(0, 1, 0), plane_trim)
+
+blocks_part = geo.MakePartition([hole], [plane_a, plane_b], [], [], geo.ShapeType["SOLID"])
+blocks_list = [box] + geo.SubShapeAll(blocks_part, geo.ShapeType["SOLID"])
+blocks_all = geo.MakeCompound(blocks_list)
+blocks = geo.MakeGlueFaces(blocks_all, 0.0001)
+
+geo.addToStudy(blocks, "cylinder:blocks")
+
+# Build geometric groups
+# ----------------------
+
+def group(name, shape, type, base=None, direction=None):
+    t = geo.ShapeType[type]
+    g = geo.CreateGroup(shape, t)
+
+    geo.addToStudy(g, name)
+    g.SetName(name)
+
+    if base!=None:
+        l = geo.GetShapesOnPlaneWithLocationIDs(shape, t, direction, base, geo.GEOM.ST_ON)
+        geo.UnionIDs(g, l)
+
+    return g
+
+group_a = group("baseA", blocks, "FACE", base, direction)
+
+base_b  = geo.MakeVertex(0, 0, height)
+group_b = group("baseB", blocks, "FACE", base_b, direction)
+
+group_1 = group("limit", blocks, "SOLID")
+group_1_all = geo.SubShapeAllIDs(blocks, geo.ShapeType["SOLID"])
+geo.UnionIDs(group_1, group_1_all)
+group_1_box = geo.GetBlockNearPoint(blocks, base)
+geo.DifferenceList(group_1, [group_1_box])
+
+# Mesh the blocks with hexahedral
+# -------------------------------
+
+def discretize(x, y, z,  n, s=blocks):
+    p = geo.MakeVertex(x, y, z)
+    e = geo.GetEdgeNearPoint(s, p)
+    a = hexa.Segment(e)
+    a.NumberOfSegments(n)
+    a.Propagation()
+
+hexa = smesh.Mesh(blocks)
+
+hexa_1d = hexa.Segment()
+hexa_1d.NumberOfSegments(1)
+
+discretize(+radius        , +radius,        0,   5)
+discretize(-radius        , +radius,        0,   8)
+discretize((radius+size)/2,       0,        0,  10)
+discretize(        +radius,       0, height/2,  20)
+
+hexa.Quadrangle()
+hexa.Hexahedron()
+
+hexa.Compute()
+
+hexa.Group(group_a)
+hexa.Group(group_b)
+hexa.Group(group_1)