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();
參考連結
參考連結