From 9cab063671e2aeec58d4051310a9038d59e8927a Mon Sep 17 00:00:00 2001 From: AlaaB2020 <56257353+AlaaB2020@users.noreply.github.com> Date: Mon, 24 Feb 2020 13:08:21 +0200 Subject: [PATCH 1/6] Update IfcGeomFunctions.cpp get the first material even if there are more than one material layer --- src/ifcgeom/IfcGeomFunctions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ifcgeom/IfcGeomFunctions.cpp b/src/ifcgeom/IfcGeomFunctions.cpp index de263b3755..e5e3fdfe64 100644 --- a/src/ifcgeom/IfcGeomFunctions.cpp +++ b/src/ifcgeom/IfcGeomFunctions.cpp @@ -1422,7 +1422,7 @@ const IfcSchema::IfcMaterial* IfcGeom::Kernel::get_single_material_association(c // in accordance with other viewers. if (!single_material && associated_material->as()) { IfcSchema::IfcMaterialLayerSet* layerset = associated_material->as()->ForLayerSet(); - if (layerset->MaterialLayers()->size() == 1) { + if (layerset->MaterialLayers()->size() >= 1) { IfcSchema::IfcMaterialLayer* layer = (*layerset->MaterialLayers()->begin()); if (layer->hasMaterial()) { single_material = layer->Material(); From 9f2443e01c2d5ff0d386694fcc6f2bc3ac6d8dfc Mon Sep 17 00:00:00 2001 From: AlaaB2020 <56257353+AlaaB2020@users.noreply.github.com> Date: Wed, 26 Feb 2020 10:42:23 +0200 Subject: [PATCH 2/6] Update IfcGeomFunctions.cpp Changing comment to be suitable for the code change --- src/ifcgeom/IfcGeomFunctions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ifcgeom/IfcGeomFunctions.cpp b/src/ifcgeom/IfcGeomFunctions.cpp index e5e3fdfe64..2dc3017828 100644 --- a/src/ifcgeom/IfcGeomFunctions.cpp +++ b/src/ifcgeom/IfcGeomFunctions.cpp @@ -1418,8 +1418,8 @@ const IfcSchema::IfcMaterial* IfcGeom::Kernel::get_single_material_association(c IfcSchema::IfcMaterialSelect* associated_material = (*associated_materials->begin())->RelatingMaterial(); single_material = associated_material->as(); - // NB: Single-layer layersets are also considered, regardless of --enable-layerset-slicing, this - // in accordance with other viewers. + // NB: IfcMaterialLayerSets are also considered, regardless of --enable-layerset-slicing. Picking + // the first material (in accordance with other viewers) when layerset-slicing is disabled. if (!single_material && associated_material->as()) { IfcSchema::IfcMaterialLayerSet* layerset = associated_material->as()->ForLayerSet(); if (layerset->MaterialLayers()->size() >= 1) { From 3c355b4848e939fdb3da7872a1bcbb60d76ef11b Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sun, 8 Mar 2020 10:13:35 +0100 Subject: [PATCH 3/6] Add py38 to nix build --- nix/build-all.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/build-all.py b/nix/build-all.py index 4fdfba5f8a..8bb800444e 100644 --- a/nix/build-all.py +++ b/nix/build-all.py @@ -64,7 +64,7 @@ PROJECT_NAME="IfcOpenShell" OCE_VERSION="0.18" # OCCT_VERSION="7.1.0" # OCCT_HASH="89aebde" -PYTHON_VERSIONS=["2.7.16", "3.2.6", "3.3.6", "3.4.6", "3.5.3", "3.6.2", "3.7.3"] +PYTHON_VERSIONS=["2.7.16", "3.2.6", "3.3.6", "3.4.6", "3.5.3", "3.6.2", "3.7.3", "3.8.2"] # OCCT_VERSION="7.2.0" # OCCT_HASH="88af392" OCCT_VERSION="7.3.0p3" From 7e6ebbebe04a76229d364d0231777566532a7d4a Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Wed, 25 Mar 2020 14:09:22 +0100 Subject: [PATCH 4/6] Update docs in accordance with #804 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 59c3289221..61aec8828a 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,8 @@ Instructions in a nutshell (**assuming Visual Studio 2015 x64 environment variab > build-deps.cmd > run-cmake.bat +NB: `build-deps.cmd` need to be ran from the directory containing it, i.e. the `./win` folder. + You can now open and build the solution file in Visual Studio: > ..\build-vs2015-x64\IfcOpenShell.sln From 8625aab5f0c2c4752eb10ad20daee744547b377e Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Wed, 25 Mar 2020 14:20:47 +0100 Subject: [PATCH 5/6] Check CWD in builds-deps.cmd #804 --- win/build-deps.cmd | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/win/build-deps.cmd b/win/build-deps.cmd index d04e9e6c47..31adbedd6f 100644 --- a/win/build-deps.cmd +++ b/win/build-deps.cmd @@ -24,6 +24,13 @@ @echo off echo. +for %%Q in ("%~dp0\.") DO set "batpath=%%~fQ" + +if NOT "%CD%" == "%batpath%" ( + GOTO :ErrorAndPrintUsage +) + + set PROJECT_NAME=IfcOpenShell call utils\cecho.cmd 15 0 "This script fetches and builds all %PROJECT_NAME% dependencies" echo. @@ -562,3 +569,5 @@ echo - https://www.visualstudio.com/ echo 5. Run this batch script with Visual Studio environment variables set. echo - https://msdn.microsoft.com/en-us/library/ms229859(v=vs.110).aspx echo. +echo NB: This script needs to be ran from the directory directly containing it. +echo. From 86d7205760bb9657183329442a48268d9488c2cf Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sun, 7 Jun 2020 19:46:10 +0200 Subject: [PATCH 6/6] layerset-first setting --- src/ifcconvert/IfcConvert.cpp | 4 ++++ src/ifcgeom/IfcGeom.h | 6 ++++-- src/ifcgeom/IfcGeomFunctions.cpp | 8 +++++++- src/ifcgeom/IfcGeomIterator.h | 6 ++++++ src/ifcgeom/IfcGeomIteratorSettings.h | 4 +++- src/ifcwrap/IfcGeomWrapper.i | 6 ++++++ 6 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index c9ea8bdddc..7fd0379ffb 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -255,6 +255,8 @@ int main(int argc, char** argv) { ("enable-layerset-slicing", "Specifies whether to enable the slicing of products according " "to their associated IfcMaterialLayerSet.") + ("layerset-first", "Assigns the first layer material of the layerset " + "to the complete product.") ("include", po::value(&include_filter)->multitoken(), "Specifies that the entities that match a specific filtering criteria are to be included in the geometrical output:\n" "1) 'entities': the following list of types should be included. SVG output defaults " @@ -390,6 +392,7 @@ int main(int argc, char** argv) { const bool include_plan = vmap.count("plan") != 0; const bool include_model = vmap.count("model") != 0 || (!include_plan); const bool enable_layerset_slicing = vmap.count("enable-layerset-slicing") != 0; + const bool layerset_first = vmap.count("layerset-first") != 0; const bool use_element_names = vmap.count("use-element-names") != 0; const bool use_element_guids = vmap.count("use-element-guids") != 0; const bool use_material_names = vmap.count("use-material-names") != 0; @@ -603,6 +606,7 @@ int main(int argc, char** argv) { settings.set(IfcGeom::IteratorSettings::INCLUDE_CURVES, include_plan); settings.set(IfcGeom::IteratorSettings::EXCLUDE_SOLIDS_AND_SURFACES, !include_model); settings.set(IfcGeom::IteratorSettings::APPLY_LAYERSETS, enable_layerset_slicing); + settings.set(IfcGeom::IteratorSettings::LAYERSET_FIRST, layerset_first); settings.set(IfcGeom::IteratorSettings::NO_NORMALS, no_normals); settings.set(IfcGeom::IteratorSettings::GENERATE_UVS, generate_uvs); settings.set(IfcGeom::IteratorSettings::SEARCH_FLOOR, use_element_hierarchy); diff --git a/src/ifcgeom/IfcGeom.h b/src/ifcgeom/IfcGeom.h index 13dc5acba8..d267a4beec 100644 --- a/src/ifcgeom/IfcGeom.h +++ b/src/ifcgeom/IfcGeom.h @@ -108,6 +108,7 @@ private: double ifc_planeangle_unit; double modelling_precision; double dimensionality; + double layerset_first; #ifndef NO_CACHE Cache cache; @@ -146,7 +147,7 @@ public: setValue(GV_PLANEANGLE_UNIT, other.getValue(GV_PLANEANGLE_UNIT)); setValue(GV_PRECISION, other.getValue(GV_PRECISION)); setValue(GV_DIMENSIONALITY, other.getValue(GV_DIMENSIONALITY)); - setValue(GV_DEFLECTION_TOLERANCE, other.getValue(GV_DEFLECTION_TOLERANCE)); + setValue(GV_LAYERSET_FIRST, other.getValue(GV_LAYERSET_FIRST)); return *this; } @@ -181,7 +182,8 @@ public: // Default: 0.00001 (obtained from IfcGeometricRepresentationContext if available) GV_PRECISION, // Whether to process shapes of type Face or higher (1) Wire or lower (-1) or all (0) - GV_DIMENSIONALITY + GV_DIMENSIONALITY, + GV_LAYERSET_FIRST }; bool convert_wire_to_face(const TopoDS_Wire& wire, TopoDS_Face& face); diff --git a/src/ifcgeom/IfcGeomFunctions.cpp b/src/ifcgeom/IfcGeomFunctions.cpp index 2dc3017828..47aaa30959 100644 --- a/src/ifcgeom/IfcGeomFunctions.cpp +++ b/src/ifcgeom/IfcGeomFunctions.cpp @@ -1084,6 +1084,9 @@ void IfcGeom::Kernel::setValue(GeomValue var, double value) { case GV_DIMENSIONALITY: dimensionality = value; break; + case GV_LAYERSET_FIRST: + layerset_first = value; + break; default: assert(!"never reach here"); } @@ -1115,6 +1118,9 @@ double IfcGeom::Kernel::getValue(GeomValue var) const { case GV_DIMENSIONALITY: return dimensionality; break; + case GV_LAYERSET_FIRST: + return layerset_first; + break; } assert(!"never reach here"); return 0; @@ -1422,7 +1428,7 @@ const IfcSchema::IfcMaterial* IfcGeom::Kernel::get_single_material_association(c // the first material (in accordance with other viewers) when layerset-slicing is disabled. if (!single_material && associated_material->as()) { IfcSchema::IfcMaterialLayerSet* layerset = associated_material->as()->ForLayerSet(); - if (layerset->MaterialLayers()->size() >= 1) { + if (getValue(GV_LAYERSET_FIRST) > 0.0 ? layerset->MaterialLayers()->size() >= 1 : layerset->MaterialLayers()->size() == 1) { IfcSchema::IfcMaterialLayer* layer = (*layerset->MaterialLayers()->begin()); if (layer->hasMaterial()) { single_material = layer->Material(); diff --git a/src/ifcgeom/IfcGeomIterator.h b/src/ifcgeom/IfcGeomIterator.h index 1451976048..0a322b2b46 100644 --- a/src/ifcgeom/IfcGeomIterator.h +++ b/src/ifcgeom/IfcGeomIterator.h @@ -712,6 +712,12 @@ namespace IfcGeom { kernel.setValue(IfcGeom::Kernel::GV_MAX_FACES_TO_SEW, settings.get(IteratorSettings::SEW_SHELLS) ? 1000 : -1); kernel.setValue(IfcGeom::Kernel::GV_DIMENSIONALITY, (settings.get(IteratorSettings::INCLUDE_CURVES) ? (settings.get(IteratorSettings::EXCLUDE_SOLIDS_AND_SURFACES) ? -1. : 0.) : +1.)); + kernel.setValue(IfcGeom::Kernel::GV_LAYERSET_FIRST, + settings.get(IteratorSettings::LAYERSET_FIRST) + ? +1.0 + : -1.0 + ); + if (settings.get(IteratorSettings::BUILDING_LOCAL_PLACEMENT)) { if (settings.get(IteratorSettings::SITE_LOCAL_PLACEMENT)) { Logger::Message(Logger::LOG_WARNING, "building-local-placement takes precedence over site-local-placement"); diff --git a/src/ifcgeom/IfcGeomIteratorSettings.h b/src/ifcgeom/IfcGeomIteratorSettings.h index 8a601c4e55..93d54dd40a 100644 --- a/src/ifcgeom/IfcGeomIteratorSettings.h +++ b/src/ifcgeom/IfcGeomIteratorSettings.h @@ -84,8 +84,10 @@ namespace IfcGeom SITE_LOCAL_PLACEMENT = 1 << 15, /// BUILDING_LOCAL_PLACEMENT = 1 << 16, + /// Assigns the first layer material to the entire product + LAYERSET_FIRST = 1 << 17, /// Number of different setting flags. - NUM_SETTINGS = 16 + NUM_SETTINGS = 17 }; /// Used to store logical OR combination of setting flags. typedef unsigned SettingField; diff --git a/src/ifcwrap/IfcGeomWrapper.i b/src/ifcwrap/IfcGeomWrapper.i index be0d37ae39..a8480b1f48 100644 --- a/src/ifcwrap/IfcGeomWrapper.i +++ b/src/ifcwrap/IfcGeomWrapper.i @@ -301,6 +301,12 @@ struct ShapeRTTI : public boost::static_visitor IfcGeom::Kernel kernel; kernel.setValue(IfcGeom::Kernel::GV_MAX_FACES_TO_SEW, settings.get(IfcGeom::IteratorSettings::SEW_SHELLS) ? 1000 : -1); kernel.setValue(IfcGeom::Kernel::GV_DIMENSIONALITY, (settings.get(IfcGeom::IteratorSettings::INCLUDE_CURVES) ? (settings.get(IfcGeom::IteratorSettings::EXCLUDE_SOLIDS_AND_SURFACES) ? -1. : 0.) : +1.)); + kernel.setValue(IfcGeom::Kernel::GV_LAYERSET_FIRST, + settings.get(IteratorSettings::LAYERSET_FIRST) + ? +1.0 + : -1.0 + ); + std::pair length_unit = kernel.initializeUnits(project->UnitsInContext()); if (instance->is(IfcSchema::Type::IfcProduct)) {