Need union of "sweeping" closed curve along path

I need to construct a closed planar curve that represents the union of “sweeping” a second closed planar curve along a co-planar path. I used the word “sweeping” in quotes here because this is similar to but different than the builtin sweep commands.

For example, consider the following closed curve and path.

The following python script will drag the curve along the path depositing 20 copies along the way.

import math
import rhinoscriptsyntax as rs
import Rhino
import System.Drawing.Color

def SweepObject():
    object_ids = rs.GetObjects("Select objects to sweep")
    if object_ids == None: return

    curve_id = rs.GetObject("Select rail curve", rs.filter.curve)
    if curve_id == None: return

    domain = rs.CurveDomain(curve_id)
    start_pt = rs.EvaluateCurve(curve_id, domain[0])
    start_tangent = rs.CurveTangent(curve_id, domain[0])
    for step in range(1, 20):
        t = (step / 20.0) * (domain[1] - domain[0]) + domain[0];
        pt = rs.EvaluateCurve(curve_id, t)
        tangent = rs.CurveTangent(curve_id, t)

        new_ids = rs.CopyObjects(object_ids)

        translation = rs.XformTranslation(pt - start_pt)
        rs.TransformObject(new_ids, translation)

        rotation = rs.XformRotation3(start_tangent, tangent, pt)
        rs.TransformObject(new_ids, rotation)

    return None


# Check to see if this file is being executed as the "Main" python
# script instead of being used as a module by some other python script
# This allows us to use the module which ever way we want.
if __name__ == '__main__':
    SweepObject()

The desired result is a curve that encompasses all of the curves that would be produced by this script if it deposited an infinite number of copies along the path.

What are the possible strategies for accomplishing this result?

Hi Mark. Append the ids of your closed curve profiles (new_ids) to some list, then return that list at the end of your function (instead of return None).
After that just supply the returned closed curve profile ids to rs.CurveBooleanUnion function:

if __name__ == '__main__':
    closedCrvs = SweepObject()
    unionCrv = rs.CurveBooleanUnion(closedCrvs)

Thank you @djordje for the pointer to CurveBooleanUnion. That brings me a lot closer to what I want.

However, the union of the discrete curves will require a lot of samples to produce the desired result along the top edge as shown below. Applying the union to the discrete curves disregards the continuous nature of the sweep – of course, using a sufficient number of discrete curves may overcome this issue, but at some computational cost.

This did spur the following idea. Each successive pair of curves generated during the sweep can be combined with the following algorithm to better approximate the continuous nature of the sweep:

  1. Connect the correspond pairs of vertices with line segments
  2. Compute the outer most curve comprised of the available line segments

E.g.,

The curves produced by this method can then be combined using CurveBooleanUnion.

I will work on this approach and report back.