Work towards v1.0 data model with encapsulated weak_ptr as basis for instances

This commit is contained in:
Thomas Krijnen
2026-01-04 10:40:02 +01:00
parent f09ca658f1
commit 7098beb819
210 changed files with 28269 additions and 26471 deletions
+33 -30
View File
@@ -37,12 +37,14 @@ namespace {
}
}
IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_representation_and_product(taxonomy::ptr representation_node, const IfcUtil::IfcBaseEntity* product, const taxonomy::matrix4::ptr& place_) {
IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_representation_and_product(taxonomy::ptr representation_node, const express::Base product_, const taxonomy::matrix4::ptr& place_) {
auto product = product_.as<express::Entity>();
std::stringstream representation_id_builder;
auto place = place_;
representation_id_builder << representation_node->instance->as<IfcUtil::IfcBaseEntity>()->id();
representation_id_builder << representation_node->instance.id();
IfcGeom::Representation::BRep* shape;
IfcGeom::ConversionResults shapes;
@@ -50,11 +52,11 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
if (!kernel_->convert(representation_node, shapes)) {
return 0;
}
if (settings_.get<ifcopenshell::geometry::settings::ApplyLayerSets>().get()) {
ifcopenshell::geometry::layerset_information layerinfo;
std::vector<ifcopenshell::geometry::endpoint_connection> neighbours;
std::map<IfcUtil::IfcBaseEntity*, ifcopenshell::geometry::layerset_information> neigbour_layers;
std::map<express::Base, ifcopenshell::geometry::layerset_information> neigbour_layers;
int layerset_id, lid;
if (mapping_->get_layerset_information(product, layerinfo, layerset_id)) {
@@ -146,10 +148,10 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
}
if (material_style_applied) {
representation_id_builder << "-material-" << single_material->id();
representation_id_builder << "-material-" << single_material.id();
}
if (settings_.get<ifcopenshell::geometry::settings::ForceSpaceTransparency>().has() && product->declaration().is("IfcSpace")) {
if (settings_.get<ifcopenshell::geometry::settings::ForceSpaceTransparency>().has() && product.declaration().is("IfcSpace")) {
for (auto& s : shapes) {
if (s.hasStyle()) {
// @todo the uglyness
@@ -160,27 +162,27 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
int parent_id = -1;
try {
IfcUtil::IfcBaseEntity* parent_object = mapping_->get_decomposing_entity(product);
express::Base parent_object = mapping_->get_decomposing_entity(product);
if (parent_object) {
parent_id = parent_object->id();
parent_id = parent_object.id();
}
} catch (const std::exception& e) {
Logger::Error(e);
}
const std::string name = product->get_value<std::string>("Name", "");
const std::string guid = product->get_value<std::string>("GlobalId", "");
const std::string name = product.get_value<std::string>("Name", "");
const std::string guid = product.get_value<std::string>("GlobalId", "");
const std::string product_type = product->declaration().name();
const std::string product_type = product.declaration().name();
// Does the IfcElement have any IfcOpenings?
// Note that openings for IfcOpeningElements are not processed
auto openings = mapping_->find_openings(product);
if (!settings_.get<ifcopenshell::geometry::settings::DisableOpeningSubtractions>().get() && openings && openings->size()) {
if (!settings_.get<ifcopenshell::geometry::settings::DisableOpeningSubtractions>().get() && !openings.empty()) {
representation_id_builder << "-openings";
for (auto it = openings->begin(); it != openings->end(); ++it) {
representation_id_builder << "-" << (*it)->id();
for (auto& op : openings) {
representation_id_builder << "-" << op.id();
}
IfcGeom::ConversionResults opened_shapes;
@@ -188,9 +190,9 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
try {
std::vector<std::pair<taxonomy::ptr, taxonomy::matrix4>> opening_items;
std::transform(openings->begin(), openings->end(), std::back_inserter(opening_items), [this](IfcUtil::IfcBaseClass* opening) {
std::transform(openings.begin(), openings.end(), std::back_inserter(opening_items), [this](express::Base opening) {
auto prod_item = mapping()->map(opening);
auto repr = mapping()->representation_of(opening->as<IfcUtil::IfcBaseEntity>());
auto repr = mapping()->representation_of(opening);
if (repr) {
return std::make_pair(mapping()->map(repr), *taxonomy::cast<taxonomy::geom_item>(prod_item)->matrix);
} else {
@@ -251,21 +253,21 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
std::string context_string = "";
// IfcShapeRepresentation.
const IfcUtil::IfcBaseEntity *representation = representation_node->instance->as<IfcUtil::IfcBaseEntity>();
auto representation_identifier = representation->get("RepresentationIdentifier");
auto representation = representation_node->instance.as<express::Entity>();
auto representation_identifier = representation.get("RepresentationIdentifier");
if (!representation_identifier.isNull()) {
context_string = (std::string) representation_identifier;
}
else {
IfcUtil::IfcBaseClass *context = (IfcUtil::IfcBaseClass*)representation->get("ContextOfItems");
auto context_type = context->as<IfcUtil::IfcBaseEntity>()->get("ContextType");
auto context = (express::Base)representation.get("ContextOfItems");
auto context_type = context.as<express::Entity>().get("ContextType");
if (!context_type.isNull()) {
context_string = (std::string)context_type;
}
}
auto elem = new IfcGeom::BRepElement(
product->id(),
product.id(),
parent_id,
name,
product_type,
@@ -351,25 +353,26 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
return elem;
}
IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_processed_representation(const IfcUtil::IfcBaseEntity* product, const taxonomy::matrix4::ptr& place, IfcGeom::BRepElement* brep) {
IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_processed_representation(const express::Base product_, const taxonomy::matrix4::ptr& place, IfcGeom::BRepElement* brep) {
auto product = product_.as<express::Entity>();
int parent_id = -1;
try {
IfcUtil::IfcBaseEntity* parent_object = mapping_->get_decomposing_entity(product);
express::Base parent_object = mapping_->get_decomposing_entity(product);
if (parent_object) {
parent_id = parent_object->id();
parent_id = parent_object.id();
}
} catch (const std::exception& e) {
Logger::Error(e);
}
const std::string guid = product->get_value<std::string>("GlobalId");
const std::string name = product->get_value<std::string>("Name", "");
const std::string product_type = product->declaration().name();
const std::string guid = product.get_value<std::string>("GlobalId");
const std::string name = product.get_value<std::string>("Name", "");
const std::string product_type = product.declaration().name();
const std::string context_string = brep->context();
return new IfcGeom::BRepElement(
product->id(),
product.id(),
parent_id,
name,
product_type,
@@ -381,7 +384,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_process
);
}
IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_representation_and_product(const IfcUtil::IfcBaseEntity* representation, const IfcUtil::IfcBaseEntity* product) {
IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_representation_and_product(const express::Base representation, const express::Base product) {
auto interpreted_representation = mapping_->map(representation);
if (!interpreted_representation) {
interpreted_representation = taxonomy::make<taxonomy::collection>();
@@ -394,7 +397,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
);
}
IfcGeom::ConversionResults ifcopenshell::geometry::Converter::convert(IfcUtil::IfcBaseClass * item)
IfcGeom::ConversionResults ifcopenshell::geometry::Converter::convert(express::Base item)
{
std::clock_t map_start = std::clock();
auto geom_item = mapping_->map(item);