Skip to content

Commit 206933a

Browse files
committed
#2819 Handle periodic bspline curves in serialization
1 parent ff209b4 commit 206933a

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/ifcgeom/Serialization.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#include "IfcGeom.h"
2020

21+
#include <numeric>
22+
2123
template <typename T, typename U>
2224
int convert_to_ifc(const T& t, U*& u, bool /*advanced*/) {
2325
std::vector<double> coords(3);
@@ -220,6 +222,15 @@ int convert_to_ifc(const Handle_Geom_Curve& c, IfcSchema::IfcCurve*& curve, bool
220222
}
221223
}
222224

225+
if (bspline->IsPeriodic() && points->size()) {
226+
points->push(*points->begin());
227+
weights.push_back(weights[0]);
228+
auto sum = std::accumulate(mults.begin(), mults.end(), 0);
229+
auto d = sum - (bspline->Degree() + (int)points->size() + 1);
230+
(*mults.begin()) -= d / 2;
231+
(*mults.rbegin()) -= d / 2;
232+
}
233+
223234
if (rational) {
224235
curve = new IfcSchema::IfcRationalBSplineCurveWithKnots(
225236
bspline->Degree(),

0 commit comments

Comments
 (0)