1 # Copyright (C) 2014-2019 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 # Initialization of the test
21 from ModelAPI import *
22 from GeomDataAPI import *
23 from GeomAlgoAPI import *
27 aSession = ModelAPI_Session.get()
28 aDocument = aSession.moduleDocument()
31 aSession.startOperation()
32 aPartFeature = aDocument.addFeature("Part")
33 aSession.finishOperation()
34 aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
35 aPart = aPartResult.partDoc()
37 # Create a sketch with circle for pipe profile
38 aSession.startOperation()
39 aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
40 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
41 origin.setValue(0, 0, 0)
42 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
43 dirx.setValue(1, 0, 0)
44 norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
45 norm.setValue(0, 0, 1)
48 aSketchCircleFeature = aSketchFeature.addFeature("SketchCircle")
49 anCircleCentr = geomDataAPI_Point2D(aSketchCircleFeature.attribute("circle_center"))
50 aCircleRadius = aSketchCircleFeature.real("circle_radius")
51 anCircleCentr.setValue(0, 0)
52 aCircleRadius.setValue(10)
53 aSession.finishOperation()
54 aSketchResult = aSketchFeature.firstResult()
55 aSketchShape = aSketchResult.shape()
58 aSession.startOperation()
59 aFaceFeature = aPart.addFeature("Face")
60 aBaseObjectsList = aFaceFeature.selectionList("base_objects")
61 aShapeExplorer = GeomAPI_ShapeExplorer(aSketchShape, GeomAPI_Shape.EDGE)
62 while aShapeExplorer.more():
63 aBaseObjectsList.append(aSketchResult, aShapeExplorer.current())
65 aSession.finishOperation()
66 aFaceResult1 = aFaceFeature.firstResult()
68 # Create a sketch with edges for pipe path
69 aSession.startOperation()
70 aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
71 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
72 origin.setValue(0, 0, 0)
73 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
74 dirx.setValue(1, 0, 0)
75 norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
76 norm.setValue(0, -1, 0)
79 aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
80 aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
81 aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
82 aSketchLineStartPoint.setValue(0, 0)
83 aSketchLineEndPoint.setValue(0, 200)
86 aSketchArcFeature = aSketchFeature.addFeature("SketchArc")
87 aSketchArcCenterPoint = geomDataAPI_Point2D(aSketchArcFeature.attribute("center_point"))
88 aSketchArcStartPoint = geomDataAPI_Point2D(aSketchArcFeature.attribute("start_point"))
89 aSketchArcEndPoint = geomDataAPI_Point2D(aSketchArcFeature.attribute("end_point"))
90 aSketchArcCenterPoint.setValue(100, 200)
91 aSketchArcStartPoint.setValue(200, 200)
92 aSketchArcEndPoint.setValue(0, 200)
94 aSession.finishOperation()
95 aSketchResult = aSketchFeature.firstResult()
96 aSketchShape = aSketchResult.shape()
99 aSession.startOperation()
100 aWireFeature = aPart.addFeature("Wire")
101 aBaseObjectsList = aWireFeature.selectionList("base_objects")
102 aShapeExplorer = GeomAPI_ShapeExplorer(aSketchShape, GeomAPI_Shape.EDGE)
103 while aShapeExplorer.more():
104 aBaseObjectsList.append(aSketchResult, aShapeExplorer.current())
105 aShapeExplorer.next()
106 aSession.finishOperation()
107 aWireResult = aWireFeature.firstResult()
110 aSession.startOperation()
111 aPipeFeature = aPart.addFeature("Pipe")
112 aBaseObjectsList = aPipeFeature.selectionList("base_objects")
113 aBaseObjectsList.append(aFaceResult1, None)
114 aPathObjectSelection = aPipeFeature.selection("path_object")
115 aPathObjectSelection.setValue(aWireResult, None)
116 aPipeFeature.string("creation_method").setValue("simple")
117 aSession.finishOperation()
120 assert (len(aPipeFeature.results()) > 0)
123 # Recover original face
124 aSession.startOperation()
125 aRecover = aPart.addFeature("Recover")
126 aBaseObject = aRecover.reference("base_feature")
127 aBaseObject.setValue(aPipeFeature)
128 aRecoveredObjects = aRecover.reflist("recovered")
129 aRecoveredObjects.append(aFaceResult1)
130 aSession.finishOperation()
132 # Create pipe with bi-normal
133 aSession.startOperation()
134 aPipeFeature = aPart.addFeature("Pipe")
135 aBaseObjectsList = aPipeFeature.selectionList("base_objects")
136 aBaseObjectsList.append(aRecover.firstResult(), None)
137 aPathObjectSelection = aPipeFeature.selection("path_object")
138 aPathObjectSelection.setValue(aWireResult, None)
139 aPipeFeature.string("creation_method").setValue("binormal")
140 aBinormalObjectSelection = aPipeFeature.selection("binormal")
141 aShapeExplorer = GeomAPI_ShapeExplorer(aSketchShape, GeomAPI_Shape.EDGE)
142 aBinormalObjectSelection.setValue(aSketchResult, aShapeExplorer.current())
143 aSession.finishOperation()
146 assert (len(aPipeFeature.results()) > 0)
149 # Recover original face
150 aSession.startOperation()
151 aRecover2 = aPart.addFeature("Recover")
152 aBaseObject = aRecover2.reference("base_feature")
153 aBaseObject.setValue(aPipeFeature)
154 aRecoveredObjects = aRecover2.reflist("recovered")
155 aRecoveredObjects.append(aRecover.firstResult())
156 aSession.finishOperation()
158 # Create pipe with locations
159 # Create a sketch with circle for pipe profile
160 aSession.startOperation()
161 aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
162 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
163 origin.setValue(0, 0, 200)
164 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
165 dirx.setValue(1, 0, 0)
166 norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
167 norm.setValue(0, 0, 1)
170 aSketchCircleFeature = aSketchFeature.addFeature("SketchCircle")
171 anCircleCentr = geomDataAPI_Point2D(aSketchCircleFeature.attribute("circle_center"))
172 aCircleRadius = aSketchCircleFeature.real("circle_radius")
173 anCircleCentr.setValue(0, 0)
174 aCircleRadius.setValue(20)
175 aSession.finishOperation()
176 aSketchResult = aSketchFeature.firstResult()
177 aSketchShape = aSketchResult.shape()
180 aSession.startOperation()
181 aFaceFeature = aPart.addFeature("Face")
182 aBaseObjectsList = aFaceFeature.selectionList("base_objects")
183 aShapeExplorer = GeomAPI_ShapeExplorer(aSketchShape, GeomAPI_Shape.EDGE)
184 while aShapeExplorer.more():
185 aBaseObjectsList.append(aSketchResult, aShapeExplorer.current())
186 aShapeExplorer.next()
187 aSession.finishOperation()
188 aFaceResult2 = aFaceFeature.firstResult()
190 aSession.startOperation()
191 aPipeFeature = aPart.addFeature("Pipe")
192 aBaseObjectsList = aPipeFeature.selectionList("base_objects")
193 aBaseObjectsList.append(aRecover2.firstResult(), None)
194 aBaseObjectsList.append(aFaceResult2, None)
195 aPathObjectSelection = aPipeFeature.selection("path_object")
196 aPathObjectSelection.setValue(aWireResult, None)
197 aPipeFeature.string("creation_method").setValue("locations")
198 aSession.finishOperation()
201 assert (len(aPipeFeature.results()) > 0)
203 from salome.shaper import model
204 assert(model.checkPythonDump())