1 # Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #============================================================================
24 # File : PYCALCULATOR.py
25 # Author : Vadim SANDLER, OPEN CASCADE S.A.S. (vadim.sandler@opencascade.com)
26 #============================================================================
28 # Instruct Python to load dynamic libraries using global resolution of symbols
29 # This is necessary to ensure that different modules will have the same definition
30 # of dynamic types and C++ RTTI will work between them
33 sys.setdlopenflags(DLFCN.RTLD_NOW | DLFCN.RTLD_GLOBAL)
35 import PYCALCULATOR_ORB__POA
36 import SALOME_ComponentPy
39 from MEDCouplingClient import *
40 from MEDCouplingCorba import *
42 from salome_utils import verbose
44 class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SALOME_ComponentPy_i):
47 def __init__(self, orb, poa, contID, containerName, instanceName,
50 if verbose(): print "Begin of PYCALCULATOR::__init__"
52 SALOME_ComponentPy.SALOME_ComponentPy_i.__init__(
56 contID, # SALOME container id
57 containerName, # SALOME container name
58 instanceName, # component instance name
59 interfaceName, # component interface name
60 0) # notification flag (for notification server)
62 self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i(self._orb)
64 if verbose(): print "End of PYCALCULATOR::__init__"
68 ## base interface method: get version of the component
69 def getVersion( self ):
71 return salome_version.getVersion("PYCALCULATOR", True)
73 ## interface service: clone field
74 def Clone(self, field):
75 self.beginService("PYCALCULATOR::Clone")
78 print "Begin of PYCALCULATOR::Clone"
79 print " field : ", field
85 # create local field from corba field
86 f = MEDCouplingFieldDoubleClient.New(field)
89 frescorba = MEDCouplingFieldDoubleServant._this(f)
96 print "End of PYCALCULATOR::Clone"
99 self.endService("PYCALCULATOR::Clone")
103 ## interface service: add two fields
104 def Add(self, field1, field2):
105 self.beginService("PYCALCULATOR::Add")
108 print "Begin of PYCALCULATOR::Add"
109 print " field 1 : ", field1
110 print " field 2 : ", field2
116 # create local fields from corba fields
117 f1 = MEDCouplingFieldDoubleClient.New(field1)
118 f2 = MEDCouplingFieldDoubleClient.New(field2)
121 f2.changeUnderlyingMesh(f1.getMesh(), 0, 1e-12)
125 frescorba = MEDCouplingFieldDoubleServant._this(fres)
128 if verbose(): print e
132 print "End of PYCALCULATOR::Add"
135 self.endService("PYCALCULATOR::Add")
139 ## interface service: multiply two fields
140 def Mul(self, field1, field2):
141 self.beginService("PYCALCULATOR::Mul")
144 print "Begin of PYCALCULATOR::Mul"
145 print " field 1 : ", field1
146 print " field 2 : ", field2
152 # create local fields from corba fields
153 f1 = MEDCouplingFieldDoubleClient.New(field1)
154 f2 = MEDCouplingFieldDoubleClient.New(field2)
157 f2.changeUnderlyingMesh(f1.getMesh(), 0, 1e-12)
161 frescorba = MEDCouplingFieldDoubleServant._this(fres)
164 if verbose(): print e
168 print "End of PYCALCULATOR::Mul"
171 self.endService("PYCALCULATOR::Mul")
175 ## interface service: add a constant to a field
176 def AddConstant(self, field, val):
177 self.beginService("PYCALCULATOR::AddConstant")
180 print "Begin of PYCALCULATOR::AddConstant"
181 print " field : ", field
182 print " constant : ", val
188 # create local field from corba field
189 f = MEDCouplingFieldDoubleClient.New(field)
191 # add constant to a field
195 frescorba = MEDCouplingFieldDoubleServant._this(fres)
198 if verbose(): print e
202 print "End of PYCALCULATOR::AddConstant"
205 self.endService("PYCALCULATOR::AddConstant")
209 ## interface service: multiply a field to a constant
210 def MulConstant(self, field, val):
211 self.beginService("PYCALCULATOR::MulConstant")
214 print "Begin of PYCALCULATOR::MulConstant"
215 print " field : ", field
216 print " constant : ", val
222 # create local field from corba field
223 f = MEDCouplingFieldDoubleClient.New(field)
225 # multiply field to a constant
229 frescorba = MEDCouplingFieldDoubleServant._this(fres)
232 if verbose(): print e
236 print "End of PYCALCULATOR::MulConstant"
239 self.endService("PYCALCULATOR::MulConstant")
243 pass # end of class PYCALCULATOR