HdfSerializer::read_surface_style - fill style.instance

E.g. Bonsai is relying on geometry.materials to identify what styles object has and in this case it would skip all styles without entities.
This commit is contained in:
Andrej730
2025-08-07 21:01:18 +05:00
parent 4b7dfcdae5
commit 2855e96e53
2 changed files with 11 additions and 4 deletions
+8 -3
View File
@@ -233,7 +233,9 @@ namespace {
}
}
void HdfSerializer::read_surface_style(surface_style_serialization& s, ifcopenshell::geometry::taxonomy::style& gss) {
void HdfSerializer::read_surface_style(const surface_style_serialization& s,
ifcopenshell::geometry::taxonomy::style& gss,
IfcParse::IfcFile& f) {
if (strlen(s.name) || s.id) {
if (s.diffuse[0] == s.diffuse[0]) {
gss.diffuse = ifcopenshell::geometry::taxonomy::colour(s.diffuse[0], s.diffuse[1], s.diffuse[2]);
@@ -247,6 +249,9 @@ void HdfSerializer::read_surface_style(surface_style_serialization& s, ifcopensh
if (s.specularity == s.specularity) {
gss.specularity = s.specularity;
}
if (s.id != 0) {
gss.instance = f.instance_by_id(s.id)->as<IfcUtil::IfcBaseEntity>();
}
}
}
@@ -355,7 +360,7 @@ IfcGeom::Element* HdfSerializer::read(IfcParse::IfcFile& f, const std::string& g
matrix->components() << Eigen::Map<Eigen::Matrix4d>(&part.matrix[0][0]);
auto style_ptr = ifcopenshell::geometry::taxonomy::make<ifcopenshell::geometry::taxonomy::style>();
read_surface_style(part.surface_style, *style_ptr);
read_surface_style(part.surface_style, *style_ptr, f);
shapes.push_back(IfcGeom::ConversionResult(part.id, matrix, new ifcopenshell::geometry::OpenCascadeShape(shp), style_ptr));
}
@@ -421,7 +426,7 @@ IfcGeom::Element* HdfSerializer::read(IfcParse::IfcFile& f, const std::string& g
for (size_t i = 0; i < surface_styles.size(); ++i) {
surface_style_ptrs[i] = ifcopenshell::geometry::taxonomy::make<ifcopenshell::geometry::taxonomy::style>();
read_surface_style(surface_styles[i], *surface_style_ptrs[i]);
read_surface_style(surface_styles[i], *surface_style_ptrs[i], f);
}
triangulation_geometry = boost::shared_ptr<IfcGeom::Representation::Triangulation>(new IfcGeom::Representation::Triangulation(
+3 -1
View File
@@ -90,7 +90,9 @@ private:
std::map<std::string, std::string> group_cache_;
H5::Group createRepresentationGroup(const H5::Group& element_group, const std::string& gid);
void read_surface_style(surface_style_serialization& serialized_style, ifcopenshell::geometry::taxonomy::style& style);
void read_surface_style(const surface_style_serialization& s,
ifcopenshell::geometry::taxonomy::style& gss,
IfcParse::IfcFile& f);
void write_style(surface_style_serialization& data, const ifcopenshell::geometry::taxonomy::style::ptr& s);
public: