我在尝试使用 openNURBS 库将我们自己的数据转换成 3dm 格式,但发现导出的曲线在 rhino 中打开显示“无效的曲线”
for(MyBSplineCurve* pCurve : curves) {
if(pCurve; int pntCnt = pCurve->CtrlPoints().size()) {
ON_NurbsCurve* rhinoCurve = new ON_NurbsCurve(
3, // dimension
true, // true if rational
pCurve->Degree()+1, // order = degree+1
pntCnt // number of control vertices
);
for(int j = 0; j < pntCnt; j++) {
ON_3dPoint pt(pCurve->CtrlPoints()[j].GetPos().x(),
pCurve->CtrlPoints()[j].GetPos().y(),
pCurve->CtrlPoints()[j].GetPos().z());
rhinoCurve->SetCV(j, pt);
}
// ON_NurbsCurve's have order+cv_count-2 knots
int nKnots = pCurve->KnotVec().GetCount();
lxd::print("order:{}, cv:{}, knots:{}\n", pCurve->Degree() + 1, pntCnt, nKnots);
for(int k = 1; k < nKnots - 1; k++) {
rhinoCurve->SetKnot(k, pCurve->KnotVec().GetKnots()[k]);
}
auto name = fmt::format(L"RefCurve {}_{}", pair.first, w++);
model.AddManagedModelGeometryComponent(
rhinoCurve,
Internal_CreateManagedAttributes(layerRefCurve[i], name.c_str())
);
}
}
85RT_P1_20220915160131_15.3dm (328.1 KB)