From 14193fb486c909cb64d49013279da199f95d8fad Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Thu, 10 Dec 2020 10:48:14 +0100 Subject: [PATCH] #1126 more elaborate polygonal curve segment check --- src/ifcgeom/IfcGeomSerialisation.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/ifcgeom/IfcGeomSerialisation.cpp b/src/ifcgeom/IfcGeomSerialisation.cpp index 214c2915d5..cc6a04be31 100644 --- a/src/ifcgeom/IfcGeomSerialisation.cpp +++ b/src/ifcgeom/IfcGeomSerialisation.cpp @@ -433,6 +433,21 @@ int convert_to_ifc(const TopoDS_Edge& e, IfcSchema::IfcEdge*& edge, bool advance } } +namespace { + bool is_polygonal(const Handle_Geom_Curve& crv) { + if (crv->DynamicType() == STANDARD_TYPE(Geom_Line)) { + return true; + } else if (crv->DynamicType() == STANDARD_TYPE(Geom_TrimmedCurve)) { + return is_polygonal(Handle_Geom_TrimmedCurve::DownCast(crv)->BasisCurve()); + } else if (crv->DynamicType() == STANDARD_TYPE(Geom_BSplineCurve)) { + auto bspl = Handle_Geom_BSplineCurve::DownCast(crv); + return bspl->NbPoles() == 2 && bspl->Degree() == 1; + } else { + return false; + } + } +} + template <> int convert_to_ifc(const TopoDS_Wire& wire, IfcSchema::IfcLoop*& loop, bool advanced) { bool polygonal = true; @@ -442,7 +457,7 @@ int convert_to_ifc(const TopoDS_Wire& wire, IfcSchema::IfcLoop*& loop, bool adva if (crv.IsNull()) { continue; } - if (crv->DynamicType() != STANDARD_TYPE(Geom_Line)) { + if (!is_polygonal(crv)) { polygonal = false; break; }