1 # Copyright (C) 2014-2022 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #=========================================================================
21 # Initialization of the test
22 #=========================================================================
23 from ModelAPI import *
24 from GeomDataAPI import *
25 from GeomAlgoAPI import *
29 aSession = ModelAPI_Session.get()
30 aDocument = aSession.moduleDocument()
32 # Create a part for extrusion
33 aSession.startOperation()
34 aPartFeature = aDocument.addFeature("Part")
35 aSession.finishOperation()
36 assert (len(aPartFeature.results()) == 1)
38 aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
39 aPart = aPartResult.partDoc()
41 #=========================================================================
42 # Create a sketch to extrude
43 #=========================================================================
44 aSession.startOperation()
45 aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
46 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
47 origin.setValue(0, 0, 0)
48 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
49 dirx.setValue(1, 0, 0)
50 norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
51 norm.setValue(0, 0, 1)
54 aSketchCircle = aSketchFeature.addFeature("SketchCircle")
55 anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
56 aCircleRadius = aSketchCircle.real("circle_radius")
57 anCircleCentr.setValue(-25, 0)
58 aCircleRadius.setValue(50)
59 aSketchCircle = aSketchFeature.addFeature("SketchCircle")
60 anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
61 aCircleRadius = aSketchCircle.real("circle_radius")
62 anCircleCentr.setValue(25, 0)
63 aCircleRadius.setValue(50)
64 aSession.finishOperation()
65 aSketchResult = aSketchFeature.firstResult()
67 #=========================================================================
68 # Make extrusion on sketch
69 #=========================================================================
71 aSession.startOperation()
72 anExtrusionFeature = aPart.addFeature("Extrusion")
73 anExtrusionFeature.selectionList("base").append(aSketchResult, None)
74 anExtrusionFeature.string("CreationMethod").setValue("BySizes")
75 anExtrusionFeature.real("to_size").setValue(50)
76 anExtrusionFeature.real("from_size").setValue(0)
77 anExtrusionFeature.real("to_offset").setValue(0) #TODO: remove
78 anExtrusionFeature.real("from_offset").setValue(0) #TODO: remove
79 anExtrusionFeature.execute()
80 aSession.finishOperation()
81 anExtrusionResult = modelAPI_ResultBody(anExtrusionFeature.firstResult())
83 #=========================================================================
84 # Make union on extrusion
85 #=========================================================================
86 aSession.startOperation()
87 aUnionFeature = aPart.addFeature("Fuse")
88 aUnionFeature.string("creation_method").setValue("simple")
89 aUnionFeature.selectionList("main_objects").append(anExtrusionResult.subResult(0), None);
90 aUnionFeature.selectionList("main_objects").append(anExtrusionResult.subResult(1), None);
91 aUnionFeature.selectionList("main_objects").append(anExtrusionResult.subResult(2), None);
92 aUnionFeature.boolean("remove_intersection_edges").setValue(False)
93 aSession.finishOperation()
94 assert (len(aUnionFeature.results()) > 0)
95 anUnionResult = modelAPI_ResultBody(aUnionFeature.firstResult())
96 assert (anUnionResult.numberOfSubs() == 0)
98 from salome.shaper import model
99 assert(model.checkPythonDump())