From 8d40ab92e3b65d20bbebb54b24da1845ffc68c93 Mon Sep 17 00:00:00 2001
From: ifcapps <fabian.gerold@gmail.com>
Date: Tue, 13 May 2025 14:47:08 +0200
Subject: [PATCH] With flatten() and BoolProcess, the color of sub-items gets
 lost. Restore it here

---
 src/cpp/web-ifc/geometry/IfcGeometryProcessor.cpp | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/cpp/web-ifc/geometry/IfcGeometryProcessor.cpp b/src/cpp/web-ifc/geometry/IfcGeometryProcessor.cpp
index a1b559f8..14dbe492 100644
--- a/src/cpp/web-ifc/geometry/IfcGeometryProcessor.cpp
+++ b/src/cpp/web-ifc/geometry/IfcGeometryProcessor.cpp
@@ -290,6 +290,21 @@ namespace webifc::geometry
                     resultMesh.hasColor = false;
                 }
 
+
+				// Sometimes, a geometric item like IFCEXTRUDEDAREASOLID has a color assigned.
+                // With flatten() and BoolProcess, that color gets lost. Restore it here:
+                if (!mesh.hasGeometry && mesh.children.size() > 0)
+                {
+                    auto geometricItem = mesh.children.front();
+                    std::optional<glm::dvec4> geometricItemColor = geometricItem.GetColor();
+                    if (geometricItemColor.has_value())
+                    {
+                        glm::dvec4 colorValue = geometricItemColor.value();
+                        resultMesh.color = colorValue;
+                        resultMesh.hasColor = true;
+                    }
+                }
+
                 return resultMesh;
             }
             else