Skip to content

Commit f1099fc

Browse files
committed
Merge branch 'master' into tridify_ifcgeom_dll
# Conflicts: # cmake/CMakeLists.txt
2 parents 0f85728 + 16e8fff commit f1099fc

35 files changed

+1349
-1095
lines changed

README.md

Lines changed: 68 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Prerequisites
1111
-------------
1212
* Git
1313
* CMake (2.6 or newer)
14-
* Windows: Visual Studio 2008 or newer with C++ toolset, MinGW not supported currently
14+
* Windows: [Visual Studio] 2008 or newer with C++ toolset (or [Visual C++ Build Tools]) or [MSYS2] + MinGW
1515
* *nix: GCC 4.7 or newer, or Clang (any version)
1616

1717
Dependencies
@@ -34,10 +34,11 @@ Building IfcOpenShell
3434
---------------------
3535
### Compiling on Windows
3636
The preferred way to fetch and build this project's dependencies is to use the build scripts
37-
in win/ folder. **See [win/readme.md] for more information**. Instructions in a nutshell
38-
(**assuming Visual Studio 2015 x64 environment variables set**):
37+
in win/ folder. **See [win/readme.md] for more information**.
38+
39+
#### Using Visual Studio
40+
Instructions in a nutshell (**assuming Visual Studio 2015 x64 environment variables set**):
3941

40-
> git clone https://github.com/IfcOpenShell/IfcOpenShell.git
4142
> cd IfcOpenShell\win
4243
> build-deps.cmd
4344
> run-cmake.bat
@@ -55,39 +56,86 @@ Alternatively, one can use the utility batch files to build and install the proj
5556
> build-ifcopenshell.bat
5657
> install-ifcopenshell.bat
5758

59+
#### Using MSYS2 + MinGW
60+
61+
Start the MSYS2 Shell and then:
62+
63+
$ cd IfcOpenShell/win
64+
$ ./build-deps.sh
65+
$ ./run-cmake.sh
66+
$ ./build-ifcopenshell.sh
67+
$ ./install-ifcopenshell.sh
68+
69+
#### Using Bash on Ubuntu on Windows
70+
71+
Start Bash on Ubuntu on Windows and follow the instructions below. Ubuntu 14.04.4 LTS with GCC 4.8.4 has been
72+
confirmed to work.
73+
5874
### Compiling on *nix
59-
There might be an Open CASCADE package in your operating system's software repository. If not, you will need to compile
60-
Open CASCADE yourself. See http://opencascade.org.
6175

62-
For building the IfcPython wrapper, SWIG and Python development are
63-
required.
76+
The following instructions are for Ubuntu, modify as required for other operating systems. [nix/build-all.sh] script
77+
can be experimented with and studied for pointers for other operating systems, but note that this script is not currently
78+
meant to be used for a typical IfcOpenShell workspace setup.
79+
80+
Install most of the prerequisites and dependencies:
81+
82+
$ sudo apt-get install git cmake gcc g++ libboost-all-dev libicu-dev
83+
84+
There might be an Open CASCADE package in your operating system's software repository (see http://opencascade.org
85+
for additional information):
86+
87+
$ sudo apt-get install liboce-foundation-dev liboce-modeling-dev liboce-ocaf-dev liboce-visualization-dev liboce-ocaf-lite-dev
6488

65-
Additionally, on Ubuntu (and possibly other linux flavors) the following steps
66-
install some of the prerequisites:
89+
If not, you will need to compile Open CASCADE yourself:
6790

68-
$ sudo apt-get install git swig cmake gcc g++ libftgl-dev libtbb2 libtbb-dev libboost-all-dev libgl1-mesa-dev libfreetype6-dev
91+
$ sudo apt-get install libftgl-dev libtbb2 libtbb-dev libgl1-mesa-dev libfreetype6-dev
6992
$ git clone https://github.com/tpaviot/oce.git
7093
$ cd oce
7194
$ mkdir build && cd build
7295
$ cmake ..
7396
$ make
74-
$ sudo make install
97+
$ sudo make install
98+
99+
For building IfcConvert with COLLADA (.dae) support (on by default), OpenCOLLADA is needed:
100+
101+
$ sudo apt-get install libpcre3-dev
102+
$ git clone https://github.com/KhronosGroup/OpenCOLLADA.git
103+
$ cd OpenCOLLADA
104+
Using a known good revision, but HEAD should work too:
105+
$ git checkout 064a60b65c2c31b94f013820856bc84fb1937cc6
106+
$ mkdir build && cd build
107+
$ cmake ..
108+
$ make
109+
$ sudo make install
110+
111+
For building the IfcPython wrapper (on by default), SWIG and Python development are needed, if not already available:
112+
113+
$ sudo apt-get install python-all-dev swig
75114

