mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-11 06:18:09 +00:00
Fix #148 catch errors when computing model bounding box from product placements.
This commit is contained in:
@@ -284,16 +284,23 @@ namespace IfcGeom {
|
|||||||
for (IfcSchema::IfcProduct::list::it iter = products->begin(); iter != products->end(); ++iter) {
|
for (IfcSchema::IfcProduct::list::it iter = products->begin(); iter != products->end(); ++iter) {
|
||||||
IfcSchema::IfcProduct* product = *iter;
|
IfcSchema::IfcProduct* product = *iter;
|
||||||
if (product->hasObjectPlacement()) {
|
if (product->hasObjectPlacement()) {
|
||||||
gp_Trsf trsf; // Use a fresh trsf every time in order to prevent the result to be concatenated
|
// Use a fresh trsf every time in order to prevent the result to be concatenated
|
||||||
if (kernel.convert(product->ObjectPlacement(), trsf)) {
|
gp_Trsf trsf;
|
||||||
const gp_XYZ& pos = trsf.TranslationPart();
|
bool success = false;
|
||||||
bounds_min_.SetX(std::min(bounds_min_.X(), pos.X()));
|
try {
|
||||||
bounds_min_.SetY(std::min(bounds_min_.Y(), pos.Y()));
|
success = kernel.convert(product->ObjectPlacement(), trsf);
|
||||||
bounds_min_.SetZ(std::min(bounds_min_.Z(), pos.Z()));
|
} catch (...) {}
|
||||||
bounds_max_.SetX(std::max(bounds_max_.X(), pos.X()));
|
if (!success) {
|
||||||
bounds_max_.SetY(std::max(bounds_max_.Y(), pos.Y()));
|
continue;
|
||||||
bounds_max_.SetZ(std::max(bounds_max_.Z(), pos.Z()));
|
}
|
||||||
}
|
|
||||||
|
const gp_XYZ& pos = trsf.TranslationPart();
|
||||||
|
bounds_min_.SetX(std::min(bounds_min_.X(), pos.X()));
|
||||||
|
bounds_min_.SetY(std::min(bounds_min_.Y(), pos.Y()));
|
||||||
|
bounds_min_.SetZ(std::min(bounds_min_.Z(), pos.Z()));
|
||||||
|
bounds_max_.SetX(std::max(bounds_max_.X(), pos.X()));
|
||||||
|
bounds_max_.SetY(std::max(bounds_max_.Y(), pos.Y()));
|
||||||
|
bounds_max_.SetZ(std::max(bounds_max_.Z(), pos.Z()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
Logger::Message(Logger::LOG_ERROR, std::string(e.what()) + "\nFailed to convert:", l->entity); \
|
Logger::Message(Logger::LOG_ERROR, std::string(e.what()) + "\nFailed to convert:", l->entity); \
|
||||||
return false; \
|
return false; \
|
||||||
} catch (const Standard_Failure& f) { \
|
} catch (const Standard_Failure& f) { \
|
||||||
if (f.GetMessageString()) \
|
if (f.GetMessageString() && strlen(f.GetMessageString())) \
|
||||||
Logger::Message(Logger::LOG_ERROR, std::string("Error in: ") + f.GetMessageString() + "\nFailed to convert:", l->entity); \
|
Logger::Message(Logger::LOG_ERROR, std::string("Error in: ") + f.GetMessageString() + "\nFailed to convert:", l->entity); \
|
||||||
else \
|
else \
|
||||||
Logger::Message(Logger::LOG_ERROR, "Failed to convert:", l->entity); \
|
Logger::Message(Logger::LOG_ERROR, "Failed to convert:", l->entity); \
|
||||||
|
|||||||
Reference in New Issue
Block a user