MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / read_colour_component

Function read_colour_component

src/ifcgeom/SurfaceStyle.cpp:57–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57ifcopenshell::geometry::taxonomy::colour read_colour_component(const boost::optional<pt::ptree&> list) {
58 if (!list) {
59 return ifcopenshell::geometry::taxonomy::colour();
60 }
61 double rgb[3];
62 int i = 0;
63 for (pt::ptree::value_type &colour : list.get()) {
64 if (3 <= i) {
65 throw std::runtime_error("rgb array over 3 elements large");
66 }
67 rgb[i] = colour.second.get_value<double>();
68 i++;
69 }
70 if (i != 3) {
71 throw std::runtime_error("rgb array less than 3 elements large (was " + std::to_string(i) + ")");
72 }
73 return ifcopenshell::geometry::taxonomy::colour(rgb[0], rgb[1], rgb[2]);
74}
75
76void IfcGeom::set_default_style_file(const std::string& json_file) {
77 if (!default_materials_initialized) InitDefaultMaterials();

Callers 1

Calls 2

to_stringFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected