]> SALOME platform Git repositories - modules/shaper.git/blob - src/PythonAPI/model/construction/plane.py
Salome HOME
Improve PythonAPI documentstion.
[modules/shaper.git] / src / PythonAPI / model / construction / plane.py
1 """Plane 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 addPlane(part, *args):
10     """Add a Plane feature to the Part and return Plane.
11
12     Pass all args to Plane __init__ function.
13     """
14     feature = part.addFeature("Plane")
15     return Plane(feature, *args)
16
17
18 class Plane(Interface):
19     """Interface class for Plane feature.
20
21     Plane(feature) -> feature interface without initialization
22     Plane(feature, face, distance) ->
23         feature interface initialized from arguments:
24         - face -- planeFace
25         - distance -- distance
26     Plane(feature, a, b, c, d) ->
27         feature interface initialized from arguments:
28         - A, B, C, D -- GeneralEquation parameters
29     """
30
31     def __init__(self, feature, *args):
32         """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
33         Interface.__init__(self, feature)
34         assert(self._feature.getKind() == "Plane")
35
36         self._CreationMethod = self._feature.data().string("CreationMethod")
37         self._plane_face = self._feature.data().selection("planeFace")
38         self._distance = self._feature.data().real("distance")
39         self._a = self._feature.data().real("A")
40         self._b = self._feature.data().real("B")
41         self._c = self._feature.data().real("C")
42         self._d = self._feature.data().real("D")
43
44         assert(self._CreationMethod)
45         assert(self._plane_face)
46         assert(self._distance)
47         assert(self._a)
48         assert(self._b)
49         assert(self._c)
50         assert(self._d)
51
52         if not args:
53             return
54
55         assert(len(args) in (2, 4))
56         if len(args) == 2:
57             self.setFaceAndDistance(*args)
58         elif len(args) == 4:
59             self.setGeneralEquation(*args)
60
61         self._execute()
62         pass
63
64     def __clear(self):
65         self._fill_attribute(self._CreationMethod, "PlaneByFaceAndDistance")
66         self._fill_attribute(self._plane_face, None)
67         self._fill_attribute(self._distance, 0)
68         self._fill_attribute(self._a, 0)
69         self._fill_attribute(self._b, 0)
70         self._fill_attribute(self._c, 0)
71         self._fill_attribute(self._d, 0)
72
73     def setFaceAndDistance(self, face, distance):
74         """Modify face and distance attribute of the feature.
75
76         See __init__.
77         """
78         self.__clear()
79         self._fill_attribute(self._CreationMethod, "PlaneByFaceAndDistance")
80         self._fill_attribute(self._plane_face, face)
81         self._fill_attribute(self._distance, distance)
82         pass
83
84     def setGeneralEquation(self, a, b, c, d):
85         """Modify GeneralEquation parameters of the feature.
86
87         See __init__.
88         """
89         self.__clear()
90         self._fill_attribute(self._CreationMethod, "PlaneByGeneralEquation")
91         self._fill_attribute(self._a, a)
92         self._fill_attribute(self._b, b)
93         self._fill_attribute(self._c, c)
94         self._fill_attribute(self._d, d)
95         pass