Salome HOME
Merge from V5_1_3_BR branch (07/12/09)
[modules/geom.git] / src / GEOM_SWIG / GEOM_Nut.py
1 #  -*- coding: iso-8859-1 -*-
2 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
4 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 #
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.
11 #
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.
16 #
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
20 #
21 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #
23 #####################################################################
24 #Created                :17/02/2005
25 #Auhtor                 :MASLOV Eugeny, KOVALTCHUK Alexey 
26 #####################################################################
27 #
28 import geompy
29 import salome
30 import os
31 import math
32
33 #Sketcher_1 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")
38
39 #Line creation
40 Line_1 = geompy.MakeLineTwoPnt(geompy.MakeVertex(0,0,0), geompy.MakeVertex(0,0,100))
41 geompy.addToStudy(Line_1, "Line_1")
42
43 #Prism creation
44 Prism_1 = geompy.MakePrismVecH(Face_1, Line_1, 100)
45 geompy.addToStudy(Prism_1, "Prism_1")
46
47 #Sketcher_2 creation
48 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]) 
49 geompy.addToStudy(Sketcher_2, "Sketcher_2")
50 Face_2 = geompy.MakeFace(Sketcher_2, 1)
51 geompy.addToStudy(Face_2, "Face_2")
52
53 #Revolution creation
54 Revolution_1 = geompy.MakeRevolution(Face_2, Line_1, 2*math.pi)
55 geompy.addToStudy(Revolution_1, "Revolution_1")
56
57 #Common applying
58 Common_1 = geompy.MakeBoolean(Revolution_1, Prism_1, 1)
59 geompy.addToStudy(Common_1, "Common_1")
60
61 #Explode Common_1 on edges
62 CommonExplodedListEdges = geompy.SubShapeAll(Common_1, geompy.ShapeType["EDGE"])
63 for i in range(0, len(CommonExplodedListEdges)):
64     name = "Edge_"+str(i+1)
65     geompy.addToStudyInFather(Common_1, CommonExplodedListEdges[i], name)
66
67 #Fillet applying
68 #ID = geompy.GetSubShapeID(Common_1, CommonExplodedListEdges[0])
69 Fillet_1 = geompy.MakeFillet(Common_1, 10, geompy.ShapeType["EDGE"], [5])
70 geompy.addToStudy(Fillet_1, "Fillet_1")
71
72 #Chamfer applying
73 Chamfer_1 = geompy.MakeChamferEdge(Fillet_1, 10, 10, 16, 50 )
74 geompy.addToStudy(Chamfer_1, "Chamfer_1")
75
76 Chamfer_2 = geompy.MakeChamferEdge(Chamfer_1, 10, 10, 21, 31 )
77 geompy.addToStudy(Chamfer_2, "Chamfer_2")
78
79 #Import of the shape from "slots.brep"
80 thePath = os.getenv("DATA_DIR")
81 theFileName = thePath + "/Shapes/Brep/slots.brep"
82 theShapeForCut = geompy.ImportBREP(theFileName)
83 geompy.addToStudy(theShapeForCut, "slot.brep_1")
84
85 #Cut applying
86 Cut_1 = geompy.MakeBoolean(Chamfer_2, theShapeForCut, 2)
87 geompy.addToStudy(Cut_1, "Cut_1")
88
89 salome.sg.updateObjBrowser(1)
90