1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 #####################################################################
26 #Auhtor :MASLOV Eugeny, KOVALTCHUK Alexey
27 #####################################################################
36 print "Sketcher creation..."
37 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")
38 geompy.addToStudy(Sketcher_1, "Sketcher_1")
39 Face_1 = geompy.MakeFace(Sketcher_1, 1)
40 geompy.addToStudy(Face_1, "Face_1")
43 print "Line creation..."
44 Line_1 = geompy.MakeLineTwoPnt(geompy.MakeVertex(0,0,0), geompy.MakeVertex(0,0,100))
45 geompy.addToStudy(Line_1, "Line_1")
48 print "Prism creation..."
49 Prism_1 = geompy.MakePrismVecH(Face_1, Line_1, 100)
50 geompy.addToStudy(Prism_1, "Prism_1")
53 print "Sketcher creation..."
54 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])
55 geompy.addToStudy(Sketcher_2, "Sketcher_2")
56 Face_2 = geompy.MakeFace(Sketcher_2, 1)
57 geompy.addToStudy(Face_2, "Face_2")
60 print "Revolution creation..."
61 Revolution_1 = geompy.MakeRevolution(Face_2, Line_1, 2*math.pi)
62 geompy.addToStudy(Revolution_1, "Revolution_1")
65 print "Common of Revolution and Prism..."
66 Common_1 = geompy.MakeBoolean(Revolution_1, Prism_1, 1)
67 geompy.addToStudy(Common_1, "Common_1")
69 #Explode Common_1 on edges
70 CommonExplodedListEdges = geompy.SubShapeAll(Common_1, geompy.ShapeType["EDGE"])
71 for i in range(0, len(CommonExplodedListEdges)):
72 name = "Edge_"+str(i+1)
73 geompy.addToStudyInFather(Common_1, CommonExplodedListEdges[i], name)
76 print "Fillet creation..."
77 Fillet_1 = geompy.MakeFillet(Common_1, 10, geompy.ShapeType["EDGE"], [5])
78 geompy.addToStudy(Fillet_1, "Fillet_1")
81 print "Chamfer creation..."
82 Chamfer_1 = geompy.MakeChamferEdge(Fillet_1, 10, 10, 16, 50 )
83 geompy.addToStudy(Chamfer_1, "Chamfer_1")
84 Chamfer_2 = geompy.MakeChamferEdge(Chamfer_1, 10, 10, 21, 31 )
85 geompy.addToStudy(Chamfer_2, "Chamfer_2")
87 #Import of the shape from "slots.brep"
88 print "Import multi-rotation from the DATA_DIR/Shapes/Brep/slots.brep"
89 thePath = os.getenv("DATA_DIR")
90 theFileName = os.path.join( thePath,"Shapes","Brep","slots.brep")
91 theShapeForCut = geompy.ImportBREP(theFileName)
92 geompy.addToStudy(theShapeForCut, "slot.brep_1")
96 Cut_1 = geompy.MakeBoolean(Chamfer_2, theShapeForCut, 2)
97 Cut_1_ID = geompy.addToStudy(Cut_1, "Cut_1")
101 smesh.SetCurrentStudy(salome.myStudy)
104 shape_mesh = salome.IDToObject( Cut_1_ID )
106 mesh = smesh.Mesh(shape_mesh, "Nut")
109 print "-------------------------- Average length"
111 algoReg1D = mesh.Segment()
112 hAvLength = algoReg1D.LocalLength(theAverageLength)
113 print hAvLength.GetName()
114 print hAvLength.GetId()
115 print hAvLength.GetLength()
116 smesh.SetName(hAvLength, "AverageLength_"+str(theAverageLength))
118 print "-------------------------- MaxElementArea"
119 theMaxElementArea = 20
120 algoMef = mesh.Triangle(smesh.MEFISTO)
121 hArea = algoMef.MaxElementArea( theMaxElementArea )
122 print hArea.GetName()
124 print hArea.GetMaxElementArea()
125 smesh.SetName(hArea, "MaxElementArea_"+str(theMaxElementArea))
127 print "-------------------------- MaxElementVolume"
128 theMaxElementVolume = 150
129 algoNg = mesh.Tetrahedron(smesh.NETGEN)
130 hVolume = algoNg.MaxElementVolume( theMaxElementVolume )
131 print hVolume.GetName()
132 print hVolume.GetId()
133 print hVolume.GetMaxElementVolume()
134 smesh.SetName(hVolume, "MaxElementVolume_"+str(theMaxElementVolume))
137 print "-------------------------- compute the mesh of the mechanic piece"
140 print "Information about the Nut:"
141 print "Number of nodes : ", mesh.NbNodes()
142 print "Number of edges : ", mesh.NbEdges()
143 print "Number of faces : ", mesh.NbFaces()
144 print "Number of triangles : ", mesh.NbTriangles()
145 print "Number of quadrangles : ", mesh.NbQuadrangles()
146 print "Number of volumes : ", mesh.NbVolumes()
147 print "Number of tetrahedrons: ", mesh.NbTetras()
149 salome.sg.updateObjBrowser(1)