1 ## Copyright (C) 2014-2017 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
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 # Initialization of the test
22 from ModelAPI import *
23 from GeomDataAPI import *
24 from GeomAlgoAPI import *
28 aSession = ModelAPI_Session.get()
29 aDocument = aSession.moduleDocument()
32 aSession.startOperation()
33 aPartFeature = aDocument.addFeature("Part")
34 aSession.finishOperation()
35 aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
36 aPart = aPartResult.partDoc()
38 # Create a sketch with circle for pipe profile
39 aSession.startOperation()
40 aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
41 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
42 origin.setValue(0, 0, 0)
43 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
44 dirx.setValue(1, 0, 0)
45 norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
46 norm.setValue(0, 0, 1)
49 aSketchCircleFeature = aSketchFeature.addFeature("SketchCircle")
50 anCircleCentr = geomDataAPI_Point2D(aSketchCircleFeature.attribute("circle_center"))
51 aCircleRadius = aSketchCircleFeature.real("circle_radius")
52 anCircleCentr.setValue(0, 0)
53 aCircleRadius.setValue(10)
54 aSession.finishOperation()
55 aSketchResult = aSketchFeature.firstResult()
56 aSketchShape = aSketchResult.shape()
59 aSession.startOperation()
60 aFaceFeature = aPart.addFeature("Face")
61 aBaseObjectsList = aFaceFeature.selectionList("base_objects")
62 aShapeExplorer = GeomAPI_ShapeExplorer(aSketchShape, GeomAPI_Shape.EDGE)
63 while aShapeExplorer.more():
64 aBaseObjectsList.append(aSketchResult, aShapeExplorer.current())
66 aSession.finishOperation()
67 aFaceResult1 = aFaceFeature.firstResult()
69 # Create a sketch with edges for pipe path
70 aSession.startOperation()
71 aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
72 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
73 origin.setValue(0, 0, 0)
74 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
75 dirx.setValue(1, 0, 0)
76 norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
77 norm.setValue(0, -1, 0)
80 aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
81 aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
82 aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
83 aSketchLineStartPoint.setValue(0, 0)
84 aSketchLineEndPoint.setValue(0, 200)
87 aSketchArcFeature = aSketchFeature.addFeature("SketchArc")
88 aSketchArcCenterPoint = geomDataAPI_Point2D(aSketchArcFeature.attribute("center_point"))
89 aSketchArcStartPoint = geomDataAPI_Point2D(aSketchArcFeature.attribute("start_point"))
90 aSketchArcEndPoint = geomDataAPI_Point2D(aSketchArcFeature.attribute("end_point"))
91 aSketchArcCenterPoint.setValue(100, 200)
92 aSketchArcStartPoint.setValue(200, 200)
93 aSketchArcEndPoint.setValue(0, 200)
95 aSession.finishOperation()
96 aSketchResult = aSketchFeature.firstResult()
97 aSketchShape = aSketchResult.shape()
100 aSession.startOperation()
101 aWireFeature = aPart.addFeature("Wire")
102 aBaseObjectsList = aWireFeature.selectionList("base_objects")
103 aShapeExplorer = GeomAPI_ShapeExplorer(aSketchShape, GeomAPI_Shape.EDGE)
104 while aShapeExplorer.more():
105 aBaseObjectsList.append(aSketchResult, aShapeExplorer.current())
106 aShapeExplorer.next()
107 aSession.finishOperation()
108 aWireResult = aWireFeature.firstResult()
111 aSession.startOperation()
112 aPipeFeature = aPart.addFeature("Pipe")
113 aBaseObjectsList = aPipeFeature.selectionList("base_objects")
114 aBaseObjectsList.append(aFaceResult1, None)
115 aPathObjectSelection = aPipeFeature.selection("path_object")
116 aPathObjectSelection.setValue(aWireResult, None)
117 aPipeFeature.string("creation_method").setValue("simple")
118 aSession.finishOperation()
121 assert (len(aPipeFeature.results()) > 0)
124 # Create pipe with bi-normal
125 aSession.startOperation()
126 aPipeFeature = aPart.addFeature("Pipe")
127 aBaseObjectsList = aPipeFeature.selectionList("base_objects")
128 aBaseObjectsList.append(aFaceResult1, None)
129 aPathObjectSelection = aPipeFeature.selection("path_object")
130 aPathObjectSelection.setValue(aWireResult, None)
131 aPipeFeature.string("creation_method").setValue("binormal")
132 aBinormalObjectSelection = aPipeFeature.selection("binormal")
133 aShapeExplorer = GeomAPI_ShapeExplorer(aSketchShape, GeomAPI_Shape.EDGE)
134 aBinormalObjectSelection.setValue(aSketchResult, aShapeExplorer.current())
135 aSession.finishOperation()
138 assert (len(aPipeFeature.results()) > 0)
141 # Create pipe with locations
142 # Create a sketch with circle for pipe profile
143 aSession.startOperation()
144 aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
145 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
146 origin.setValue(0, 0, 200)
147 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
148 dirx.setValue(1, 0, 0)
149 norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
150 norm.setValue(0, 0, 1)
153 aSketchCircleFeature = aSketchFeature.addFeature("SketchCircle")
154 anCircleCentr = geomDataAPI_Point2D(aSketchCircleFeature.attribute("circle_center"))
155 aCircleRadius = aSketchCircleFeature.real("circle_radius")
156 anCircleCentr.setValue(0, 0)
157 aCircleRadius.setValue(20)
158 aSession.finishOperation()
159 aSketchResult = aSketchFeature.firstResult()
160 aSketchShape = aSketchResult.shape()
163 aSession.startOperation()
164 aFaceFeature = aPart.addFeature("Face")
165 aBaseObjectsList = aFaceFeature.selectionList("base_objects")
166 aShapeExplorer = GeomAPI_ShapeExplorer(aSketchShape, GeomAPI_Shape.EDGE)
167 while aShapeExplorer.more():
168 aBaseObjectsList.append(aSketchResult, aShapeExplorer.current())
169 aShapeExplorer.next()
170 aSession.finishOperation()
171 aFaceResult2 = aFaceFeature.firstResult()
173 aSession.startOperation()
174 aPipeFeature = aPart.addFeature("Pipe")
175 aBaseObjectsList = aPipeFeature.selectionList("base_objects")
176 aBaseObjectsList.append(aFaceResult1, None)
177 aBaseObjectsList.append(aFaceResult2, None)
178 aPathObjectSelection = aPipeFeature.selection("path_object")
179 aPathObjectSelection.setValue(aWireResult, None)
180 aPipeFeature.string("creation_method").setValue("locations")
181 aSession.finishOperation()
184 assert (len(aPipeFeature.results()) > 0)
186 from salome.shaper import model
187 assert(model.checkPythonDump())