Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Prerequisites
-------------
* Git
* CMake (2.6 or newer)
* Windows: Visual Studio 2008 or newer with C++ toolset, MinGW not supported currently
* Windows: Visual Studio 2008 or newer with C++ toolset or [MSYS2] + MinGW
* *nix: GCC 4.7 or newer, or Clang (any version)

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

#### Compiling using Visual Studio
Instructions in a nutshell (**assuming Visual Studio 2015 x64 environment variables set**):

> git clone https://github.com/IfcOpenShell/IfcOpenShell.git
> cd IfcOpenShell\win
> build-deps.cmd
> run-cmake.bat
Expand All @@ -55,6 +56,16 @@ Alternatively, one can use the utility batch files to build and install the proj
> build-ifcopenshell.bat
> install-ifcopenshell.bat

#### Compiling using MSYS2 + MinGW

Start the MSYS2 Shell and then:

$ cd IfcOpenShell/win
$ ./build-deps.sh
$ ./run-cmake.sh
$ ./build-ifcopenshell.sh
$ ./install-ifcopenshell.sh

### Compiling on *nix
There might be an Open CASCADE package in your operating system's software repository. If not, you will need to compile
Open CASCADE yourself. See http://opencascade.org.
Expand Down Expand Up @@ -163,4 +174,5 @@ Usage examples
[IFC]: http://www.buildingsmart-tech.org/specifications/ifc-overview "IFC"
[IFC2x3 TC1]: http://www.buildingsmart-tech.org/specifications/ifc-releases/ifc2x3-tc1-release "IFC2x3 TC1"
[IFC4 Add1]: http://www.buildingsmart-tech.org/specifications/ifc-releases/ifc4-add1-release "IFC4 Add1"
[MSYS2]: https://msys2.github.io/ "MSYS2"
[win/readme.md]: https://github.com/IfcOpenShell/IfcOpenShell/tree/master/win/readme.md "win/readme.md"
45 changes: 26 additions & 19 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ MACRO(SET_INSTALL_RPATHS _target _paths)
SET(${_target}_rpaths "")
FOREACH(_path ${_paths})
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${_path}" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
IF("${isSystemDir}" STREQUAL "-1")
LIST(APPEND ${_target}_rpaths ${_path})
ENDIF()
ENDFOREACH()
Expand All @@ -107,7 +107,7 @@ MACRO(SET_INSTALL_RPATHS _target _paths)
ENDMACRO()

# Find Boost
IF(MSVC)
IF(WIN32)
SET(Boost_USE_STATIC_LIBS ON)
SET(Boost_USE_STATIC_RUNTIME ON)
SET(Boost_USE_MULTITHREADED ON)
Expand Down Expand Up @@ -195,10 +195,11 @@ IF(UNICODE_SUPPORT)
MESSAGE(STATUS "ICU libraries found")
# NOTE icudata appears to be icudt on Windows/MSVC and icudata on others
# dl is included to resolve dlopen and friends symbols
IF(MSVC OR MINGW)
IF(WIN32)
SET(ICU_LIBRARIES icuuc icudt)
ADD_DEBUG_VARIANTS(ICU_LIBRARIES "${ICU_LIBRARIES}" "d")
ADD_DEFINITIONS(-DU_STATIC_IMPLEMENTATION) # required for static ICU
# TODO MinGW build would appear to be using dynamic ICU regardless of this definition.
ADD_DEFINITIONS(-DU_STATIC_IMPLEMENTATION) # required for static ICU
ELSE()
SET(ICU_LIBRARIES icuuc icudata dl)
ENDIF()
Expand Down Expand Up @@ -273,12 +274,12 @@ IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "Release")
ENDIF()

# NOTE: RelWithDebInfo and Release use O2 (= /Ox /Gl /Gy/ = Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy) by default,
# with the exception with RelWithDebInfo has /Ob1 instead. /Ob2 has been observed to improve the performance
# of IfcConvert significantly.
# TODO Setting of /GL and /LTCG don't seem to apply for static libraries (IfcGeom, IfcParse)
if(ENABLE_BUILD_OPTIMIZATIONS)
if(MSVC)
# NOTE: RelWithDebInfo and Release use O2 (= /Ox /Gl /Gy/ = Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy) by default,
# with the exception with RelWithDebInfo has /Ob1 instead. /Ob2 has been observed to improve the performance
# of IfcConvert significantly.
# TODO Setting of /GL and /LTCG don't seem to apply for static libraries (IfcGeom, IfcParse)
# C++
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ob2 /GL")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
Expand All @@ -290,8 +291,9 @@ if(ENABLE_BUILD_OPTIMIZATIONS)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG /OPT:REF")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:NOICF")
else()
#TODO GCC (& Clang?) optimizations
message(STATUS "ENABLE_BUILD_OPTIMIZATIONS not implemented for GCC/non-MSVC compilers.)")
# GCC-like: Release should use O3 but RelWithDebInfo 02 so enforce 03. Anything other useful that could be added here?
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -O3")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also experiment with -flto and -fwhole-program here.

