|
4 | 4 | from .utils import toCompound
|
5 | 5 |
|
6 | 6 | from OCP.gp import gp_Dir
|
7 |
| -from OCP.GeomConvert import GeomConvert |
| 7 | +from OCP.GeomConvert import GeomConvert, GeomConvert_ApproxCurve |
| 8 | +from OCP.GeomAbs import GeomAbs_C0 |
8 | 9 |
|
9 | 10 | import ezdxf
|
10 | 11 |
|
@@ -72,12 +73,20 @@ def _dxf_spline(e: Edge, msp: ezdxf.layouts.Modelspace, plane: Plane):
|
72 | 73 | adaptor = e._geomAdaptor()
|
73 | 74 | curve = GeomConvert.CurveToBSplineCurve_s(adaptor.Curve().Curve())
|
74 | 75 |
|
75 |
| - spline = GeomConvert.SplitBSplineCurve_s( |
| 76 | + full_spline = GeomConvert.SplitBSplineCurve_s( |
76 | 77 | curve, adaptor.FirstParameter(), adaptor.LastParameter(), CURVE_TOLERANCE
|
77 | 78 | )
|
78 | 79 |
|
79 | 80 | # need to apply the transform on the geometry level
|
80 |
| - spline.Transform(plane.fG.wrapped.Trsf()) |
| 81 | + full_spline.Transform(plane.fG.wrapped.Trsf()) |
| 82 | + |
| 83 | + # approximate the transformed spline down to max degree 3 for |
| 84 | + # compatibilitly with more DXF processing tools. |
| 85 | + # |
| 86 | + # parameters choosen to match FreeCAD 0.20 |
| 87 | + approx_spline = GeomConvert_ApproxCurve(full_spline, 0.001, GeomAbs_C0, 50, 3) |
| 88 | + |
| 89 | + spline = approx_spline.Curve() |
81 | 90 |
|
82 | 91 | order = spline.Degree() + 1
|
83 | 92 | knots = list(spline.KnotSequence())
|
|
0 commit comments