dwg解析-样条曲线拟合点解析(中望CAD导出)

dwg解析-样条曲线拟合点解析(中望CAD导出)

中望CAD导出的dwg文件,其中样条曲线拟合点解析出的结果出拟合点和起始点的方向,
解析代码如下:

/ harray is the Handle(TColgp_HArray1OfPnt) containing the sampled circle points in the YZ plane at PI/4, PI/2, 3/2PI and 2PI

GeomAPI_Interpolate interp(harray, Standard_True, 0.001);

TColgp_Array1OfVec tangents(1, 4);

tangets.SetValue(1, gp_Vec(0, -1, 0));

tangents.SetValue(2, gp_Vec(0, 0, -1));

tangents.SetValue(3, gp_Vec(0, 1, 0));

tangents.SetValue(4, gp_Vec(0, 0, 1));

TColstd_HArray1OfBoolean flags(1,4);

flags.SetValue(1, Standard_True);

flags.SetValue(2, Standard_True);

flags.SetValue(3, Standard_True);

flags.SetValue(4, Standard_True);

interp.Load(tangents, flags.GetHandle());

interp.Perform();
	int fitlen = fitPts->Count;
	Handle(TColgp_HArray1OfPnt) arry = new TColgp_HArray1OfPnt(1, fitlen);
	TColgp_Array1OfVec tangents(1, fitlen);
	Handle_TColStd_HArray1OfBoolean farray = new TColStd_HArray1OfBoolean(1, fitlen);
	for (int i = 0; i < fitlen; i++)
	{
		arry->SetValue(i + 1, gp_Pnt(fitPts[i]->X, fitPts[i]->Y, fitPts[i]->Z));
		tangents.SetValue(i + 1, gp_Vec(dirs[i]->X, dirs[i]->Y, dirs[i]->Z));
		farray->SetValue(i + 1, true);
	}
	GeomAPI_Interpolate interp(arry, false, 0.001);
	interp.Load(tangents, farray);
	interp.Perform();
	Handle(Geom_BSplineCurve) theSpline = interp.Curve();
	BRepBuilderAPI_MakeEdge nativeHandle_MakeEdge = BRepBuilderAPI_MakeEdge(theSpline);
	TopoDS_Edge  tmp = nativeHandle_MakeEdge.Edge();

参考链接
参考链接

posted @   一只小小汤圆  阅读(29)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· spring官宣接入deepseek,真的太香了~
点击右上角即可分享
微信分享提示