From 4d39dbca2a2f3cd02caf0c92634aea6bbd6eddde Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Wed, 23 Jan 2019 15:10:20 +0100 Subject: [PATCH] Build static cgal, fix null pointer access --- nix/build-all.py | 2 +- src/ifcgeom/schema_agnostic/IfcGeomElement.h | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/nix/build-all.py b/nix/build-all.py index ff5889a622..ff3373bae2 100644 --- a/nix/build-all.py +++ b/nix/build-all.py @@ -660,7 +660,7 @@ if "cgal" in targets: if BUILD_CFG != "Debug": # CGAL only supports Debug and Release for CMAKE_BUILD_TYPE BUILD_CFG = "Release" - build_dependency(name="cgal-{CGAL_VERSION}".format(**locals()), mode="cmake", build_tool_args=["-DGMP_LIBRARIES=%s/install/gmp-%s/lib/libgmp.a" % (DEPS_DIR, GMP_VERSION), "-DGMP_INCLUDE_DIR=%s/install/gmp-%s/include" % (DEPS_DIR, GMP_VERSION), "-DMPFR_LIBRARIES=%s/install/mpfr-%s/lib/libmpfr.a" % (DEPS_DIR, MPFR_VERSION), "-DMPFR_INCLUDE_DIR=%s/install/mpfr-%s/include" % (DEPS_DIR, MPFR_VERSION), "-DBoost_INCLUDE_DIR=%s/install/boost-%s" % (DEPS_DIR, BOOST_VERSION), "-DCMAKE_INSTALL_PREFIX=%s/install/cgal-%s/" % (DEPS_DIR, CGAL_VERSION)], download_url="https://github.com/CGAL/cgal.git", download_name="cgal", download_tool=download_tool_git, revision="releases/CGAL-{CGAL_VERSION}".format(**locals())) + build_dependency(name="cgal-{CGAL_VERSION}".format(**locals()), mode="cmake", build_tool_args=["-DGMP_LIBRARIES=%s/install/gmp-%s/lib/libgmp.a" % (DEPS_DIR, GMP_VERSION), "-DGMP_INCLUDE_DIR=%s/install/gmp-%s/include" % (DEPS_DIR, GMP_VERSION), "-DMPFR_LIBRARIES=%s/install/mpfr-%s/lib/libmpfr.a" % (DEPS_DIR, MPFR_VERSION), "-DMPFR_INCLUDE_DIR=%s/install/mpfr-%s/include" % (DEPS_DIR, MPFR_VERSION), "-DBoost_INCLUDE_DIR=%s/install/boost-%s" % (DEPS_DIR, BOOST_VERSION), "-DCMAKE_INSTALL_PREFIX=%s/install/cgal-%s/" % (DEPS_DIR, CGAL_VERSION), "-DBUILD_SHARED_LIBS=Off"], download_url="https://github.com/CGAL/cgal.git", download_name="cgal", download_tool=download_tool_git, revision="releases/CGAL-{CGAL_VERSION}".format(**locals())) BUILD_CFG = OLD_BUILD_CFG cecho("Building IfcOpenShell:", GREEN) diff --git a/src/ifcgeom/schema_agnostic/IfcGeomElement.h b/src/ifcgeom/schema_agnostic/IfcGeomElement.h index b8ac73eff4..44d885f635 100644 --- a/src/ifcgeom/schema_agnostic/IfcGeomElement.h +++ b/src/ifcgeom/schema_agnostic/IfcGeomElement.h @@ -45,8 +45,10 @@ namespace IfcGeom { // internally in IfcOpenShell everything is measured in meters. for(int i = 1; i < 5; ++i) { for (int j = 1; j < 4; ++j) { - const double trsf_value = trsf->Value(j,i); - const double matrix_value = i == 4 && settings.get(IteratorSettings::CONVERT_BACK_UNITS) + const double trsf_value = (trsf == nullptr) + ? (i == j ? 1. : 0.) + : trsf->Value(j,i); + const double matrix_value = (i == 4 && settings.get(IteratorSettings::CONVERT_BACK_UNITS)) ? trsf_value / settings.unit_magnitude() : trsf_value; _data.push_back(static_cast

(matrix_value)); @@ -65,7 +67,7 @@ namespace IfcGeom { public: Transformation(const ElementSettings& settings, const ConversionResultPlacement* trsf) : settings_(settings) - , trsf_(trsf->clone()) + , trsf_(trsf ? trsf->clone() : nullptr) , matrix_(settings, trsf) {} const ConversionResultPlacement* data() const { return trsf_; }