Debian Codegraph @

src/ifcconvert/cityjson/IfcOpenShell/test/run.py

raw
1 ###############################################################################
2 # #
3 # This file is part of IfcOpenShell. #
4 # #
5 # IfcOpenShell is free software: you can redistribute it and/or modify #
6 # it under the terms of the Lesser GNU General Public License as published by #
7 # the Free Software Foundation, either version 3.0 of the License, or #
8 # (at your option) any later version. #
9 # #
10 # IfcOpenShell is distributed in the hope that it will be useful, #
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
13 # Lesser GNU General Public License for more details. #
14 # #
15 # You should have received a copy of the Lesser GNU General Public License #
16 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
17 # #
18 ###############################################################################
19
20 ###############################################################################
21 # #
22 # The IfcOpenShell test suite downloads IFC files that are publicely #
23 # available on the internet and uses Blender and IfcOpenShell to generate a #
24 # render of the parsed file. For the script to run, Blender needs to be #
25 # installed and added to PATH. #
26 # #
27 ###############################################################################
28
29 import os
30 import sys
31 import shutil
32 import inspect
33 import subprocess
34 from zipfile import ZipFile
35 from urllib.request import urlretrieve
36
37 # Test whether Blender and IfcOpenShell are installed
38 if subprocess.call(['blender','-b','-P','bpy.py','TEST']) != 0:
39 print("[Error] Failed to launch Blender")
40 sys.exit(1)
41 else:
42 print("[Notice] Found Blender and IfcOpenShell on system")
43
44 # Global variables for keeping track of test cases
45 test_cases = []
46 failed = []
47
48 # Create the ouput directory
49 cwd = os.path.abspath(os.path.dirname(inspect.getfile(inspect.currentframe())))
50 os.chdir(cwd)
51 if not os.path.exists("output"): os.mkdir("output")
52 if not os.path.exists("input"): os.mkdir("input")
53
54 def extension(fn):
55 return os.path.splitext(fn)[-1].lower()
56
57 # Class to download extract and convert IFC files
58 class TestFile:
59 def __init__(self,fn,store_as=None):
60 global test_cases
61 self.fn = fn
62 self.store_as = store_as
63 self.failed = []
64 test_cases.append(self)
65 def __call__(self):
66 if self.fn.startswith("http://") or self.fn.startswith("ftp://"):
67 fn = self.store_as if self.store_as else self.fn.split("/")[-1]
68 if os.path.exists(os.path.join("input",fn)):
69 print ("[Notice] Already downloaded:",fn)
70 else:
71 print ("[Notice] Downloading:",fn)
72 urlretrieve(self.fn,os.path.join("input",fn))
73 self.fn = fn
74 if extension(self.fn) == '.zip':
75 print ("[Notice] Extracting:",self.fn)
76 zf = ZipFile(os.path.join("input",self.fn))
77 self.fn = [n for n in zf.namelist() if extension(n) == '.ifc' and not n.startswith('__') and not n.startswith('.')]
78 for fn in self.fn:
79 if not os.path.exists(os.path.join("input",fn)): zf.extract(fn,"input")
80 zf.close()
81 else: self.fn = [self.fn]
82 for fn in self.fn:
83 print ("[Notice] Rendering:",fn)
84 succes = subprocess.call(['blender','-b','-P','bpy.py','render',os.path.join("input",fn)]) == 0
85 if not succes: self.failed.append(fn)
86 return len(self.failed) == 0
87 def __str__(self): return "\n".join(self.failed) if len(self.failed) else ""
88
89 # Karlsruher Institut fuer Technologie
90 TestFile("http://iai-typo3.iai.fzk.de/www-extern-kit/fileadmin/download/download-vrsys/ADT-FZK-Haus-2005-2006.zip")
91 TestFile("http://iai-typo3.iai.fzk.de/www-extern-kit/fileadmin/download/download-vrsys/Nem-FZK-Haus-2x3.zip")
92 TestFile("http://iai-typo3.iai.fzk.de/www-extern-kit/fileadmin/download/download-vrsys/AC14-FZK-Haus.zip")
93 TestFile("http://iai-typo3.iai.fzk.de/www-extern-kit/fileadmin/download/download-vrsys/FZK-Haus-EliteCAD.zip")
94
95 TestFile("http://iai-typo3.iai.fzk.de/www-extern-kit/fileadmin/download/download-vrsys/FJK-Project-Final.zip")
96
97 TestFile("http://www.iai.fzk.de/www-extern-kit/fileadmin/download/download-vrsys/Bien-Zenker_Jasmin-Sun-AC14-V2-IFC.zip")
98
99 TestFile("http://www.iai.fzk.de/www-extern-kit/fileadmin/download/download-vrsys/ADT-Smiley-West-Project-14-10-2005.zip")
100 TestFile("http://www.iai.fzk.de/www-extern-kit/fileadmin/download/download-vrsys/Allplan-Smiley-West.zip")
101 TestFile("http://www.iai.fzk.de/www-extern-kit/fileadmin/download/download-vrsys/AC-11-Smiley-West-04-07-2007-IFC.zip")
102
103 TestFile("http://www.iai.fzk.de/www-extern-kit/fileadmin/download/download-vrsys/Allplan-2008-Institute-Var-2-IFC.zip")
104 TestFile("http://www.iai.fzk.de/www-extern-kit/fileadmin/download/download-vrsys/AC11-Institute-Var-2-IFC.zip")
105
106 TestFile("http://iai-typo3.iai.fzk.de/www-extern-kit/fileadmin/download/download-vrsys/PART02_Wilfer_200302_20070209_IFC.zip")
107 TestFile("http://iai-typo3.iai.fzk.de/www-extern-kit/fileadmin/download/download-vrsys/PART06_Kermi_200405_20070401_IFC.zip")
108
109 TestFile("http://iai-typo3.iai.fzk.de/www-extern-kit/fileadmin/download/download-vrsys/Ettenheim-GIS-05-11-2006_optimized.zip")
110
111 # Selvaag Gruppen
112 TestFile("ftp://ftp.dds.no/pub/ifc/Munkerud/Munkerud_hus6_BE.zip")
113
114 # Statsbygg
115 TestFile("ftp://ftp.dds.no/pub/ifc/HiTOS/2x3_HiTOS_EL_new.zip")
116 TestFile("ftp://ftp.dds.no/pub/ifc/HiTOS/2x3_HiTOS_HVAC_new.zip")
117 TestFile("ftp://ftp.dds.no/pub/ifc/HiTOS/HITOS_Architectural_2006-10-25.zip")
118
119 # Nemetschek Vectorworks
120 TestFile("http://download2cf.nemetschek.net/www_misc/bim/DCR-LOD_100.zip")
121 TestFile("http://download2cf.nemetschek.net/www_misc/bim/DCR-LOD_200.zip")
122 # Rather large:
123 # TestFile("http://download2cf.nemetschek.net/www_misc/bim/DCR-LOD_300.zip")
124
125 # Data Design Systems
126 TestFile("ftp://ftp.dds.no/pub/ifc/BardNa/Dds_BardNa.zip")
127
128 # Common Building Information Model Files
129 TestFile("http://projects.buildingsmartalliance.org/files/?artifact_id=4278","2011-09-14-Duplex-IFC.zip")
130 TestFile("http://projects.buildingsmartalliance.org/files/?artifact_id=4284","2011-09-14-Office-IFC.zip")
131 # Rather large:
132 # TestFile("http://projects.buildingsmartalliance.org/files/?artifact_id=4289","2011-09-14-Clinic-IFC.zip")
133
134 # http://openifcmodel.cs.auckland.ac.nz IAI
135 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912101-01wall_layers_number_1.ifc")
136 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912101-02wall_opening_straight_ac_1.ifc")
137 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912101-03wall_recess_ben_1.ifc")
138 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912101-04wall_L-shape_all_1.ifc")
139 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912102-01beam_profile_basic_rev_1.ifc")
140 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912102-01beam_profile_para_ac_1.ifc")
141 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912102-02brep_beams_opening_ben_1.ifc")
142 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912102-02extruded_beam_open_tek_1.ifc")
143 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912103-01col_profile_clip_ben_1.ifc")
144 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912103-01columns_basic_all_1.ifc")
145 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912103-02col_brep_opening_ben_1.ifc")
146 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912103-02OpeningsInExtrudedColumns_rev_1.ifc")
147 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912104-01slab_profile_basic_ac_1.ifc")
148 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912104-03extruded_slab_openings_all_1.ifc")
149 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912104-04slab_recess_tek_1.ifc")
150 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912105-01doors_explicit_geom_all_1.ifc")
151 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912105-02DoorOperationsPlacementInsideWall_rev_1.ifc")
152 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912106-01window_brep_ac_1.ifc")
153 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912106-02windows_placement_inside_wall_all_1.ifc")
154 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912107-01stair_geometry_ben_1.ifc")
155 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912108-01ramp_geometry_ben_2.ifc")
156 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912108-01RampAsContainer_rev_1.ifc")
157 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912109-01railing_brep_ac_1.ifc")
158 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/0912109-01railing_extrusion_tek_1.ifc")
159 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/09121010-01RoofWithGeometry_rev_1.ifc")
160 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/09121010-02roof_with_openings_ben_1.ifc")
161 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/09121011curtain_wall_basic_rev_1.ifc")
162 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/09121012mem_profile_basic_tek_1.ifc")
163 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/09121013plate_steel_exam_tek_1.ifc")
164 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/09121014pile_basic_tek_1.ifc")
165 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/09121015footing_ac_1.ifc")
166
167 # http://openifcmodel.cs.auckland.ac.nz NIST
168 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/171210AISC_Sculpture_brep.ifc")
169 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/171210AISC_Sculpture_param.ifc")
170 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/171210analysis_brep.ifc")
171 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/171210analysis_param.ifc")
172 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/171210Bentley1_brep.ifc")
173 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/171210Bentley1_param.ifc")
174 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/171210CADstudio_brep.ifc")
175 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/171210cutouts_brep.ifc")
176 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/171210DesignData1_brep.ifc")
177 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/171210DesignData3_brep.ifc")
178 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/171210PlayersTheater_param.ifc")
179 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/171210profiles_brep.ifc")
180 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/171210profilescp1_brep.ifc")
181 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/171210sections_brep.ifc")
182 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/171210threebeams_brep.ifc")
183 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/171210TrainingStructure_brep.ifc")
184 TestFile("http://openifcmodel.cs.auckland.ac.nz/_models/171210eccentricity_physical.ifc")
185
186 # BIMserver
187 TestFile("http://bimserver.googlecode.com/svn/trunk/TestData/data/06-03-01_windows_in_curved_wall_vw.ifc")
188 TestFile("http://bimserver.googlecode.com/svn/trunk/TestData/data/4351.ifc")
189 TestFile("http://bimserver.googlecode.com/svn/trunk/TestData/data/AC9R1-Haus-G-H-Ver2-2x3.ifc")
190 TestFile("http://bimserver.googlecode.com/svn/trunk/TestData/data/AC90R1-niedriha-V2-2x3.ifc")
191
192 # File courtesey of Jon Mirtschin / Geometry Gym
193 TestFile("geometrygym_great_court_roof.ifc")
194
195 # File courtesey of Ryan Schultz / Opening Design / Studio Wikitecture
196 TestFile("revit2012_janesville_restaurant.zip")
197
198 # Walls cut by IfcPolygonalBoundedHalfSpaces from Revit 2011
199 TestFile("revit2011_wall1.ifc")
200 TestFile("revit2011_wall2.ifc")
201
202 # Objects from Autocad Architecture 2010
203 TestFile("acad2010_walls.ifc")
204 TestFile("acad2010_objects.ifc")
205
206 # Various half space configuration to test cutting tolerances
207 TestFile("ifcopenshell_halfspaces.ifc")
208
209 # Several IfcPolygonalBoundedHalfSpaces cutting a single solid
210 TestFile("revit2014_multiple_bounded_halfspaces.ifc")
211
212 # Several parameterized profile extrusions generated by one
213 # of the examples from the IfcOpenShell repository
214 TestFile("IfcCShapeProfileDef.ifc")
215 TestFile("IfcCircleProfileDef.ifc")
216 TestFile("IfcEllipseProfileDef.ifc")
217 TestFile("IfcIShapeProfileDef.ifc")
218 TestFile("IfcLShapeProfileDef.ifc")
219 TestFile("IfcRectangleProfileDef.ifc")
220 TestFile("IfcTShapeProfileDef.ifc")
221 TestFile("IfcTrapeziumProfileDef.ifc")
222 TestFile("IfcUShapeProfileDef.ifc")
223 TestFile("IfcZShapeProfileDef.ifc")
224 TestFile("IfcReinforcingBar.ifc")
225
226 TestFile("advanced_brep.ifc")
227 TestFile("basic_shape_Brep.ifc")
228 TestFile("basic_shape_CSG.ifc")
229 TestFile("basic_shape_SurfaceModel.ifc")
230 TestFile("basic_shape_SweptSolid.ifc")
231 TestFile("basic_shape_Tessellation.ifc")
232 TestFile("building_element_configuration_wall.ifc")
233 TestFile("building_service_element_air-terminal-type.ifc")
234 TestFile("building_service_element_air-terminal.ifc")
235 TestFile("construction_scheduling_task.ifc")
236 TestFile("mapped_shape_multiple.ifc")
237 TestFile("mapped_shape_representation.ifc")
238 TestFile("mapped_shape_transformation.ifc")
239 TestFile("standard_case_element_beam.ifc")
240 TestFile("structural_analysis_curve.ifc")
241
242 for test in test_cases:
243 succes = test()
244 if not succes:
245 failed.append(test)
246
247 if len(failed):
248 print("[Notice] Conversion failed for the following cases:")
249 for test in failed:
250 print (test)
251 else:
252 print("[Notice] All cases succeeded")
253