]> SALOME platform Git repositories - modules/shaper.git/blob - src/FeaturesPlugin/Test/TestPlacement_Face_Edge.py
Salome HOME
b723c3cc253e48076fee974d2fbabc5c1dd1669d
[modules/shaper.git] / src / FeaturesPlugin / Test / TestPlacement_Face_Edge.py
1 ## Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 ##
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.
7 ##
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.
12 ##
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
16 ##
17 ## See http:##www.salome-platform.org/ or
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 ##
20
21 #=========================================================================
22 # Initialization of the test
23 #=========================================================================
24 from ModelAPI import *
25 from GeomDataAPI import *
26 from GeomAlgoAPI import *
27 from GeomAPI import *
28 import math
29
30 __updated__ = "2014-12-16"
31
32 aSession = ModelAPI_Session.get()
33 aDocument = aSession.moduleDocument()
34
35 aSession.startOperation()
36 aPartFeature = aDocument.addFeature("Part")
37 aSession.finishOperation()
38 assert (len(aPartFeature.results()) == 1)
39 aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
40 aPart = aPartResult.partDoc()
41
42 #=========================================================================
43 # Create a sketch to extrude
44 #=========================================================================
45 aSession.startOperation()
46 aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
47 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
48 origin.setValue(0, 0, 0)
49 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
50 dirx.setValue(1, 0, 0)
51 norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
52 norm.setValue(0, 0, 1)
53 aLineA1 = aSketchFeature.addFeature("SketchLine")
54 aLineB1 = aSketchFeature.addFeature("SketchLine")
55 aLineC1 = aSketchFeature.addFeature("SketchLine")
56 aLineD1 = aSketchFeature.addFeature("SketchLine")
57 aLineA1StartPoint = geomDataAPI_Point2D(aLineA1.attribute("StartPoint"))
58 aLineA1EndPoint = geomDataAPI_Point2D(aLineA1.attribute("EndPoint"))
59 aLineB1StartPoint = geomDataAPI_Point2D(aLineB1.attribute("StartPoint"))
60 aLineB1EndPoint = geomDataAPI_Point2D(aLineB1.attribute("EndPoint"))
61 aLineC1StartPoint = geomDataAPI_Point2D(aLineC1.attribute("StartPoint"))
62 aLineC1EndPoint = geomDataAPI_Point2D(aLineC1.attribute("EndPoint"))
63 aLineD1StartPoint = geomDataAPI_Point2D(aLineD1.attribute("StartPoint"))
64 aLineD1EndPoint = geomDataAPI_Point2D(aLineD1.attribute("EndPoint"))
65 aLineA1StartPoint.setValue(-100, 0)
66 aLineA1EndPoint.setValue(-50, 0)
67 aLineB1StartPoint.setValue(-50, 0)
68 aLineB1EndPoint.setValue(-50, 50)
69 aLineC1StartPoint.setValue(-50, 50)
70 aLineC1EndPoint.setValue(-100, 50)
71 aLineD1StartPoint.setValue(-100, 50)
72 aLineD1EndPoint.setValue(-100, 0)
73 aLineA2 = aSketchFeature.addFeature("SketchLine")
74 aLineB2 = aSketchFeature.addFeature("SketchLine")
75 aLineC2 = aSketchFeature.addFeature("SketchLine")
76 aLineD2 = aSketchFeature.addFeature("SketchLine")
77 aLineA2StartPoint = geomDataAPI_Point2D(aLineA2.attribute("StartPoint"))
78 aLineA2EndPoint = geomDataAPI_Point2D(aLineA2.attribute("EndPoint"))
79 aLineB2StartPoint = geomDataAPI_Point2D(aLineB2.attribute("StartPoint"))
80 aLineB2EndPoint = geomDataAPI_Point2D(aLineB2.attribute("EndPoint"))
81 aLineC2StartPoint = geomDataAPI_Point2D(aLineC2.attribute("StartPoint"))
82 aLineC2EndPoint = geomDataAPI_Point2D(aLineC2.attribute("EndPoint"))
83 aLineD2StartPoint = geomDataAPI_Point2D(aLineD2.attribute("StartPoint"))
84 aLineD2EndPoint = geomDataAPI_Point2D(aLineD2.attribute("EndPoint"))
85 aLineA2StartPoint.setValue(100, 0)
86 aLineA2EndPoint.setValue(50, 0)
87 aLineB2StartPoint.setValue(50, 0)
88 aLineB2EndPoint.setValue(50, 50)
89 aLineC2StartPoint.setValue(50, 50)
90 aLineC2EndPoint.setValue(100, 50)
91 aLineD2StartPoint.setValue(100, 50)
92 aLineD2EndPoint.setValue(100, 0)
93 aSession.finishOperation()
94
95 #=========================================================================
96 # Make extrusion
97 #=========================================================================
98 aSketchResult = modelAPI_ResultConstruction(aSketchFeature.firstResult())
99 assert (aSketchResult.facesNum() > 1)
100
101 aSession.startOperation()
102 anExtrusionFt = aPart.addFeature("Extrusion")
103 assert (anExtrusionFt.getKind() == "Extrusion")
104 anExtrusionFt.selectionList("base").append(aSketchResult, aSketchResult.face(0))
105 anExtrusionFt.selectionList("base").append(aSketchResult, aSketchResult.face(1))
106 anExtrusionFt.string("CreationMethod").setValue("BySizes")
107 anExtrusionFt.real("to_size").setValue(50)
108 anExtrusionFt.real("from_size").setValue(0)
109 anExtrusionFt.real("to_offset").setValue(0) #TODO: remove
110 anExtrusionFt.real("from_offset").setValue(0) #TODO: remove
111 anExtrusionFt.execute()
112 aSession.finishOperation()
113 assert (anExtrusionFt.real("to_size").value() == 50.0)
114
115 # Check extrusion results
116 assert (len(anExtrusionFt.results()) > 0)
117 anExtrusionResult = modelAPI_ResultBody(anExtrusionFt.firstResult())
118 assert (anExtrusionResult is not None)
119
120 #=========================================================================
121 # Test placement by face - edge
122 #=========================================================================
123 aSession.startOperation()
124 aPlacementFt = aPart.addFeature("Placement")
125 aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape())
126 aPlacementFt.selection("placement_start_shape").selectSubShape("face", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4")
127 aPlacementFt.selection("placement_end_shape").selectSubShape("edge", "[Extrusion_1_2/Generated_Face&Sketch_1/SketchLine_7][Extrusion_1_2/To_Face]")
128 aPlacementFt.boolean("placement_reverse_direction").setValue(False)
129 aPlacementFt.boolean("placement_centering").setValue(True)
130 aPlacementFt.execute()
131 aSession.finishOperation()
132
133 # Check placement results
134 assert (len(aPlacementFt.results()) > 0)
135 aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult())
136 assert (aPlacementResult is not None)
137 aSession.finishOperation()
138
139 from salome.shaper import model
140 assert(model.checkPythonDump())