From ed37d110020015261c2f335aa3c8d67b53bdd044 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sun, 8 Jan 2023 21:17:12 +1100 Subject: [PATCH] Fix #2631. Add support for flange edge radius and flange slope for I-shapes. --- src/ifcgeom/IfcIShapeProfileDef.cpp | 64 ++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 10 deletions(-) diff --git a/src/ifcgeom/IfcIShapeProfileDef.cpp b/src/ifcgeom/IfcIShapeProfileDef.cpp index 8ce9b9a69c..ec3e0be39a 100644 --- a/src/ifcgeom/IfcIShapeProfileDef.cpp +++ b/src/ifcgeom/IfcIShapeProfileDef.cpp @@ -24,19 +24,43 @@ #define Kernel MAKE_TYPE_NAME(Kernel) bool IfcGeom::Kernel::convert(const IfcSchema::IfcIShapeProfileDef* l, TopoDS_Shape& face) { + + const bool doFillet1 = !!l->FilletRadius(); +#ifdef SCHEMA_IfcIShapeProfileDef_HAS_FlangeEdgeRadius + const bool doFlangeEdgeRadius = !!l->FlangeEdgeRadius(); + const bool hasSlope = !!l->FlangeSlope(); +#endif + const double x1 = l->OverallWidth() / 2.0f * getValue(GV_LENGTH_UNIT); const double y = l->OverallDepth() / 2.0f * getValue(GV_LENGTH_UNIT); - const double d1 = l->WebThickness() / 2.0f * getValue(GV_LENGTH_UNIT); - const double dy1 = l->FlangeThickness() * getValue(GV_LENGTH_UNIT); + const double d1 = l->WebThickness() / 2.0f * getValue(GV_LENGTH_UNIT); + const double d2 = l->FlangeThickness() * getValue(GV_LENGTH_UNIT); +#ifdef SCHEMA_IfcIShapeProfileDef_HAS_FlangeEdgeRadius + const double slope = l->FlangeSlope().get_value_or(0.) * getValue(GV_PLANEANGLE_UNIT); +#endif + + double dy1 = 0.0f; + double dy2 = 0.0f; + double f1 = 0.0f; + double f2 = 0.0f; + double fe1 = 0.0f; + double fe2 = 0.0f; + double x2 = x1; - bool doFillet1 = !!l->FilletRadius(); - double f1 = 0.; if ( doFillet1 ) { f1 = *l->FilletRadius() * getValue(GV_LENGTH_UNIT); } +#ifdef SCHEMA_IfcIShapeProfileDef_HAS_FlangeEdgeRadius + if (doFlangeEdgeRadius) { + fe1 = *l->FlangeEdgeRadius() * getValue(GV_LENGTH_UNIT); + } + if (hasSlope) { + dy1 = (x1 - d1) * tan(slope); + dy2 = x1 * tan(slope); + } +#endif bool doFillet2 = doFillet1; - double x2 = x1, dy2 = dy1, f2 = f1; // @todo in IFC4 a IfcAsymmetricIShapeProfileDef is not a subtype anymore of IfcIShapeProfileDef! if (l->declaration().is(IfcSchema::IfcAsymmetricIShapeProfileDef::Class())) { @@ -49,7 +73,10 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcIShapeProfileDef* l, TopoDS_Sh if (assym->TopFlangeThickness()) { dy2 = *assym->TopFlangeThickness() * getValue(GV_LENGTH_UNIT); } - } + } else { + f2 = f1; + fe2 = fe1; + } if ( x1 < ALMOST_ZERO || x2 < ALMOST_ZERO || y < ALMOST_ZERO || d1 < ALMOST_ZERO || dy1 < ALMOST_ZERO || dy2 < ALMOST_ZERO ) { Logger::Message(Logger::LOG_NOTICE,"Skipping zero sized profile:",l); @@ -65,8 +92,25 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcIShapeProfileDef* l, TopoDS_Sh IfcGeom::Kernel::convert(l->Position(), trsf2d); } - double coords[24] = {-x1,-y, x1,-y, x1,-y+dy1, d1,-y+dy1, d1,y-dy2, x2,y-dy2, x2,y, -x2,y, -x2,y-dy2, -d1,y-dy2, -d1,-y+dy1, -x1,-y+dy1}; - int fillets[4] = {3,4,9,10}; - double radii[4] = {f1,f2,f2,f1}; - return util::profile_helper(12,coords,(doFillet1||doFillet2) ? 4 : 0,fillets,radii,trsf2d,face); + double coords[24] = { + -x1,-y, + x1,-y, + x1,-y+d2-dy2, + d1,-y+d2+dy1, + d1,y-d2-dy1, + x2,y-d2+dy2, + x2,y, + -x2,y, + -x2,y-d2+dy2, + -d1,y-d2-dy1, + -d1,-y+d2+dy1, + -x1,-y+d2-dy2 + }; + int fillets[8] = {2,3,4,5,8,9,10,11}; + double radii[8] = {fe1,f1,f2,fe2,fe2,f2,f1,fe1}; +#ifdef SCHEMA_IfcIShapeProfileDef_HAS_FlangeEdgeRadius + return util::profile_helper(12,coords,(doFillet1 || doFillet2 || doFlangeEdgeRadius) ? 8 : 0,fillets,radii,trsf2d,face); +#else + return util::profile_helper(12,coords,(doFillet1 || doFillet2 ) ? 8 : 0,fillets,radii,trsf2d,face); +#endif }