76115
To build IfcOpenShell please take the following steps:
77116

78-
$ cd /path/to/IfcOpenShell/cmake
117+
$ cd /path/to/IfcOpenShell
79118
$ mkdir build
80119
$ cd build
81-
Optionally:
120+
Optionally, if required:
82121
$ OCC_INCLUDE_PATH="/path/to/OpenCASCADE/include"
83122
$ OCC_LIBRARY_PATH="/path/to/OpenCASCADE/lib"
84123
$ export OCC_INCLUDE_PATH
85124
$ export OCC_LIBRARY_PATH
86-
$ cmake ../
125+
If building with COLLADA support (path might vary):
126+
$ OPENCOLLADA_INCLUDE_DIR="/usr/local/include/opencollada"
127+
$ OPENCOLLADA_LIBRARY_DIR="/usr/local/lib/opencollada"
128+
$ export OPENCOLLADA_INCLUDE_DIR
129+
$ export OPENCOLLADA_LIBRARY_DIR
130+
$ cmake ../cmake
87131
$ make
88132

89133
If all worked out correctly you can now use IfcOpenShell. See the examples below.
90134

135+
Install the project if wanted:
136+
137+
$ sudo make install
138+
91139
Usage examples
92140
--------------
93141

@@ -163,4 +211,8 @@ Usage examples
163211
[IFC]: http://www.buildingsmart-tech.org/specifications/ifc-overview "IFC"
164212
[IFC2x3 TC1]: http://www.buildingsmart-tech.org/specifications/ifc-releases/ifc2x3-tc1-release "IFC2x3 TC1"
165213
[IFC4 Add1]: http://www.buildingsmart-tech.org/specifications/ifc-releases/ifc4-add1-release "IFC4 Add1"
166-
[win/readme.md]: https://github.com/IfcOpenShell/IfcOpenShell/tree/master/win/readme.md "win/readme.md"
214+
[Visual Studio]: https://www.visualstudio.com/ "Visual Studio"
215+
[Visual C++ Build Tools]: http://landinghub.visualstudio.com/visual-cpp-build-tools "Visual C++ Build Tools"
216+
[MSYS2]: https://msys2.github.io/ "MSYS2"
217+
[win/readme.md]: https://github.com/IfcOpenShell/IfcOpenShell/tree/master/win/readme.md "win/readme.md"
218+
[nix/build-all.sh]: https://github.com/IfcOpenShell/IfcOpenShell/tree/master/nix/build-all.sh "nix/build-all.sh"

cmake/CMakeLists.txt

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ MACRO(SET_INSTALL_RPATHS _target _paths)
9898
SET(${_target}_rpaths "")
9999
FOREACH(_path ${_paths})
100100
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${_path}" isSystemDir)
101-
IF("${isSystemDir}" STREQUAL "-1")
101+
IF("${isSystemDir}" STREQUAL "-1")
102102
LIST(APPEND ${_target}_rpaths ${_path})
103103
ENDIF()
104104
ENDFOREACH()
@@ -107,7 +107,7 @@ MACRO(SET_INSTALL_RPATHS _target _paths)
107107
ENDMACRO()
108108