endif()
endif()

Expand Down Expand Up @@ -328,12 +330,13 @@ IF(MSVC)
ENDIF()
ENDFOREACH()
ElSE()
IF(WIN32)
# -fPIC is not relevant on Windows and create pointless warnings
ADD_DEFINITIONS(-Wno-non-virtual-dtor -Wall -Wextra)
ELSE()
ADD_DEFINITIONS(-fPIC -Wno-non-virtual-dtor -Wall -Wextra)
ENDIF()
add_definitions(-Wno-non-virtual-dtor -Wall)
# TODO Preferably use -Wextra too, but currently too much warning spam coming from the dependencies' headers.
add_definitions(-std=c++03)
# -fPIC is not relevant on Windows and creates pointless warnings
if (UNIX)
add_definitions(-fPIC)
endif()
ENDIF()

INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${OCC_INCLUDE_DIR} ${OPENCOLLADA_INCLUDE_DIRS}
Expand Down Expand Up @@ -490,10 +493,14 @@ endif()
get_filename_component(libTKernelExt ${libTKernel} EXT)
if("${libTKernelExt}" STREQUAL ".a")
find_package(Threads)
if (NOT APPLE)
set(LIB_RT "rt")
# OPENCASCADE_LIBRARIES repeated three times below in order to fix cyclic dependencies - use --start-group ... --end-group instead?
set(OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
if (NOT APPLE AND NOT WIN32)
set(OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARIES} "rt")
endif()
if (NOT WIN32)
set(OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARIES} "dl")
endif()
set(OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${LIB_RT} dl)
endif()

