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