Debian Codegraph @

src/ifcconvert/cityjson/IfcOpenShell/README.md

raw
1 About this branch
2 =================
3
4 This version splits the geometry interpretation process into two steps (a) map IFC to a smaller set of schema-agnostic definitions (`ifcopenshell::geometry::taxonomy`) (b) convert these into explicit breps or polyhedra with Open CASCADE or CGAL.
5
6 Three validation options are added to IfcConvert for (a) storey containment (b) wall connectivity (c) space boundaries.
7
8 IfcOpenShell
9 ============
10 IfcOpenShell is an open source ([LGPL]) software library for working with the Industry Foundation Classes ([IFC])
11 file format. Currently supported IFC releases are [IFC2x3 TC1] and [IFC4 Add2 TC1].
12
13 For more information, see
14 * [http://ifcopenshell.org](http://ifcopenshell.org)
15 * [http://academy.ifcopenshell.org](http://academy.ifcopenshell.org)
16
17 [![Build Status](https://api.travis-ci.org/IfcOpenShell/IfcOpenShell.png)](https://api.travis-ci.org/IfcOpenShell/IfcOpenShell)
18
19 Prerequisites
20 -------------
21 * Git
22 * CMake (2.6 or newer)
23 * Windows: [Visual Studio] 2008 or newer with C++ toolset (or [Visual C++ Build Tools]) or [MSYS2] + MinGW
24 * *nix: GCC 4.7 or newer, or Clang (any version)
25
26 Dependencies
27 -------------
28 * [Boost](http://www.boost.org/)
29 * [Open Cascade](http://opencascade.org) - *optional*, but required for building IfcGeom
30 ([official](http://www.opencascade.org/getocc/download/loadocc/), "OCCT", or [community edition](https://github.com/tpaviot/oce), "OCE")
31 For converting IFC representation items into BRep solids and tesselated meshes
32 * [OpenCOLLADA](https://github.com/khronosGroup/OpenCOLLADA/) - *optional*
33 For IfcConvert to be able to write tessellated Collada (.dae) files
34 * [SWIG](http://www.swig.org/) and [Python](https://www.python.org/) - *optional*
35 For building the IfcOpenShell Python interface and the Blender add-on
36 * [3ds Max SDK](http://www.autodesk.com/products/3ds-max/free-trial) - *optional*
37 For building the 3ds Max plug-in.
38 All recent versions of 3ds Max (2014 and newer) are 64-bit only, so a 64-bit installation is assumed.
39
40 Building IfcOpenShell
41 ---------------------
42
43 **Note:** The path where the source code is cloned to can contain spaces but non-ASCII characters are very likely to cause problems with the build.
44
45 ### Compiling on Windows
46 The preferred way to fetch and build this project's dependencies is to use the build scripts
47 in win/ folder. **See [win/readme.md] for more information**.
48
49 #### Using Visual Studio
50 Instructions in a nutshell (**assuming Visual Studio 2015 x64 environment variables set**):
51
52 > cd IfcOpenShell\win
53 > build-deps.cmd
54 > run-cmake.bat
55
56 You can now open and build the solution file in Visual Studio:
57
58 > ..\build-vs2015-x64\IfcOpenShell.sln
59
60 As the scripts default to using the `RelWithDebInfo` configuration, and a freshly created solution by CMake defaults
61 to `Debug`, make sure to switch the used build configuration. Build the `INSTALL` project (right-click -> Project
62 Only) to deploy the headers and binaries into a single location if wanted/needed.
63
64 Alternatively, one can use the utility batch file(s) to build and install the project easily from the command-line
65 (installing a project will build it also, if required):
66
67 > install-ifcopenshell.bat
68
69 #### Using MSYS2 + MinGW
70
71 Start the MSYS2 Shell and then:
72
73 $ cd IfcOpenShell/win
74 $ ./build-deps.sh
75 $ ./run-cmake.sh
76 $ ./install-ifcopenshell.sh
77
78 #### Using Bash on Ubuntu on Windows
79
80 Start Bash on Ubuntu on Windows and follow the instructions below. Compiling on Ubuntu 14.04.4 LTS using GCC 4.8.4
81 or Clang 3.5 has been confirmed to work.
82
83 ### Compiling on *nix
84
85 The following instructions are for Ubuntu, modify as required for other operating systems. [nix/build-all.py] script
86 can be experimented with and studied for pointers for other operating systems, but note that this script is not currently
87 meant to be used for a typical IfcOpenShell workspace setup.
88
89 Note: where `make -j` is written, add a number roughly equal to the amount of CPU cores + 1.
90
91 **1)** Install most of the prerequisites and dependencies:
92
93 $ sudo apt-get install git cmake gcc g++ libboost-all-dev
94
95 **2a)** Either use an OCE package from your operating system's software repository
96
97 $ sudo apt-get install liboce-foundation-dev liboce-modeling-dev liboce-ocaf-dev liboce-visualization-dev liboce-ocaf-lite-dev
98
99 **2b)** or (if not available, or the latest code is wanted) compile OCE yourself (note that the build takes a long time):
100
101 $ sudo apt-get install libftgl-dev libtbb2 libtbb-dev libgl1-mesa-dev libfreetype6-dev
102 $ git clone https://github.com/tpaviot/oce.git
103 $ cd oce
104 $ mkdir build && cd build
105 $ cmake ..
106 $ make -j
107 $ sudo make install
108
109 **2c)** or obtain and compile OCCT from http://www.opencascade.org/getocc/download/loadocc/
110
111 **3)** For building IfcConvert with COLLADA (.dae) support (on by default), OpenCOLLADA is needed:
112
113 $ sudo apt-get install libpcre3-dev libxml2-dev
114 $ git clone https://github.com/KhronosGroup/OpenCOLLADA.git
115 $ cd OpenCOLLADA
116 Using a known good revision, but HEAD should work too:
117 $ git checkout 064a60b65c2c31b94f013820856bc84fb1937cc6
118 $ mkdir build && cd build
119 $ cmake ..
120 $ make -j
121 $ sudo make install
122
123 **4)** For building the IfcPython wrapper (on by default), SWIG and Python development are needed, if not already available:
124
125 $ sudo apt-get install python-all-dev swig
126
127 **5)** To build IfcOpenShell please take the following steps. Alternatively use environment variables for setting the
128 dependencies' paths. `OCC_INCLUDE_DIR` might be needed to set also. `OPENCOLLADA_INCLUDE_DIR` and `OPENCOLLADA_LIBRARY_DIR`
129 (and potentially `PCRE_LIBRARY_DIR`) are needed if building with COLLADA support. (`-DCOLLADA_SUPPORT=0` disables it).
130
131 $ cd /path/to/IfcOpenShell
132 $ mkdir build && cd build
133 $ cmake ../cmake -DOCC_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu/ \
134 -DOPENCOLLADA_INCLUDE_DIR="/usr/local/include/opencollada" \
135 -DOPENCOLLADA_LIBRARY_DIR="/usr/local/lib/opencollada" \
136 -DPCRE_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu/
137 $ make -j
138
139 If all worked out correctly you can now use IfcOpenShell. See the examples below.
140
141 **6)** Install the project if wanted:
142
143 $ sudo make install
144
145 Installing IfcOpenShell with Conda
146 ----------------------------------
147 Another option for building and installing IfcOpenShell is to use the popular
148 [Anaconda Python Distribution](https://www.anaconda.com/download).
149 The requirements are spread across a number of channels.
150 You can add these channels to your configuration, or specify them all on the command line:
151
152 $ conda install -c conda-forge -c oce -c dlr-sc -c ifcopenshell ifcopenshell
153
154 Usage examples
155 --------------
156
157 **Invoking IfcConvert from the command line**
158
159 $ wget ftp://ftp.dds.no/pub/ifc/Munkerud/Munkerud_hus6_BE.zip
160 $ unzip Munkerud_hus6_BE.zip
161 $ ./IfcConvert Munkerud_hus6_BE.ifc
162 $ less Munkerud_hus6_BE.obj
163
164 **Using the IfcOpenShell Python interface**
165
166 $ wget -O duplex.zip http://projects.buildingsmartalliance.org/files/?artifact_id=4278
167 $ unzip duplex.zip
168 $ python
169 >>> import ifcopenshell
170 >>> f = ifcopenshell.open("Duplex_A_20110907_optimized.ifc")
171 >>>
172 >>> # Accessing entity instances by type:
173 >>> f.by_type("ifcwall")[:2]
174 [#91=IfcWallStandardCase('2O2Fr$t4X7Zf8NOew3FL9r',#1,'Basic Wall:Interior - Partition (92mm Stud):144586',$,'Basic Wall:Interior - Partition (92mm Stud):128360',#5198,#18806,'144586'), #92=IfcWallStandardCase('2O2Fr$t4X7Zf8NOew3FLIE',#1,'Basic Wall:Interior - Partition (92mm Stud):143921',$,'Basic Wall:Interior - Partition (92mm Stud):128360',#5206,#18805,'143921')]
175 >>> wall = _[0]
176 >>> len(wall) # number of EXPRESS attributes
177 8
178 >>>
179 >>> # Accessing EXPRESS attributes by name:
180 >>> wall.GlobalId
181 '2O2Fr$t4X7Zf8NOew3FL9r'
182 >>> wall.Name = "My wall"
183 >>> wall.NonExistingAttr
184 Traceback (most recent call last):
185 File "<stdin>", line 1, in <module>
186 File ".\ifcopenshell.py", line 14, in __getattr__
187 except: raise AttributeError("entity instance of type '%s' has no attribute'%s'"%(self.wrapped_data.is_a(), name)) from None
188 AttributeError: entity instance of type 'IfcWallStandardCase' has no attribute 'NonExistingAttr'
189 >>> wall.GlobalId = 3
190 Traceback (most recent call last):
191 File "<stdin>", line 1, in <module>
192 File ".\ifcopenshell.py", line 26, in __setattr__
193 self[self.wrapped_data.get_argument_index(key)] = value
194 File ".\ifcopenshell.py", line 30, in __setitem__
195 self.wrapped_data.set_argument(idx, entity_instance.map_value(value))
196 File ".\ifc_wrapper.py", line 118, in <lambda>
197 set_argument = lambda self,x,y: self._set_argument(x) if y is None else self
198 ._set_argument(x,y)
199 File ".\ifc_wrapper.py", line 114, in _set_argument
200 def _set_argument(self, *args): return _ifc_wrapper.entity_instance__set_argument(self, *args)
201 RuntimeError: INT is not a valid type for 'GlobalId'
202 >>> # Creating new entity instances
203 >>> f.createIfcCartesianPoint(Coordinates=(1.0,1.5,2.0))
204 #27530=IfcCartesianPoint((1.,1.5,2.))
205 >>>
206 >>> # Working with GlobalId attributes:
207 >>> import uuid
208 >>> ifcopenshell.guid.compress(uuid.uuid1().hex)
209 '3x4C8Q_6qHuv$P$FYkANRX'
210 >>> new_guid = _
211 >>> owner_hist = f.by_type("IfcOwnerHistory")[0]
212 >>> new_wall = f.createIfcWallStandardCase(new_guid, owner_hist, None, None, Tag='my_tag')
213 >>> new_wall.ObjectType = ''
214 >>> new_wall.ObjectPlacement = new_wall.Representation = None
215 >>>
216 >>> # Accessing entity instances by instance id or GlobalId:
217 >>> f[92]
218 #92=IfcWallStandardCase('2O2Fr$t4X7Zf8NOew3FLIE',#1,'Basic Wall:Interior - Partition (92mm Stud):143921',$,'Basic Wall:Interior - Partition (92mm Stud):128360',#5206,#18805,'143921')
219 >>> f['2O2Fr$t4X7Zf8NOew3FLIE']
220 #92=IfcWallStandardCase('2O2Fr$t4X7Zf8NOew3FLIE',#1,'Basic Wall:Interior - Partition (92mm Stud):143921',$,'Basic Wall:Interior - Partition (92mm Stud):128360',#5206,#18805,'143921')
221 >>>
222 >>> # Writing IFC-SPF files to disk:
223 >>> f.write("out.ifc")
224
225 [LGPL]: https://github.com/IfcOpenShell/IfcOpenShell/tree/master/COPYING "LGPL"
226 [IFC]: http://www.buildingsmart-tech.org/specifications/ifc-overview "IFC"
227 [IFC2x3 TC1]: http://www.buildingsmart-tech.org/specifications/ifc-releases/ifc2x3-tc1-release "IFC2x3 TC1"
228 [IFC4 Add1]: http://www.buildingsmart-tech.org/specifications/ifc-releases/ifc4-add1-release "IFC4 Add1"
229 [Visual Studio]: https://www.visualstudio.com/ "Visual Studio"
230 [Visual C++ Build Tools]: http://landinghub.visualstudio.com/visual-cpp-build-tools "Visual C++ Build Tools"
231 [MSYS2]: https://msys2.github.io/ "MSYS2"
232 [win/readme.md]: https://github.com/IfcOpenShell/IfcOpenShell/tree/master/win/readme.md "win/readme.md"
233 [nix/build-all.py]: https://github.com/IfcOpenShell/IfcOpenShell/tree/master/nix/build-all.py "nix/build-all.py"