Salome HOME
updated copyright message
[modules/shaper.git] / src / FeaturesPlugin / Test / TestPointCoordinates.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       Unit test of ...
22 """
23 #=========================================================================
24 # Initialization of the test
25 #=========================================================================
26
27 import os
28 import math
29
30 from salome.shaper import model
31
32 __updated__ = "2020-11-12"
33
34 #=========================================================================
35 # test get point coordinates
36 #=========================================================================
37 def test_point_coordinates():
38
39     model.begin()
40     file_path = os.path.join(os.getenv("DATA_DIR"),"Shapes","Brep","box1.brep")
41     partSet = model.moduleDocument()
42     Part_1 = model.addPart(partSet)
43     Part_1_doc = Part_1.document()
44     Import_1 = model.addImport(Part_1_doc,file_path)
45     model.do()
46
47     myDelta = 1e-6
48     coordinates = model.getPointCoordinates(Part_1_doc,model.selection("VERTEX", "[box1_1/Shape_2][box1_1/Shape_3][box1_1/Shape_6]"))
49
50     print(" x: ", coordinates[0])
51     print(" y: ", coordinates[1])
52     print(" z: ", coordinates[2])
53
54     aRef = 200
55     aRes = coordinates[0]
56     assert (math.fabs(aRes - aRef) < myDelta), "The coordinate X is wrong: expected = {0}, real = {1}".format(aRef, aRes)
57
58     aRef = 0
59     aRes= coordinates[1]
60     assert (math.fabs(aRes - aRef) < myDelta), "The coordinate Y is wrong: expected = {0}, real = {1}".format(aRef, aRes)
61
62     aRef = 200
63     aRes = coordinates[2]
64     assert (math.fabs(aRes - aRef) < myDelta), "The coordinate Z is wrong: expected = {0}, real = {1}".format(aRef, aRes)
65
66
67 if __name__ == '__main__':
68
69     test_point_coordinates()
70
71     #=========================================================================
72     # End of test
73     #=========================================================================