AbstractKernel::convert to use upgrade to edge as a fallback

This commit is contained in:
Andrej730
2024-09-11 11:56:21 +05:00
parent 37315e941a
commit 35221ed772
2 changed files with 20 additions and 2 deletions
+16 -2
View File
@@ -29,8 +29,22 @@ bool ifcopenshell::geometry::kernels::AbstractKernel::convert(const taxonomy::pt
try {
return dispatch_conversion<0>::dispatch(this, item->kind(), item, results);
} catch (std::exception& e) {
Logger::Error(e, item->instance);
return false;
std::string prev_exception;
try {
prev_exception = std::string(e.what());
// Try to upgrade. Works for circles and ellipses.
auto concrete_item = ifcopenshell::geometry::taxonomy::template dcast<ifcopenshell::geometry::taxonomy::edge>(item);
if (concrete_item) {
return convert_impl(concrete_item, results);
}
Logger::Error(prev_exception + " Upgrade also didn't worked.", item->instance);
return false;
} catch (std::exception& e) {
Logger::Error(prev_exception + " Conversion for upgraded element failed with: " + std::string(e.what()), item->instance);
return false;
} catch (...) {
return false;
}
} catch (...) {
// @todo we can't log OCCT exceptions here, can we do some reraising to solve this?
return false;
+4
View File
@@ -624,12 +624,16 @@ boost::optional<edge::ptr> ifcopenshell::geometry::taxonomy::curve_to_edge_upgra
edge_ = make<edge>();
if (circle_) {
(*edge_)->basis = circle_;
(*edge_)->instance = circle_->instance;
} else if (ellipse_) {
(*edge_)->basis = ellipse_;
(*edge_)->instance = ellipse_->instance;
} else if (line_) {
(*edge_)->basis = line_;
(*edge_)->instance = line_->instance;
} else if (bspline_curve_) {
(*edge_)->basis = bspline_curve_;
(*edge_)->instance = bspline_curve_->instance;
}
if (circle_ || ellipse_) {