Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / BuildPlugin / Test / TestFace.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 # Initialization of the test
22 from ModelAPI import *
23 from GeomDataAPI import *
24 from GeomAlgoAPI import *
25 from GeomAPI import *
26
27 # Get document
28 aSession = ModelAPI_Session.get()
29 aDocument = aSession.moduleDocument()
30
31 # Create a part
32 aSession.startOperation()
33 aPartFeature = aDocument.addFeature("Part")
34 aSession.finishOperation()
35 aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
36 aPart = aPartResult.partDoc()
37
38 # Create a sketch
39 aSession.startOperation()
40 aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
41 anOrigin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
42 anOrigin.setValue(0, 0, 0)
43 aDirX = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
44 aDirX.setValue(1, 0, 0)
45 aNorm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
46 aNorm.setValue(0, 0, 1)
47
48 # Create lines
49 aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
50 aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
51 aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
52 aSketchLineStartPoint.setValue(0, 0)
53 aSketchLineEndPoint.setValue(0, 50)
54 aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
55 aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
56 aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
57 aSketchLineStartPoint.setValue(0, 50)
58 aSketchLineEndPoint.setValue(50, 50)
59 aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
60 aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
61 aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
62 aSketchLineStartPoint.setValue(50, 50)
63 aSketchLineEndPoint.setValue(50, 0)
64 aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
65 aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
66 aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
67 aSketchLineStartPoint.setValue(50, 0)
68 aSketchLineEndPoint.setValue(0, 0)
69 aSession.finishOperation()
70 aSketchResult = aSketchFeature.firstResult()
71 aSketchShape = aSketchResult.shape()
72
73 # Create face
74 aSession.startOperation()
75 aFaceFeature = aPart.addFeature("Face")
76 aBaseObjectsList = aFaceFeature.selectionList("base_objects")
77 aShapeExplorer = GeomAPI_ShapeExplorer(aSketchShape, GeomAPI_Shape.EDGE)
78 while aShapeExplorer.more():
79     aBaseObjectsList.append(aSketchResult, aShapeExplorer.current())
80     aShapeExplorer.next()
81 aSession.finishOperation()
82
83 # Test results
84 assert (len(aFaceFeature.results()) > 0)
85
86 from salome.shaper import model
87 assert(model.checkPythonDump())