mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 10:57:49 +00:00
AbstractKernel::convert to use upgrade to edge as a fallback
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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_) {
|
||||
|
||||
Reference in New Issue
Block a user