Last minute refactoring

This commit is contained in:
Thomas Krijnen
2026-08-08 07:42:45 +02:00
parent 8870ffb018
commit af58eaf79f
300 changed files with 5230 additions and 5150 deletions
+33 -33
View File
@@ -8,55 +8,55 @@
namespace pt = boost::property_tree;
static std::map<std::string, ifcopenshell::geometry::taxonomy::style::ptr> default_materials;
static ifcopenshell::geometry::taxonomy::style::ptr default_material;
static std::map<std::string, ifcopenshell::geom::taxonomy::style::ptr> default_materials;
static ifcopenshell::geom::taxonomy::style::ptr default_material;
static bool default_materials_initialized = false;
void InitDefaultMaterials() {
default_materials.insert(std::make_pair("IfcSite", std::make_shared<ifcopenshell::geometry::taxonomy::style>("IfcSite")));
default_materials["IfcSite"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.75, 0.8, 0.65);
default_materials.insert(std::make_pair("IfcSite", std::make_shared<ifcopenshell::geom::taxonomy::style>("IfcSite")));
default_materials["IfcSite"]->diffuse = ifcopenshell::geom::taxonomy::colour(0.75, 0.8, 0.65);
default_materials.insert(std::make_pair("IfcSlab", std::make_shared<ifcopenshell::geometry::taxonomy::style>("IfcSlab")));
default_materials["IfcSlab"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.4, 0.4, 0.4);
default_materials.insert(std::make_pair("IfcSlab", std::make_shared<ifcopenshell::geom::taxonomy::style>("IfcSlab")));
default_materials["IfcSlab"]->diffuse = ifcopenshell::geom::taxonomy::colour(0.4, 0.4, 0.4);
default_materials.insert(std::make_pair("IfcWallStandardCase", std::make_shared<ifcopenshell::geometry::taxonomy::style>("IfcWallStandardCase")));
default_materials["IfcWallStandardCase"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.9, 0.9, 0.9);
default_materials.insert(std::make_pair("IfcWallStandardCase", std::make_shared<ifcopenshell::geom::taxonomy::style>("IfcWallStandardCase")));
default_materials["IfcWallStandardCase"]->diffuse = ifcopenshell::geom::taxonomy::colour(0.9, 0.9, 0.9);
default_materials.insert(std::make_pair("IfcWall", std::make_shared<ifcopenshell::geometry::taxonomy::style>("IfcWall")));
default_materials["IfcWall"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.9, 0.9, 0.9);
default_materials.insert(std::make_pair("IfcWall", std::make_shared<ifcopenshell::geom::taxonomy::style>("IfcWall")));
default_materials["IfcWall"]->diffuse = ifcopenshell::geom::taxonomy::colour(0.9, 0.9, 0.9);
default_materials.insert(std::make_pair("IfcWindow", std::make_shared<ifcopenshell::geometry::taxonomy::style>("IfcWindow")));
default_materials["IfcWindow"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.75, 0.8, 0.75);
default_materials.insert(std::make_pair("IfcWindow", std::make_shared<ifcopenshell::geom::taxonomy::style>("IfcWindow")));
default_materials["IfcWindow"]->diffuse = ifcopenshell::geom::taxonomy::colour(0.75, 0.8, 0.75);
default_materials["IfcWindow"]->transparency = 0.3;
default_materials.insert(std::make_pair("IfcDoor", std::make_shared<ifcopenshell::geometry::taxonomy::style>("IfcDoor")));
default_materials["IfcDoor"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.55, 0.3, 0.15);
default_materials.insert(std::make_pair("IfcDoor", std::make_shared<ifcopenshell::geom::taxonomy::style>("IfcDoor")));
default_materials["IfcDoor"]->diffuse = ifcopenshell::geom::taxonomy::colour(0.55, 0.3, 0.15);
default_materials.insert(std::make_pair("IfcBeam", std::make_shared<ifcopenshell::geometry::taxonomy::style>("IfcBeam")));
default_materials["IfcBeam"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.75, 0.7, 0.7);
default_materials.insert(std::make_pair("IfcBeam", std::make_shared<ifcopenshell::geom::taxonomy::style>("IfcBeam")));
default_materials["IfcBeam"]->diffuse = ifcopenshell::geom::taxonomy::colour(0.75, 0.7, 0.7);
default_materials.insert(std::make_pair("IfcRailing", std::make_shared<ifcopenshell::geometry::taxonomy::style>("IfcRailing")));
default_materials["IfcRailing"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.65, 0.6, 0.6);
default_materials.insert(std::make_pair("IfcRailing", std::make_shared<ifcopenshell::geom::taxonomy::style>("IfcRailing")));
default_materials["IfcRailing"]->diffuse = ifcopenshell::geom::taxonomy::colour(0.65, 0.6, 0.6);
default_materials.insert(std::make_pair("IfcMember", std::make_shared<ifcopenshell::geometry::taxonomy::style>("IfcMember")));
default_materials["IfcMember"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.65, 0.6, 0.6);
default_materials.insert(std::make_pair("IfcMember", std::make_shared<ifcopenshell::geom::taxonomy::style>("IfcMember")));
default_materials["IfcMember"]->diffuse = ifcopenshell::geom::taxonomy::colour(0.65, 0.6, 0.6);
default_materials.insert(std::make_pair("IfcPlate", std::make_shared<ifcopenshell::geometry::taxonomy::style>("IfcPlate")));
default_materials["IfcPlate"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.8, 0.8, 0.8);
default_materials.insert(std::make_pair("IfcPlate", std::make_shared<ifcopenshell::geom::taxonomy::style>("IfcPlate")));
default_materials["IfcPlate"]->diffuse = ifcopenshell::geom::taxonomy::colour(0.8, 0.8, 0.8);
default_materials.insert(std::make_pair("IfcSpace", std::make_shared<ifcopenshell::geometry::taxonomy::style>("IfcSpace")));
default_materials["IfcSpace"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.65, 0.75, 0.8);
default_materials.insert(std::make_pair("IfcSpace", std::make_shared<ifcopenshell::geom::taxonomy::style>("IfcSpace")));
default_materials["IfcSpace"]->diffuse = ifcopenshell::geom::taxonomy::colour(0.65, 0.75, 0.8);
default_materials["IfcSpace"]->transparency = 0.8;
default_material = std::make_shared<ifcopenshell::geometry::taxonomy::style>("DefaultMaterial");
default_material->diffuse = ifcopenshell::geometry::taxonomy::colour(0.7, 0.7, 0.7);
default_material = std::make_shared<ifcopenshell::geom::taxonomy::style>("DefaultMaterial");
default_material->diffuse = ifcopenshell::geom::taxonomy::colour(0.7, 0.7, 0.7);
default_materials_initialized = true;
}
ifcopenshell::geometry::taxonomy::colour read_colour_component(const boost::optional<pt::ptree&> list) {
ifcopenshell::geom::taxonomy::colour read_colour_component(const boost::optional<pt::ptree&> list) {
if (!list) {
return ifcopenshell::geometry::taxonomy::colour();
return ifcopenshell::geom::taxonomy::colour();
}
double rgb[3];
int i = 0;
@@ -70,10 +70,10 @@ ifcopenshell::geometry::taxonomy::colour read_colour_component(const boost::opti
if (i != 3) {
throw std::runtime_error("rgb array less than 3 elements large (was " + std::to_string(i) + ")");
}
return ifcopenshell::geometry::taxonomy::colour(rgb[0], rgb[1], rgb[2]);
return ifcopenshell::geom::taxonomy::colour(rgb[0], rgb[1], rgb[2]);
}
void IfcGeom::set_default_style_file(const std::string& json_file) {
void ifcopenshell::geom::set_default_style_file(const std::string& json_file) {
if (!default_materials_initialized) InitDefaultMaterials();
default_materials.clear();
@@ -83,7 +83,7 @@ void IfcGeom::set_default_style_file(const std::string& json_file) {
for (pt::ptree::value_type &material_pair : root) {
std::string name = material_pair.first;
default_materials.insert(std::make_pair(name, std::make_shared<ifcopenshell::geometry::taxonomy::style>(name)));
default_materials.insert(std::make_pair(name, std::make_shared<ifcopenshell::geom::taxonomy::style>(name)));
pt::ptree material = material_pair.second;
auto diffuse = material.get_child_optional("diffuse");
@@ -112,7 +112,7 @@ void IfcGeom::set_default_style_file(const std::string& json_file) {
}
}
const ifcopenshell::geometry::taxonomy::style::ptr& IfcGeom::get_default_style(const std::string& s) {
const ifcopenshell::geom::taxonomy::style::ptr& ifcopenshell::geom::get_default_style(const std::string& s) {
static std::mutex m;
std::lock_guard<std::mutex> lk(m);
@@ -125,7 +125,7 @@ const ifcopenshell::geometry::taxonomy::style::ptr& IfcGeom::get_default_style(c
return it->second;
}
ifcopenshell::geometry::taxonomy::style::ptr& IfcGeom::update_default_style(const std::string& s) {
ifcopenshell::geom::taxonomy::style::ptr& ifcopenshell::geom::update_default_style(const std::string& s) {
if (!default_materials_initialized) InitDefaultMaterials();
auto it = default_materials.find(s);
if (it == default_materials.end()) {