109109
# Find Boost
110-
IF(MSVC)
110+
IF(WIN32)
111111
SET(Boost_USE_STATIC_LIBS ON)
112112
SET(Boost_USE_STATIC_RUNTIME ON)
113113
SET(Boost_USE_MULTITHREADED ON)
@@ -195,10 +195,11 @@ IF(UNICODE_SUPPORT)
195195
MESSAGE(STATUS "ICU libraries found")
196196
# NOTE icudata appears to be icudt on Windows/MSVC and icudata on others
197197
# dl is included to resolve dlopen and friends symbols
198-
IF(MSVC OR MINGW)
198+
IF(WIN32)
199199
SET(ICU_LIBRARIES icuuc icudt)
200200
ADD_DEBUG_VARIANTS(ICU_LIBRARIES "${ICU_LIBRARIES}" "d")
201-
ADD_DEFINITIONS(-DU_STATIC_IMPLEMENTATION) # required for static ICU
201+
# TODO MinGW build would appear to be using dynamic ICU regardless of this definition.
202+
ADD_DEFINITIONS(-DU_STATIC_IMPLEMENTATION) # required for static ICU
202203
ELSE()
203204
SET(ICU_LIBRARIES icuuc icudata dl)
204205
ENDIF()
@@ -249,47 +250,26 @@ ENDIF()
249250
get_filename_component(libTKernelExt ${libTKernel} EXT)
250251
if("${libTKernelExt}" STREQUAL ".a")
251252
find_package(Threads)
252-
if (NOT APPLE)
253-
set(LIB_RT "rt")
253+
# OPENCASCADE_LIBRARIES repeated three times below in order to fix cyclic dependencies - use --start-group ... --end-group instead?
254+
set(OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
255+
if (NOT APPLE AND NOT WIN32)
256+
set(OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARIES} "rt")
257+
endif()
258+
if (NOT WIN32)
259+
set(OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARIES} "dl")
254260
endif()
255-
set(OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${LIB_RT} dl)
256261
endif()
257262

258-
# TODO Are these needed on other platforms still or can these be removed for good?
259-
IF (NOT WIN32)
260-
INCLUDE(CheckIncludeFileCXX)
261-
262-
MACRO(CHECK_ADD_OCE_OCC_DEF INCLUDE)
263-
STRING(REPLACE . _ STR ${INCLUDE})
264-
STRING(TOUPPER ${STR} STR)
265-
CHECK_INCLUDE_FILE_CXX("${INCLUDE}" FOUND_${STR})
266-
IF(FOUND_${STR})
267-
ADD_DEFINITIONS(-DOCE_HAVE_${STR})
268-
ADD_DEFINITIONS(-DHAVE_${STR})
269-
ENDIF(FOUND_${STR})
270-
ENDMACRO()
271-
272-
CHECK_ADD_OCE_OCC_DEF(limits)
273-
CHECK_ADD_OCE_OCC_DEF(climits)
274-
CHECK_ADD_OCE_OCC_DEF(limits.h)
275-
CHECK_ADD_OCE_OCC_DEF(fstream)
276-
CHECK_ADD_OCE_OCC_DEF(fstream.h)
277-
CHECK_ADD_OCE_OCC_DEF(iomanip)
278-
CHECK_ADD_OCE_OCC_DEF(iomanip.h)
279-
CHECK_ADD_OCE_OCC_DEF(iostream)
280-
CHECK_ADD_OCE_OCC_DEF(iostream.h)
281-
ENDIF()
282-
283263
IF(NOT CMAKE_BUILD_TYPE)
284264
SET(CMAKE_BUILD_TYPE "Release")
285265
ENDIF()
286266

287-
# NOTE: RelWithDebInfo and Release use O2 (= /Ox /Gl /Gy/ = Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy) by default,
288-
# with the exception with RelWithDebInfo has /Ob1 instead. /Ob2 has been observed to improve the performance
289-
# of IfcConvert significantly.
290-
# TODO Setting of /GL and /LTCG don't seem to apply for static libraries (IfcGeom, IfcParse)
291267
if(ENABLE_BUILD_OPTIMIZATIONS)
292268
if(MSVC)
269+
# NOTE: RelWithDebInfo and Release use O2 (= /Ox /Gl /Gy/ = Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy) by default,
270+
# with the exception with RelWithDebInfo has /Ob1 instead. /Ob2 has been observed to improve the performance
271+
# of IfcConvert significantly.
272+
# TODO Setting of /GL and /LTCG don't seem to apply for static libraries (IfcGeom, IfcParse)
293273
# C++
294274
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ob2 /GL")
295275
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
@@ -301,8 +281,9 @@ if(ENABLE_BUILD_OPTIMIZATIONS)
301281
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG /OPT:REF")
302282
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:NOICF")
303283
else()
304-
#TODO GCC (& Clang?) optimizations
305-
message(STATUS "ENABLE_BUILD_OPTIMIZATIONS not implemented for GCC/non-MSVC compilers.)")
284+
# GCC-like: Release should use O3 but RelWithDebInfo 02 so enforce 03. Anything other useful that could be added here?
285+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
286+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -O3")
306287
endif()
307288
endif()
308289

