1 # Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/
20 #####################################################################
22 #Auhtor :MASLOV Eugeny, KOVALTCHUK Alexey
23 #####################################################################
33 print "Sketcher creation..."
34 Sketcher_1 = geompy.MakeSketcher("Sketcher:F 100 -57.7:TT 100 57.7:TT 0 115.47:TT -100 57.7:TT -100 -57.7:TT 0 -115.47:WW")
35 geompy.addToStudy(Sketcher_1, "Sketcher_1")
36 Face_1 = geompy.MakeFace(Sketcher_1, 1)
37 geompy.addToStudy(Face_1, "Face_1")
40 print "Line creation..."
41 Line_1 = geompy.MakeLineTwoPnt(geompy.MakeVertex(0,0,0), geompy.MakeVertex(0,0,100))
42 geompy.addToStudy(Line_1, "Line_1")
45 print "Prism creation..."
46 Prism_1 = geompy.MakePrismVecH(Face_1, Line_1, 100)
47 geompy.addToStudy(Prism_1, "Prism_1")
50 print "Sketcher creation..."
51 Sketcher_2 = geompy.MakeSketcher("Sketcher:F 50 0:TT 80 0:TT 112 13:TT 112 48:TT 80 63:TT 80 90:TT 50 90:WW", [0,0,0, 1,0,0, 0,1,0])
52 geompy.addToStudy(Sketcher_2, "Sketcher_2")
53 Face_2 = geompy.MakeFace(Sketcher_2, 1)
54 geompy.addToStudy(Face_2, "Face_2")
57 print "Revolution creation..."
58 Revolution_1 = geompy.MakeRevolution(Face_2, Line_1, 2*math.pi)
59 geompy.addToStudy(Revolution_1, "Revolution_1")
62 print "Common of Revolution and Prism..."
63 Common_1 = geompy.MakeBoolean(Revolution_1, Prism_1, 1)
64 geompy.addToStudy(Common_1, "Common_1")
66 #Explode Common_1 on edges
67 CommonExplodedListEdges = geompy.SubShapeAll(Common_1, geompy.ShapeType["EDGE"])
68 for i in range(0, len(CommonExplodedListEdges)):
69 name = "Edge_"+str(i+1)
70 geompy.addToStudyInFather(Common_1, CommonExplodedListEdges[i], name)
73 print "Fillet creation..."
74 Fillet_1 = geompy.MakeFillet(Common_1, 10, geompy.ShapeType["EDGE"], [6])
75 geompy.addToStudy(Fillet_1, "Fillet_1")
78 print "Chamfer creation..."
79 Chamfer_1 = geompy.MakeChamferEdge(Fillet_1, 10, 10, 16, 50 )
80 geompy.addToStudy(Chamfer_1, "Chamfer_1")
81 Chamfer_2 = geompy.MakeChamferEdge(Chamfer_1, 10, 10, 21, 31 )
82 geompy.addToStudy(Chamfer_2, "Chamfer_2")
84 #Import of the shape from "slots.brep"
85 print "Import multi-rotation from the DATA_DIR/Shapes/Brep/slots.brep"
86 thePath = os.getenv("DATA_DIR")
87 theFileName = thePath + "/Shapes/Brep/slots.brep"
88 theShapeForCut = geompy.ImportBREP(theFileName)
89 geompy.addToStudy(theShapeForCut, "slot.brep_1")
93 Cut_1 = geompy.MakeBoolean(Chamfer_2, theShapeForCut, 2)
94 Cut_1_ID = geompy.addToStudy(Cut_1, "Cut_1")
97 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
100 shape_mesh = salome.IDToObject( Cut_1_ID )
101 smesh.SetCurrentStudy(salome.myStudy)
102 mesh = smesh.CreateMesh(shape_mesh)
103 smeshgui = salome.ImportComponentGUI("SMESH")
104 smeshgui.Init(salome.myStudyId)
105 idmesh = salome.ObjectToID(mesh)
106 smeshgui.SetName( idmesh, "Nut" )
109 print "-------------------------- Average length"
111 hAvLength = smesh.CreateHypothesis( "LocalLength", "libStdMeshersEngine.so" )
112 hAvLength.SetLength( theAverageLength )
113 print hAvLength.GetName()
114 print hAvLength.GetId()
115 smeshgui.SetName(salome.ObjectToID(hAvLength), "AverageLength_5")
117 print "-------------------------- MaxElementArea"
118 theMaxElementArea = 20
119 hArea20 = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" )
120 hArea20.SetMaxElementArea( theMaxElementArea )
121 print hArea20.GetName()
122 print hArea20.GetId()
123 print hArea20.GetMaxElementArea()
124 smeshgui.SetName(salome.ObjectToID(hArea20), "MaxElementArea_20")
126 print "-------------------------- MaxElementVolume"
127 theMaxElementVolume = 150
128 hVolume150 = smesh.CreateHypothesis( "MaxElementVolume", "libStdMeshersEngine.so" )
129 hVolume150.SetMaxElementVolume( theMaxElementVolume )
130 print hVolume150.GetName()
131 print hVolume150.GetId()
132 print hVolume150.GetMaxElementVolume()
133 smeshgui.SetName(salome.ObjectToID(hVolume150), "MaxElementVolume_150")
135 mesh.AddHypothesis(shape_mesh, hAvLength)
136 mesh.AddHypothesis(shape_mesh, hArea20)
137 mesh.AddHypothesis(shape_mesh, hVolume150)
139 print "-------------------------- Regular_1D"
141 algoReg1D = smesh.CreateHypothesis( "Regular_1D", "libStdMeshersEngine.so" )
142 listHyp = algoReg1D.GetCompatibleHypothesis()
145 print algoReg1D.GetName()
146 print algoReg1D.GetId()
147 smeshgui.SetName(salome.ObjectToID(algoReg1D), "Wire discretisation")
149 print "-------------------------- MEFISTO_2D"
150 algoMef = smesh.CreateHypothesis( "MEFISTO_2D", "libStdMeshersEngine.so" )
151 listHyp = algoMef.GetCompatibleHypothesis()
154 print algoMef.GetName()
155 print algoMef.GetId()
156 smeshgui.SetName(salome.ObjectToID(algoMef), "Triangle (Mefisto)")
158 print "-------------------------- NETGEN_3D"
160 algoNg = smesh.CreateHypothesis( "NETGEN_3D", "libNETGENEngine.so" )
161 print algoNg.GetName()
163 smeshgui.SetName(salome.ObjectToID(algoNg), "Tetrahedron (NETGEN)")
164 mesh.AddHypothesis(shape_mesh, algoReg1D)
165 mesh.AddHypothesis(shape_mesh, algoMef)
166 mesh.AddHypothesis(shape_mesh, algoNg)
168 print "-------------------------- compute the mesh of the mechanic piece"
169 smesh.Compute(mesh,shape_mesh)
171 print "Information about the Nut:"
172 print "Number of nodes : ", mesh.NbNodes()
173 print "Number of edges : ", mesh.NbEdges()
174 print "Number of faces : ", mesh.NbFaces()
175 print "Number of triangles : ", mesh.NbTriangles()
176 print "Number of quadrangles : ", mesh.NbQuadrangles()
177 print "Number of volumes : ", mesh.NbVolumes()
178 print "Number of tetrahedrons: ", mesh.NbTetras()
180 salome.sg.updateObjBrowser(1)