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 *
27 def createFace(thePart, theNormX, theNormY, theNormZ):
29 aSession.startOperation()
30 aSketchFeature = featureToCompositeFeature(thePart.addFeature("Sketch"))
31 anOrigin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
32 anOrigin.setValue(0, 0, 0)
33 aDirX = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
34 aDirX.setValue(1, 0, 0)
35 aNorm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
36 aNorm.setValue(theNormX, theNormY, theNormZ)
39 aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
40 aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
41 aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
42 aSketchLineStartPoint.setValue(0, 0)
43 aSketchLineEndPoint.setValue(0, 50)
44 aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
45 aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
46 aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
47 aSketchLineStartPoint.setValue(0, 50)
48 aSketchLineEndPoint.setValue(50, 50)
49 aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
50 aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
51 aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
52 aSketchLineStartPoint.setValue(50, 50)
53 aSketchLineEndPoint.setValue(50, 0)
54 aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
55 aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
56 aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
57 aSketchLineStartPoint.setValue(50, 0)
58 aSketchLineEndPoint.setValue(0, 0)
59 aSession.finishOperation()
60 aSketchResult = aSketchFeature.firstResult()
61 aSketchShape = aSketchResult.shape()
64 aSession.startOperation()
65 aFaceFeature = thePart.addFeature("Face")
66 aBaseObjectsList = aFaceFeature.selectionList("base_objects")
67 aShapeExplorer = GeomAPI_ShapeExplorer(aSketchShape, GeomAPI_Shape.EDGE)
68 while aShapeExplorer.more():
69 aBaseObjectsList.append(aSketchResult, aShapeExplorer.current())
71 aSession.finishOperation()
72 return aFaceFeature.firstResult()
75 aSession = ModelAPI_Session.get()
76 aDocument = aSession.moduleDocument()
79 aSession.startOperation()
80 aPartFeature = aDocument.addFeature("Part")
81 aSession.finishOperation()
82 aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
83 aPart = aPartResult.partDoc()
87 aFaceResults.append(createFace(aPart, 0, 0, 1))
88 aFaceResults.append(createFace(aPart, 0, 1, 0))
91 aSession.startOperation()
92 aShellFeature = aPart.addFeature("Shell")
93 aBaseObjectsList = aShellFeature.selectionList("base_objects")
94 for aFaceResult in aFaceResults:
95 aBaseObjectsList.append(aFaceResult, None)
96 aSession.finishOperation()
99 assert (len(aShellFeature.results()) > 0)
101 # Test shell building on set of faces from another result
104 aSession.startOperation()
105 aCylinder = aPart.addFeature("Cylinder")
106 aCylinder.string("CreationMethod").setValue("Cylinder")
107 aCylinder.selection("base_point").selectSubShape("VERTEX", "PartSet/Origin")
108 aCylinder.selection("axis").selectSubShape("EDGE", "PartSet/OZ")
109 aCylinder.real("radius").setValue(25)
110 aCylinder.real("height").setValue(50)
111 aSession.finishOperation()
112 aCylinderResult = aCylinder.firstResult()
113 aCylinderShape = aCylinderResult.shape()
116 aSession.startOperation()
117 aShellFeature2 = aPart.addFeature("Shell")
118 aBaseObjectsList = aShellFeature2.selectionList("base_objects")
119 aBaseObjectsList.append("Cylinder_1_1/Face_1", "FACE")
120 aBaseObjectsList.append("Cylinder_1_1/Face_3", "FACE")
121 aSession.finishOperation()
124 assert (len(aShellFeature2.results()) > 0)
126 # Check Shell feature failed on incorrect input
127 aShellResult = aShellFeature.firstResult()
128 aSession.startOperation()
129 aShellFeature3 = aPart.addFeature("Shell")
130 aBaseObjectsList = aShellFeature3.selectionList("base_objects")
131 aShapeExplorer = GeomAPI_ShapeExplorer(aShellResult.shape(), GeomAPI_Shape.EDGE)
132 while aShapeExplorer.more():
133 aBaseObjectsList.append(aShellResult, aShapeExplorer.current())
134 aShapeExplorer.next()
135 aSession.finishOperation()
136 assert (len(aShellFeature3.results()) == 0)
138 # remove failed feature
139 aSession.startOperation()
140 aPart.removeFeature(aShellFeature3)
141 aSession.finishOperation()
143 from salome.shaper import model
144 assert(model.checkPythonDump())