Salome HOME
updated copyright message
[modules/shaper.git] / src / ConstructionPlugin / Test / UnitTestAxis.py
1 # Copyright (C) 2014-2023  CEA, EDF
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 email : webmaster.salome@opencascade.com
18 #
19
20 """
21     UnitTestAxis.py
22     Unit Test of ConstructionPlugin_Axis class
23
24
25     static const std::string CONSTRUCTION_AXIS_KIND("Axis");
26     static const std::string METHOD_ATTR("CreationMethod");
27     static const std::string POINT_ATTR_FIRST("FirstPoint");
28     static const std::string POINT_ATTR_SECOND("SecondPoint");
29     static const std::string CYLINDRICAL_FACE_ATTR("CylindricalFace");
30     static const std::string X_ATTR("X");
31     static const std::string Y_ATTR("Y");
32     static const std::string Z_ATTR("Z");
33
34
35     data()->addAttribute(ConstructionPlugin_Axis::METHOD(), ModelAPI_AttributeString::typeId());
36
37     data()->addAttribute(ConstructionPlugin_Axis::POINT_FIRST(), ModelAPI_AttributeSelection::typeId());
38     data()->addAttribute(ConstructionPlugin_Axis::POINT_SECOND(), ModelAPI_AttributeSelection::typeId());
39
40     data()->addAttribute(ConstructionPlugin_Axis::CYLINDRICAL_FACE(), ModelAPI_AttributeSelection::typeId());
41
42     data()->addAttribute(ConstructionPlugin_Axis::X(), ModelAPI_AttributeDouble::typeId());
43     data()->addAttribute(ConstructionPlugin_Axis::Y(), ModelAPI_AttributeDouble::typeId());
44     data()->addAttribute(ConstructionPlugin_Axis::Z(), ModelAPI_AttributeDouble::typeId());
45
46 """
47
48
49 #=========================================================================
50 # Initialization of the test
51 #=========================================================================
52 from ModelAPI import *
53 from GeomDataAPI import *
54 from GeomAlgoAPI import *
55 from GeomAPI import *
56 import math
57
58 __updated__ = "2016-01-04"
59
60 aSession = ModelAPI_Session.get()
61 aDocument = aSession.moduleDocument()
62 # Create a part for creation of a box
63 aSession.startOperation()
64 aPartFeature = aDocument.addFeature("Part")
65 aSession.finishOperation()
66 assert (len(aPartFeature.results()) == 1)
67
68 aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
69 aPart = aPartResult.partDoc()
70 #=========================================================================
71 # Creation of an Axis by coordinates
72 #=========================================================================
73 aSession.startOperation()
74 anAxisByDimensions = aPart.addFeature("Axis")
75 anAxisByDimensions.string("CreationMethod").setValue("AxisByDimensionsCase")
76 anAxisByDimensions.real("DX").setValue(2.5)
77 anAxisByDimensions.real("DY").setValue(3.2)
78 anAxisByDimensions.real("DZ").setValue(1.4)
79 anAxisByDimensions.execute()
80
81
82 assert(len(anAxisByDimensions.results()) > 0)
83 anAxisByDimensions = modelAPI_ResultConstruction(anAxisByDimensions.firstResult())
84 assert(anAxisByDimensions is not None)
85
86 aSession.finishOperation()
87 #=========================================================================
88 # End of test
89 #=========================================================================
90
91 from salome.shaper import model
92 assert(model.checkPythonDump())