diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index c3eb82e2c9..f5f6c44346 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -737,6 +737,7 @@ int main(int argc, char** argv) { if (vmap.count("force-space-transparency")) { settings.force_space_transparency(force_space_transparency); + IfcGeom::update_default_style("IfcSpace").Transparency().reset(force_space_transparency); } boost::shared_ptr serializer; /**< @todo use std::unique_ptr when possible */ diff --git a/src/ifcgeom_schema_agnostic/IfcGeomRenderStyles.h b/src/ifcgeom_schema_agnostic/IfcGeomRenderStyles.h index 2154fe24b4..33971f7182 100644 --- a/src/ifcgeom_schema_agnostic/IfcGeomRenderStyles.h +++ b/src/ifcgeom_schema_agnostic/IfcGeomRenderStyles.h @@ -96,7 +96,10 @@ namespace IfcGeom { boost::optional& Specularity() { return specularity; } }; - IFC_GEOM_API const SurfaceStyle* get_default_style(const std::string& ifc_type); + IFC_GEOM_API const SurfaceStyle* get_default_style(const std::string& ifc_type); + + IFC_GEOM_API SurfaceStyle& update_default_style(const std::string& ifc_type); + IFC_GEOM_API void set_default_style_file(const std::string& json_file); } diff --git a/src/ifcgeom_schema_agnostic/SurfaceStyle.cpp b/src/ifcgeom_schema_agnostic/SurfaceStyle.cpp index 10c2335ff3..6760b20a6d 100644 --- a/src/ifcgeom_schema_agnostic/SurfaceStyle.cpp +++ b/src/ifcgeom_schema_agnostic/SurfaceStyle.cpp @@ -43,6 +43,10 @@ void InitDefaultMaterials() { default_materials.insert(std::make_pair("IfcPlate", IfcGeom::SurfaceStyle("IfcPlate"))); default_materials["IfcPlate"].Diffuse().reset(IfcGeom::SurfaceStyle::ColorComponent(0.8, 0.8, 0.8)); + default_materials.insert(std::make_pair("IfcSpace", IfcGeom::SurfaceStyle("IfcSpace"))); + default_materials["IfcWindow"].Diffuse().reset(IfcGeom::SurfaceStyle::ColorComponent(0.65, 0.75, 0.8)); + default_materials["IfcWindow"].Transparency().reset(0.8); + default_material = IfcGeom::SurfaceStyle("DefaultMaterial"); default_material.Diffuse().reset(IfcGeom::SurfaceStyle::ColorComponent(0.7, 0.7, 0.7)); @@ -121,3 +125,12 @@ const IfcGeom::SurfaceStyle* IfcGeom::get_default_style(const std::string& s) { const IfcGeom::SurfaceStyle& surface_style = it->second; return &surface_style; } + +IfcGeom::SurfaceStyle& IfcGeom::update_default_style(const std::string& s) { + if (!default_materials_initialized) InitDefaultMaterials(); + std::map::iterator it = default_materials.find(s); + if (it == default_materials.end()) { + throw std::runtime_error("No style registered for " + s); + } + return it->second; +}