Salome HOME
Merge from V6_main 01/04/2013
[modules/geom.git] / src / GEOM_SWIG / GEOM_Nut.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2013  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 #####################################################################
25 #Created                :17/02/2005
26 #Auhtor                 :MASLOV Eugeny, KOVALTCHUK Alexey 
27 #####################################################################
28 #
29 import geompy
30 import salome
31 import os
32 import math
33
34 #Sketcher_1 creation
35 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") 
36 geompy.addToStudy(Sketcher_1, "Sketcher_1")
37 Face_1 = geompy.MakeFace(Sketcher_1, 1)
38 geompy.addToStudy(Face_1, "Face_1")
39
40 #Line creation
41 Line_1 = geompy.MakeLineTwoPnt(geompy.MakeVertex(0,0,0), geompy.MakeVertex(0,0,100))
42 geompy.addToStudy(Line_1, "Line_1")
43
44 #Prism creation
45 Prism_1 = geompy.MakePrismVecH(Face_1, Line_1, 100)
46 geompy.addToStudy(Prism_1, "Prism_1")
47
48 #Sketcher_2 creation
49 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]) 
50 geompy.addToStudy(Sketcher_2, "Sketcher_2")
51 Face_2 = geompy.MakeFace(Sketcher_2, 1)
52 geompy.addToStudy(Face_2, "Face_2")
53
54 #Revolution creation
55 Revolution_1 = geompy.MakeRevolution(Face_2, Line_1, 2*math.pi)
56 geompy.addToStudy(Revolution_1, "Revolution_1")
57
58 #Common applying
59 Common_1 = geompy.MakeBoolean(Revolution_1, Prism_1, 1)
60 geompy.addToStudy(Common_1, "Common_1")
61
62 #Explode Common_1 on edges
63 CommonExplodedListEdges = geompy.SubShapeAll(Common_1, geompy.ShapeType["EDGE"])
64 for i in range(0, len(CommonExplodedListEdges)):
65     name = "Edge_"+str(i+1)
66     geompy.addToStudyInFather(Common_1, CommonExplodedListEdges[i], name)
67
68 #Fillet applying
69 #ID = geompy.GetSubShapeID(Common_1, CommonExplodedListEdges[0])
70 Fillet_1 = geompy.MakeFillet(Common_1, 10, geompy.ShapeType["EDGE"], [5])
71 geompy.addToStudy(Fillet_1, "Fillet_1")
72
73 #Chamfer applying
74 Chamfer_1 = geompy.MakeChamferEdge(Fillet_1, 10, 10, 16, 50 )
75 geompy.addToStudy(Chamfer_1, "Chamfer_1")
76
77 Chamfer_2 = geompy.MakeChamferEdge(Chamfer_1, 10, 10, 21, 31 )
78 geompy.addToStudy(Chamfer_2, "Chamfer_2")
79
80 #Import of the shape from "slots.brep"
81 thePath = os.getenv("DATA_DIR")
82 theFileName = thePath + "/Shapes/Brep/slots.brep"
83 theShapeForCut = geompy.ImportBREP(theFileName)
84 geompy.addToStudy(theShapeForCut, "slot.brep_1")
85
86 #Cut applying
87 Cut_1 = geompy.MakeBoolean(Chamfer_2, theShapeForCut, 2)
88 geompy.addToStudy(Cut_1, "Cut_1")
89
90 salome.sg.updateObjBrowser(1)
91