diff --git a/README.md b/README.md index b74232d078..22aa5259b8 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,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 diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index 0d9d0d8ae3..2b840e4240 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -269,6 +269,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 instances 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 " @@ -406,6 +408,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; @@ -644,6 +647,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 || output_extension == SVG); diff --git a/src/ifcgeom/IfcGeom.h b/src/ifcgeom/IfcGeom.h index baf6307e30..87664e7fcd 100644 --- a/src/ifcgeom/IfcGeom.h +++ b/src/ifcgeom/IfcGeom.h @@ -221,7 +221,8 @@ private: double ifc_planeangle_unit; double modelling_precision; double dimensionality; - + double layerset_first; + #ifndef NO_CACHE MAKE_TYPE_NAME(Cache) cache; #endif @@ -259,7 +260,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; } diff --git a/src/ifcgeom/IfcGeomFunctions.cpp b/src/ifcgeom/IfcGeomFunctions.cpp index 8043921d8e..0a5557dc34 100644 --- a/src/ifcgeom/IfcGeomFunctions.cpp +++ b/src/ifcgeom/IfcGeomFunctions.cpp @@ -1317,6 +1317,9 @@ void IfcGeom::Kernel::setValue(GeomValue var, double value) { case GV_MAX_FACES_TO_ORIENT: max_faces_to_orient = value; break; + case GV_LAYERSET_FIRST: + layerset_first = value; + break; default: throw std::runtime_error("Invalid setting"); } @@ -1342,6 +1345,8 @@ double IfcGeom::Kernel::getValue(GeomValue var) const { return dimensionality; case GV_MAX_FACES_TO_ORIENT: return max_faces_to_orient; + case GV_LAYERSET_FIRST: + return layerset_first; } throw std::runtime_error("Invalid setting"); } @@ -1644,11 +1649,11 @@ 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) { + 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/IfcGeomIteratorImplementation.h b/src/ifcgeom/IfcGeomIteratorImplementation.h index e656d9e706..2926999ba4 100644 --- a/src/ifcgeom/IfcGeomIteratorImplementation.h +++ b/src/ifcgeom/IfcGeomIteratorImplementation.h @@ -971,6 +971,12 @@ namespace IfcGeom { kernel.setValue(IfcGeom::Kernel::GV_MAX_FACES_TO_ORIENT, settings.get(IteratorSettings::SEW_SHELLS) ? std::numeric_limits::infinity() : -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 7928d296ec..a78acbd2ef 100644 --- a/src/ifcgeom/IfcGeomIteratorSettings.h +++ b/src/ifcgeom/IfcGeomIteratorSettings.h @@ -86,8 +86,10 @@ namespace IfcGeom BUILDING_LOCAL_PLACEMENT = 1 << 16, /// VALIDATE_QUANTITIES = 1 << 17, + /// Assigns the first layer material to the entire product + LAYERSET_FIRST = 1 << 18, /// Number of different setting flags. - NUM_SETTINGS = 17 + NUM_SETTINGS = 18 }; /// Used to store logical OR combination of setting flags. typedef unsigned SettingField; diff --git a/src/ifcgeom_schema_agnostic/Kernel.h b/src/ifcgeom_schema_agnostic/Kernel.h index 21a76b8fe4..b42f246dff 100644 --- a/src/ifcgeom_schema_agnostic/Kernel.h +++ b/src/ifcgeom_schema_agnostic/Kernel.h @@ -49,7 +49,8 @@ namespace IfcGeom { // 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 }; Kernel(IfcParse::IfcFile* file_ = 0); diff --git a/src/ifcwrap/IfcGeomWrapper.i b/src/ifcwrap/IfcGeomWrapper.i index e81e055597..eb7051ed37 100644 --- a/src/ifcwrap/IfcGeomWrapper.i +++ b/src/ifcwrap/IfcGeomWrapper.i @@ -325,6 +325,11 @@ struct ShapeRTTI : public boost::static_visitor IfcGeom::Kernel kernel(file); kernel.setValue(IfcGeom::Kernel::GV_MAX_FACES_TO_ORIENT, settings.get(IfcGeom::IteratorSettings::SEW_SHELLS) ? std::numeric_limits::infinity() : -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 + ); if (instance->declaration().is(Schema::IfcProduct::Class())) { if (representation) { diff --git a/win/build-deps.cmd b/win/build-deps.cmd index 2f30e1e55b..b0a3a2fc5f 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. @@ -535,3 +542,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.