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