Salome HOME
updated copyright message
[modules/shaper.git] / src / ExchangePlugin / Test / TestStep2.py
1 # Copyright (C) 2014-2023  CEA, EDF
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 email : webmaster.salome@opencascade.com
18 #
19
20 from salome.shaper import model
21
22 import os
23
24 model.begin()
25 partSet = model.moduleDocument()
26
27 ### Create Part
28 Part_1 = model.addPart(partSet)
29 Part_1_doc = Part_1.document()
30 ### Import from step
31 data_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data")
32 #data_dir = os.path.join(os.path.dirname(os.path.abspath("C:\\NewGEOM\\SALOME-9.8.0D\\MODULES\\SRC\\SHAPER_SRC\\src\\ExchangePlugin\\Test\\TestStep2.py")), "data")
33 Import_1 = model.addImportSTEP(Part_1_doc, os.path.join(data_dir, "pipe_with_colors_and_names.stp"), True, True, True)
34
35 model.end()
36
37 def checkColor(body, rComponent, gComponent, bComponent):
38   assert(body.data().intArray("Color").size() == 3)
39   assert(body.data().intArray("Color").value(0) == rComponent)
40   assert(body.data().intArray("Color").value(1) == gComponent)
41   assert(body.data().intArray("Color").value(2) == bComponent)
42
43 # Check the imported names and colors correspond to the exported ones
44 res = Import_1.result()
45 assert(res.name() == "pipe_with_colors_and_names_1") # the higher level compound name equals to the file name
46 assert(res.subResult(0).name() == "2WCL-2.0-316-7-01")
47 assert(res.subResult(1).name() == "2WCL-2.0-316-7-01__1")
48 assert(res.subResult(2).name() == "2WCL-2.0-316-7-01__2")
49 assert(res.subResult(3).name() == "B7WWW-2.0-304-7-01")
50 assert(res.subResult(4).name() == "B7WWW-2.0-304-7-01__1")
51 assert(res.subResult(5).name() == "2WCL-2.0-316-7-01__3")
52 assert(res.subResult(6).name() == "RNT-304-2.000-0.065-WL-7_oa_0")
53 assert(res.subResult(7).name() == "RNT-304-2.000-0.065-WL-7_oa_1")
54 assert(res.subResult(8).name() == "RNT-304-2.000-0.065-WL-7_oa_2")
55 assert(res.subResult(9).name() == "RNT-304-2.000-0.065-WL-7_oa_3")
56 assert(res.subResult(10).name() == "RNT-304-2.000-0.065-WL-7_oa_4")
57 rootBody = model.modelAPI_ResultBody(Import_1.feature().firstResult())
58 checkColor(rootBody.subResult(0), 153, 33, 0)
59 checkColor(rootBody.subResult(1), 153, 33, 0)
60 checkColor(rootBody.subResult(2), 153, 33, 0)
61 checkColor(rootBody.subResult(3), 153, 33, 0)
62 checkColor(rootBody.subResult(4), 153, 33, 0)
63 checkColor(rootBody.subResult(5), 153, 33, 0)
64 checkColor(rootBody.subResult(6), 0, 12, 132)
65 checkColor(rootBody.subResult(7), 0, 12, 132)
66 checkColor(rootBody.subResult(8), 0, 12, 132)
67 checkColor(rootBody.subResult(9), 0, 12, 132)
68 checkColor(rootBody.subResult(10), 0, 12, 132)