Salome HOME
Add extrusion cut icon
[modules/shaper.git] / src / FeaturesPlugin / Test / TestGroup.py
1 """
2       TestBoolean.py
3       Unit test of FeaturesPlugin_Group class
4       
5       class FeaturesPlugin_Group
6         static const std::string MY_GROUP_ID("Group");
7         static const std::string MY_GROUP_LIST_ID("group_list");
8         
9         data()->addAttribute(FeaturesPlugin_Group::LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
10 """
11 #=========================================================================
12 # Initialization of the test
13 #=========================================================================
14 from ModelAPI import *
15 from GeomDataAPI import *
16 from GeomAlgoAPI import *
17 from GeomAPI import *
18
19 __updated__ = "2014-12-16"
20
21 aSession = ModelAPI_Session.get()
22 # Create a part for extrusions & boolean
23 aSession.startOperation()
24 aPartFeature = aSession.moduleDocument().addFeature("Part")
25 aSession.finishOperation()
26 aPart = aSession.activeDocument()
27 #=========================================================================
28 # Create a sketch with triangle and extrude it
29 #=========================================================================
30 aSession.startOperation()
31 aTriangleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
32 origin = geomDataAPI_Point(aTriangleSketchFeature.attribute("Origin"))
33 origin.setValue(0, 0, 0)
34 dirx = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX"))
35 dirx.setValue(1, 0, 0)
36 norm = geomDataAPI_Dir(aTriangleSketchFeature.attribute("Norm"))
37 norm.setValue(0, 0, 1)
38 aSketchLineA = aTriangleSketchFeature.addFeature("SketchLine")
39 aSketchLineB = aTriangleSketchFeature.addFeature("SketchLine")
40 aSketchLineC = aTriangleSketchFeature.addFeature("SketchLine")
41 aLineAStartPoint = geomDataAPI_Point2D(aSketchLineA.attribute("StartPoint"))
42 aLineAEndPoint = geomDataAPI_Point2D(aSketchLineA.attribute("EndPoint"))
43 aLineBStartPoint = geomDataAPI_Point2D(aSketchLineB.attribute("StartPoint"))
44 aLineBEndPoint = geomDataAPI_Point2D(aSketchLineB.attribute("EndPoint"))
45 aLineCStartPoint = geomDataAPI_Point2D(aSketchLineC.attribute("StartPoint"))
46 aLineCEndPoint = geomDataAPI_Point2D(aSketchLineC.attribute("EndPoint"))
47 aLineAStartPoint.setValue(25., 25.)
48 aLineAEndPoint.setValue(100., 25.)
49 aLineBStartPoint.setValue(100., 25.)
50 aLineBEndPoint.setValue(60., 75.)
51 aLineCStartPoint.setValue(60., 75.)
52 aLineCEndPoint.setValue(25., 25.)
53 aSession.finishOperation()
54 # Build sketch faces
55 aSession.startOperation()
56 aSketchResult = aTriangleSketchFeature.firstResult()
57 aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape()
58 origin = geomDataAPI_Point(aTriangleSketchFeature.attribute("Origin")).pnt()
59 dirX = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX")).dir()
60 norm = geomDataAPI_Dir(aTriangleSketchFeature.attribute("Norm")).dir()
61 aSketchFaces = ShapeList()
62 GeomAlgoAPI_SketchBuilder.createFaces(
63     origin, dirX, norm, aSketchEdges, aSketchFaces)
64 # Create extrusion on them
65 anExtrusionFt = aPart.addFeature("Extrusion")
66 anExtrusionFt.selectionList("base").append(
67     aSketchResult, aSketchFaces[0])
68 anExtrusionFt.real("from_size").setValue(50)
69 anExtrusionFt.real("to_size").setValue(50)
70 anExtrusionFt.execute()
71 aSession.finishOperation()
72 anExtrusionBody = modelAPI_ResultBody(anExtrusionFt.firstResult())
73 #=========================================================================
74 # Create group of edges
75 # TODO: After implementation of selection from batch script
76 # update this test to have proper reslts in the group feature
77 #=========================================================================
78 aSession.startOperation()
79 aGroupFeature = aSession.activeDocument().addFeature("Group")
80 aSelectionListAttr = aGroupFeature.selectionList("group_list")
81 aSelectionListAttr.setSelectionType("edge")
82 aSelectionListAttr.append("Extrusion_1/LateralFace_3|Extrusion_1/LateralFace_1")
83 aSession.finishOperation()
84 #=========================================================================
85 # Check results
86 #=========================================================================
87 #aGroupResult = aGroupFeature.firstResult()
88 #assert(aGroupResult)
89 #=========================================================================
90 # End of test
91 #=========================================================================