From 3a687fecda8a25024bdadf83c073ed81641ae713 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sun, 1 Dec 2024 11:20:37 +0100 Subject: [PATCH] SVG reliance on UseElemHierarchy for storey decomposition --- src/ifcconvert/IfcConvert.cpp | 23 ++++++++++++-------- src/ifcopenshell-python/ifcopenshell/draw.py | 2 ++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index 4b3a139e58..7fdbe148fb 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -815,6 +815,15 @@ int main(int argc, char** argv) { } } + if (geometry_settings.get().get() && output_extension != DAE && output_extension != USD && output_extension != USDA && output_extension != USDC) { + cerr_ << "[Error] --use-element-hierarchy can be used only with .dae or .usd output.\n"; + /// @todo Lots of duplicate error-and-exit code. + write_log(!quiet); + print_usage(); + IfcUtil::path::delete_file(IfcUtil::path::to_utf8(output_temp_filename)); + return EXIT_FAILURE; + } + if (vmap[ifcopenshell::geometry::settings::WeldVertices::name].defaulted()) { geometry_settings.get().value = false; } @@ -831,6 +840,11 @@ int main(int argc, char** argv) { geometry_settings.get().value = ifcopenshell::geometry::settings::TriangulationMethod::POLYHEDRON_WITH_HOLES; } + if (output_extension == SVG) { + // SVG serialiazation depends on element hierarchy now to look up the parent + geometry_settings.get().value = true; + } + boost::shared_ptr serializer; /**< @todo use std::unique_ptr when possible */ if (output_extension == OBJ) { // Do not use temp file for MTL as it's such a small file. @@ -875,15 +889,6 @@ int main(int argc, char** argv) { return EXIT_FAILURE; } - if (geometry_settings.get().get() && output_extension != DAE && output_extension != USD && output_extension != USDA && output_extension != USDC) { - cerr_ << "[Error] --use-element-hierarchy can be used only with .dae or .usd output.\n"; - /// @todo Lots of duplicate error-and-exit code. - write_log(!quiet); - print_usage(); - IfcUtil::path::delete_file(IfcUtil::path::to_utf8(output_temp_filename)); - return EXIT_FAILURE; - } - const bool is_tesselated = serializer->isTesselated(); // isTesselated() doesn't change at run-time if (!is_tesselated) { if (geometry_settings.get().get()) { diff --git a/src/ifcopenshell-python/ifcopenshell/draw.py b/src/ifcopenshell-python/ifcopenshell/draw.py index 1c35c9f14e..200da97bb9 100644 --- a/src/ifcopenshell-python/ifcopenshell/draw.py +++ b/src/ifcopenshell-python/ifcopenshell/draw.py @@ -86,6 +86,8 @@ def main( geom_settings = ifcopenshell.geom.settings( # when not doing booleans, proper solids from shells isn't a requirement REORIENT_SHELLS=settings.subtract_before_hlr, + # SVG serialiazation depends on element hierarchy now to look up the parent + ELEMENT_HIERARCHY=True, ) # this is required for serialization