]> SALOME platform Git repositories - modules/shaper.git/blob - src/PythonAPI/model/construction/point.py
Salome HOME
fa81fcf1f3042200462d4d43859b3e95d606a1c8
[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     feature = part.addFeature("Point")
15     return Point(feature, *args)
16
17
18 class Point(Interface):
19     """Interface on an Point feature."""
20
21     def __init__(self, feature, *args):
22         """Initialize an Point feature with given parameters.
23
24         Expected arguments for all modes:
25         feature -- a Point feature
26
27         Expected arguments for initializing the feature:
28         x, y, z -- x, y, z coordinates for the point.
29         """
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