Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / ModelAPI / Test / TestDoubleArray.py
1 ## Copyright (C) 2014-2017  CEA/DEN, EDF R&D
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, or (at your option) any later version.
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
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 ##
20
21 #=========================================================================
22 # Initialization of the test
23 #=========================================================================
24 from ModelAPI import *
25 from GeomDataAPI import *
26 from GeomAlgoAPI import *
27 from GeomAPI import *
28
29 import math
30
31 aSession = ModelAPI_Session.get()
32
33 #=========================================================================
34 # Test double array attribute
35 #=========================================================================
36 aPartSet = aSession.moduleDocument()
37 aSession.startOperation()
38 aSketchFeature = featureToCompositeFeature(aPartSet.addFeature("Sketch"))
39 aFeatureData = aSketchFeature.data()
40 anArray = aFeatureData.addAttribute("double_array", "DoubleArray")
41 aFeatureData.realArray("double_array").setSize(5)
42 assert(aFeatureData.realArray("double_array").size() == 5)
43 aFeatureData.realArray("double_array").setValue(0, 1)
44 assert(math.fabs(aFeatureData.realArray("double_array").value(0) - 1) < 10 ** -7)
45 aFeatureData.realArray("double_array").setValue(1, 1.5)
46 assert(math.fabs(aFeatureData.realArray("double_array").value(1) - 1.5) < 10 ** -7)
47
48 #=========================================================================
49 # End of test
50 #=========================================================================