Salome HOME
Fix Platine test
[modules/shaper.git] / src / PythonAPI / model / construction / point.py
1 """Point Interface
2 Author: Sergey Pokhodenko
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 """
5
6 from model.roots import Interface
7
8
9 def addPoint(part, *args):
10     """Add an Point feature to the Part and return Point.
11
12     .. function:: addPoint(part, x, y, z)
13
14     Args:
15         part (ModelAPI_Document): part document
16         x (double): X coordinate for the point
17         y (double): Y coordinate for the point
18         z (double): Z coordinate for the point
19
20     Returns:
21         Point: point object
22     """
23     assert(args)
24     feature = part.addFeature("Point")
25     return Point(feature, *args)
26
27
28 class Point(Interface):
29     """Interface class for Point feature.
30
31     .. function:: Point(feature)
32
33         Create interface for the feature without initialization.
34
35     .. function:: Point(feature, x, y, z)
36
37         Create interface for the feature and initialize the feature with arguments.
38     """
39
40     def __init__(self, feature, *args):
41         """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
42         Interface.__init__(self, feature)
43         assert(self._feature.getKind() == "Point")
44
45         self._x = self._feature.data().real("x")
46         self._y = self._feature.data().real("y")
47         self._z = self._feature.data().real("z")
48
49         assert(self._x)
50         assert(self._y)
51         assert(self._z)
52
53         if not args:
54             return
55
56         assert(len(args) == 3)
57         self.setPoint(*args)
58
59         self.execute()
60         pass
61
62     def setPoint(self, x, y, z):
63         """Modify base attribute of the feature.
64
65         See __init__.
66         """
67         self._fillAttribute(self._x, x)
68         self._fillAttribute(self._y, y)
69         self._fillAttribute(self._z, z)
70         pass