Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
/install*/
/win/BuildDepsCache*.txt
# IfcExpressParser residue
/src/ifcexpressparser/__pycache__
/src/ifcexpressparser/express_parser.py
# Python test residue
/test/__pycache__
# General Python residue
__pycache__
# Visual Studio Code files
.vscode
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
IfcOpenShell
============
IfcOpenShell is an open source ([LGPL]) software library for working with the Industry Foundation Classes ([IFC])
file format. Currently supported IFC releases are [IFC2x3 TC1] and [IFC4].
file format. Currently supported IFC releases are [IFC2x3 TC1] and [IFC4 Add1].

For more information, see
* [http://ifcopenshell.org](http://ifcopenshell.org)
Expand Down Expand Up @@ -162,5 +162,5 @@ Usage examples
[LGPL]: https://github.com/IfcOpenShell/IfcOpenShell/tree/master/COPYING "LGPL"
[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]: http://www.buildingsmart-tech.org/specifications/ifc-releases/ifc4-release "IFC4"
[IFC4 Add1]: http://www.buildingsmart-tech.org/specifications/ifc-releases/ifc4-add1-release "IFC4 Add1"
[win/readme.md]: https://github.com/IfcOpenShell/IfcOpenShell/tree/master/win/readme.md "win/readme.md"
70 changes: 43 additions & 27 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ OPTION(BUILD_IFCPYTHON "Build IfcPython." ON)
OPTION(BUILD_EXAMPLES "Build example applications." ON)
OPTION(USE_VLD "Use Visual Leak Detector for debugging memory leaks, MSVC-only." OFF)
OPTION(BUILD_IFCMAX "Build IfcMax, a 3ds Max plug-in, Windows-only." OFF)
OPTION(BUILD_SHARED_LIBS "Build ifcparse and ifcgeom libs shared." OFF)
OPTION(BUILD_SHARED_LIBS "Build IfcParse and IfcGeom as shared libs (SO/DLL)." OFF)
# TODO QtViewer is deprecated ATM as it uses the 0.4 API
# OPTION(BUILD_QTVIEWER "Build IfcOpenShell Qt GUI Viewer (requires Qt 4 framework)." OFF)

Expand Down Expand Up @@ -60,7 +60,18 @@ IF(NOT IS_ABSOLUTE ${LIBDIR})
ENDIF()
MESSAGE(STATUS "LIBDIR: ${LIBDIR}")

set(IFCOPENSHELL_LIBARY_DIR "") # for *nix rpaths

if (BUILD_SHARED_LIBS)
add_definitions(-DBUILD_SHARED_LIBS)
if (MSVC)
message(WARNING "Building DLLs against the static VC run-time. This is not recommended if the DLLs are to be redistributed.")
# C4521: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
# There will be couple hundreds of these so suppress them away, https://msdn.microsoft.com/en-us/library/esew7y1w.aspx
add_definitions(-wd4251)
endif()
set(IFCOPENSHELL_LIBARY_DIR "${LIBDIR}")
endif()

# Create cache entries if absent for environment variables
MACRO(UNIFY_ENVVARS_AND_CACHE VAR)
Expand Down Expand Up @@ -305,6 +316,7 @@ IF(MSVC)
ADD_DEFINITIONS(-wd4458)
ENDIF()
# Link against the static VC runtime
# TODO Make this configurable
FOREACH(flag CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
Expand All @@ -318,9 +330,9 @@ IF(MSVC)
ElSE()
IF(WIN32)
# -fPIC is not relevant on Windows and create pointless warnings
ADD_DEFINITIONS(-Wno-non-virtual-dtor)
ADD_DEFINITIONS(-Wno-non-virtual-dtor -Wall -Wextra)
ELSE()
ADD_DEFINITIONS(-fPIC -Wno-non-virtual-dtor)
ADD_DEFINITIONS(-fPIC -Wno-non-virtual-dtor -Wall -Wextra)
ENDIF()
ENDIF()

Expand Down Expand Up @@ -408,7 +420,7 @@ else()
endif()
endif()

# Boost >= 1.58 requires BOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE to build
# Boost >= 1.58 requires BOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE to build on some Linux distros.
if(NOT Boost_VERSION LESS 105800)
add_definitions(-DBOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE)
endif()
Expand All @@ -420,6 +432,8 @@ if(NOT WIN32)
LINK_DIRECTORIES(${LINK_DIRECTORIES} /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64)
endif()

SET(IFCOPENSHELL_LIBRARIES IfcParse IfcGeom)

# IfcParse
file(GLOB IFCPARSE_H_FILES ../src/ifcparse/*.h)
file(GLOB IFCPARSE_CPP_FILES ../src/ifcparse/*.cpp)
Expand All @@ -434,7 +448,8 @@ endforeach()

set(IFCPARSE_FILES ${IFCPARSE_CPP_FILES} ${IFCPARSE_H_FILES})

ADD_LIBRARY(IfcParse STATIC ${IFCPARSE_FILES})
add_library(IfcParse ${IFCPARSE_FILES})
set_target_properties(IfcParse PROPERTIES COMPILE_FLAGS -DIfcParse_EXPORTS)

IF(UNICODE_SUPPORT)
TARGET_LINK_LIBRARIES(IfcParse ${ICU_LIBRARIES} ${Boost_LIBRARIES})
Expand All @@ -443,31 +458,24 @@ ENDIF()
# IfcGeom
file(GLOB IFCGEOM_H_FILES ../src/ifcgeom/*.h)
file(GLOB IFCGEOM_CPP_FILES ../src/ifcgeom/*.cpp)

set(IFCGEOM_FILES ${IFCGEOM_CPP_FILES} ${IFCGEOM_H_FILES})
IF(BUILD_SHARED_LIBS)
ADD_LIBRARY(IfcGeom SHARED ${IFCGEOM_FILES})
SET(IFCLIBS "IfcGeom")
SET(IFCDIRS "${LIBDIR}")
message(WARNING "Building IfcGeom as shared library not currently supported")
add_library(IfcGeom STATIC ${IFCGEOM_FILES})
ELSE()
ADD_LIBRARY(IfcGeom STATIC ${IFCGEOM_FILES})
SET(IFCLIBS "IfcParse;IfcGeom")
SET(IFCDIRS "")

# add macro for every project: use IfcParse as static lib
ADD_DEFINITIONS(-DIFCPARSE_STATIC_DEFINE)
add_library(IfcGeom ${IFCGEOM_FILES})
ENDIF()

TARGET_LINK_LIBRARIES(IfcGeom IfcParse)

# IfcConvert
if (IFCCONVERT_DOUBLE_PRECISION)
add_definitions(-DIFCCONVERT_DOUBLE_PRECISION)
endif()
file(GLOB IFCCONVERT_CPP_FILES ../src/ifcconvert/*.cpp)
file(GLOB IFCCONVERT_H_FILES ../src/ifcconvert/*.h)
set(IFCCONVERT_FILES ${IFCCONVERT_CPP_FILES} ${IFCCONVERT_H_FILES})
ADD_EXECUTABLE(IfcConvert ${IFCCONVERT_FILES})
if (IFCCONVERT_DOUBLE_PRECISION)
set_target_properties(IfcConvert PROPERTIES COMPILE_FLAGS -DIFCCONVERT_DOUBLE_PRECISION)
endif()

# Make sure cross-referenced symbols between static OCC libraries get
# resolved. Also add thread and rt libraries.
Expand All @@ -480,20 +488,19 @@ if("${libTKernelExt}" STREQUAL ".a")
set(OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${LIB_RT} dl)
endif()

TARGET_LINK_LIBRARIES(IfcConvert ${IFCLIBS} ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES} ${OPENCOLLADA_LIBRARIES} ${ICU_LIBRARIES})
TARGET_LINK_LIBRARIES(IfcConvert ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES} ${OPENCOLLADA_LIBRARIES} ${ICU_LIBRARIES})
if (NOT WIN32)
SET_INSTALL_RPATHS(IfcConvert "${IFCDIRS};${OCC_LIBRARY_DIR};${Boost_LIBRARY_DIRS};${OPENCOLLADA_LIBRARY_DIR};${ICU_LIBRARY_DIR}")
SET_INSTALL_RPATHS(IfcConvert "${IFCOPENSHELL_LIBARY_DIR};${OCC_LIBRARY_DIR};${Boost_LIBRARY_DIRS};${OPENCOLLADA_LIBRARY_DIR};${ICU_LIBRARY_DIR}")
endif()

# IfcGeomServer
file(GLOB CPP_FILES ../src/ifcgeomserver/*.cpp)
file(GLOB H_FILES ../src/ifcgeomserver/*.h)
set(SOURCE_FILES ${CPP_FILES} ${H_FILES})
ADD_EXECUTABLE(IfcGeomServer ${SOURCE_FILES})

TARGET_LINK_LIBRARIES(IfcGeomServer ${IFCLIBS} ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES} ${ICU_LIBRARIES})
TARGET_LINK_LIBRARIES(IfcGeomServer ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES} ${ICU_LIBRARIES})
if (NOT WIN32)
SET_INSTALL_RPATHS(IfcGeomServer "${IFCDIRS};${OCC_LIBRARY_DIR};${Boost_LIBRARY_DIRS};${ICU_LIBRARY_DIR}")
SET_INSTALL_RPATHS(IfcGeomServer "${IFCOPENSHELL_LIBARY_DIR};${OCC_LIBRARY_DIR};${Boost_LIBRARY_DIRS};${ICU_LIBRARY_DIR}")
endif()

IF(BUILD_IFCPYTHON)
Expand All @@ -509,7 +516,16 @@ IF(BUILD_IFCMAX)
ENDIF()

# CMake installation targets
INSTALL(FILES ${IFCPARSE_H_FILES} DESTINATION ${INCLUDEDIR}/ifcparse)
INSTALL(FILES ${IFCGEOM_H_FILES} DESTINATION ${INCLUDEDIR}/ifcgeom)
INSTALL(TARGETS IfcConvert IfcGeomServer DESTINATION ${BINDIR})
INSTALL(TARGETS ${IFCLIBS} DESTINATION ${LIBDIR})
INSTALL(FILES ${IFCPARSE_H_FILES}
DESTINATION ${INCLUDEDIR}/ifcparse
)

INSTALL(FILES ${IFCGEOM_H_FILES}
DESTINATION ${INCLUDEDIR}/ifcgeom
)

INSTALL(TARGETS IfcParse IfcGeom IfcConvert IfcGeomServer
ARCHIVE DESTINATION ${LIBDIR}
LIBRARY DESTINATION ${LIBDIR}
RUNTIME DESTINATION ${BINDIR}
)
8 changes: 2 additions & 6 deletions src/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@
################################################################################

ADD_EXECUTABLE(IfcParseExamples IfcParseExamples.cpp)
IF(BUILD_SHARED_LIBS)
TARGET_LINK_LIBRARIES(IfcParseExamples ${IFCLIBS})
ELSE()
TARGET_LINK_LIBRARIES(IfcParseExamples IfcParse)
ENDIF()
TARGET_LINK_LIBRARIES(IfcParseExamples IfcParse)
set_target_properties(IfcParseExamples PROPERTIES FOLDER Examples)

ADD_EXECUTABLE(IfcOpenHouse IfcOpenHouse.cpp)
TARGET_LINK_LIBRARIES(IfcOpenHouse ${IFCLIBS} ${OPENCASCADE_LIBRARIES})
TARGET_LINK_LIBRARIES(IfcOpenHouse ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES})
set_target_properties(IfcOpenHouse PROPERTIES FOLDER Examples)
27 changes: 14 additions & 13 deletions src/ifcexpressparser/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,24 @@

#define IfcSchema %(schema_name)s

#include "../ifcparse/IfcParse_Export.h"
#include "../ifcparse/IfcUtil.h"
#include "../ifcparse/IfcEntityDescriptor.h"
#include "../ifcparse/IfcWritableEntity.h"

namespace %(schema_name)s {
namespace Type {
int GetAttributeCount(Enum t);
int GetAttributeIndex(Enum t, const std::string& a);
IfcUtil::ArgumentType GetAttributeType(Enum t, unsigned char a);
Enum GetAttributeEntity(Enum t, unsigned char a);
const std::string& GetAttributeName(Enum t, unsigned char a);
bool GetAttributeOptional(Enum t, unsigned char a);
bool GetAttributeDerived(Enum t, unsigned char a);
std::pair<const char*, int> GetEnumerationIndex(Enum t, const std::string& a);
std::pair<Enum, unsigned> GetInverseAttribute(Enum t, const std::string& a);
std::set<std::string> GetInverseAttributeNames(Enum t);
void PopulateDerivedFields(IfcWrite::IfcWritableEntity* e);
IfcParse_EXPORT int GetAttributeCount(Enum t);
IfcParse_EXPORT int GetAttributeIndex(Enum t, const std::string& a);
IfcParse_EXPORT IfcUtil::ArgumentType GetAttributeType(Enum t, unsigned char a);
IfcParse_EXPORT Enum GetAttributeEntity(Enum t, unsigned char a);
IfcParse_EXPORT const std::string& GetAttributeName(Enum t, unsigned char a);
IfcParse_EXPORT bool GetAttributeOptional(Enum t, unsigned char a);
IfcParse_EXPORT bool GetAttributeDerived(Enum t, unsigned char a);
IfcParse_EXPORT std::pair<const char*, int> GetEnumerationIndex(Enum t, const std::string& a);
IfcParse_EXPORT std::pair<Enum, unsigned> GetInverseAttribute(Enum t, const std::string& a);
IfcParse_EXPORT std::set<std::string> GetInverseAttributeNames(Enum t);
IfcParse_EXPORT void PopulateDerivedFields(IfcWrite::IfcWritableEntity* e);
}}

#endif
Expand Down Expand Up @@ -389,8 +390,8 @@ class IfcParse_EXPORT %(name)s : public %(superclass)s {
enumeration = """namespace %(name)s {
%(documentation)s
typedef enum {%(values)s} %(name)s;
const char* ToString(%(name)s v);
%(name)s FromString(const std::string& s);
IfcParse_EXPORT const char* ToString(%(name)s v);
IfcParse_EXPORT %(name)s FromString(const std::string& s);
}
"""

Expand Down
4 changes: 1 addition & 3 deletions src/ifcgeom/IfcGeomFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1294,9 +1294,7 @@ std::pair<std::string, double> IfcGeom::Kernel::initializeUnits(IfcSchema::IfcUn
Logger::Message(Logger::LOG_ERROR, "No unit information found");
} else {
for (IfcEntityList::it it = units->begin(); it != units->end(); ++it) {
std::string current_unit_name = "";
IfcUtil::IfcBaseClass* base = *it;
IfcSchema::IfcSIUnit* unit = 0;
if (base->is(IfcSchema::Type::IfcNamedUnit)) {
IfcSchema::IfcNamedUnit* named_unit = base->as<IfcSchema::IfcNamedUnit>();
if (named_unit->UnitType() == IfcSchema::IfcUnitEnum::IfcUnit_LENGTHUNIT ||
Expand Down Expand Up @@ -1387,7 +1385,7 @@ bool IfcGeom::Kernel::convert_layerset(const IfcSchema::IfcProduct* product, std
double u1, u2;
Handle_Geom_Curve axis_curve = BRep_Tool::Curve(axis_edge, u1, u2);

if (true) {
if (true) { /**< @todo Why always true? */
if (axis_curve->DynamicType() == STANDARD_TYPE(Geom_Line)) {
Handle_Geom_Line axis_line = Handle_Geom_Line::DownCast(axis_curve);
reference_surface = new Geom_Plane(axis_line->Lin().Location(), axis_line->Lin().Direction() ^ gp::DZ());
Expand Down
19 changes: 17 additions & 2 deletions src/ifcgeom/IfcGeomIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#include <algorithm>

#include <boost/algorithm/string.hpp>
#include <boost/regex.hpp>

#include <gp_Mat.hxx>
#include <gp_Mat2d.hxx>
Expand Down Expand Up @@ -308,7 +309,7 @@ namespace IfcGeom {
{
names_to_include_or_exclude.clear();
foreach(const std::string &name, names)
names_to_include_or_exclude.insert(IfcUtil::wildcard_string_to_regex(name));
names_to_include_or_exclude.insert(wildcard_string_to_regex(name));
include_entities_in_processing = true;
}

Expand All @@ -317,10 +318,24 @@ namespace IfcGeom {
{
names_to_include_or_exclude.clear();
foreach(const std::string &name, names)
names_to_include_or_exclude.insert(IfcUtil::wildcard_string_to_regex(name));
names_to_include_or_exclude.insert(wildcard_string_to_regex(name));
include_entities_in_processing = false;
}

static boost::regex wildcard_string_to_regex(std::string str)
{
// Escape all non-"*?" regex special chars
std::string special_chars = "\\^.$|()[]+/";
foreach(char c, special_chars) {
std::string char_str(1, c);
boost::replace_all(str, char_str, "\\" + char_str);
}
// Convert "*?" to their regex equivalents
boost::replace_all(str, "?", ".");
boost::replace_all(str, "*", ".*");
return boost::regex(str);
}

const gp_XYZ& bounds_min() const { return bounds_min_; }
const gp_XYZ& bounds_max() const { return bounds_max_; }

Expand Down
14 changes: 8 additions & 6 deletions src/ifcparse/Ifc2x3-latebound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
* *
********************************************************************************/

/********************************************************************************
* *
* This file has been generated from IFC2X3_TC1.exp. Do not make modifications *
* but instead modify the python script that has been used to generate this. *
* *
********************************************************************************/
/********************************************************************************************
* *
* This file has been generated from *
* http://www.buildingsmart-tech.org/downloads/ifc/ifc2x3tc/IFC2X3_TC1_EXPRESS_longform.zip *
* Do not make modifications but instead modify the Python script that has been *
* used to generate this. *
* *
********************************************************************************************/

#ifndef USE_IFC4

Expand Down
37 changes: 20 additions & 17 deletions src/ifcparse/Ifc2x3-latebound.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,38 @@
* *
********************************************************************************/

/********************************************************************************
* *
* This file has been generated from IFC2X3_TC1.exp. Do not make modifications *
* but instead modify the python script that has been used to generate this. *
* *
********************************************************************************/
/********************************************************************************************
* *
* This file has been generated from *
* http://www.buildingsmart-tech.org/downloads/ifc/ifc2x3tc/IFC2X3_TC1_EXPRESS_longform.zip *
* Do not make modifications but instead modify the Python script that has been *
* used to generate this. *
* *
********************************************************************************************/

#ifndef IFC2X3RT_H
#define IFC2X3RT_H

#define IfcSchema Ifc2x3

#include "../ifcparse/IfcParse_Export.h"
#include "../ifcparse/IfcUtil.h"
#include "../ifcparse/IfcEntityDescriptor.h"
#include "../ifcparse/IfcWritableEntity.h"

namespace Ifc2x3 {
namespace Type {
int GetAttributeCount(Enum t);
int GetAttributeIndex(Enum t, const std::string& a);
IfcUtil::ArgumentType GetAttributeType(Enum t, unsigned char a);
Enum GetAttributeEntity(Enum t, unsigned char a);
const std::string& GetAttributeName(Enum t, unsigned char a);
bool GetAttributeOptional(Enum t, unsigned char a);
bool GetAttributeDerived(Enum t, unsigned char a);
std::pair<const char*, int> GetEnumerationIndex(Enum t, const std::string& a);
std::pair<Enum, unsigned> GetInverseAttribute(Enum t, const std::string& a);
std::set<std::string> GetInverseAttributeNames(Enum t);
void PopulateDerivedFields(IfcWrite::IfcWritableEntity* e);
IfcParse_EXPORT int GetAttributeCount(Enum t);
IfcParse_EXPORT int GetAttributeIndex(Enum t, const std::string& a);
IfcParse_EXPORT IfcUtil::ArgumentType GetAttributeType(Enum t, unsigned char a);
IfcParse_EXPORT Enum GetAttributeEntity(Enum t, unsigned char a);
IfcParse_EXPORT const std::string& GetAttributeName(Enum t, unsigned char a);
IfcParse_EXPORT bool GetAttributeOptional(Enum t, unsigned char a);
IfcParse_EXPORT bool GetAttributeDerived(Enum t, unsigned char a);
IfcParse_EXPORT std::pair<const char*, int> GetEnumerationIndex(Enum t, const std::string& a);
IfcParse_EXPORT std::pair<Enum, unsigned> GetInverseAttribute(Enum t, const std::string& a);
IfcParse_EXPORT std::set<std::string> GetInverseAttributeNames(Enum t);
IfcParse_EXPORT void PopulateDerivedFields(IfcWrite::IfcWritableEntity* e);
}}

#endif
Loading