From c05f7762f8fe0ffb1716bc5b19a2904febb1cef3 Mon Sep 17 00:00:00 2001 From: Sebastian Hoogen Date: Tue, 20 Jan 2015 17:59:04 +0100 Subject: [PATCH 1/2] import dxf splines as Draft BezCurve if applicable fixes 1743 --- src/Mod/Draft/importDXF.py | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/Mod/Draft/importDXF.py b/src/Mod/Draft/importDXF.py index cc1c60214896..c1d9cd8f69d6 100644 --- a/src/Mod/Draft/importDXF.py +++ b/src/Mod/Draft/importDXF.py @@ -621,7 +621,7 @@ def drawSpline(spline,forceShape=False): non-parametric curve""" flags = rawValue(spline,70) closed = (flags & 1) != 0 - periodic = (flags & 2) != 0 + periodic = (flags & 2) != 0 and False # workaround rational = (flags & 4) != 0 planar = (flags & 8) != 0 linear = (flags & 16) != 0 @@ -694,11 +694,31 @@ def drawSpline(spline,forceShape=False): previousknot = knotvalue knotvector.append(knotvalue) multvector.append(mult) + # check if the multiplicities are valid innermults = multvector[:] if periodic else multvector[1:-1] - if any(m>degree for m in innermults): - #raise ValueError('Invalid multiplicities') - #warn('polygon fallback on %s' %spline) - return drawSplineIterpolation(controlpoints,closed=closed,\ + if any(m>degree for m in innermults): #invalid + if all(m == degree+1 for m in multvector): + if not forceShape and weights is None: + points=controlpoints[:] + del points[degree+1::degree+1] + return Draft.makeBezCurve(points,Degree=degree) + else: + poles=controlpoints[:] + edges=[] + while len(poles) >= degree+1: + #bezier segments + bzseg=Part.BezierCurve() + bzseg.increase(degree) + bzseg.setPoles(poles[0:degree+1]) + poles=poles[degree+1:] + if weights is not None: + bzseg.setWeights(weights[0:degree+1]) + weights=weights[degree+1:] + edges.append(bzseg.toShape()) + return Part.Wire(edges) + else: + warn('polygon fallback on %s' %spline) + return drawSplineIterpolation(controlpoints,closed=closed,\ forceShape=forceShape,alwaysDiscretize=True) try: bspline=Part.BSplineCurve() From 2c7d8a2358ce68ed46cd2cf9141006eb7d78befa Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 20 Jan 2015 21:38:38 +0100 Subject: [PATCH 2/2] + fixes #0001928: The export CAD dialog in PartGui always adds an extension to the filename --- src/Gui/FileDialog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Gui/FileDialog.cpp b/src/Gui/FileDialog.cpp index 5aa1846e1b00..2372dad2eb2a 100644 --- a/src/Gui/FileDialog.cpp +++ b/src/Gui/FileDialog.cpp @@ -78,7 +78,8 @@ void FileDialog::accept() if (!files.isEmpty()) { QString ext = this->defaultSuffix(); QString file = files.front(); - if (!ext.isEmpty() && !file.endsWith(ext, Qt::CaseInsensitive)) { + QFileInfo fi(file); + if (!ext.isEmpty() && fi.suffix().isEmpty()) { file = QString::fromLatin1("%1.%2").arg(file).arg(ext); // That's the built-in line edit QLineEdit* fileNameEdit = this->findChild(QString::fromLatin1("fileNameEdit"));