]> SALOME platform Git repositories - samples/randomizer.git/blob - src/Randomizer/RANDOMIZER.py
Salome HOME
22b2b899069f199a93741ee7e47ea74b3fc7ea9a
[samples/randomizer.git] / src / Randomizer / RANDOMIZER.py
1 # Copyright (C) 2005-2012  OPEN CASCADE
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 ###############################################################
21 # File    : RANDOMIZER.py
22 # Author  : Vadim SANDLER (OCN)
23 # Created : 13/07/05
24 ###############################################################
25 #
26 import RANDOMIZER_ORB__POA
27 import SALOME_ComponentPy
28
29 class RANDOMIZER( RANDOMIZER_ORB__POA.RANDOMIZER,
30                   SALOME_ComponentPy.SALOME_ComponentPy_i ):
31     """
32     The implementation of the RANDOMIZER interface
33     """
34     def __init__ ( self, orb, poa, contID, containerName, instanceName, interfaceName ):
35         """
36         Constructor
37         """
38         SALOME_ComponentPy.SALOME_ComponentPy_i.__init__( self, orb, poa, contID, containerName,instanceName, interfaceName, 0 )
39
40     def InitPoint( self ):
41         """
42         Generate random 2d-point:  x, y = [0,1)
43         """
44         self.beginService( "RANDOMIZER::InitPoint" )
45
46         import random
47         x = random.random()
48         y = random.random()
49
50         self.endService( "RANDOMIZER::InitPoint" )
51
52         return x, y
53     
54     def NextIteration( self ):
55         """
56         Get next random iteration step: ret = {1,2,3}
57         """
58         self.beginService( "RANDOMIZER::NextIteration" )
59
60         import random
61         iter = random.randint( 1,3 )
62
63         self.endService( "RANDOMIZER::NextIteration" )
64         
65         return iter