Implement element-hierarchy setting in USD

This commit is contained in:
Thomas Krijnen
2024-06-29 14:16:07 +02:00
parent a92d51aeb1
commit c68dcba087
5 changed files with 113 additions and 37 deletions
+2 -2
View File
@@ -96,8 +96,8 @@ namespace IfcGeom {
const std::string& unique_id() const { return _unique_id; }
const Transformation& transformation() const { return _transformation; }
const IfcUtil::IfcBaseEntity* product() const { return product_; }
const std::vector<const IfcGeom::Element*> parents() const { return _parents; }
void SetParents(std::vector<const IfcGeom::Element*> newparents) { _parents = newparents; }
const std::vector<const IfcGeom::Element*>& parents() const { return _parents; }
void SetParents(std::vector<const IfcGeom::Element*>& newparents) { _parents = newparents; }
Element(const ifcopenshell::geometry::Settings& settings, int id, int parent_id, const std::string& name, const std::string& type,
const std::string& guid, const std::string& context, const ifcopenshell::geometry::taxonomy::matrix4::ptr& trsf, const IfcUtil::IfcBaseEntity* product)
+13 -7
View File
@@ -712,20 +712,26 @@ namespace IfcGeom {
IfcUtil::IfcBaseEntity* ifc_product = 0;
try {
IfcUtil::IfcBaseEntity* ifc_entity = ifc_file->instance_by_id(id)->as<IfcUtil::IfcBaseEntity>();
instance_type = ifc_entity->declaration().name();
ifc_product = ifc_file->instance_by_id(id)->as<IfcUtil::IfcBaseEntity>();
instance_type = ifc_product->declaration().name();
if (ifc_entity->declaration().is("IfcRoot")) {
product_guid = (std::string) *ifc_entity->get("GlobalId");
product_name = ifc_entity->get_value<std::string>("Name", "");
if (ifc_product->declaration().is("IfcRoot")) {
product_guid = (std::string) *ifc_product->get("GlobalId");
product_name = ifc_product->get_value<std::string>("Name", "");
}
auto parent_object = converter_->mapping()->get_decomposing_entity(ifc_entity);
auto parent_object = converter_->mapping()->get_decomposing_entity(ifc_product);
if (parent_object) {
parent_id = parent_object->data().id();
}
m4 = ifcopenshell::geometry::taxonomy::cast<ifcopenshell::geometry::taxonomy::geom_item>(converter_->mapping()->map(ifc_product))->matrix;
// fails in case of IfcProject
auto mapped = converter_->mapping()->map(ifc_product);
auto casted = mapped ? ifcopenshell::geometry::taxonomy::dcast<ifcopenshell::geometry::taxonomy::geom_item>(mapped) : nullptr;
if (casted) {
m4 = casted->matrix;
}
} catch (const std::exception& e) {
Logger::Error(e);
}