--- /dev/null
+from __future__ import division\r
+\r
+from salome.geom import geomBuilder\r
+from salome.smesh import smeshBuilder\r
+\r
+import sys\r
+import os\r
+\r
+from math import pi, cos, sin, sqrt\r
+import SMESH\r
+\r
+geompy = geomBuilder.New()\r
+smesh = smeshBuilder.New()\r
+\r
+\r
+def create_group_from(name, mother_shape, list_elem, type="EDGE"):\r
+ new = geompy.CreateGroup(mother_shape, geompy.ShapeType[type])\r
+ geompy.UnionList(new, list_elem)\r
+ new.SetName(name)\r
+ geompy.addToStudyInFather(mother_shape, new, name)\r
+ return new\r
+\r
+# We build a regular tetrahedron with center of mass at (0,0,0) and \r
+r = 1.#distance between any two vertices\r
+h = sqrt(6.) / 3. * r # height of the tetrahedron (distance between a vertex and the opposite plane)\r
+\r
+points = [geompy.MakeVertex(r * cos(2 * i * pi / 3), r * sin(2 * i * pi / 3), -1./4 * h) for i in range(3)]\r
+points.append(geompy.MakeVertex(0., 0., 3./4 * h))\r
+\r
+faces_connectivity = [[0, 1, 2], [0, 1, 3], [1, 2, 3], [2, 3, 0]]\r
+\r
+faces = []\r
+for fc in faces_connectivity:\r
+ fc2 = fc + [fc[0]]\r
+ edges = [geompy.MakeEdge(points[fc2[i]], points[fc2[i + 1]]) for i in range(len(fc2) - 1)]\r
+ faces.append(geompy.MakeFace(geompy.MakeWire(edges), True))\r
+\r
+tetra_skin = geompy.MakeShell(faces)\r
+tetra = geompy.MakeSolid(tetra_skin)\r
+geompy.addToStudy(tetra, "Tetrahedron")\r
+g = create_group_from("TetrahedronBoundary", tetra, [geompy.GetInPlace(tetra, tetra_skin, 1)], type="FACE")\r
+\r
+### Mesh ###\r
+number_of_segments = 50\r
+\r
+TetrahedronMesh = smesh.Mesh(tetra, "Tetrahedron"+str(number_of_segments))\r
+NETGEN_1D_2D_3D = TetrahedronMesh.Tetrahedron(algo=smeshBuilder.NETGEN_1D2D3D)\r
+NETGEN_3D_Simple_Parameters_1 = NETGEN_1D_2D_3D.Parameters(smeshBuilder.SIMPLE)\r
+\r
+NETGEN_3D_Simple_Parameters_1.SetNumberOfSegments(number_of_segments)\r
+NETGEN_3D_Simple_Parameters_1.LengthFromEdges()\r
+NETGEN_3D_Simple_Parameters_1.LengthFromFaces()\r
+\r
+TetrahedronBoundary_1 = TetrahedronMesh.GroupOnGeom(g, 'BoundaryFaces', SMESH.FACE)\r
+TetrahedronBoundary_2 = TetrahedronMesh.GroupOnGeom(g, 'BoundaryNodes', SMESH.NODE)\r
+isDone = TetrahedronMesh.Compute()\r
+\r
+TetrahedronMesh.ExportMED("meshTetrahedron" + str(number_of_segments) + ".med")\r