@@ -339,12 +320,13 @@ IF(MSVC)
339320
ENDIF()
340321
ENDFOREACH()
341322
ElSE()
342-
IF(WIN32)
343-
# -fPIC is not relevant on Windows and create pointless warnings
344-
ADD_DEFINITIONS(-Wno-non-virtual-dtor -Wall -Wextra)
345-
ELSE()
346-
ADD_DEFINITIONS(-fPIC -Wno-non-virtual-dtor -Wall -Wextra)
347-
ENDIF()
323+
add_definitions(-Wno-non-virtual-dtor -Wall)
324+
# TODO Preferably use -Wextra too, but currently too much warning spam coming from the dependencies' headers.
325+
add_definitions(-std=c++03)
326+
# -fPIC is not relevant on Windows and creates pointless warnings
327+
if (UNIX)
328+
add_definitions(-fPIC)
329+
endif()
348330
ENDIF()
349331

350332
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${OCC_INCLUDE_DIR} ${OPENCOLLADA_INCLUDE_DIRS}

src/ifcconvert/ColladaSerializer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ class ColladaSerializer : public GeometrySerializer
159159
{
160160
}
161161
ColladaMaterials materials;
162-
ColladaSerializer *serializer;
163162
ColladaGeometries geometries;
163+
ColladaSerializer *serializer;
164164
std::vector<DeferredObject> deferreds;
165165
virtual ~ColladaExporter() {}
166166
void startDocument(const std::string& unit_name, float unit_magnitude);

src/ifcconvert/IfcConvert.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040

4141
#include <boost/program_options.hpp>
4242
#include <boost/algorithm/string.hpp>
43-
#include <boost/optional/optional_io.hpp>
4443

