1 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # Tetrahedrization of the geometry union of 3 boxes aligned where the middle
23 # one has a race in common with the two others.
24 # Hypothesis and algorithms for the mesh generation are global
31 # ---- define 3 boxes box1, box2 and box3
33 box1 = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
35 idbox1 = geompy.addToStudy(box1, "box1")
37 print "Analysis of the geometry box1 :"
38 subShellList = geompy.SubShapeAll(box1, geompy.ShapeType["SHELL"])
39 subFaceList = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"])
40 subEdgeList = geompy.SubShapeAll(box1, geompy.ShapeType["EDGE"])
42 print "number of Shells in box1 : ", len(subShellList)
43 print "number of Faces in box1 : ", len(subFaceList)
44 print "number of Edges in box1 : ", len(subEdgeList)
46 box2 = geompy.MakeBox(100., 0., 0., 200., 200., 300.)
48 idbox2 = geompy.addToStudy(box2, "box2")
50 print "Analysis of the geometry box2 :"
51 subShellList = geompy.SubShapeAll(box2, geompy.ShapeType["SHELL"])
52 subFaceList = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"])
53 subEdgeList = geompy.SubShapeAll(box2, geompy.ShapeType["EDGE"])
55 print "number of Shells in box2 : ", len(subShellList)
56 print "number of Faces in box2 : ", len(subFaceList)
57 print "number of Edges in box2 : ", len(subEdgeList)
59 box3 = geompy.MakeBox(0., 0., 300., 200., 200., 500.)
61 idbox3 = geompy.addToStudy(box3, "box3")
63 print "Analysis of the geometry box3 :"
64 subShellList = geompy.SubShapeAll(box3, geompy.ShapeType["SHELL"])
65 subFaceList = geompy.SubShapeAll(box3, geompy.ShapeType["FACE"])
66 subEdgeList = geompy.SubShapeAll(box3, geompy.ShapeType["EDGE"])
68 print "number of Shells in box3 : ", len(subShellList)
69 print "number of Faces in box3 : ", len(subFaceList)
70 print "number of Edges in box3 : ", len(subEdgeList)
72 shell = geompy.MakePartition([box1, box2, box3])
73 idshell = geompy.addToStudy(shell,"shell")
75 print "Analysis of the geometry shell (union of box1, box2 and box3) :"
76 subShellList = geompy.SubShapeAll(shell, geompy.ShapeType["SHELL"])
77 subFaceList = geompy.SubShapeAll(shell, geompy.ShapeType["FACE"])
78 subEdgeList = geompy.SubShapeAll(shell, geompy.ShapeType["EDGE"])
80 print "number of Shells in shell : ", len(subShellList)
81 print "number of Faces in shell : ", len(subFaceList)
82 print "number of Edges in shell : ", len(subEdgeList)
85 ### ---------------------------- SMESH --------------------------------------
88 # ---- init a Mesh with the shell
90 mesh = smesh.Mesh(shell, "MeshBox3")
93 # ---- set Hypothesis and Algorithm
95 print "-------------------------- NumberOfSegments"
99 regular1D = mesh.Segment()
100 hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
101 print hypNbSeg.GetName()
102 print hypNbSeg.GetId()
103 print hypNbSeg.GetNumberOfSegments()
104 smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
106 print "-------------------------- MaxElementArea"
110 mefisto2D = mesh.Triangle()
111 hypArea = mefisto2D.MaxElementArea(maxElementArea)
112 print hypArea.GetName()
113 print hypArea.GetId()
114 print hypArea.GetMaxElementArea()
115 smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
117 print "-------------------------- MaxElementVolume"
119 maxElementVolume = 500
121 netgen3D = mesh.Tetrahedron(smesh.NETGEN)
122 hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
123 print hypVolume.GetName()
124 print hypVolume.GetId()
125 print hypVolume.GetMaxElementVolume()
126 smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
129 salome.sg.updateObjBrowser(1)
131 print "-------------------------- compute shell"
135 log = mesh.GetLog(0) # no erase trace
138 print "Information about the MeshBox3:"
139 print "Number of nodes : ", mesh.NbNodes()
140 print "Number of edges : ", mesh.NbEdges()
141 print "Number of faces : ", mesh.NbFaces()
142 print "Number of triangles : ", mesh.NbTriangles()
143 print "Number of volumes : ", mesh.NbVolumes()
144 print "Number of tetrahedrons: ", mesh.NbTetras()
146 print "probleme when computing the mesh"