Sat, 01/21/2023 - 16:15
I want to write/read a BSPline to/from file.
Writing to IGES is quite trivial:
Handle(Geom_BSplineCurve) m_hBSpline;
IGESControl_Writer IgesWriter;
IgesWriter.AddGeom(m_hBSpline);
IgesWriter.Write("somefile.igs");
And this write the spline as entity 126 to the IGES file
If I look at IGESCAFControl_Reader for reading the spline, typically a TopoDS_Shape is returned, so in the case of a spline you would get a wire.
But I would like to get the original spline back: poles, breaks,....
I did find some traces back
IGESConvGeom::SplineCurveFromIGES can be used to convert IGESData_IGESEntity to Geom_BSplineCurve, so that is getting close to what I want.
How can I get all the IGESData_IGESEntity out of my iges file?
IGESControl_Reader::IGESModel returns only 1 Entity.
Sat, 01/21/2023 - 18:36
Did a bit of further research and came up with this
IGESControl_Reader aReader; IFSelect_ReturnStatus stat = aReader.ReadFile(FilePath); if (stat != IFSelect_RetDone) return false; Handle(IGESData_IGESModel) IgesDataModel = aReader.IGESModel(); IGESToBRep_BasicCurve Convertor; for (int i=1;i<=IgesDataModel->NbEntities();i++) { Handle(IGESData_IGESEntity) IgesEntity = IgesDataModel->Entity(i); Handle(IGESGeom_BSplineCurve) hIGESSpline = Handle(IGESGeom_BSplineCurve)::DownCast(IgesEntity); if (hIGESSpline) { Handle(Geom_Curve) hGeomCurve = Convertor.TransferBSplineCurve(hIGESSpline); if (hGeomCurve) { m_hBSpline = Handle(Geom_BSplineCurve)::DownCast(hGeomCurve); if (m_hBSpline) return true; } } }