]> SALOME platform Git repositories - modules/shaper.git/blob - src/BuildPlugin/Test/TestFace.py
Salome HOME
Tests for Build plug-in features.
[modules/shaper.git] / src / BuildPlugin / Test / TestFace.py
1 # Initialization of the test
2 from ModelAPI import *
3 from GeomDataAPI import *
4 from GeomAlgoAPI import *
5 from GeomAPI import *
6
7 # Get document
8 aSession = ModelAPI_Session.get()
9 aDocument = aSession.moduleDocument()
10
11 # Create a part
12 aSession.startOperation()
13 aPartFeature = aDocument.addFeature("Part")
14 aSession.finishOperation()
15 aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
16 aPart = aPartResult.partDoc()
17
18 # Create a sketch
19 aSession.startOperation()
20 aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
21 anOrigin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
22 anOrigin.setValue(0, 0, 0)
23 aDirX = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
24 aDirX.setValue(1, 0, 0)
25 aNorm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
26 aNorm.setValue(0, 0, 1)
27
28 # Create lines
29 aNumOfLines = 10
30 aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
31 aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
32 aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
33 aSketchLineStartPoint.setValue(0, 0)
34 aSketchLineEndPoint.setValue(0, 50)
35 aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
36 aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
37 aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
38 aSketchLineStartPoint.setValue(0, 50)
39 aSketchLineEndPoint.setValue(50, 50)
40 aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
41 aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
42 aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
43 aSketchLineStartPoint.setValue(50, 50)
44 aSketchLineEndPoint.setValue(50, 0)
45 aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
46 aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
47 aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
48 aSketchLineStartPoint.setValue(50, 0)
49 aSketchLineEndPoint.setValue(0, 0)
50 aSession.finishOperation()
51 aSketchResult = aSketchFeature.firstResult()
52 aSketchShape = aSketchResult.shape()
53
54 # Create face
55 aSession.startOperation()
56 aFaceFeature = aPart.addFeature("Face")
57 aBaseObjectsList = aFaceFeature.selectionList("base_objects")
58 aShapeExplorer = GeomAPI_ShapeExplorer(aSketchShape, GeomAPI_Shape.EDGE)
59 while aShapeExplorer.more():
60     aBaseObjectsList.append(aSketchResult, aShapeExplorer.current())
61     aShapeExplorer.next()
62 aSession.finishOperation()
63
64 # Test results
65 assert (len(aFaceFeature.results()) > 0)