update_default_style() and default material for IfcSpace

This commit is contained in:
Thomas Krijnen
2020-09-27 16:01:59 +02:00
parent a13e28930a
commit e70d08c3a1
3 changed files with 18 additions and 1 deletions
+1
View File
@@ -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<GeometrySerializer> serializer; /**< @todo use std::unique_ptr when possible */
@@ -96,7 +96,10 @@ namespace IfcGeom {
boost::optional<double>& 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);
}
@@ -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<std::string, IfcGeom::SurfaceStyle>::iterator it = default_materials.find(s);
if (it == default_materials.end()) {
throw std::runtime_error("No style registered for " + s);
}
return it->second;
}