diff --git a/src/ifcgeom/IfcGeomRenderStyles.h b/src/ifcgeom/IfcGeomRenderStyles.h index 01b4515b5f..2486f2c9dc 100644 --- a/src/ifcgeom/IfcGeomRenderStyles.h +++ b/src/ifcgeom/IfcGeomRenderStyles.h @@ -31,9 +31,9 @@ #include namespace IfcGeom { - IFC_GEOM_API const ifcopenshell::geometry::taxonomy::style& get_default_style(const std::string& ifc_type); + IFC_GEOM_API const ifcopenshell::geometry::taxonomy::style::ptr& get_default_style(const std::string& ifc_type); - IFC_GEOM_API ifcopenshell::geometry::taxonomy::style& update_default_style(const std::string& ifc_type); + IFC_GEOM_API ifcopenshell::geometry::taxonomy::style::ptr& 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/IfcGeomRepresentation.cpp b/src/ifcgeom/IfcGeomRepresentation.cpp index 7678d0d28c..89eb2bdd6b 100644 --- a/src/ifcgeom/IfcGeomRepresentation.cpp +++ b/src/ifcgeom/IfcGeomRepresentation.cpp @@ -334,10 +334,10 @@ IfcGeom::Representation::Triangulation::Triangulation(const BRep& shape_model) int surface_style_id = -1; if (iit->hasStyle()) { - auto jt = std::find(_materials.begin(), _materials.end(), iit->Style()); + auto jt = std::find(_materials.begin(), _materials.end(), iit->StylePtr()); if (jt == _materials.end()) { surface_style_id = (int)_materials.size(); - _materials.push_back(iit->Style()); + _materials.push_back(iit->StylePtr()); } else { surface_style_id = (int)(jt - _materials.begin()); } diff --git a/src/ifcgeom/IfcGeomRepresentation.h b/src/ifcgeom/IfcGeomRepresentation.h index 07f6962110..a52953d602 100644 --- a/src/ifcgeom/IfcGeomRepresentation.h +++ b/src/ifcgeom/IfcGeomRepresentation.h @@ -108,7 +108,7 @@ namespace IfcGeom { std::vector _normals; std::vector uvs_; std::vector _material_ids; - std::vector _materials; + std::vector _materials; std::vector _item_ids; size_t weld_offset_; VertexKeyMap welds; @@ -127,7 +127,7 @@ namespace IfcGeom { std::vector& uvs() { return uvs_; } const std::vector& uvs() const { return uvs_; } const std::vector& material_ids() const { return _material_ids; } - const std::vector& materials() const { return _materials; } + const std::vector& materials() const { return _materials; } const std::vector& item_ids() const { return _item_ids; } Triangulation(const BRep& shape_model); @@ -142,7 +142,7 @@ namespace IfcGeom { const std::vector& normals, const std::vector& uvs, const std::vector& material_ids, - const std::vector& materials, + const std::vector& materials, const std::vector& item_ids ) : Representation(settings, entity) diff --git a/src/ifcgeom/SurfaceStyle.cpp b/src/ifcgeom/SurfaceStyle.cpp index badbd4b687..3d862b4825 100644 --- a/src/ifcgeom/SurfaceStyle.cpp +++ b/src/ifcgeom/SurfaceStyle.cpp @@ -8,48 +8,48 @@ namespace pt = boost::property_tree; -static std::map default_materials; -static ifcopenshell::geometry::taxonomy::style default_material; +static std::map default_materials; +static ifcopenshell::geometry::taxonomy::style::ptr default_material; static bool default_materials_initialized = false; void InitDefaultMaterials() { - default_materials.insert(std::make_pair("IfcSite", 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("IfcSite"))); + default_materials["IfcSite"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.75, 0.8, 0.65); - default_materials.insert(std::make_pair("IfcSlab", 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("IfcSlab"))); + default_materials["IfcSlab"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.4, 0.4, 0.4); - default_materials.insert(std::make_pair("IfcWallStandardCase", 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("IfcWallStandardCase"))); + default_materials["IfcWallStandardCase"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.9, 0.9, 0.9); - default_materials.insert(std::make_pair("IfcWall", 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("IfcWall"))); + default_materials["IfcWall"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.9, 0.9, 0.9); - default_materials.insert(std::make_pair("IfcWindow", ifcopenshell::geometry::taxonomy::style("IfcWindow"))); - default_materials["IfcWindow"].diffuse = ifcopenshell::geometry::taxonomy::colour(0.75, 0.8, 0.75); - default_materials["IfcWindow"].transparency = 0.3; + default_materials.insert(std::make_pair("IfcWindow", std::make_shared("IfcWindow"))); + default_materials["IfcWindow"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.75, 0.8, 0.75); + default_materials["IfcWindow"]->transparency = 0.3; - default_materials.insert(std::make_pair("IfcDoor", 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("IfcDoor"))); + default_materials["IfcDoor"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.55, 0.3, 0.15); - default_materials.insert(std::make_pair("IfcBeam", 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("IfcBeam"))); + default_materials["IfcBeam"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.75, 0.7, 0.7); - default_materials.insert(std::make_pair("IfcRailing", 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("IfcRailing"))); + default_materials["IfcRailing"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.65, 0.6, 0.6); - default_materials.insert(std::make_pair("IfcMember", 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("IfcMember"))); + default_materials["IfcMember"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.65, 0.6, 0.6); - default_materials.insert(std::make_pair("IfcPlate", 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("IfcPlate"))); + default_materials["IfcPlate"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.8, 0.8, 0.8); - default_materials.insert(std::make_pair("IfcSpace", ifcopenshell::geometry::taxonomy::style("IfcSpace"))); - default_materials["IfcSpace"].diffuse = ifcopenshell::geometry::taxonomy::colour(0.65, 0.75, 0.8); - default_materials["IfcSpace"].transparency = 0.8; + default_materials.insert(std::make_pair("IfcSpace", std::make_shared("IfcSpace"))); + default_materials["IfcSpace"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.65, 0.75, 0.8); + default_materials["IfcSpace"]->transparency = 0.8; - default_material = ifcopenshell::geometry::taxonomy::style("DefaultMaterial"); - default_material.diffuse = ifcopenshell::geometry::taxonomy::colour(0.7, 0.7, 0.7); + default_material = std::make_shared("DefaultMaterial"); + default_material->diffuse = ifcopenshell::geometry::taxonomy::colour(0.7, 0.7, 0.7); default_materials_initialized = true; } @@ -83,20 +83,20 @@ 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, ifcopenshell::geometry::taxonomy::style(name))); + default_materials.insert(std::make_pair(name, std::make_shared(name))); pt::ptree material = material_pair.second; boost::optional diffuse = material.get_child_optional("diffuse"); - default_materials[name].diffuse = read_colour_component(diffuse); + default_materials[name]->diffuse = read_colour_component(diffuse); boost::optional specular = material.get_child_optional("specular"); - default_materials[name].specular = read_colour_component(specular); + default_materials[name]->specular = read_colour_component(specular); if (material.get_child_optional("specular-roughness")) { - default_materials[name].specularity = 1.0 / material.get("specular-roughness"); + default_materials[name]->specularity = 1.0 / material.get("specular-roughness"); } if (material.get_child_optional("transparency")) { - default_materials[name].transparency = material.get("transparency"); + default_materials[name]->transparency = material.get("transparency"); } } @@ -108,7 +108,7 @@ void IfcGeom::set_default_style_file(const std::string& json_file) { } } -const ifcopenshell::geometry::taxonomy::style& IfcGeom::get_default_style(const std::string& s) { +const ifcopenshell::geometry::taxonomy::style::ptr& IfcGeom::get_default_style(const std::string& s) { static std::mutex m; std::lock_guard lk(m); @@ -121,7 +121,7 @@ const ifcopenshell::geometry::taxonomy::style& IfcGeom::get_default_style(const return it->second; } -ifcopenshell::geometry::taxonomy::style& IfcGeom::update_default_style(const std::string& s) { +ifcopenshell::geometry::taxonomy::style::ptr& IfcGeom::update_default_style(const std::string& s) { if (!default_materials_initialized) InitDefaultMaterials(); auto it = default_materials.find(s); if (it == default_materials.end()) { diff --git a/src/ifcwrap/IfcGeomWrapper.i b/src/ifcwrap/IfcGeomWrapper.i index cc9b37fb15..ea4d637356 100644 --- a/src/ifcwrap/IfcGeomWrapper.i +++ b/src/ifcwrap/IfcGeomWrapper.i @@ -40,8 +40,6 @@ } } -%template(material_vector) std::vector; - // SWIG does not support bool references in a meaningful way, so the // ifcopenshell::geometry::Settings functions degrade to return a read only value %typemap(out) double& { @@ -198,6 +196,8 @@ std::string taxonomy_item_repr(ifcopenshell::geometry::taxonomy::item::ptr i) { %include "../serializers/XmlSerializer.h" %include "../serializers/GltfSerializer.h" +%template(material_vector) std::vector; + %extend ifcopenshell::geometry::taxonomy::style { size_t instance_id() const { // @todo for some reason we have the IfcStyledItem/IfcMaterial here, but @@ -529,7 +529,8 @@ struct ShapeRTTI : public boost::static_visitor PyObject* colors_buffer() const { std::vector clrs; clrs.reserve(self->materials().size() * 4); - for (auto& m : self->materials()) { + for (auto& mptr : self->materials()) { + auto& m = *mptr; if (m.diffuse) { clrs.push_back(m.diffuse.ccomponents()[0]); clrs.push_back(m.diffuse.ccomponents()[1]); diff --git a/src/serializers/ColladaSerializer.cpp b/src/serializers/ColladaSerializer.cpp index e2bf3af474..b77a3c369c 100644 --- a/src/serializers/ColladaSerializer.cpp +++ b/src/serializers/ColladaSerializer.cpp @@ -66,7 +66,7 @@ void ColladaSerializer::ColladaExporter::ColladaGeometries::write( const std::string &mesh_id, const std::string &/**<@todo 'default_material_name' unused, remove? */, const std::vector& positions, const std::vector& normals, const std::vector& faces, const std::vector& edges, - const std::vector& material_ids, const std::vector& /**<@todo 'materials' unused, remove? */, + const std::vector& material_ids, const std::vector& /**<@todo 'materials' unused, remove? */, const std::vector& uvs, const std::vector& material_references) { openMesh(mesh_id); @@ -302,24 +302,24 @@ void ColladaSerializer::ColladaExporter::ColladaScene::write() { } void ColladaSerializer::ColladaExporter::ColladaMaterials::ColladaEffects::write( - const ifcopenshell::geometry::taxonomy::style &material, const std::string &material_uri) + const ifcopenshell::geometry::taxonomy::style::ptr &material, const std::string &material_uri) { openEffect(material_uri + "-fx"); COLLADASW::EffectProfile effect(mSW); effect.setShaderType(COLLADASW::EffectProfile::LAMBERT); - if (material.diffuse) { - const auto& diffuse = material.diffuse.ccomponents(); + if (material->diffuse) { + const auto& diffuse = material->diffuse.ccomponents(); effect.setDiffuse(COLLADASW::ColorOrTexture(COLLADASW::Color(diffuse(0),diffuse(1),diffuse(2)))); } - if (material.specular) { - const auto& specular = material.specular.ccomponents(); + if (material->specular) { + const auto& specular = material->specular.ccomponents(); effect.setSpecular(COLLADASW::ColorOrTexture(COLLADASW::Color(specular(0),specular(1),specular(2)))); } - if (material.specularity == material.specularity) { - effect.setShininess(material.specularity); + if (material->specularity == material->specularity) { + effect.setShininess(material->specularity); } - if (material.transparency == material.transparency) { - const double transparency = material.transparency; + if (material->transparency == material->transparency) { + const double transparency = material->transparency; if (transparency > 0) { // The default opacity mode for Collada is A_ONE, which apparently indicates a // transparency value of 1 to be fully opaque. Hence transparency is inverted. @@ -334,12 +334,12 @@ void ColladaSerializer::ColladaExporter::ColladaMaterials::ColladaEffects::close closeLibrary(); } -void ColladaSerializer::ColladaExporter::ColladaMaterials::add(const ifcopenshell::geometry::taxonomy::style& material) { +void ColladaSerializer::ColladaExporter::ColladaMaterials::add(const ifcopenshell::geometry::taxonomy::style::ptr& material) { if (!contains(material)) { - std::string material_name = material.name; + std::string material_name = material->name; if (material_name.empty()) { - material_name = "missing-material-" + material.name; + material_name = "missing-material-" + material->name; } collada_id(material_name); @@ -350,19 +350,19 @@ void ColladaSerializer::ColladaExporter::ColladaMaterials::add(const ifcopenshel } } -std::string ColladaSerializer::ColladaExporter::ColladaMaterials::getMaterialUri(const ifcopenshell::geometry::taxonomy::style& material) { - std::vector::iterator it = std::find(materials.begin(), materials.end(), material); +std::string ColladaSerializer::ColladaExporter::ColladaMaterials::getMaterialUri(const ifcopenshell::geometry::taxonomy::style::ptr& material) { + std::vector::iterator it = std::find(materials.begin(), materials.end(), material); ptrdiff_t index = std::distance(materials.begin(), it); return material_uris.at(index); } -bool ColladaSerializer::ColladaExporter::ColladaMaterials::contains(const ifcopenshell::geometry::taxonomy::style& material) { +bool ColladaSerializer::ColladaExporter::ColladaMaterials::contains(const ifcopenshell::geometry::taxonomy::style::ptr& material) { return std::find(materials.begin(), materials.end(), material) != materials.end(); } void ColladaSerializer::ColladaExporter::ColladaMaterials::write() { effects.close(); - BOOST_FOREACH(const ifcopenshell::geometry::taxonomy::style& material, materials) { + BOOST_FOREACH(const ifcopenshell::geometry::taxonomy::style::ptr& material, materials) { std::string material_name = getMaterialUri(material); openMaterial(material_name); @@ -396,7 +396,7 @@ void ColladaSerializer::ColladaExporter::write(const IfcGeom::TriangulationEleme collada_id(representation_id); std::vector material_references; - BOOST_FOREACH(const ifcopenshell::geometry::taxonomy::style& material, mesh.materials()) { + BOOST_FOREACH(const ifcopenshell::geometry::taxonomy::style::ptr& material, mesh.materials()) { materials.add(material); std::string material_name = materials.getMaterialUri(material); diff --git a/src/serializers/ColladaSerializer.h b/src/serializers/ColladaSerializer.h index 58dc4de4fa..690b8b7c6c 100644 --- a/src/serializers/ColladaSerializer.h +++ b/src/serializers/ColladaSerializer.h @@ -75,7 +75,7 @@ private: const std::string &mesh_id, const std::string &default_material_name, const std::vector& positions, const std::vector& normals, const std::vector& faces, const std::vector& edges, - const std::vector& material_ids, const std::vector& materials, + const std::vector& material_ids, const std::vector& materials, const std::vector& uvs, const std::vector& material_references); void close(); ColladaSerializer *serializer; @@ -118,11 +118,11 @@ private: explicit ColladaEffects(COLLADASW::StreamWriter& stream) : COLLADASW::LibraryEffects(&stream) {} - void write(const ifcopenshell::geometry::taxonomy::style &material, const std::string &material_uri); + void write(const ifcopenshell::geometry::taxonomy::style::ptr& material, const std::string &material_uri); void close(); ColladaSerializer *serializer; }; - std::vector materials; + std::vector materials; std::vector material_uris; public: explicit ColladaMaterials(COLLADASW::StreamWriter& stream, ColladaSerializer *_serializer) @@ -130,9 +130,9 @@ private: , serializer(_serializer) , effects(stream) {} - void add(const ifcopenshell::geometry::taxonomy::style& material); - std::string getMaterialUri(const ifcopenshell::geometry::taxonomy::style& material); - bool contains(const ifcopenshell::geometry::taxonomy::style& material); + void add(const ifcopenshell::geometry::taxonomy::style::ptr& material); + std::string getMaterialUri(const ifcopenshell::geometry::taxonomy::style::ptr& material); + bool contains(const ifcopenshell::geometry::taxonomy::style::ptr& material); void write(); ColladaSerializer *serializer; ColladaEffects effects; @@ -165,14 +165,14 @@ private: std::vector faces; std::vector edges; std::vector material_ids; - std::vector materials; + std::vector materials; std::vector material_references; std::vector uvs; std::vector parents_; DeferredObject(const std::string& unique_id, const std::string& representation_id, const std::string& type, const IfcGeom::Transformation& transformation, const std::vector& vertices, const std::vector& normals, const std::vector& faces, - const std::vector& edges, const std::vector& material_ids, const std::vector& materials, + const std::vector& edges, const std::vector& material_ids, const std::vector& materials, const std::vector& material_references, const std::vector& uvs) : unique_id(unique_id) , representation_id(representation_id) diff --git a/src/serializers/GltfSerializer.cpp b/src/serializers/GltfSerializer.cpp index fac2ed51b0..c5b4d4c776 100644 --- a/src/serializers/GltfSerializer.cpp +++ b/src/serializers/GltfSerializer.cpp @@ -86,29 +86,29 @@ void GltfSerializer::writeHeader() { json_["materials"] = json::array(); } -int GltfSerializer::writeMaterial(const ifcopenshell::geometry::taxonomy::style& style) { - auto it = materials_.find(style.name); +int GltfSerializer::writeMaterial(const ifcopenshell::geometry::taxonomy::style::ptr style) { + auto it = materials_.find(style->name); if (it != materials_.end()) { return it->second; } int idx = json_["materials"].size(); - materials_[style.name] = idx; + materials_[style->name] = idx; std::array base; base.fill(1.0); - if (style.diffuse) { + if (style->diffuse) { for (int i = 0; i < 3; ++i) { - base[i] = style.diffuse.ccomponents()(i); + base[i] = style->diffuse.ccomponents()(i); } } - if (style.transparency == style.transparency) { - base[3] = 1. - style.transparency; + if (style->transparency == style->transparency) { + base[3] = 1. - style->transparency; } json_["materials"].push_back({ {"doubleSided", true}, {"pbrMetallicRoughness", {{"baseColorFactor", base}, {"metallicFactor", 0}}} }); - if (style.transparency == style.transparency && style.transparency > 1.e-9) { + if (style->transparency == style->transparency && style->transparency > 1.e-9) { json_["materials"].back()["alphaMode"] = "BLEND"; } diff --git a/src/serializers/GltfSerializer.h b/src/serializers/GltfSerializer.h index cbdbe0dacb..d2c6edab89 100644 --- a/src/serializers/GltfSerializer.h +++ b/src/serializers/GltfSerializer.h @@ -39,7 +39,7 @@ private: boost::optional ecef_transform_, north_rotation_; int bufferViewId; - int writeMaterial(const ifcopenshell::geometry::taxonomy::style& style); + int writeMaterial(const ifcopenshell::geometry::taxonomy::style::ptr style); public: GltfSerializer(const std::string& filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings); virtual ~GltfSerializer(); diff --git a/src/serializers/HdfSerializer.cpp b/src/serializers/HdfSerializer.cpp index 6d380ce607..f393f8a379 100644 --- a/src/serializers/HdfSerializer.cpp +++ b/src/serializers/HdfSerializer.cpp @@ -233,7 +233,8 @@ namespace { } } -void HdfSerializer::read_surface_style(surface_style_serialization& s, ifcopenshell::geometry::taxonomy::style& gss) { +void HdfSerializer::read_surface_style(surface_style_serialization& s, const ifcopenshell::geometry::taxonomy::style::ptr& gss_) { + auto& gss = *gss_; 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]); @@ -355,7 +356,7 @@ IfcGeom::Element* HdfSerializer::read(IfcParse::IfcFile& f, const std::string& g matrix->components() << Eigen::Map(&part.matrix[0][0]); auto style_ptr = ifcopenshell::geometry::taxonomy::make(); - read_surface_style(part.surface_style, *style_ptr); + read_surface_style(part.surface_style, style_ptr); shapes.push_back(IfcGeom::ConversionResult(part.id, matrix, new ifcopenshell::geometry::OpenCascadeShape(shp), style_ptr)); } @@ -416,7 +417,7 @@ IfcGeom::Element* HdfSerializer::read(IfcParse::IfcFile& f, const std::string& g ds.read(surface_styles.data(), style_compound); } - std::vector surface_style_ptrs(surface_styles.size()); + std::vector surface_style_ptrs(surface_styles.size()); for (size_t i = 0; i < surface_styles.size(); ++i) { read_surface_style(surface_styles[i], surface_style_ptrs[i]); @@ -536,7 +537,8 @@ H5::Group HdfSerializer::createRepresentationGroup(const H5::Group& element_grou return representation_group; } -void HdfSerializer::write_style(surface_style_serialization& data, const ifcopenshell::geometry::taxonomy::style& s) { +void HdfSerializer::write_style(surface_style_serialization& data, const ifcopenshell::geometry::taxonomy::style::ptr& sptr) { + auto& s = *sptr; data.name = s.name.c_str(); // @todo data.original_name = s.name.c_str(); @@ -609,7 +611,7 @@ void HdfSerializer::write(const IfcGeom::BRepElement* o) { parts[i].surface_style = { "", "", 0, {nan,nan,nan}, {nan,nan,nan}, nan, nan }; if (it->hasStyle()) { - auto& s = it->Style(); + auto s = it->StylePtr(); write_style(parts[i].surface_style, s); } diff --git a/src/serializers/HdfSerializer.h b/src/serializers/HdfSerializer.h index db1c838994..0326300420 100644 --- a/src/serializers/HdfSerializer.h +++ b/src/serializers/HdfSerializer.h @@ -89,8 +89,8 @@ private: std::map group_cache_; H5::Group createRepresentationGroup(const H5::Group& element_group, const std::string& gid); - void read_surface_style(surface_style_serialization& sss, ifcopenshell::geometry::taxonomy::style& style_ptr); - void write_style(surface_style_serialization& data, const ifcopenshell::geometry::taxonomy::style& s); + void read_surface_style(surface_style_serialization& sss, const ifcopenshell::geometry::taxonomy::style::ptr& style_ptr); + void write_style(surface_style_serialization& data, const ifcopenshell::geometry::taxonomy::style::ptr& s); public: HdfSerializer(const std::string& hdf_filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, bool read_only=false); diff --git a/src/serializers/WavefrontObjSerializer.cpp b/src/serializers/WavefrontObjSerializer.cpp index f4c532aec2..0414659b98 100644 --- a/src/serializers/WavefrontObjSerializer.cpp +++ b/src/serializers/WavefrontObjSerializer.cpp @@ -59,8 +59,9 @@ void WaveFrontOBJSerializer::writeHeader() { mtl_stream.stream << "# File generated by IfcOpenShell " << IFCOPENSHELL_VERSION << "\n"; } -void WaveFrontOBJSerializer::writeMaterial(const ifcopenshell::geometry::taxonomy::style& style) +void WaveFrontOBJSerializer::writeMaterial(const ifcopenshell::geometry::taxonomy::style::ptr styleptr) { + auto& style = *styleptr; std::string material_name = style.name; IfcUtil::sanitate_material_name(material_name); mtl_stream.stream << "newmtl " << material_name << "\n"; @@ -127,8 +128,8 @@ void WaveFrontOBJSerializer::write(const IfcGeom::TriangulationElement* o) const int material_id = *(material_it++); if (material_id != previous_material_id) { - const ifcopenshell::geometry::taxonomy::style& material = mesh.materials()[material_id]; - std::string material_name = material.name; + const ifcopenshell::geometry::taxonomy::style::ptr material = mesh.materials()[material_id]; + std::string material_name = material->name; IfcUtil::sanitate_material_name(material_name); obj_stream.stream << "usemtl " << material_name << "\n"; if (materials.find(material_name) == materials.end()) { @@ -170,8 +171,8 @@ void WaveFrontOBJSerializer::write(const IfcGeom::TriangulationElement* o) const int material_id = *(material_it++); if (material_id != previous_material_id) { - const ifcopenshell::geometry::taxonomy::style& material = mesh.materials()[material_id]; - std::string material_name = material.name; + const ifcopenshell::geometry::taxonomy::style::ptr material = mesh.materials()[material_id]; + std::string material_name = material->name; IfcUtil::sanitate_material_name(material_name); obj_stream.stream << "usemtl " << material_name << "\n"; if (materials.find(material_name) == materials.end()) { diff --git a/src/serializers/WavefrontObjSerializer.h b/src/serializers/WavefrontObjSerializer.h index d732a231ce..4085dfa376 100644 --- a/src/serializers/WavefrontObjSerializer.h +++ b/src/serializers/WavefrontObjSerializer.h @@ -39,7 +39,7 @@ public: virtual ~WaveFrontOBJSerializer() {} bool ready(); void writeHeader(); - void writeMaterial(const ifcopenshell::geometry::taxonomy::style& style); + void writeMaterial(const ifcopenshell::geometry::taxonomy::style::ptr style); void write(const IfcGeom::TriangulationElement* o); void write(const IfcGeom::BRepElement* /*o*/) {} void finalize() {}