Skip to content

Commit 2a215bb

Browse files
authored
Merge branch 'master' into master
2 parents bf5c985 + 475b855 commit 2a215bb

22 files changed

+1829
-50
lines changed

cmake/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ get_filename_component(libTKernelExt ${libTKernel} EXT)
335335
if("${libTKernelExt}" STREQUAL ".a")
336336
find_package(Threads)
337337
# OPENCASCADE_LIBRARIES repeated three times below in order to fix cyclic dependencies - use --start-group ... --end-group instead?
338-
set(OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
338+
set(OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
339339
if (NOT APPLE AND NOT WIN32)
340340
set(OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARIES} "rt")
341341
endif()

nix/build-all.py

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,20 @@
2424
# #
2525
# Prerequisites for this script to function correctly: #
2626
# * git * bzip2 * tar * c(++) compilers * yacc * autoconf #
27+
# #
28+
# if building with USE_OCCT additionally: #
29+
# * freetype * glx.h #
30+
# #
2731
# on debian 7.8 these can be obtained with: #
2832
# $ apt-get install git gcc g++ autoconf bison bzip2 #
33+
# libfreetype6-dev mesa-common-dev #
34+
# #
2935
# on ubuntu 14.04: #
3036
# $ apt-get install git gcc g++ autoconf bison make #
37+
# libfreetype6-dev mesa-common-dev #
38+
# #
3139
# on OS X El Capitan with homebrew: #
32-
# $ brew install git bison autoconf automake #
40+
# $ brew install git bison autoconf automake freetype #
3341
# #
3442
###############################################################################
3543

@@ -41,6 +49,7 @@
4149
import time
4250
import tarfile
4351
import multiprocessing
52+
import urllib
4453

4554
logger = logging.getLogger(__name__)
4655
logger.setLevel(logging.INFO)
@@ -50,6 +59,8 @@
5059

5160
PROJECT_NAME="IfcOpenShell"
5261
OCE_VERSION="0.18"
62+
OCCT_VERSION="7.1.0"
63+
OCCT_HASH="89aebde"
5364
PYTHON_VERSIONS=["2.7.12", "3.2.6", "3.3.6", "3.4.6", "3.5.3"]
5465
BOOST_VERSION="1.59.0"
5566
PCRE_VERSION="8.39"
@@ -86,7 +97,7 @@
8697

8798
def cecho(message, color=NO_COLOR):
8899
"""Logs message `message` in color `color`."""
89-
logger.info("%s%s\033[0m\n" % (color, message))
100+
logger.info("%s%s\033[0m" % (color, message))
90101

91102
def fullpath(arg):
92103
return os.path.realpath(os.path.dirname(sys.argv[1]))
@@ -131,11 +142,7 @@ def get_os():
131142
BUILD_CFG="RelWithDebInfo"
132143
os.environ["BUILD_CFG"]=BUILD_CFG
133144

134-
try:
135-
BUILD_TYPE=os.environ["BUILD_TYPE"]
136-
except KeyError:
137-
BUILD_TYPE="Build"
138-
os.environ["BUILD_TYPE"] = BUILD_TYPE
145+
USE_OCCT = os.environ.get("USE_OCCT", "false").lower() == "true"
139146

140147
# Print build configuration information
141148

@@ -146,6 +153,11 @@ def get_os():
146153
""", GREEN)
147154
cecho("""* Target Architecture = %s""" % (TARGET_ARCH,), MAGENTA)
148155
cecho(" - Whether 32-bit (i686) or 64-bit (x86_64) will be built.")
156+
cecho("""* USE_OCCT = %r""" % (USE_OCCT,), MAGENTA)
157+
if USE_OCCT:
158+
cecho(" - Compiling against official Open Cascade")
159+
else:
160+
cecho(" - Compiling against Open Cascade Community Edition")
149161
cecho("* Dependency Directory = %s" % (DEPS_DIR,), MAGENTA)
150162
cecho(" - The directory where %s dependencies are installed." % (PROJECT_NAME,))
151163
cecho("* Build Config Type = %s" % (BUILD_CFG,), MAGENTA)
@@ -239,7 +251,7 @@ def run_cmake(arg1, cmake_args, cmake_dir=None, cwd=None):
239251
else:
240252
P=cmake_dir
241253
cmake_path= os.path.join(DEPS_DIR, "install", "cmake-%s" % (CMAKE_VERSION,), "bin", "cmake")
242-
__check_call__([cmake_path, P]+cmake_args+["-DCMAKE_BUILD_TYPE=%s" % (BUILD_TYPE,)], cwd=cwd)
254+
__check_call__([cmake_path, P]+cmake_args+["-DCMAKE_BUILD_TYPE=%s" % (BUILD_CFG,)], cwd=cwd)
243255

244256
def run_icu(arg1, icu_args, cwd):
245257
PLATFORM=get_os()
@@ -261,7 +273,7 @@ def git_clone(clone_url, target_dir, revision=None):
261273
if revision != None:
262274
__check_call__([git, "checkout", revision], cwd=target_dir)
263275

264-
def build_dependency(name, mode, build_tool_args, download_url, download_name, download_tool=download_tool_default, revision=None):
276+
def build_dependency(name, mode, build_tool_args, download_url, download_name, download_tool=download_tool_default, revision=None, additional_files={}):
265277
"""Handles building of dependencies with different tools (which are
266278
distinguished with the `mode` argument. `build_tool_args` is expected to be
267279
a list which is necessary in order to not mess up quoting of compiler and
@@ -292,6 +304,7 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d
292304
else:
293305
raise ValueError("download tool '%s' is not supported" % (download_tool,))
294306
download_dir = os.path.join(build_dir, download_name)
307+
295308
if os.path.isdir(download_dir):
296309
extract_dir_name=download_name
297310
extract_dir = os.path.join(build_dir, extract_dir_name)
@@ -312,6 +325,10 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d
312325
if not os.path.exists(extract_dir):
313326
__check_call__([tar, "-xf", download_name], cwd=build_dir)
314327

328+
for path, url in additional_files.items():
329+
if not os.path.exists(path):
330+
urllib.urlretrieve(url, os.path.join(extract_dir, path))
331+
315332
if mode != "bjam":
316333
extract_build_dir = os.path.join(extract_dir, "build")
317334
if os.path.exists(extract_build_dir):
@@ -420,7 +437,26 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d
420437
# Therefore, build a recent copy from source
421438
build_dependency(name="swig", mode="autoconf", build_tool_args=["--with-pcre-prefix=%s/install/pcre-%s" % (DEPS_DIR, PCRE_VERSION)], download_url="https://github.com/swig/swig.git", download_name="swig", download_tool=download_tool_git, revision="rel-3.0.8")
422439

423-
build_dependency(name="oce-%s" % (OCE_VERSION,), mode="cmake", build_tool_args=["-DOCE_DISABLE_TKSERVICE_FONT=ON", "-DOCE_TESTING=OFF", "-DOCE_BUILD_SHARED_LIB=OFF", "-DOCE_DISABLE_X11=ON", "-DOCE_VISUALISATION=OFF", "-DOCE_OCAF=OFF", "-DOCE_INSTALL_PREFIX=%s/install/oce-%s" % (DEPS_DIR, OCE_VERSION)], download_url="https://github.com/tpaviot/oce/archive/", download_name="OCE-%s.tar.gz" % (OCE_VERSION,))
440+
if USE_OCCT:
441+
long_filename = "src/RWStepVisual/RWStepVisual_RWCharacterizedObjectAndCharacterizedRepresentationAndDraughtingModelAndRepresentation"
442+
occt_gitweb = "http://git.dev.opencascade.org/gitweb/?p=occt.git"
443+
build_dependency(
444+
name="occt-%s" % OCCT_VERSION,
445+
mode="cmake",
446+
build_tool_args=[
447+
"-DINSTALL_DIR=%s/install/occt-%s" % (DEPS_DIR, OCCT_VERSION),
448+
"-DBUILD_LIBRARY_TYPE=Static",
449+
"-DBUILD_MODULE_Draw=0",
450+
],
451+
download_url="%s;a=snapshot;h=%s;sf=tgz" % (occt_gitweb, OCCT_HASH),
452+
additional_files = {
453+
"%s.hxx" % (long_filename): "%s;a=blob_plain;hb=%s;f=%s.hxx" % (occt_gitweb, OCCT_HASH, long_filename),
454+
"%s.cxx" % (long_filename): "%s;a=blob_plain;hb=%s;f=%s.cxx" % (occt_gitweb, OCCT_HASH, long_filename)
455+
},
456+
download_name="occt-%s.tar.gz" % OCCT_HASH)
457+
else:
458+
build_dependency(name="oce-%s" % (OCE_VERSION,), mode="cmake", build_tool_args=["-DOCE_DISABLE_TKSERVICE_FONT=ON", "-DOCE_TESTING=OFF", "-DOCE_BUILD_SHARED_LIB=OFF", "-DOCE_DISABLE_X11=ON", "-DOCE_VISUALISATION=OFF", "-DOCE_OCAF=OFF", "-DOCE_INSTALL_PREFIX=%s/install/oce-%s" % (DEPS_DIR, OCE_VERSION)], download_url="https://github.com/tpaviot/oce/archive/", download_name="OCE-%s.tar.gz" % (OCE_VERSION,))
459+
424460
build_dependency("libxml2-%s" % (LIBXML_VERSION,), "autoconf", build_tool_args=["--without-python", "--disable-shared", "--without-zlib", "--without-iconv", "--without-lzma"], download_url="ftp://xmlsoft.org/libxml2/", download_name="libxml2-%s.tar.gz" % (LIBXML_VERSION,))
425461
build_dependency("OpenCOLLADA", "cmake", build_tool_args=["-DLIBXML2_INCLUDE_DIR=%s/install/libxml2-%s/include/libxml2" % (DEPS_DIR, LIBXML_VERSION), "-DLIBXML2_LIBRARIES=%s/install/libxml2-%s/lib/libxml2.a" % (DEPS_DIR, LIBXML_VERSION), "-DPCRE_INCLUDE_DIR=%s/install/pcre-%s/include" % (DEPS_DIR, PCRE_VERSION), "-DPCRE_PCREPOSIX_LIBRARY=%s/install/pcre-%s/lib/libpcreposix.a" % (DEPS_DIR, PCRE_VERSION), "-DPCRE_PCRE_LIBRARY=%s/install/pcre-%s/lib/libpcre.a" % (DEPS_DIR, PCRE_VERSION), "-DCMAKE_INSTALL_PREFIX=%s/install/OpenCOLLADA/" % (DEPS_DIR,)], download_url="https://github.com/KhronosGroup/OpenCOLLADA.git", download_name="OpenCOLLADA", download_tool=download_tool_git, revision=OPENCOLLADA_COMMIT)
426462

@@ -471,10 +507,17 @@ def PYTHON_VERSION_CONFS():
471507

472508
logger.info("\rConfiguring executables...")
473509

510+
if USE_OCCT:
511+
occ_include_dir = "%s/install/occt-%s/include/opencascade" % (DEPS_DIR, OCCT_VERSION)
512+
occ_library_dir = "%s/install/occt-%s/lib" % (DEPS_DIR, OCCT_VERSION)
513+
else:
514+
occ_include_dir = "%s/install/oce-%s/include/oce" % (DEPS_DIR, OCE_VERSION)
515+
occ_library_dir = "%s/install/oce-%s/lib" % (DEPS_DIR, OCE_VERSION)
516+
474517
run_cmake("", cmake_args=[
475518
"-DBOOST_ROOT=" "%s/install/boost-%s" % (DEPS_DIR, BOOST_VERSION),
476-
"-DOCC_INCLUDE_DIR=" "%s/install/oce-%s/include/oce" % (DEPS_DIR, OCE_VERSION),
477-
"-DOCC_LIBRARY_DIR=" "%s/install/oce-%s/lib" % (DEPS_DIR, OCE_VERSION),
519+
"-DOCC_INCLUDE_DIR=" +occ_include_dir,
520+
"-DOCC_LIBRARY_DIR=" +occ_library_dir,
478521
"-DOPENCOLLADA_INCLUDE_DIR=" "%s/install/OpenCOLLADA/include/opencollada" % (DEPS_DIR,),
479522
"-DOPENCOLLADA_LIBRARY_DIR=" "%s/install/OpenCOLLADA/lib/opencollada" % (DEPS_DIR,),
480523
"-DICU_INCLUDE_DIR=" "%s/install/icu-%s/include" % (DEPS_DIR, ICU_VERSION),
@@ -511,8 +554,8 @@ def PYTHON_VERSION_CONFS():
511554
os.environ["PYTHON_LIBRARY_BASENAME"]=os.path.basename(PYTHON_LIBRARY)
512555

513556
run_cmake("", cmake_args=["-DBOOST_ROOT=%s/install/boost-%s" % (DEPS_DIR, BOOST_VERSION),
514-
"-DOCC_INCLUDE_DIR=%s/install/oce-%s/include/oce" % (DEPS_DIR, OCE_VERSION),
515-
"-DOCC_LIBRARY_DIR=%s/install/oce-%s/lib" % (DEPS_DIR, OCE_VERSION),
557+
"-DOCC_INCLUDE_DIR="+occ_include_dir,
558+
"-DOCC_LIBRARY_DIR="+occ_library_dir,
516559
"-DOPENCOLLADA_INCLUDE_DIR=%s/install/OpenCOLLADA/include/opencollada" % (DEPS_DIR,),
517560
"-DOPENCOLLADA_LIBRARY_DIR=%s/install/OpenCOLLADA/lib/opencollada" % (DEPS_DIR,),
518561
"-DICU_INCLUDE_DIR=%s/install/icu-%s/include" % (DEPS_DIR, ICU_VERSION),

src/ifcconvert/IfcConvert.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,9 @@ int main(int argc, char** argv)
293293
"all placements as an offset. Applicable for OBJ and DAE output.")
294294
("model-offset", po::value<std::string>(&offset_str),
295295
"Applies an arbitrary offset of form 'x;y;z' to all placements. Applicable for OBJ and DAE output.")
296+
("site-local-placement",
297+
"Place elements locally in the IfcSite coordinate system, instead of placing "
298+
"them in the IFC global coords. Applicable for OBJ and DAE output.")
296299
("precision", po::value<short>(&precision)->default_value(SerializerSettings::DEFAULT_PRECISION),
297300
"Sets the precision to be used to format floating-point values, 15 by default. "
298301
"Use a negative value to use the system's default precision (should be 6 typically). "
@@ -364,6 +367,7 @@ int main(int argc, char** argv)
364367
const bool no_normals = vmap.count("no-normals") != 0 ;
365368
const bool center_model = vmap.count("center-model") != 0 ;
366369
const bool model_offset = vmap.count("model-offset") != 0 ;
370+
const bool site_local_placement = vmap.count("site-local-placement") != 0 ;
367371
const bool generate_uvs = vmap.count("generate-uvs") != 0 ;
368372

369373
#ifdef HAVE_ICU
@@ -496,6 +500,7 @@ int main(int argc, char** argv)
496500
settings.set(IfcGeom::IteratorSettings::NO_NORMALS, no_normals);
497501
settings.set(IfcGeom::IteratorSettings::GENERATE_UVS, generate_uvs);
498502
settings.set(IfcGeom::IteratorSettings::SEARCH_FLOOR, use_element_hierarchy);
503+
settings.set(IfcGeom::IteratorSettings::SITE_LOCAL_PLACEMENT, site_local_placement);
499504

500505
settings.set(SerializerSettings::USE_ELEMENT_NAMES, use_element_names);
501506
settings.set(SerializerSettings::USE_ELEMENT_GUIDS, use_element_guids);
@@ -602,6 +607,11 @@ int main(int argc, char** argv)
602607
if (center_model || model_offset) {
603608
double* offset = serializer->settings().offset;
604609
if (center_model) {
610+
if (site_local_placement) {
611+
Logger::Error("Cannot use --center-model together with --site-local-placement");
612+
delete serializer;
613+
return EXIT_FAILURE;
614+
}
605615
gp_XYZ center = (context_iterator.bounds_min() + context_iterator.bounds_max()) * 0.5;
606616
offset[0] = -center.X();
607617
offset[1] = -center.Y();

src/ifcexpressparser/templates.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
} Enum;
7474
IFC_PARSE_API boost::optional<Enum> Parent(Enum v);
7575
IFC_PARSE_API Enum FromString(const std::string& s);
76-
IFC_PARSE_API std::string ToString(Enum v);
76+
IFC_PARSE_API const std::string& ToString(Enum v);
7777
IFC_PARSE_API bool IsSimple(Enum v);
7878
}
7979
@@ -128,9 +128,9 @@
128128
}
129129
}
130130
131-
std::string Type::ToString(Enum v) {
131+
const std::string& Type::ToString(Enum v) {
132132
if (v < 0 || v >= %(max_id)d) throw IfcException("Unable to find find keyword in schema");
133-
const char* names[] = { %(type_name_strings)s };
133+
static std::string names[] = { %(type_name_strings)s };
134134
return names[v];
135135
}
136136

src/ifcgeom/IfcGeom.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ class IFC_GEOM_API Kernel {
9999
std::map<int, SurfaceStyle> style_cache;
100100

101101
const SurfaceStyle* internalize_surface_style(const std::pair<IfcSchema::IfcSurfaceStyle*, IfcSchema::IfcSurfaceStyleShading*>& shading_style);
102+
103+
// For stopping PlacementRelTo recursion in convert(const IfcSchema::IfcObjectPlacement* l, gp_Trsf& trsf)
104+
IfcSchema::Type::Enum placement_rel_to;
105+
102106
public:
103107
Kernel()
104108
: deflection_tolerance(0.001)
@@ -109,6 +113,7 @@ class IFC_GEOM_API Kernel {
109113
, ifc_planeangle_unit(-1.0)
110114
, modelling_precision(0.00001)
111115
, dimensionality(1.)
116+
, placement_rel_to(IfcSchema::Type::UNDEFINED)
112117
{}
113118

114119
Kernel(const Kernel& other) {
@@ -313,6 +318,8 @@ class IFC_GEOM_API Kernel {
313318
#endif
314319
}
315320

321+
void set_conversion_placement_rel_to(IfcSchema::Type::Enum type);
322+
316323
#include "IfcRegisterGeomHeader.h"
317324

318325
};

src/ifcgeom/IfcGeomHelpers.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,10 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcAxis2Placement2D* l, gp_Trsf2d
357357
return true;
358358
}
359359

360+
void IfcGeom::Kernel::set_conversion_placement_rel_to(IfcSchema::Type::Enum type) {
361+
placement_rel_to = type;
362+
}
363+
360364
bool IfcGeom::Kernel::convert(const IfcSchema::IfcObjectPlacement* l, gp_Trsf& trsf) {
361365
IN_CACHE(IfcObjectPlacement,l,gp_Trsf,trsf)
362366
if ( ! l->is(IfcSchema::Type::IfcLocalPlacement) ) {
@@ -372,12 +376,20 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcObjectPlacement* l, gp_Trsf& t
372376
trsf.PreMultiply(trsf2);
373377
}
374378
if ( current->hasPlacementRelTo() ) {
375-
IfcSchema::IfcObjectPlacement* relto = current->PlacementRelTo();
376-
if ( relto->is(IfcSchema::Type::IfcLocalPlacement) )
379+
IfcSchema::IfcObjectPlacement* parent = current->PlacementRelTo();
380+
IfcSchema::IfcProduct::list::ptr parentPlaces = parent->PlacesObject();
381+
bool parentPlacesType = false;
382+
for ( IfcSchema::IfcProduct::list::it iter = parentPlaces->begin();
383+
iter != parentPlaces->end(); ++iter) {
384+
if ( (*iter)->is(placement_rel_to) ) parentPlacesType = true;
385+
}
386+
387+
if ( parentPlacesType ) break;
388+
else if ( parent->is(IfcSchema::Type::IfcLocalPlacement) )
377389
current = (IfcSchema::IfcLocalPlacement*)current->PlacementRelTo();
378-
else break;
390+
else break;
379391
} else break;
380392
}
381393
CACHE(IfcObjectPlacement,l,trsf)
382394
return true;
383-
}
395+
}

src/ifcgeom/IfcGeomIterator.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,9 @@ namespace IfcGeom {
755755
kernel.setValue(IfcGeom::Kernel::GV_MAX_FACES_TO_SEW, settings.get(IteratorSettings::SEW_SHELLS) ? 1000 : -1);
756756
kernel.setValue(IfcGeom::Kernel::GV_DIMENSIONALITY, (settings.get(IteratorSettings::INCLUDE_CURVES)
757757
? (settings.get(IteratorSettings::EXCLUDE_SOLIDS_AND_SURFACES) ? -1. : 0.) : +1.));
758+
if (settings.get(IteratorSettings::SITE_LOCAL_PLACEMENT)) {
759+
kernel.set_conversion_placement_rel_to(IfcSchema::Type::IfcSite);
760+
}
758761
}
759762

760763
bool owns_ifc_file;

src/ifcgeom/IfcGeomIteratorSettings.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ namespace IfcGeom
8080
APPLY_LAYERSETS = 1 << 13,
8181
/// Search for a parent of type IfcBuildingStorey for each representation
8282
SEARCH_FLOOR = 1 << 14,
83+
///
84+
SITE_LOCAL_PLACEMENT = 1 << 15,
8385
/// Number of different setting flags.
84-
NUM_SETTINGS = 14
86+
NUM_SETTINGS = 15
8587
};
8688
/// Used to store logical OR combination of setting flags.
8789
typedef unsigned SettingField;

src/ifcopenshell-python/ifcopenshell/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,4 @@ def create_entity(type,*args,**kwargs):
7070
version = ifcopenshell_wrapper.version()
7171
schema_identifier = ifcopenshell_wrapper.schema_identifier()
7272
get_supertype = ifcopenshell_wrapper.get_supertype
73+
get_log = ifcopenshell_wrapper.get_log

src/ifcparse/Ifc2x3.cpp

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)