mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-19 03:33:48 +00:00
Work towards v1.0 data model with encapsulated weak_ptr as basis for instances
This commit is contained in:
@@ -23,15 +23,15 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#if defined SCHEMA_HAS_IfcAxis2PlacementLinear
|
||||
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2PlacementLinear* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2PlacementLinear& inst) {
|
||||
|
||||
if (!inst->Location()->as<IfcSchema::IfcPointByDistanceExpression>()) {
|
||||
if (!inst.Location().as<IfcSchema::IfcPointByDistanceExpression>()) {
|
||||
Logger::Error(std::runtime_error("Location must be IfcPointByDistanceExpression for IfcAxis2PlacementLinear"));
|
||||
}
|
||||
|
||||
Eigen::Vector3d o, axis(0, 0, 1), refDirection;
|
||||
|
||||
taxonomy::matrix4::ptr m = taxonomy::cast<taxonomy::matrix4>(map(inst->Location()));
|
||||
taxonomy::matrix4::ptr m = taxonomy::cast<taxonomy::matrix4>(map(inst.Location()));
|
||||
o = m->components().col(3).head<3>();
|
||||
|
||||
// From 8.9.3.4 IfcAxis2PlacementLinear there are 4 cases that need to be considered
|
||||
@@ -40,8 +40,8 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2PlacementLinear* inst)
|
||||
// 3) Neither Axis or RefDirection are provided
|
||||
// 4) Both Axis and RefDirection are provided
|
||||
|
||||
const bool hasAxis = inst->Axis() != nullptr;
|
||||
const bool hasRef = inst->RefDirection() != nullptr;
|
||||
const bool hasAxis = !!inst.Axis();
|
||||
const bool hasRef = !!inst.RefDirection();
|
||||
|
||||
/*
|
||||
if (hasAxis != hasRef) {
|
||||
@@ -50,7 +50,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2PlacementLinear* inst)
|
||||
*/
|
||||
|
||||
if (hasAxis && !hasRef) {
|
||||
taxonomy::direction3::ptr a = taxonomy::cast<taxonomy::direction3>(map(inst->Axis()));
|
||||
taxonomy::direction3::ptr a = taxonomy::cast<taxonomy::direction3>(map(inst.Axis()));
|
||||
axis = *a->components_;
|
||||
|
||||
refDirection = m->components().col(0).head<3>(); // RefDirection is the curve tangent when omitted
|
||||
@@ -58,7 +58,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2PlacementLinear* inst)
|
||||
// axis.cross(refDirection) gives y. y.cross(axis) gives x=refDirection
|
||||
refDirection = axis.cross(refDirection).cross(axis);
|
||||
} else if (!hasAxis && hasRef) {
|
||||
taxonomy::direction3::ptr r = taxonomy::cast<taxonomy::direction3>(map(inst->RefDirection()));
|
||||
taxonomy::direction3::ptr r = taxonomy::cast<taxonomy::direction3>(map(inst.RefDirection()));
|
||||
refDirection = *r->components_;
|
||||
Eigen::Vector3d up(0, 0, 1);
|
||||
axis = refDirection.cross(up.cross(refDirection));
|
||||
@@ -67,10 +67,10 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2PlacementLinear* inst)
|
||||
Eigen::Vector3d up(0, 0, 1);
|
||||
axis = refDirection.cross(up.cross(refDirection));
|
||||
} else {
|
||||
taxonomy::direction3::ptr a = taxonomy::cast<taxonomy::direction3>(map(inst->Axis()));
|
||||
taxonomy::direction3::ptr a = taxonomy::cast<taxonomy::direction3>(map(inst.Axis()));
|
||||
axis = *a->components_;
|
||||
|
||||
taxonomy::direction3::ptr r = taxonomy::cast<taxonomy::direction3>(map(inst->RefDirection()));
|
||||
taxonomy::direction3::ptr r = taxonomy::cast<taxonomy::direction3>(map(inst.RefDirection()));
|
||||
refDirection = *r->components_;
|
||||
refDirection = axis.cross(refDirection).cross(axis); // refDirection needs to be orthogonal to axis
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user