Skip to content

Commit e9a3464

Browse files
author
aothms
committed
Account for unit magnitude in matrix translation part when CONVERT_BACK_UNITS is enabled
1 parent e08db74 commit e9a3464

2 files changed

Lines changed: 13 additions & 114 deletions

File tree

src/ifcgeom/IfcGeomObjects.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,19 @@ IfcGeomObjects::IfcObject::IfcObject(
240240
, _guid(guid)
241241
{
242242
// Convert the gp_Trsf into a 4x3 Matrix
243-
for( int i = 1; i < 5; ++ i )
244-
for ( int j = 1; j < 4; ++ j )
245-
_matrix.push_back((float)trsf.Value(j,i));
243+
// Note that in case the CONVERT_BACK_UNITS setting is enabled
244+
// the translation component of the matrix needs to be divided
245+
// by the magnitude of the IFC model length unit because
246+
// internally in IfcOpenShell everything is measured in meters.
247+
for(int i = 1; i < 5; ++i) {
248+
for (int j = 1; j < 4; ++j) {
249+
const double trsf_value = trsf.Value(j,i);
250+
const double matrix_value = i == 4 && convert_back_units
251+
? trsf_value / IfcGeom::GetValue(IfcGeom::GV_LENGTH_UNIT)
252+
: trsf_value;
253+
_matrix.push_back(static_cast<float>(matrix_value));
254+
}
255+
}
246256
}
247257

248258
IfcGeomObjects::IfcGeomShapeModelObject::IfcGeomShapeModelObject(

src/ifcserver/IfcServer.cpp

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)