]> SALOME platform Git repositories - modules/shaper_study.git/blob - src/PY/SHAPERSTUDY_Object.py
Salome HOME
The initial version of Open and Save in the SHAPER-STUDY
[modules/shaper_study.git] / src / PY / SHAPERSTUDY_Object.py
1 # Copyright (C) 2007-2019  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
10 #
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # Lesser General Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22
23 import SHAPERSTUDY_ORB__POA
24 import GEOM
25 from SHAPERSTUDY_utils import getEngine
26
27 import StudyData_Swig
28
29 # converter from the integer values to idl shape_type enumerations
30 __shape_types__ = {
31   0:GEOM.COMPOUND, 1:GEOM.COMPSOLID, 2:GEOM.SOLID,
32   3:GEOM.SHELL, 4:GEOM.FACE, 5:GEOM.WIRE,
33   6:GEOM.EDGE, 7:GEOM.VERTEX, 8:GEOM.SHAPE, 9:GEOM.FLAT}
34
35
36 class SHAPERSTUDY_Object(SHAPERSTUDY_ORB__POA.SHAPER_Object):
37     """
38     Construct an instance of SHAPERSTUDY Object.
39     """
40     def __init__ ( self, *args):
41         self.SO = None
42         self.data = None
43         pass
44
45     def GetShapeType( self ):
46         """
47         Get a GEOM.shape_type of the object value.
48         """
49         if self.data is None:
50             return GEOM.SHAPE
51         global __shape_types__
52         return __shape_types__[self.data.type()];
53
54     def IsMainShape( self ):
55         """
56         Returns True if this object is not a sub-shape of another object.
57         """
58         return True
59
60     def GetSubShapeIndices( self ):
61         """
62         Get a list of ID's of sub-shapes in the main shape.
63         """
64         return []
65
66     def GetMainShape( self ):
67         """
68         Get a main shape object to which this object is a sub-shape.
69         """
70         return getShape()
71
72     def getShape( self ):
73         """
74         Get the TopoDS_Shape, for colocated case only.
75         Called by GEOM_Client to get TopoDS_Shape pointer
76         """
77         if self.data is None:
78             return 0
79         return self.data.shape()
80
81     def GetShapeStream( self ):
82         """
83         Get geometric shape of the object as a byte stream in BRep format
84         """
85         if self.data is None:
86             return b''
87         return self.data.shapeStream().encode()
88
89     def SetShapeByStream(self, theStream):
90         """
91         Sets geometric shape content of the object as a byte stream in BRep format
92         """
93         if self.data:
94           self.data.updateShape(theStream)
95         else:
96           self.data = StudyData_Swig.StudyData_Object(theStream)
97
98     """
99     Methods from BaseObject
100     """
101     def GetName( self ):
102         """
103         Get name of the object associated with this object.
104         """
105         return self.SO.GetName()
106
107     def SetEntry( self, theInternalEntry ):
108         """
109         Sets internal (unique) entry of the object in the component's data tree.
110         """
111         self.entry = theInternalEntry
112
113     def GetEntry( self ):
114         """
115         Get internal (unique) entry of the object in the component's data tree.
116         """
117         return self.entry
118
119     def GetType( self ):
120         """
121         Get internal type of operation created this object.
122         In SMESH is used to find out if an object is GROUP (type == 37)
123         """
124         # 1 corresponds to the Import feature (GEOMImpl_Types.hxx )
125         return 1
126
127     def GetTick( self ):
128         """
129         Get value of a modification counter of the object
130         """
131         if self.data:
132           return self.data.getTick()
133         return 0
134
135     def GetStudyEntry( self ):
136         """
137         Get a Study entry where this object was published.
138         """
139         return self.SO.GetID()
140
141     def IsShape( self ):
142         """
143         Return true if geom object represents a shape.
144         For example, method return false for GEOM_MARKER
145         """
146         return True
147
148     def IsSame( self, other ):
149         """
150         Return true if passed object is identical to this object
151         """
152         return self.GetType() == other.GetType() and self.GetEntry() == other.GetEntry()
153
154     def GetGen( self ):
155         """
156         Return the engine creating this object
157         """
158         return getEngine()
159
160     def SetSO( self, theSO ):
161         """
162         Sets SObject of this object (when it is published)
163         """
164         self.SO = theSO
165         
166     def GetSO( self ):
167         """
168         Returns SObject of this object
169         """
170         return self.SO
171
172     def IsParametrical(self):
173         """
174         Returns true if the current object has connection to a parametrical model
175         which can be modified by parameters change.
176         """
177         return True
178
179     pass