1 # Copyright (C) 2014-2020 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #=========================================================================
24 # Initialization of the test
25 #=========================================================================
31 from ModelAPI import *
32 from salome.shaper import model
35 __updated__ = "2020-11-12"
38 #=========================================================================
40 #=========================================================================
41 def test_Bounding_Box():
44 file_path = os.path.join(os.getenv("DATA_DIR"),"Shapes","Step","screw.step")
45 partSet = model.moduleDocument()
46 Part_1 = model.addPart(partSet)
47 Part_1_doc = Part_1.document()
48 Import_1 = model.addImport(Part_1_doc,file_path)
50 ### Create BoundingBox
51 BoundingBox_1 = model.getBoundingBox(Part_1_doc, model.selection("SOLID", "screw_1"))
55 Props = model.getGeometryCalculation(Part_1_doc,model.selection("SOLID", "BoundingBox_1_1"))
57 print(" Basic Properties:")
58 print(" Wires length: ", Props[0])
59 print(" Surface area: ", Props[1])
60 print(" Volume : ", Props[2])
62 aReflength = 0.32855301948678
64 assert (math.fabs(aReslength - aReflength) < myDelta), "The surface is wrong: expected = {0}, real = {1}".format(aReflength, aReslength)
66 aRefSurface = 0.0041640657342782
67 aResSurface = Props[1]
68 assert (math.fabs(aResSurface - aRefSurface) < myDelta), "The surface is wrong: expected = {0}, real = {1}".format(aRefSurface, aResSurface)
70 aRefVolume = 1.6785355394103e-05
72 assert (math.fabs(aResVolume - aRefVolume) < myDelta), "The volume is wrong: expected = {0}, real = {1}".format(aRefVolume, aResVolume)
75 if __name__ == '__main__':
79 #=========================================================================
81 #=========================================================================