Skip to content

Commit

Permalink
Actualize trapezium profile per https://forums.buildingsmart.org/t/ho…
Browse files Browse the repository at this point in the history
  • Loading branch information
aothms committed Sep 9, 2020
1 parent 68a821b commit ac24949
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/ifcgeom/IfcGeomFaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,10 +584,14 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcRectangleHollowProfileDef* l,
}

bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrapeziumProfileDef* l, TopoDS_Shape& face) {
const double x1 = l->BottomXDim() / 2.0f * getValue(GV_LENGTH_UNIT);
const double x1 = l->BottomXDim() / 2. * getValue(GV_LENGTH_UNIT);
const double w = l->TopXDim() * getValue(GV_LENGTH_UNIT);
const double dx = l->TopXOffset() * getValue(GV_LENGTH_UNIT);
const double y = l->YDim() / 2.0f * getValue(GV_LENGTH_UNIT);
const double y = l->YDim() / 2. * getValue(GV_LENGTH_UNIT);

// See: https://forums.buildingsmart.org/t/how-are-the-sides-of-ifctrapeziumprofiledefs-bounding-box-calculated-in-most-implementations/2945/8
// The trapezium x center should not be midway of BottomXDim but rather at the center of the overall bounding box.
const double x_offset = ((std::min(dx, 0.) + std::max(w + dx, x1 * 2.)) / 2.) - x1;

if ( x1 < ALMOST_ZERO || w < ALMOST_ZERO || y < ALMOST_ZERO ) {
Logger::Message(Logger::LOG_NOTICE,"Skipping zero sized profile:",l);
Expand All @@ -603,7 +607,12 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrapeziumProfileDef* l, TopoDS
IfcGeom::Kernel::convert(l->Position(), trsf2d);
}

double coords[8] = {-x1,-y, x1,-y, dx+w-x1,y, dx-x1,y};
double coords[8] = {
-x1 - x_offset, -y,
+x1 - x_offset, -y,
-x1 + dx + w - x_offset, y,
-x1 + dx - x_offset,y
};
return profile_helper(4,coords,0,0,0,trsf2d,face);
}

Expand Down

0 comments on commit ac24949

Please sign in to comment.