From f25fb0db51b82a84d6d1d4b3c06ddad2fe9eb8e1 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 3 Aug 2021 13:29:13 +1000 Subject: [PATCH] New hppfcl IfcClash packaged for the BlenderBIM Add-on. New MacOS support. See #1357. --- src/blenderbim/Makefile | 139 ++++++++++++++++-- .../blenderbim/bim/module/clash/operator.py | 23 +-- src/ifcclash/ifcclash/ifcclash.py | 2 +- 3 files changed, 141 insertions(+), 23 deletions(-) diff --git a/src/blenderbim/Makefile b/src/blenderbim/Makefile index 08bb266a63..f6ce39e6af 100644 --- a/src/blenderbim/Makefile +++ b/src/blenderbim/Makefile @@ -1,6 +1,58 @@ VERSION:=`date '+%y%m%d'` PYVERSION:=py37 +ifeq ($(PYVERSION), py37) +PYLIBDIR:=python3.7 +endif +ifeq ($(PYVERSION), py39) +PYLIBDIR:=python3.9 +endif + +ifeq ($(PLATFORM), linux) +ifeq ($(PYVERSION), py37) +HPPFCL_URL:=https://anaconda.org/conda-forge/hpp-fcl/1.7.5/download/linux-64/hpp-fcl-1.7.5-py37h5f1835d_0.tar.bz2 +EIGENPY_URL:=https://anaconda.org/conda-forge/eigenpy/2.6.5/download/linux-64/eigenpy-2.6.5-py37h95e2c48_0.tar.bz2 +BOOST_URL:=https://anaconda.org/conda-forge/boost/1.74.0/download/linux-64/boost-1.74.0-py37h0379df6_3.tar.bz2 +endif +ifeq ($(PYVERSION), py39) +HPPFCL_URL:=https://anaconda.org/conda-forge/hpp-fcl/1.7.5/download/linux-64/hpp-fcl-1.7.5-py39hbcdfc36_0.tar.bz2 +EIGENPY_URL:=https://anaconda.org/conda-forge/eigenpy/2.6.5/download/linux-64/eigenpy-2.6.5-py39h5aed9d1_0.tar.bz2 +BOOST_URL:=https://anaconda.org/conda-forge/boost/1.74.0/download/linux-64/boost-1.74.0-py39h5472131_3.tar.bz2 +endif +ASSIMP_URL:=https://anaconda.org/conda-forge/assimp/5.0.1/download/linux-64/assimp-5.0.1-hedfc422_6.tar.bz2 +OCTOMAP_URL:=https://anaconda.org/conda-forge/octomap/1.9.7/download/linux-64/octomap-1.9.7-h4bd325d_0.tar.bz2 +endif + +ifeq ($(PLATFORM), macos) +ifeq ($(PYVERSION), py37) +HPPFCL_URL:=https://anaconda.org/conda-forge/hpp-fcl/1.7.5/download/osx-64/hpp-fcl-1.7.5-py37h2d7f23a_0.tar.bz2 +EIGENPY_URL:=https://anaconda.org/conda-forge/eigenpy/2.6.5/download/osx-64/eigenpy-2.6.5-py37h0695097_0.tar.bz2 +BOOST_URL:=https://anaconda.org/conda-forge/boost/1.74.0/download/osx-64/boost-1.74.0-py37hd79e0ac_3.tar.bz2 +endif +ifeq ($(PYVERSION), py39) +HPPFCL_URL:=https://anaconda.org/conda-forge/hpp-fcl/1.7.5/download/osx-64/hpp-fcl-1.7.5-py39h1e32b98_0.tar.bz2 +EIGENPY_URL:=https://anaconda.org/conda-forge/eigenpy/2.6.5/download/osx-64/eigenpy-2.6.5-py39h5405915_0.tar.bz2 +BOOST_URL:=https://anaconda.org/conda-forge/boost/1.74.0/download/osx-64/boost-1.74.0-py39ha641261_3.tar.bz2 +endif +ASSIMP_URL:=https://anaconda.org/conda-forge/assimp/5.0.1/download/osx-64/assimp-5.0.1-h1224e73_6.tar.bz2 +OCTOMAP_URL:=https://anaconda.org/conda-forge/octomap/1.9.7/download/osx-64/octomap-1.9.7-h940c156_0.tar.bz2 +endif + +ifeq ($(PLATFORM), win) +ifeq ($(PYVERSION), py37) +HPPFCL_URL:=https://anaconda.org/conda-forge/hpp-fcl/1.7.5/download/win-64/hpp-fcl-1.7.5-py37h839d6b1_0.tar.bz2 +EIGENPY_URL:=https://anaconda.org/conda-forge/eigenpy/2.6.5/download/win-64/eigenpy-2.6.5-py37h2c32e34_0.tar.bz2 +BOOST_URL:=https://anaconda.org/conda-forge/boost/1.74.0/download/win-64/boost-1.74.0-py37h3b38789_3.tar.bz2 +endif +ifeq ($(PYVERSION), py39) +HPPFCL_URL:=https://anaconda.org/conda-forge/hpp-fcl/1.7.5/download/win-64/hpp-fcl-1.7.5-py39h2e7c763_0.tar.bz2 +EIGENPY_URL:=https://anaconda.org/conda-forge/eigenpy/2.6.5/download/win-64/eigenpy-2.6.5-py39h3ce40e6_0.tar.bz2 +BOOST_URL:=https://anaconda.org/conda-forge/boost/1.74.0/download/win-64/boost-1.74.0-py39hefe7e4c_3.tar.bz2 +endif +ASSIMP_URL:=https://anaconda.org/conda-forge/assimp/5.0.1/download/win-64/assimp-5.0.1-hc2aa0de_6.tar.bz2 +OCTOMAP_URL:=https://anaconda.org/conda-forge/octomap/1.9.7/download/win-64/octomap-1.9.7-h5362a0b_0.tar.bz2 +endif + .PHONY: dist dist: ifndef PLATFORM @@ -49,7 +101,7 @@ endif # Provides bcf functionality cp -r dist/working/IfcOpenShell-0.6.0/src/bcf/bcf dist/blenderbim/libs/site/packages/ # Provides IFCClash functionality - cp -r dist/working/IfcOpenShell-0.6.0/src/ifcclash/* dist/blenderbim/libs/site/packages/ + cp -r dist/working/IfcOpenShell-0.6.0/src/ifcclash/ifcclash dist/blenderbim/libs/site/packages/ # Provides BIMTester functionality cd dist/working && python -m venv env cd dist/working && . env/bin/activate && pip install pybabel @@ -174,20 +226,85 @@ endif rm -rf dist/working # Required by IFCClash -ifeq ($(PLATFORM), linux) mkdir dist/working - cd dist/working && wget https://files.pythonhosted.org/packages/0c/fa/00d85f893b02289e2942849d97f8818dde8e2111182e825fb3a735677791/python_fcl-0.0.12-cp37-cp37m-manylinux1_x86_64.whl - cd dist/working && unzip python_fcl* - cp -r dist/working/fcl dist/blenderbim/libs/site/packages/ - rm -rf dist/working + cd dist/working && wget $(HPPFCL_URL) + cd dist/working && tar -xf hpp-fcl* + cp -r dist/working/lib/$(PYLIBDIR)/site-packages/hppfcl dist/blenderbim/libs/site/packages/ +ifeq ($(PLATFORM), linux) + cp -r dist/working/lib/*.so* dist/blenderbim/libs/ +endif +ifeq ($(PLATFORM), macos) + cp -r dist/working/lib/*.dylib dist/blenderbim/libs/ endif ifeq ($(PLATFORM), win) - mkdir dist/working - cd dist/working && wget https://files.pythonhosted.org/packages/19/e6/6e9f33fb59e8f27c0e1592bd26e644bc92b85c942b072b2d3854105d5887/python_fcl_win32-0.0.12.post3-py3-none-win_amd64.whl - cd dist/working && unzip python_fcl* - cp -r dist/working/fcl dist/blenderbim/libs/site/packages/ - rm -rf dist/working + cp -r dist/working/Library/lib/*.lib dist/blenderbim/libs/site/packages/hppfcl/ + cp -r dist/working/Library/bin/*.dll dist/blenderbim/libs/site/packages/hppfcl/ endif + rm -rf dist/working + + # Required by hpp-fcl + mkdir dist/working + cd dist/working && wget $(ASSIMP_URL) + cd dist/working && tar -xf assimp* +ifeq ($(PLATFORM), linux) + cp -r dist/working/lib/*.so* dist/blenderbim/libs/ +endif +ifeq ($(PLATFORM), macos) + cp -r dist/working/lib/*.dylib dist/blenderbim/libs/ +endif +ifeq ($(PLATFORM), win) + cp -r dist/working/Library/bin/*.lib dist/blenderbim/libs/site/packages/hppfcl/ + cp -r dist/working/Library/bin/*.dll dist/blenderbim/libs/site/packages/hppfcl/ +endif + rm -rf dist/working + + # Required by hpp-fcl + mkdir dist/working + cd dist/working && wget $(EIGENPY_URL) + cd dist/working && tar -xf eigenpy* +ifeq ($(PLATFORM), linux) + cp -r dist/working/lib/*.so* dist/blenderbim/libs/ +endif +ifeq ($(PLATFORM), macos) + cp -r dist/working/lib/*.dylib dist/blenderbim/libs/ +endif +ifeq ($(PLATFORM), win) + cp -r dist/working/Library/bin/*.lib dist/blenderbim/libs/site/packages/hppfcl/ + cp -r dist/working/Library/bin/*.dll dist/blenderbim/libs/site/packages/hppfcl/ +endif + rm -rf dist/working + + # Required by hpp-fcl + mkdir dist/working + cd dist/working && wget $(OCTOMAP_URL) + cd dist/working && tar -xf octomap* +ifeq ($(PLATFORM), linux) + cp -r dist/working/lib/*.so* dist/blenderbim/libs/ +endif +ifeq ($(PLATFORM), macos) + cp -r dist/working/lib/*.dylib dist/blenderbim/libs/ +endif +ifeq ($(PLATFORM), win) + cp -r dist/working/Library/bin/*.lib dist/blenderbim/libs/site/packages/hppfcl/ + cp -r dist/working/Library/bin/*.dll dist/blenderbim/libs/site/packages/hppfcl/ +endif + rm -rf dist/working + + # Required by hpp-fcl + mkdir dist/working + cd dist/working && wget $(BOOST_URL) + cd dist/working && tar -xf boost* +ifeq ($(PLATFORM), linux) + cp -r dist/working/lib/*.so* dist/blenderbim/libs/ +endif +ifeq ($(PLATFORM), macos) + cp -r dist/working/lib/*.dylib dist/blenderbim/libs/ +endif +ifeq ($(PLATFORM), win) + cp -r dist/working/Library/bin/*.lib dist/blenderbim/libs/site/packages/hppfcl/ + cp -r dist/working/Library/bin/*.dll dist/blenderbim/libs/site/packages/hppfcl/ +endif + rm -rf dist/working # Required by BIMTester mkdir dist/working diff --git a/src/blenderbim/blenderbim/bim/module/clash/operator.py b/src/blenderbim/blenderbim/bim/module/clash/operator.py index b507a90329..45b9f5cecf 100644 --- a/src/blenderbim/blenderbim/bim/module/clash/operator.py +++ b/src/blenderbim/blenderbim/bim/module/clash/operator.py @@ -186,19 +186,19 @@ class ExecuteIfcClash(bpy.types.Operator): return {"RUNNING_MODAL"} def execute(self, context): - import ifcclash + from ifcclash import ifcclash - settings = ifcclash.IfcClashSettings() + settings = ifcclash.ClashSettings() if ".json" not in self.filepath: self.filepath = bpy.path.ensure_ext(self.filepath, ".bcf") settings.output = self.filepath settings.logger = logging.getLogger("Clash") settings.logger.setLevel(logging.DEBUG) - ifc_clasher = ifcclash.IfcClasher(settings) + clasher = ifcclash.Clasher(settings) if context.scene.BIMClashProperties.should_create_clash_snapshots: - def get_viewpoint_snapshot(self, viewpoint, mat): + def get_viewpoint_snapshot(viewpoint, mat): camera = bpy.data.objects.get("IFC Clash Camera") if not camera: camera = bpy.data.objects.new("IFC Clash Camera", bpy.data.cameras.new("IFC Clash Camera")) @@ -218,9 +218,9 @@ class ExecuteIfcClash(bpy.types.Operator): bpy.ops.render.opengl(write_still=True) return context.scene.render.filepath - ifcclash.IfcClasher.get_viewpoint_snapshot = get_viewpoint_snapshot + clasher.get_viewpoint_snapshot = get_viewpoint_snapshot - ifc_clasher.clash_sets = [] + clasher.clash_sets = [] for clash_set in context.scene.BIMClashProperties.clash_sets: self.a = [] self.b = [] @@ -231,11 +231,12 @@ class ExecuteIfcClash(bpy.types.Operator): clash_source["selector"] = data.selector clash_source["mode"] = data.mode getattr(self, ab).append(clash_source) - ifc_clasher.clash_sets.append( - {"name": clash_set.name, "tolerance": clash_set.tolerance, "a": self.a, "b": self.b} - ) - ifc_clasher.clash() - ifc_clasher.export() + clash_set_data = {"name": clash_set.name, "tolerance": clash_set.tolerance, "a": self.a} + if self.b: + clash_set_data["b"] = self.b + clasher.clash_sets.append(clash_set_data) + clasher.clash() + clasher.export() return {"FINISHED"} diff --git a/src/ifcclash/ifcclash/ifcclash.py b/src/ifcclash/ifcclash/ifcclash.py index 6dd16c12e6..c966311213 100644 --- a/src/ifcclash/ifcclash/ifcclash.py +++ b/src/ifcclash/ifcclash/ifcclash.py @@ -47,7 +47,7 @@ class Clasher: if "b" in clash_set: element2 = self.get_element(clash_set["b"], result["id2"]) else: - element2 = self.get_element(clash_set["1"], result["id2"]) + element2 = self.get_element(clash_set["a"], result["id2"]) contact = result["collision"].getContacts()[0] processed_results[f"{result['id1']}-{result['id2']}"] = {