From 86d7205760bb9657183329442a48268d9488c2cf Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sun, 7 Jun 2020 19:46:10 +0200 Subject: [PATCH] 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)) {