TARGET_LINK_LIBRARIES(IfcConvert ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES} ${OPENCOLLADA_LIBRARIES} ${ICU_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion src/ifcconvert/ColladaSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ class ColladaSerializer : public GeometrySerializer
{
}
ColladaMaterials materials;
ColladaSerializer *serializer;
ColladaGeometries geometries;
ColladaSerializer *serializer;
std::vector<DeferredObject> deferreds;
virtual ~ColladaExporter() {}
void startDocument(const std::string& unit_name, float unit_magnitude);
Expand Down
7 changes: 3 additions & 4 deletions src/ifcconvert/IfcConvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

#include <boost/program_options.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/optional/optional_io.hpp>

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

boost::optional<int> bounding_width, bounding_height;
int bounding_width = -1, bounding_height = -1;
if (vmap.count("bounds") == 1) {
int w, h;
if (sscanf(bounds.c_str(), "%ux%u", &w, &h) == 2) {
if (sscanf(bounds.c_str(), "%ux%u", &w, &h) == 2 && w > 0 && h > 0) {
bounding_width = w;
bounding_height = h;
} else {
Expand Down Expand Up @@ -404,7 +403,7 @@ int main(int argc, char** argv) {
settings.set(IfcGeom::IteratorSettings::DISABLE_TRIANGULATION, true);
serializer = new SvgSerializer(output_temp_filename, settings);
if (bounding_width && bounding_height) {
static_cast<SvgSerializer*>(serializer)->setBoundingRectangle(*bounding_width, *bounding_height);
static_cast<SvgSerializer*>(serializer)->setBoundingRectangle(bounding_width, bounding_height);
}
} else {
Logger::Message(Logger::LOG_ERROR, "Unknown output filename extension '" + output_extension + "'");
Expand Down
2 changes: 2 additions & 0 deletions src/ifcconvert/XmlSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ boost::optional<std::string> format_attribute(const Argument* argument, IfcUtil:
value = unit_name;
}
break; }
default:
break;
}
return value;
}
Expand Down
6 changes: 3 additions & 3 deletions src/ifcexpressparser/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,17 @@ def case_norm(n):
argument_start = argument_count - len(type.attributes)

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 ""
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"); '
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"); '

argument_name_function_body = argument_name_function_body_switch_stmt + argument_name_function_body_tail

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 ""
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"); '
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"); '

argument_type_function_body = argument_type_function_body_switch_stmt + argument_type_function_body_tail

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 ""
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"); '
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"); '

argument_entity_function_body = argument_entity_function_body_switch_stmt + argument_entity_function_body_tail

Expand Down
12 changes: 1 addition & 11 deletions src/ifcexpressparser/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
#include "../ifcparse/IfcException.h"
#include "../ifcparse/%(schema_name)senum.h"

#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4100)
#endif

#define IfcSchema %(schema_name)s

namespace %(schema_name)s {
Expand All @@ -53,10 +48,6 @@
IfcUtil::IfcBaseClass* SchemaEntity(IfcAbstractEntity* e = 0);
}

#ifdef _MSC_VER
#pragma warning(pop)
#endif

#endif
"""

Expand Down Expand Up @@ -209,7 +200,6 @@
IfcEntityDescriptor* current;
%(entity_descriptors)s
// Enumerations
IfcEnumerationDescriptor* current_enum;
std::vector<std::string> values;
%(enumeration_descriptors)s
}
Expand Down Expand Up @@ -349,7 +339,7 @@

enumeration_descriptor = """ values.clear(); values.reserve(128);
%(enumeration_descriptor_values)s
current_enum = enumeration_descriptor_map[Type::%(type)s] = new IfcEnumerationDescriptor(Type::%(type)s, values);"""
enumeration_descriptor_map[Type::%(type)s] = new IfcEnumerationDescriptor(Type::%(type)s, values);"""

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

Expand Down
4 changes: 2 additions & 2 deletions src/ifcgeom/IfcGeom.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ class Kernel {
return _get_surface_style<T>(representation_item->as<IfcSchema::IfcStyledItem>());
}
IfcSchema::IfcStyledItem::list::ptr styled_items = representation_item->StyledByItem();
for (IfcSchema::IfcStyledItem::list::it jt = styled_items->begin(); jt != styled_items->end(); ++jt) {
if (styled_items->size()) {
// StyledByItem is a SET [0:1] OF IfcStyledItem, so we return after the first IfcStyledItem:
return _get_surface_style<T>(*jt);
return _get_surface_style<T>(*styled_items->begin());
}
return std::make_pair<IfcSchema::IfcSurfaceStyle*, T*>(0,0);
}
Expand Down
5 changes: 2 additions & 3 deletions src/ifcgeom/IfcGeomFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,6 @@ bool IfcGeom::Kernel::convert_layerset(const IfcSchema::IfcProduct* product, std
const IfcSchema::IfcMaterialLayerSet* layerset = usage->ForLayerSet();
const bool positive = usage->DirectionSense() == IfcSchema::IfcDirectionSenseEnum::IfcDirectionSense_POSITIVE;
double offset = usage->OffsetFromReferenceLine() * getValue(GV_LENGTH_UNIT);
const int axis = usage->LayerSetDirection();

IfcSchema::IfcMaterialLayer::list::ptr material_layers = layerset->MaterialLayers();

Expand Down Expand Up @@ -1723,7 +1722,7 @@ bool IfcGeom::Kernel::fold_layers(const IfcSchema::IfcWall* wall, const IfcRepre

bool found_intersection = false;
boost::optional<gp_Pnt> point_outside_param_range;
double param;
//double param;

const Handle_Geom_Surface& surface = *jt;

Expand All @@ -1734,7 +1733,7 @@ bool IfcGeom::Kernel::fold_layers(const IfcSchema::IfcWall* wall, const IfcRepre
intersections.Parameters(1, u, v, w);
if (w < axis_u1 || w > axis_u2) {
point_outside_param_range = p;
param = w;
//param = w;
} else {
// Found an intersection. Layer end point is covered by connecting wall
found_intersection = true;
Expand Down
2 changes: 0 additions & 2 deletions src/ifcgeom/IfcGeomIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,6 @@ namespace IfcGeom {
}
}

const int repid = representation->entity->id();

bool has_openings = false;
bool has_layers = false;

Expand Down
1 change: 1 addition & 0 deletions src/ifcgeom/IfcGeomSerialisation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ int convert_to_ifc(const gp_Ax2& a, IfcSchema::IfcAxis2Placement3D*& ax, bool ad
IfcSchema::IfcCartesianPoint* p;
IfcSchema::IfcDirection *x, *z;
if (!(convert_to_ifc(a.Location(), p, advanced) && convert_to_ifc(a.Direction(), z, advanced) && convert_to_ifc(a.XDirection(), x, advanced))) {
ax = 0;
return 0;
}
ax = new IfcSchema::IfcAxis2Placement3D(p, z, x);
Expand Down
1 change: 0 additions & 1 deletion src/ifcgeom/IfcGeomShapes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,6 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTriangulatedFaceSet* l, TopoDS

if (faces.empty()) return false;

const unsigned int num_faces = (unsigned)indices.size();
bool valid_shell = false;

if (faces.size() < getValue(GV_MAX_FACES_TO_SEW)) {
Expand Down
Loading