BRepOffsetAPI_ThruSections AddVertex tip behavior erratic when using gp_GTrsf


I'm having trouble using BRepOffsetAPI_ThruSections to make a body (shell) that represents something like an aircraft fuselage. I have a bunch of Wire's and a Vertex at the front & back of the body. The resulting shell has a very strange shape at the tips that doesn't make sense. The attached image shows an example of it failing. In this example, I have 300 Wires along the body with cosine spacing (clustered near the tips).

I'm using pythonocc-core, but I think the problem is with opencascade, not the python stuff. When I remove the Vertex's, it builds fine but has open sections at the front & back. I'd like a closed body.

Here is a snippet of the lofting code I'm using:

    # do loft (thru-sections)
    lofter = BRepOffsetAPI_ThruSections(False, False, 1e-3)
    # set params
    lofter.SetSmoothing(False)  # setting this to true doesn't seem to work - crashes

    # add all wires
    for wire in wires:
        if isinstance(wire, TopoDS_Vertex):
            # should only be first & last (or none)

    # checks
    # set continuity level

Isaac Asher's picture

Ok, I fixed this, kind of.

One issue had to do with using a gp_GTrsf() to transform the wires - I want to apply separate x-scale and y-scale to the sections. However, it seems that a gp_GTrsf object will mess up the lofting, though it only messes it up when you have 1 or 2 Vertex's at the ends. So, instead of using a gp_GTrsf to make a "squashed" section, I can make a bunch of "squashed" points myself in python and then fit a B-spline to it.

Annoying that gp_GTrsf() doesn't complain when you apply it to a wire, or that ThruSections doesn't complain when it gets a wire that has been transformed with one. Feels like you should be able to detect & prevent this.

I think my other issue was that in some cases the change from the last real section to the final vertex is too abrupt and the lofter can't figure out how to deal with it. I am able to "fix" this by either 1) having a better upstream geometry definition or 2) splitting into 2 lofts, where the second loft is just the final section + final vertex, and then "sew"ing the shells back together. Option 2 isn't great since the result is only C0 at the interface.

Kirill Gavrilov's picture

How exactly do you apply gp_GTrsf?