From 49d491704e92a69456294f93e2cb36a30655d954 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Tue, 2 Jun 2015 15:56:09 +0000 Subject: [PATCH] Add support for IfcBSplineCurveWithKnots --- src/ifcgeom/IfcGeomCurves.cpp | 41 ++++++++++++++++++++++++++++++++++- src/ifcgeom/IfcRegister.h | 3 +++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/ifcgeom/IfcGeomCurves.cpp b/src/ifcgeom/IfcGeomCurves.cpp index 26cba537b3..3d42984299 100644 --- a/src/ifcgeom/IfcGeomCurves.cpp +++ b/src/ifcgeom/IfcGeomCurves.cpp @@ -77,6 +77,10 @@ #include +#ifdef USE_IFC4 +#include +#endif + #include "../ifcgeom/IfcGeom.h" bool IfcGeom::Kernel::convert(const IfcSchema::IfcCircle* l, Handle(Geom_Curve)& curve) { @@ -135,4 +139,39 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcLine* l, Handle(Geom_Curve)& c // See note at IfcGeomWires.cpp:237 curve = new Geom_Line(pnt,vec); return true; -} \ No newline at end of file +} + +#ifdef USE_IFC4 +bool IfcGeom::Kernel::convert(const IfcSchema::IfcBSplineCurveWithKnots* l, Handle(Geom_Curve)& curve) { + + const IfcSchema::IfcCartesianPoint::list::ptr cps = l->ControlPointsList(); + const std::vector mults = l->KnotMultiplicities(); + const std::vector knots = l->Knots(); + + TColgp_Array1OfPnt Poles(0, cps->size() - 1); + TColStd_Array1OfReal Knots(0, knots.size() - 1); + TColStd_Array1OfInteger Mults(0, mults.size() - 1); + Standard_Integer Degree = l->Degree(); + Standard_Boolean Periodic = l->ClosedCurve(); + + int i = 0; + for (IfcSchema::IfcCartesianPoint::list::it it = cps->begin(); it != cps->end(); ++it, ++i) { + gp_Pnt pnt; + if (!convert(*it, pnt)) return false; + Poles(i) = pnt; + } + + i = 0; + for (std::vector::const_iterator it = mults.begin(); it != mults.end(); ++it, ++i) { + Mults(i) = *it; + } + + i = 0; + for (std::vector::const_iterator it = knots.begin(); it != knots.end(); ++it, ++i) { + Knots(i) = *it; + } + + curve = new Geom_BSplineCurve(Poles, Knots, Mults, Degree, Periodic); + return true; +} +#endif \ No newline at end of file diff --git a/src/ifcgeom/IfcRegister.h b/src/ifcgeom/IfcRegister.h index 71fe1a7f1d..9e09104ec3 100644 --- a/src/ifcgeom/IfcRegister.h +++ b/src/ifcgeom/IfcRegister.h @@ -112,6 +112,9 @@ WIRE(IfcArbitraryOpenProfileDef); CURVE(IfcCircle); CURVE(IfcEllipse); CURVE(IfcLine); +#ifdef USE_IFC4 +CURVE(IfcBSplineCurveWithKnots); +#endif CLASS(IfcCartesianPoint,gp_Pnt); CLASS(IfcDirection,gp_Dir);