mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Fix creating representation with inherited materials
It should be considered as inherited material can also have a style. Though occurrence's material is still prioritized.
This commit is contained in:
@@ -107,6 +107,13 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
|
|||||||
bool material_style_applied = false;
|
bool material_style_applied = false;
|
||||||
|
|
||||||
auto single_material = mapping_->get_single_material_association(product);
|
auto single_material = mapping_->get_single_material_association(product);
|
||||||
|
if (!single_material) {
|
||||||
|
auto type_product = mapping_->get_product_type(product);
|
||||||
|
if (type_product) {
|
||||||
|
single_material = mapping_->get_single_material_association(type_product);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (single_material) {
|
if (single_material) {
|
||||||
auto s = taxonomy::cast<taxonomy::style>(mapping_->map(single_material));
|
auto s = taxonomy::cast<taxonomy::style>(mapping_->map(single_material));
|
||||||
for (auto it = shapes.begin(); it != shapes.end(); ++it) {
|
for (auto it = shapes.begin(); it != shapes.end(); ++it) {
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ namespace geometry {
|
|||||||
virtual void initialize_settings() = 0;
|
virtual void initialize_settings() = 0;
|
||||||
virtual bool get_layerset_information(const IfcUtil::IfcBaseInterface*, layerset_information&, int&) = 0;
|
virtual bool get_layerset_information(const IfcUtil::IfcBaseInterface*, layerset_information&, int&) = 0;
|
||||||
virtual bool get_wall_neighbours(const IfcUtil::IfcBaseInterface*, std::vector<endpoint_connection>&) = 0;
|
virtual bool get_wall_neighbours(const IfcUtil::IfcBaseInterface*, std::vector<endpoint_connection>&) = 0;
|
||||||
|
virtual const IfcUtil::IfcBaseEntity* get_product_type(const IfcUtil::IfcBaseEntity*) = 0;
|
||||||
virtual const IfcUtil::IfcBaseEntity* get_single_material_association(const IfcUtil::IfcBaseEntity*) = 0;
|
virtual const IfcUtil::IfcBaseEntity* get_single_material_association(const IfcUtil::IfcBaseEntity*) = 0;
|
||||||
virtual double get_length_unit() const = 0;
|
virtual double get_length_unit() const = 0;
|
||||||
virtual IfcUtil::IfcBaseEntity* representation_of(const IfcUtil::IfcBaseEntity* product) = 0;
|
virtual IfcUtil::IfcBaseEntity* representation_of(const IfcUtil::IfcBaseEntity* product) = 0;
|
||||||
|
|||||||
@@ -256,8 +256,23 @@ void mapping::get_representations(std::vector<geometry_conversion_task>& tasks,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const IfcUtil::IfcBaseEntity* mapping::get_single_material_association(const IfcUtil::IfcBaseEntity* product_) {
|
const IfcUtil::IfcBaseEntity* mapping::get_product_type(const IfcUtil::IfcBaseEntity* product_) {
|
||||||
auto product = product_->as<IfcSchema::IfcProduct>();
|
auto product = product_->as<IfcSchema::IfcProduct>();
|
||||||
|
auto rels = product->IsTypedBy();
|
||||||
|
for (auto it = rels->begin(); it != rels->end(); ++it) {
|
||||||
|
auto rel = *it;
|
||||||
|
// Avoid segfault if RelatingType is unset.
|
||||||
|
if (rel->get("RelatingType")->isNull()){
|
||||||
|
break;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return rel->RelatingType();
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const IfcUtil::IfcBaseEntity* mapping::get_single_material_association(const IfcUtil::IfcBaseEntity* product_) {
|
||||||
|
auto product = product_->as<IfcSchema::IfcObjectDefinition>();
|
||||||
IfcSchema::IfcMaterial* single_material = 0;
|
IfcSchema::IfcMaterial* single_material = 0;
|
||||||
IfcSchema::IfcRelAssociatesMaterial::list::ptr associated_materials = product->HasAssociations()->as<IfcSchema::IfcRelAssociatesMaterial>();
|
IfcSchema::IfcRelAssociatesMaterial::list::ptr associated_materials = product->HasAssociations()->as<IfcSchema::IfcRelAssociatesMaterial>();
|
||||||
if (associated_materials->size() == 1) {
|
if (associated_materials->size() == 1) {
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ namespace geometry {
|
|||||||
virtual double get_length_unit() const { return length_unit_; }
|
virtual double get_length_unit() const { return length_unit_; }
|
||||||
virtual aggregate_of_instance::ptr find_openings(const IfcUtil::IfcBaseEntity*);
|
virtual aggregate_of_instance::ptr find_openings(const IfcUtil::IfcBaseEntity*);
|
||||||
virtual IfcUtil::IfcBaseEntity* representation_of(const IfcUtil::IfcBaseEntity* product);
|
virtual IfcUtil::IfcBaseEntity* representation_of(const IfcUtil::IfcBaseEntity* product);
|
||||||
|
|
||||||
|
virtual const IfcUtil::IfcBaseEntity* get_product_type(const IfcUtil::IfcBaseEntity* product_);
|
||||||
virtual const IfcUtil::IfcBaseEntity* get_single_material_association(const IfcUtil::IfcBaseEntity* product);
|
virtual const IfcUtil::IfcBaseEntity* get_single_material_association(const IfcUtil::IfcBaseEntity* product);
|
||||||
IfcSchema::IfcRepresentation* representation_mapped_to(const IfcSchema::IfcRepresentation* representation);
|
IfcSchema::IfcRepresentation* representation_mapped_to(const IfcSchema::IfcRepresentation* representation);
|
||||||
IfcSchema::IfcProduct::list::ptr products_represented_by(const IfcSchema::IfcRepresentation* representation, bool only_direct=false);
|
IfcSchema::IfcProduct::list::ptr products_represented_by(const IfcSchema::IfcRepresentation* representation, bool only_direct=false);
|
||||||
|
|||||||
Reference in New Issue
Block a user