Salome HOME
6d04280070bdccd9cfd1c4fb20e90d76a1cbd2f5
[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     Pass all args to Point __init__ function.
13     """
14     assert(args)
15     feature = part.addFeature("Point")
16     return Point(feature, *args)
17
18
19 class Point(Interface):
20     """Interface class for Point feature.
21
22     Point(feature) -> feature interface without initialization
23     Point(feature, x, y, z) ->
24         feature interface initialized from arguments:
25         - x, y, z -- coordinates for the point
26     """
27
28     def __init__(self, feature, *args):
29         """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
30         Interface.__init__(self, feature)
31         assert(self._feature.getKind() == "Point")
32
33         self._x = self._feature.data().real("x")
34         self._y = self._feature.data().real("y")
35         self._z = self._feature.data().real("z")
36
37         assert(self._x)
38         assert(self._y)
39         assert(self._z)
40
41         if not args:
42             return
43
44         assert(len(args) == 3)
45         self.setPoint(*args)
46
47         self._execute()
48         pass
49
50     def setPoint(self, x, y, z):
51         """Modify base attribute of the feature.
52
53         See __init__.
54         """
55         self._fill_attribute(self._x, x)
56         self._fill_attribute(self._y, y)
57         self._fill_attribute(self._z, z)
58         pass