IfcPlusPlus: Difference between revisions
(While the IFC++ library can be used for general purpose, a very useful component that it includes is an IFC reader and viewer based on Qt 5 and OpenSceneGraph (OSG)) |
(→Compiling in Linux: Install the libIfcPlusPlus.a and libcarve.so libraries to the appropriate library path so that they are found by the IFC++ sample viewer.) |
||
Line 29: | Line 29: | ||
# Gather all dependencies for compiling, including a C++ compiler, CMake, and Make, and the development files for Boost, Qt 5, as well as the OpenSceneGraph (OSG) library for visualization. |
# Gather all dependencies for compiling, including a C++ compiler, CMake, and Make, and the development files for Boost, Qt 5, as well as the OpenSceneGraph (OSG) library for visualization. |
||
# Run {{incode|cmake}} to generate a {{incode|Makefile}}, then start the compilation by running {{incode|make}}. |
# Run {{incode|cmake}} to generate a {{incode|Makefile}}, then start the compilation by running {{incode|make}}. |
||
# Install the {{incode| |
# Install the {{incode|libIfcPlusPlus.a}} and {{incode|libcarve.so}} libraries to the appropriate library path so that they are found by the IFC++ sample viewer. |
||
=== Prerequisites === |
=== Prerequisites === |
Revision as of 22:40, 20 August 2020
Description
IFC++ or IfcPlusPlus is an open source (MIT license) library from the IfcQuery project for reading, writing, and viewing IFC files.
While the IFC++ library can be used for general purpose, a very useful component that it includes is an IFC reader and viewer based on Qt 5 and OpenSceneGraph (OSG). This viewer is very fast, and can be used to compare the performance of other viewers of IFC data, like Blender and FreeCAD, which use the IfcOpenShell library.
Installing
The IFC++ distribution is provided as source code, so to use the library and the viewer, the code must be compiled before it can be used.
IFC++ is developed mostly on a Windows platform, so it includes solution files (.snl
) to compile the IfcPlusPlus.dll
dynamic library using Visual Studio. A static library libIfcPlusPlus.a
can also be produced for Linux using CMake.
Compiling in Windows
Follow the instructions in the official ifcplusplus repository.
Compiling in Linux
The general instructions are as follows:
- Get the source code of IFC++ from its main repository.
- Gather all dependencies for compiling, including a C++ compiler, CMake, and Make, and the development files for Boost, Qt 5, as well as the OpenSceneGraph (OSG) library for visualization.
- Run
cmake
to generate aMakefile
, then start the compilation by runningmake
. - Install the
libIfcPlusPlus.a
andlibcarve.so
libraries to the appropriate library path so that they are found by the IFC++ sample viewer.
Prerequisites
In a Debian/Ubuntu based distribution, getting the required development files is usually simple.
sudo apt install git cmake gcc g++ libboost-all-dev
sudo apt install qt5-qmake qtbase5-dev qttools5-dev libqt5widgets5 libqt5opengl5-dev
Get the source code of the project and place it in a custom directory to which you have full write access.
git clone https://github.com/ifcquery/ifcplusplus ifcplusplus-source
OpenSceneGraph
OpenSceneGraph (OSG) is a collection of C++ libraries that uses OpenGL for 3D visualization; it is used in games, virtual reality, scientific visualization, and modelling. Install the development files of OpenSceneGraph.
sudo apt install libopenscenegraph-3.4-dev
If the files are too old in your distribution, you may also compile the libraries yourself. The procedure is outlined in the main repository, openscenegraph/OpenSceneGraph. Compiling is straight forward, although you may need various dependencies like Qt 5, Freetype, Inventor, Jasper, OpenEXR, COLLADA, ZLIB, GDAL, FFmpeg, Gstremer, DirectShow, SDL, Poppler, and Lua.
git clone https://github.com/openscenegraph/OpenSceneGraph OpenSceneGraph-source
mkdir -p OpenSceneGraph-build
cd OpenSceneGraph-build
cmake ../OpenSceneGraph-source
make -j 3
sudo make install
CMake configuration
It is recommended to perform the configuration and compilation in a specific build directory separate from the source directory.
mkdir -p ifcplusplus-build
cd ifcplusplus-build
cmake ../ifcplusplus-source/
Actual compilation
If there were no error messages during configuration with CMake, a Makefile
should have been created in the build directory, so you can proceed to compile the libraries by running make
.
make -j N
N
is the number of processors that you assign to the compilation process; choose at least one fewer than the total number of CPU cores that you have.
Testing the compilation in the build directory
If the build was successful you should have a Release/
subdirectory with the newly compiled libraries.
Release/libcarve.so
Release/libIfcPlusPlus.a
Release/SimpleViewerExample
The SimpleViewerExample
executable is a simple IFC viewer that uses the compiled library libcarve.so
.
Installation of the compiled libraries
If the compilation doesn't report any errors, you may run make install
to copy the headers, compiled libraries, and binaries to their corresponding installation directories.
sudo make install
By default, the CMAKE_INSTALL_PREFIX
is /usr/local/
, so all compiled files will be placed under this directory, which normally requires elevated privileges.
/usr/local/bin/SimpleViewerExample
/usr/local/lib/libcarve.so
/usr/local/lib/libIfcPlusPlus.a
/usr/local/include/carve/*.{h, hpp}
/usr/local/include/ifcpp/geometry/*.h
/usr/local/include/ifcpp/geometry/Carve/*.h
/usr/local/include/ifcpp/geometry/OCC/*.h
/usr/local/include/ifcpp/IFC4/*.h
/usr/local/include/ifcpp/IFC4/include/*.h
/usr/local/include/ifcpp/model/*.h
/usr/local/include/ifcpp/reader/*.h
/usr/local/include/ifcpp/writer/*.h
/usr/local/share/IFCPP/cmake/*.cmake
Removing the compiled libraries
To remove the installed libraries, just remove the corresponding files that were installed.
sudo rm -rf /usr/local/bin/SimpleViewerExample
sudo rm -rf /usr/local/lib/libcarve.so
sudo rm -rf /usr/local/lib/libIfcPlusPlus.a
sudo rm -rf /usr/local/include/carve
sudo rm -rf /usr/local/include/ifcpp
sudo rm -rf /usr/local/share/IFCPP/cmake/
Links
- IFC++ project page
- ifcquery/ifcplusplus repository
- IfcQuery / IfcPlusPlus selber kompilieren, for FreeCAD
- IFC Viewer ifcplusplus (older thread)
- Getting started
- Installation: Download, Windows, Linux, Mac, Additional components, Docker, AppImage, Ubuntu Snap
- Basics: About FreeCAD, Interface, Mouse navigation, Selection methods, Object name, Preferences, Workbenches, Document structure, Properties, Help FreeCAD, Donate
- Help: Tutorials, Video tutorials
- Workbenches: Std Base, Arch, Assembly, CAM, Draft, FEM, Inspection, Mesh, OpenSCAD, Part, PartDesign, Points, Reverse Engineering, Robot, Sketcher, Spreadsheet, Surface, TechDraw, Test Framework
- Hubs: User hub, Power users hub, Developer hub