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