mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-29 03:37:21 +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 {
|
try {
|
||||||
return dispatch_conversion<0>::dispatch(this, item->kind(), item, results);
|
return dispatch_conversion<0>::dispatch(this, item->kind(), item, results);
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
Logger::Error(e, item->instance);
|
std::string prev_exception;
|
||||||
return false;
|
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 (...) {
|
} catch (...) {
|
||||||
// @todo we can't log OCCT exceptions here, can we do some reraising to solve this?
|
// @todo we can't log OCCT exceptions here, can we do some reraising to solve this?
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -624,12 +624,16 @@ boost::optional<edge::ptr> ifcopenshell::geometry::taxonomy::curve_to_edge_upgra
|
|||||||
edge_ = make<edge>();
|
edge_ = make<edge>();
|
||||||
if (circle_) {
|
if (circle_) {
|
||||||
(*edge_)->basis = circle_;
|
(*edge_)->basis = circle_;
|
||||||
|
(*edge_)->instance = circle_->instance;
|
||||||
} else if (ellipse_) {
|
} else if (ellipse_) {
|
||||||
(*edge_)->basis = ellipse_;
|
(*edge_)->basis = ellipse_;
|
||||||
|
(*edge_)->instance = ellipse_->instance;
|
||||||
} else if (line_) {
|
} else if (line_) {
|
||||||
(*edge_)->basis = line_;
|
(*edge_)->basis = line_;
|
||||||
|
(*edge_)->instance = line_->instance;
|
||||||
} else if (bspline_curve_) {
|
} else if (bspline_curve_) {
|
||||||
(*edge_)->basis = bspline_curve_;
|
(*edge_)->basis = bspline_curve_;
|
||||||
|
(*edge_)->instance = bspline_curve_->instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (circle_ || ellipse_) {
|
if (circle_ || ellipse_) {
|
||||||
|
|||||||
Reference in New Issue
Block a user