Salome HOME
9dbb8c8fc491261fbe7f364965eb84298138d4a2
[modules/shaper.git] / src / ConstructionPlugin / Test / UnitTestAxis.py
1 # Copyright (C) 2014-2016 CEA/DEN, EDF R&D
2
3 # File:        UnitTestAxis.py
4 # Created:     30 Mar 2016
5 # Author:      CEA (delegation to Alyotech)
6
7 """
8     UnitTestAxis.py
9     Unit Test of ConstructionPlugin_Axis class
10
11
12     static const std::string CONSTRUCTION_AXIS_KIND("Axis");
13     static const std::string METHOD_ATTR("CreationMethod");
14     static const std::string POINT_ATTR_FIRST("FirstPoint");
15     static const std::string POINT_ATTR_SECOND("SecondPoint");
16     static const std::string CYLINDRICAL_FACE_ATTR("CylindricalFace");
17     static const std::string X_ATTR("X");
18     static const std::string Y_ATTR("Y");
19     static const std::string Z_ATTR("Z");
20
21
22     data()->addAttribute(ConstructionPlugin_Axis::METHOD(), ModelAPI_AttributeString::typeId());
23   
24     data()->addAttribute(ConstructionPlugin_Axis::POINT_FIRST(), ModelAPI_AttributeSelection::typeId());
25     data()->addAttribute(ConstructionPlugin_Axis::POINT_SECOND(), ModelAPI_AttributeSelection::typeId());
26
27     data()->addAttribute(ConstructionPlugin_Axis::CYLINDRICAL_FACE(), ModelAPI_AttributeSelection::typeId());
28
29     data()->addAttribute(ConstructionPlugin_Axis::X(), ModelAPI_AttributeDouble::typeId());
30     data()->addAttribute(ConstructionPlugin_Axis::Y(), ModelAPI_AttributeDouble::typeId());
31     data()->addAttribute(ConstructionPlugin_Axis::Z(), ModelAPI_AttributeDouble::typeId());
32
33 """
34
35
36 #=========================================================================
37 # Initialization of the test
38 #=========================================================================
39 from ModelAPI import *
40 from GeomDataAPI import *
41 from GeomAlgoAPI import *
42 from GeomAPI import *
43 import math
44
45 __updated__ = "2016-01-04"
46
47 aSession = ModelAPI_Session.get()
48 aDocument = aSession.moduleDocument()
49 # Create a part for creation of a box
50 aSession.startOperation()
51 aPartFeature = aDocument.addFeature("Part")
52 aSession.finishOperation()
53 assert (len(aPartFeature.results()) == 1)
54
55 aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
56 aPart = aPartResult.partDoc()
57 #=========================================================================
58 # Creation of an Axis by coordinates
59 #=========================================================================
60 aSession.startOperation()
61 anAxisByDimensions = aPart.addFeature("Axis")
62 anAxisByDimensions.string("CreationMethod").setValue("AxisByDimensionsCase")
63 anAxisByDimensions.real("DX").setValue(2.5)
64 anAxisByDimensions.real("DY").setValue(3.2)
65 anAxisByDimensions.real("DZ").setValue(1.4)
66 anAxisByDimensions.execute()
67
68
69 assert(len(anAxisByDimensions.results()) > 0)
70 anAxisByDimensions = modelAPI_ResultConstruction(anAxisByDimensions.firstResult())
71 assert(anAxisByDimensions is not None)
72
73 aSession.finishOperation()
74 #=========================================================================
75 # End of test
76 #=========================================================================
77
78 import model
79 assert(model.checkPythonDump())