mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +00:00
Fixes runtime check for expected IfcPolynomialCurve coefficients and adds fallback check to IfcObjectPlacement (#3936)
* Adds support for IfcLinearPlacement * Instantiates IfcHierarchyHelper template for ADD2 * Implements Eigen shortcut Co-authored-by: Thomas Krijnen <t.krijnen@gmail.com> * Implements Eigen shortcut Co-authored-by: Thomas Krijnen <t.krijnen@gmail.com> * Implements Eigen shortcut Co-authored-by: Thomas Krijnen <t.krijnen@gmail.com> * Implements Eigen shortcut Co-authored-by: Thomas Krijnen <t.krijnen@gmail.com> * Removed assert, added Logger::Warning and Logger::Error. Made treatment of unexpected data more permissive * Fixes runtime check for polynomial curve * Adds test of fallback placement for IfcLinearPlacement and reduces number of tests for placement type. Changed to if-else if so inst isn't tested to be every placement type, every time. --------- Co-authored-by: Thomas Krijnen <t.krijnen@gmail.com>
This commit is contained in:
@@ -461,6 +461,7 @@ public:
|
||||
auto coeffX = p->CoefficientsX().get_value_or(std::vector<double>());
|
||||
auto coeffY = p->CoefficientsY().get_value_or(std::vector<double>());
|
||||
auto coeffZ = p->CoefficientsZ().get_value_or(std::vector<double>());
|
||||
if (!coeffZ.empty())
|
||||
Logger::Warning("Expected IfcPolynomialCurve.CoefficientsZ to be undefined for alignment geometry", p);
|
||||
|
||||
auto transformation_matrix = taxonomy::cast<taxonomy::matrix4>(mapping_->map(p->Position()))->ccomponents();
|
||||
|
||||
@@ -25,15 +25,23 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcObjectPlacement* inst) {
|
||||
const IfcSchema::IfcObjectPlacement* relative_to = nullptr;
|
||||
const IfcUtil::IfcBaseInterface* transform;
|
||||
|
||||
#ifdef SCHEMA_HAS_IfcLinearPlacement
|
||||
if (inst->as<IfcSchema::IfcLinearPlacement>()) {
|
||||
transform = inst->as<IfcSchema::IfcLinearPlacement>()->RelativePlacement();
|
||||
}
|
||||
#endif
|
||||
const IfcSchema::IfcAxis2Placement3D* fallback = nullptr;
|
||||
|
||||
if (inst->as<IfcSchema::IfcLocalPlacement>()) {
|
||||
transform = inst->as<IfcSchema::IfcLocalPlacement>()->RelativePlacement();
|
||||
}
|
||||
if (inst->as<IfcSchema::IfcGridPlacement>()) {
|
||||
#ifdef SCHEMA_HAS_IfcLinearPlacement
|
||||
else if (inst->as<IfcSchema::IfcLinearPlacement>()) {
|
||||
#ifdef SCHEMA_IfcLinearPlacement_HAS_RelativePlacement
|
||||
transform = inst->as<IfcSchema::IfcLinearPlacement>()->RelativePlacement();
|
||||
fallback = inst->as<IfcSchema::IfcLinearPlacement>()->CartesianPosition();
|
||||
#else
|
||||
// @todo Ifc4x1 and Ifc4x2 don't have RelativePlacement
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
else if (inst->as<IfcSchema::IfcGridPlacement>()) {
|
||||
// @todo a bit harder to map without kernel
|
||||
return nullptr;
|
||||
}
|
||||
@@ -57,17 +65,27 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcObjectPlacement* inst) {
|
||||
}
|
||||
}
|
||||
|
||||
taxonomy::ptr result;
|
||||
if (!parent_placement_ignored && relative_to) {
|
||||
// The parent placement of the current is a placement for a type that is
|
||||
// being ignored (Site or Building) or it is the host element of an opening.
|
||||
return taxonomy::make<taxonomy::matrix4>(
|
||||
result = taxonomy::make<taxonomy::matrix4>(
|
||||
taxonomy::cast<taxonomy::matrix4>(map(relative_to))->ccomponents() *
|
||||
taxonomy::cast<taxonomy::matrix4>(map(transform))->ccomponents()
|
||||
);
|
||||
} else {
|
||||
return map(transform);
|
||||
result = map(transform);
|
||||
}
|
||||
|
||||
if (fallback) {
|
||||
auto mapped_fallback = taxonomy::cast<taxonomy::matrix4>(map(fallback));
|
||||
if (mapped_fallback != result) {
|
||||
Logger::Warning("Computed placement differs from fallback", inst);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
// @todo
|
||||
// m4->components() = offset_and_rotation_ * m4->components();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user