Skip to content
This repository was archived by the owner on Nov 24, 2024. It is now read-only.

Commit 14193fb

Browse files
committed
IfcOpenShell#1126 more elaborate polygonal curve segment check
1 parent 2ac0b75 commit 14193fb

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/ifcgeom/IfcGeomSerialisation.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,21 @@ int convert_to_ifc(const TopoDS_Edge& e, IfcSchema::IfcEdge*& edge, bool advance
433433
}
434434
}
435435

436+
namespace {
437+
bool is_polygonal(const Handle_Geom_Curve& crv) {
438+
if (crv->DynamicType() == STANDARD_TYPE(Geom_Line)) {
439+
return true;
440+
} else if (crv->DynamicType() == STANDARD_TYPE(Geom_TrimmedCurve)) {
441+
return is_polygonal(Handle_Geom_TrimmedCurve::DownCast(crv)->BasisCurve());
442+
} else if (crv->DynamicType() == STANDARD_TYPE(Geom_BSplineCurve)) {
443+
auto bspl = Handle_Geom_BSplineCurve::DownCast(crv);
444+
return bspl->NbPoles() == 2 && bspl->Degree() == 1;
445+
} else {
446+
return false;
447+
}
448+
}
449+
}
450+
436451
template <>
437452
int convert_to_ifc(const TopoDS_Wire& wire, IfcSchema::IfcLoop*& loop, bool advanced) {
438453
bool polygonal = true;
@@ -442,7 +457,7 @@ int convert_to_ifc(const TopoDS_Wire& wire, IfcSchema::IfcLoop*& loop, bool adva
442457
if (crv.IsNull()) {
443458
continue;
444459
}
445-
if (crv->DynamicType() != STANDARD_TYPE(Geom_Line)) {
460+
if (!is_polygonal(crv)) {
446461
polygonal = false;
447462
break;
448463
}

0 commit comments

Comments
 (0)