4544
#include <fstream>
4645
#include <sstream>
@@ -279,10 +278,10 @@ int main(int argc, char** argv) {
279278
const bool generate_uvs = vmap.count("generate-uvs") != 0 ;
280279
const bool deflection_tolerance_specified = vmap.count("deflection-tolerance") != 0 ;
281280

282-
boost::optional<int> bounding_width, bounding_height;
281+
int bounding_width = -1, bounding_height = -1;
283282
if (vmap.count("bounds") == 1) {
284283
int w, h;
285-
if (sscanf(bounds.c_str(), "%ux%u", &w, &h) == 2) {
284+
if (sscanf(bounds.c_str(), "%ux%u", &w, &h) == 2 && w > 0 && h > 0) {
286285
bounding_width = w;
287286
bounding_height = h;
288287
} else {
@@ -404,7 +403,7 @@ int main(int argc, char** argv) {
404403
settings.set(IfcGeom::IteratorSettings::DISABLE_TRIANGULATION, true);
405404
serializer = new SvgSerializer(output_temp_filename, settings);
406405
if (bounding_width && bounding_height) {
407-
static_cast<SvgSerializer*>(serializer)->setBoundingRectangle(*bounding_width, *bounding_height);
406+
static_cast<SvgSerializer*>(serializer)->setBoundingRectangle(bounding_width, bounding_height);
408407
}
409408
} else {
410409
Logger::Message(Logger::LOG_ERROR, "Unknown output filename extension '" + output_extension + "'");

src/ifcconvert/XmlSerializer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ boost::optional<std::string> format_attribute(const Argument* argument, IfcUtil:
8383
value = unit_name;
8484
}
8585
break; }
86+
default:
87+
break;
8688
}
8789
return value;
8890
}

src/ifcconvert/util.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ namespace util {
3131
class item {
3232
public:
3333
virtual std::string str() const = 0;
34+
virtual ~item() {};
3435
};
3536
class string_item : public item {
3637
std::string s;
@@ -40,6 +41,7 @@ namespace util {
4041
const std::string& value() const { return s; }
4142
std::string& value() { return s; }
4243
std::string str() const { return s; }
44+
virtual ~string_item() {};
4345
};
4446
class float_item : public item {
4547
double d;
@@ -49,6 +51,7 @@ namespace util {
4951
const double& value() const { return d; }
5052
double& value() { return d; }
5153
std::string str() const { std::stringstream ss; ss << d; return ss.str(); }
54+
virtual ~float_item() {};
5255
};
5356
private:
5457
std::vector< boost::shared_ptr<item> > items;

src/ifcexpressparser/header.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,17 @@ def case_norm(n):
103103
argument_start = argument_count - len(type.attributes)
104104

105105
argument_name_function_body_switch_stmt = " switch (i) {%s}"%("".join(['case %d: return "%s"; '%(i+argument_start, attr.name) for i, attr in enumerate(type.attributes)])) if len(type.attributes) else ""
106-
argument_name_function_body_tail = (" return %s::getArgumentName(i); "%type.supertypes[0]) if len(type.supertypes) == 1 else ' throw IfcParse::IfcAttributeOutOfRangeException("Argument index out of range"); '
106+
argument_name_function_body_tail = (" return %s::getArgumentName(i); "%type.supertypes[0]) if len(type.supertypes) == 1 else ' (void)i; throw IfcParse::IfcAttributeOutOfRangeException("Argument index out of range"); '
107107

108108
argument_name_function_body = argument_name_function_body_switch_stmt + argument_name_function_body_tail
109109

110110
argument_type_function_body_switch_stmt = " switch (i) {%s}"%("".join(['case %d: return %s; '%(i+argument_start, mapping.make_argument_type(attr)) for i, attr in enumerate(type.attributes)])) if len(type.attributes) else ""
111-
argument_type_function_body_tail = (" return %s::getArgumentType(i); "%type.supertypes[0]) if len(type.supertypes) == 1 else ' throw IfcParse::IfcAttributeOutOfRangeException("Argument index out of range"); '
111+
argument_type_function_body_tail = (" return %s::getArgumentType(i); "%type.supertypes[0]) if len(type.supertypes) == 1 else ' (void)i; throw IfcParse::IfcAttributeOutOfRangeException("Argument index out of range"); '
112112

113113
argument_type_function_body = argument_type_function_body_switch_stmt + argument_type_function_body_tail
114114

115115
argument_entity_function_body_switch_stmt = " switch (i) {%s}"%("".join(['case %d: return %s; '%(i+argument_start, mapping.make_argument_entity(attr)) for i, attr in enumerate(type.attributes)])) if len(type.attributes) else ""
116-
argument_entity_function_body_tail = (" return %s::getArgumentEntity(i); "%type.supertypes[0]) if len(type.supertypes) == 1 else ' throw IfcParse::IfcAttributeOutOfRangeException("Argument index out of range"); '
116+
argument_entity_function_body_tail = (" return %s::getArgumentEntity(i); "%type.supertypes[0]) if len(type.supertypes) == 1 else ' (void)i; throw IfcParse::IfcAttributeOutOfRangeException("Argument index out of range"); '
117117

118118
argument_entity_function_body = argument_entity_function_body_switch_stmt + argument_entity_function_body_tail
119119

src/ifcexpressparser/templates.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@
3232
#include "../ifcparse/IfcException.h"
3333
#include "../ifcparse/%(schema_name)senum.h"
3434
35-
#ifdef _MSC_VER
36-
#pragma warning(push)
37-
#pragma warning(disable : 4100)
38-
#endif
39-
4035
#define IfcSchema %(schema_name)s
4136
4237
namespace %(schema_name)s {
@@ -53,10 +48,6 @@
5348
IfcUtil::IfcBaseClass* SchemaEntity(IfcAbstractEntity* e = 0);
5449
}
5550
56-
#ifdef _MSC_VER
57-
#pragma warning(pop)
58-
#endif
59-
6051
#endif
6152
"""
6253

@@ -209,7 +200,6 @@
209200
IfcEntityDescriptor* current;
210201
%(entity_descriptors)s
211202
// Enumerations
212-
IfcEnumerationDescriptor* current_enum;
213203
std::vector<std::string> values;
214204
%(enumeration_descriptors)s
215205
}
@@ -349,7 +339,7 @@
349339

350340
enumeration_descriptor = """ values.clear(); values.reserve(128);
351341
%(enumeration_descriptor_values)s
352-
current_enum = enumeration_descriptor_map[Type::%(type)s] = new IfcEnumerationDescriptor(Type::%(type)s, values);"""
342+
enumeration_descriptor_map[Type::%(type)s] = new IfcEnumerationDescriptor(Type::%(type)s, values);"""
353343

354344
enumeration_descriptor_value = ' values.push_back("%(name)s");'
355345

0 commit comments

Comments
 (0)