IfcPlusPlus
Descrizione
IFC++ or IfcPlusPlus is a C++ open source (MIT license) library from the IfcQuery project for reading, writing, and viewing IFC files.
The IFC++ library can be used for general purpose, and it also includes a sample IFC visualization application. This viewer is based on Qt 5 and OpenSceneGraph (OSG), and can load big IFC files very fast, and thus can be used to compare the performance of other IFC viewers, like Blender and FreeCAD, which internally use the IfcOpenShell library.
The sample IFC viewer included in the source distribution of the IfcQuery/IFC++ libraries.
Note: in common usage, the names "IfcQuery", "IFC++", and "IfcPlusPlus" may be used interchangeably to refer to the same thing, the C++ library, or more specifically the free IFC viewer.
Installazione
The IFC++ distribution is provided as source code, so to use the library and the viewer, the code must be compiled.
IFC++ is developed mostly on a Windows platform, so it includes solution (.snl) and project (.vcxproj) files to compile the IfcPlusPlus.dll dynamic library using Visual Studio. A static library libIfcPlusPlus.a can also be produced for Linux using CMake.
Note: there is a more complete viewer that uses pre-compiled IFC++ libraries intended for Windows. This viewer is free for use but is not open source. It is available by downloading the SimpleViewerExampleQt.zip package from http://www.ifcquery.com/, and running SimpleViewerExampleQt.exe. This viewer is self-contained, everything that it requires to run is included in the .zip archive.
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
cmaketo generate aMakefile, then start the compilation by runningmake. - Install the
libIfcPlusPlus.aandlibcarve.solibraries 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 can be used in games, virtual reality, scientific visualization and modelling.
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, OpenEXR, COLLADA, ZLIB, GDAL, FFmpeg, Gstreamer, SDL, Cairo, and Poppler.
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
Carve
Carve is a constructive solid geometry (CSG) C++ library designed to perform boolean operations between two arbitrary polygonal meshes. Together with the IFC++ library, libIfcPlusPlus.a, Carve is used by the IFC++ sample viewer to open and display IFC files.
- Original repository: carve, GPL2, from 2009 to 2011.
- New repository: folded/carve, from 2011 onwards; the project changed to the MIT License starting on October, 2015.
As the project is now MIT licensed, copies of the Carve source files are now included in the IFC++ repository. This means that when compiling IFC++, libcarve.so will be compiled as well. This library must be available in the system for the IFC++ sample viewer to work properly.
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/
By default the type of build is Release but it can also be set to Debug.
cmake -DCMAKE_BUILD_TYPE=Debug ../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
You can launch the SimpleViewerExample executable with an IFC file as input.
Release/SimpleViewerExample IfcOpenHouse.ifc
If the build type was set to Debug, then the compiled libraries will appear in the Debug/ subdirectory instead.
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
Library path
Once SimpleViewerExample is placed in /usr/local/bin, the executable will be available in the entire system. However, in certain platforms libcarve.so may not be found if it is installed in the default /usr/local/lib directory.
SimpleViewerExample: error while loading shared libraries: libcarve.so: cannot open shared object file: No such file or directory
If this is the case, it may be enough to update the cache of the ld.so library loader by calling ldconfig:
sudo ldconfig
Or you may have to move the library to the correct directory first:
sudo mkdir -p /usr/local/lib/x86_64-linux-gnu/
sudo mv /usr/local/lib/libcarve.so /usr/local/lib/x86_64-linux-gnu/libcarve.so
sudo ldconfig
Alternatively, you may set the LD_LIBRARY_PATH variable to the directory containing libcarve.so, before launching the executable:
LD_LIBRARY_PATH=/usr/local/lib SimpleViewerExample
To make this effect persistent, this environmental variable can be set in the shell resource file, for example, .bashrc, so that it is propagated to all terminal instances on startup:
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
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/
Fixes for Linux
The IFC++ library is developed by its author on a Windows system. This means that even if the code depends on multiplatform libraries like Boost, Qt, and OpenSceneGraph, the code is mostly tested to compile and run on Windows. Nevertheless, over the years other developers have provided fixes to the project so that IFC++ can be compiled and run on Linux distributions.
In particular, a fork of the main project is maintained with small fixes to compile and run better in Debian.
If the code of the official repository does not work or seems to have issues in Linux, try following the same compilation instructions but using the sources from this alternative repository. This repository is often some commits behind the main distribution, but it aims to remain up to date, and at the same time provide some Linux specific fixes. These improvements are normally submitted back to the main repository in order to make the official branch compile on Linux without issues.
The main developer of IFC++ does not support Linux directly, so Linux developers should be prepared to troubleshoot problems, fix them, and submit patches when using IFC++ in Linux.
Invisible icons
For the SimpleViewerExample, there are two buttons in the main interface which are invisible if the custom style sheet is not found.
QIODevice::read (QFile, ":styles.css"): device not open
The style must be included in the CMake configuration in the section devoted to the Qt libraries:
# ifcplusplus-source/examples/SimpleViewerExampleQt/CMakeLists.txt
...
ADD_DEFINITIONS(${Qt5Widgets_DEFINITIONS})
SET(viewer_dir ${IFCPP_SOURCE_DIR}/examples/SimpleViewerExampleQt)
SET(RESOURCES ${viewer_dir}/Resources/ifcplusplus.qrc)
QT5_ADD_RESOURCES(SimpleViewerExample_RESOURCES_RCC ${RESOURCES})
More information
- IFC++ project page
- ifcquery/ifcplusplus repository
- Alternative repository, especially for Debian: berndhahnebach/ifcplusplus
- Forum thread: IFC Viewer ifcplusplus (2013 to 2020)
- IfcPlusPlus compiled on Gentoo - questions and alternatives?
- German thread: IfcQuery / IfcPlusPlus selber kompilieren
- 2D drafting: Sketch, Line, Polyline, Circle, Arc, Arc From 3 Points, Fillet, Ellipse, Polygon, Rectangle, B-Spline, Bézier Curve, Cubic Bézier Curve, Point
- 3D/BIM: Project, Site, Building, Level, Space, Wall, Curtain Wall, Column, Beam, Slab, Door, Window, Pipe, Connector, Stairs, Roof, Panel, Frame, Fence, Truss, Equipment
- Reinforcement Tools: Custom Rebar, Straight Rebar, U-Shape Rebar, L-Shape Rebar, Stirrup, Bent-Shape Rebar, Helical Rebar, Column Reinforcement, Beam Reinforcement, Slab Reinforcement, Footing Reinforcement
- Generic 3D Tools: Profile, Box, Shape Builder, Facebinder, Objects Library, Component, External Reference
- Annotation: Text, Shape From Text, Aligned Dimension, Horizontal Dimension, Vertical Dimension, Leader, Label, Hatch, Axis, Axis System, Grid, Section Plane, New Page, New View
- Create 2D Views: 2D Drawing, Section View, Section Cut
- Snapping: Snap Lock, Snap Endpoint, Snap Midpoint, Snap Center, Snap Angle, Snap Intersection, Snap Perpendicular, Snap Extension, Snap Parallel, Snap Special, Snap Near, Snap Ortho, Snap Grid, Snap Working Plane, Snap Dimensions, Toggle Grid, Working Plane Front, Working Plane Top, Working Plane Side, Working Plane
- Modify: Move, Copy, Rotate, Clone, Create Simple Copy, Create Compound, Offset, 2D Offset, Trimex, Join, Split, Scale, Stretch, Draft to Sketch, Upgrade, Downgrade, Add Component, Remove Component, Array, Path Array, Polar Array, Point Array, Cut With Plane, Mirror, Extrude, Difference, Union, Intersection
- Manage: BIM Setup, Views Manager, Setup Project, Manage Doors and Windows, Manage IFC Elements, Manage IFC Quantities, Manage IFC Properties, Manage Classification, Manage Layers, Material, Schedule, Preflight Checks, Annotation Styles
- Utils: Toggle Bottom Panels, Move to Trash, Working Plane View, Select Group, Set Slope, Working Plane Proxy, Add to Construction Group, Split Mesh, Mesh to Shape, Select Non-Manifold Meshes, Remove Shape From BIM, Close Holes, Merge Walls, Check, Toggle IFC B-Rep Flag, Toggle Subcomponents, Survey, IFC Diff, IFC Explorer, New IFC Spreadsheet, Image Plane, Unclone, Rewire, Glue, Re-Extrude
- Panel Tools: Panel, Panel Cut, Panel Sheet, Nest
- Structure Tools: Structure, Structural System, Multiple Structures
- IFC Tools: IFC Diff, IFC Expand, Create IFC Project, IfcOpenShell Update
- Nudge: Nudge Switch, Nudge Up, Nudge Down, Nudge Left, Nudge Right, Nudge Rotate Left, Nudge Rotate Right, Nudge Extend, Nudge Shrink
- Additional: Preferences, Fine tuning, Import Export Preferences, IFC, DAE, OBJ, JSON, 3DS, SHP
- Materials: Solid Material, Fluid Material, Non-Linear Mechanical Material, Reinforced Material (Concrete); Material Editor
- Element Geometry: Beam Cross Section, Beam Rotation, Shell Plate Thickness, Fluid Section for 1D Flow
- Electromagnetic Boundary Conditions: Electrostatic Potential Boundary Condition, Current Density Boundary Condition, Magnetization Boundary Condition, Electric Charge Density
- Fluid Boundary Conditions: Initial Flow Velocity Condition, Initial Pressure Condition, Flow Velocity Boundary Condition
- Geometrical Analysis Features: Plane Multi-Point Constraint, Section Print Feature, Local Coordinate System
- Mechanical Boundary Conditions and Loads: Fixed Boundary Condition, Rigid Body Constraint, Displacement Boundary Condition, Contact Constraint, Tie Constraint, Spring Boundary Condition, Force Load, Pressure Load, Centrifugal Load, Gravity Load
- Thermal Boundary Conditions and Loads: Initial Temperature, Heat Flux Load, Temperature Boundary Condition, Body Heat Source
- Overwrite Constants: Constant Vacuum Permittivity
- Mesh: Mesh From Shape by Netgen, Mesh From Shape by Gmsh, Mesh Boundary Layer, Mesh Refinement, Mesh Group, Erase Elements, FEM Mesh to Mesh
- Solve: Solver CalculiX, Solver Elmer, Solver Mystran, Solver Z88; Mechanical Equations: Elasticity Equation, Deformation Equation; Electromagnetic Equations: Electrostatic Equation, Electricforce Equation, Magnetodynamic Equation, Magnetodynamic 2D Equation, Static Current Equation; Flow Equation, Flux Equation, Heat Equation, Solver Job Control, Run Solver
- Results: Purge Results, Show Result, Apply Changes to Pipeline, Post Pipeline From Result, Pipeline Branch, Warp Filter, Scalar Clip Filter, Function Cut Filter, Region Clip Filter, Contours Filter, Glyph Filter, Line Clip Filter, Stress Linearization Plot, Data at Point Clip Filter, Calculator Filter; Filter Functions: Plane, Sphere, Cylinder, Box; Data Visualizations: Create Lineplot, Create Histogram, Create Table
- Utilities: Clipping Plane on Face, Remove All Clipping Planes, FEM Examples; Clear FEM Mesh, Display Mesh Info
- Additional: Preferences; FEM Install, FEM Mesh, FEM Solver, FEM CalculiX, FEM Concrete; FEM Element Types
- 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, Assembly, BIM, CAM, Draft, FEM, Inspection, Material, Mesh, OpenSCAD, Part, PartDesign, Points, Reverse Engineering, Robot, Sketcher, Spreadsheet, Surface, TechDraw, Test Framework
- Hubs: User hub, Power users hub, Developer hub