jmplonka / InventorLoader

Workbench for FreeCAD to loads or import Autodesk (R) Inventor (R) files.
GNU General Public License v2.0
119 stars 17 forks source link

Helix not STEP converted correctly #72

Open marcocecchiscmgroup opened 1 year ago

marcocecchiscmgroup commented 1 year ago

If you create a plain helix with Fusion360, such as this one:

image

its STEP converted version looks like this:

1) ShareCAD image

2) Autodesk viewer image

helix_plain.zip

marcocecchiscmgroup commented 1 year ago

The fix should be something along these lines:

        steps_U = Helix.calcSteps(min_U, max_U, (max_U - min_U) / (2 * pi) * 4)
        steps_V = Helix.calcSteps(min_V, max_V, (max_V - min_V) / (2 * pi) * 6)
        baseCirclePoints = []
        for v in steps_V:
            p = VEC(r * cos(v), 0, r * sin(v))
            baseCirclePoints.append(p)
        for u in steps_U:
            c = Helix.calcPoint(u, min_U, self.facApex, r_maj, r_min, handed, pitch)
            circle = []
            for v in baseCirclePoints:
                rot1 = rotation_matrix(DIR_X, pi / 2)
                backRotated = vecRotateMat(self.vecAxis, rot1)
                rot = rotation_matrix(backRotated, u)
                p = vecRotateMat(v, rot)
                circle.append(p + c)
            points.append(circle)

but I am not sure why this breaks demo-status-0.6.ipt. I didn't have too much time today to look at. Any hints?

image

marcocecchiscmgroup commented 1 year ago

My suspicions were confirmed by switching to another library, as I knew the aforementioned calculations were correct. Problem is that, the buggy OCCT interpolate() (as almost anything else in OCCT that it's not a 'hello, world' job) fails to find a decent spline surface from points. The thing is that the number of steps:

steps_U = Helix.calcSteps(min_U, max_U, (max_U - min_U) / (2 pi) 4) steps_V = Helix.calcSteps(min_V, max_V, (max_V - min_V) / (2 pi) 6)

cannot be fixed, at least the U, but must depend on the 'pitch' length, as you call it (isn't pitch an angle?). But with a 'big' number my helix was OK, whilst your demo-status-0.6.ipt failed. In the enclosed patch I implemented a dirty hack to use the geomdl spline interpolation algorithm. From there, to keep it simple, I created a OCCT BSplineSurface from control points and knots, which happens to work. In the future, as we also spoke in the past, the Part.BSpline* can be totally got ridden of.

UPDATED:

patch.zip