#2819 Handle periodic bspline curves in serialization

This commit is contained in:
Thomas Krijnen
2023-06-15 16:18:48 +02:00
parent 085d420d7c
commit 02864f96e0
@@ -30,6 +30,8 @@
#define INCLUDE_PARENT_PARENT_DIR(x) STRINGIFY(../../../ifcparse/x-definitions.h)
#include INCLUDE_PARENT_PARENT_DIR(IfcSchema)
#include <numeric>
template <typename T, typename U>
int convert_to_ifc(const T& t, U*& u, bool /*advanced*/) {
std::vector<double> coords(3);
@@ -232,6 +234,15 @@ int convert_to_ifc(const Handle_Geom_Curve& c, IfcSchema::IfcCurve*& curve, bool
}
}
if (bspline->IsPeriodic() && points->size()) {
points->push(*points->begin());
weights.push_back(weights[0]);
auto sum = std::accumulate(mults.begin(), mults.end(), 0);
auto d = sum - (bspline->Degree() + (int)points->size() + 1);
(*mults.begin()) -= d / 2;
(*mults.rbegin()) -= d / 2;
}
if (rational) {
curve = new IfcSchema::IfcRationalBSplineCurveWithKnots(
bspline->Degree(),