1 # Copyright (C) 2014-2023 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
22 Unit test of ExchangePlugin_ImportFeature class for STEP
24 #=========================================================================
25 # Initialization of the test
26 #=========================================================================
32 from tempfile import TemporaryDirectory
34 from ModelAPI import *
36 from salome.shaper import model
38 from GeomAPI import GeomAPI_Shape
40 from GeomAlgoAPI import *
42 __updated__ = "2015-05-22"
47 #=========================================================================
49 #=========================================================================
50 def removeFile(theFileName):
51 try: os.remove(theFileName)
53 assert not os.path.exists(theFileName), \
54 "Can not remove file {0}".format(theFileName)
56 #=========================================================================
58 #=========================================================================
62 partSet = model.moduleDocument()
63 Part_1 = model.addPart(partSet)
64 Part_1_doc = Part_1.document()
65 aShapePath = os.path.join(os.getenv("DATA_DIR"), "Shapes", "Step", "black_and_white.step")
66 print("aShapePath=",aShapePath)
67 Import_1 = model.addImportSTEP(Part_1_doc,aShapePath, True, True, True)
72 Import_1_Feature = Import_1.feature()
73 assert Import_1_Feature.error() == ''
74 assert Import_1_Feature.name() == "black_and_white"
75 assert len(Import_1_Feature.results()) == 1
76 model.testNbSubShapes(Import_1, GeomAPI_Shape.SOLID, [2])
78 aCompositeFeature = featureToCompositeFeature(Import_1_Feature)
79 assert aCompositeFeature.numberOfSubs(False) == 4
81 aFeature1 = aCompositeFeature.subFeature(0, False)
82 assert aFeature1.getKind() == "Group"
83 assert aFeature1.name() == "Color_1"
85 aSelectionList = aFeature1.selectionList("group_list")
86 assert aSelectionList.size() == 1
88 aFeature1 = aCompositeFeature.subFeature(1, False)
89 assert aFeature1.getKind() == "Group"
90 assert aFeature1.name() == "Color_2"
92 aSelectionList = aFeature1.selectionList("group_list")
93 assert aSelectionList.size() == 1
95 aFeature1 = aCompositeFeature.subFeature(2, False)
96 assert aFeature1.getKind() == "Group"
97 assert aFeature1.name() == "Material_black"
99 aSelectionList = aFeature1.selectionList("group_list")
100 assert aSelectionList.size() == 1
103 aFeature1 = aCompositeFeature.subFeature(3, False)
104 assert aFeature1.getKind() == "Group"
105 assert aFeature1.name() == "Material_white"
107 aSelectionList = aFeature1.selectionList("group_list")
108 assert aSelectionList.size() == 1
112 if __name__ == '__main__':
113 with TemporaryDirectory() as tmp_dir: