Trim at curve crossing

 From:  Michael Gibson
11423.2 In reply to 11423.1 
Hi Peer, there isn't anything built in to the regular Trim that would do that. I'd think you would need a custom made function.

First you'd need to get the intersections between the curves which you can do with the intersect factory:

code:
var curves = moi.geometryDatabase.getSelectedObjects();

if ( curves.length == 2 )
{
    var curve_list = moi.geometryDatabase.createObjectList();
    var factory = moi.command.createFactory( 'intersect' );
    factory.setInput( 0, curves );

     var points_list = factory.calculate().getPoints();
     factory.cancel();

     var text = points_list.length + ' points\n';

     for ( var i = 0; i < points_list.length; ++i )
     {
        var pt_obj = points_list.item(i);
        text += pt_obj.pt.x.toFixed(2) + ', ' + pt_obj.pt.y.toFixed(2) + ', ' + pt_obj.pt.z.toFixed(2) + '\n';
    }

    moi.ui.alert( text );
}


Then for every point get a curve parameter value for the point with
var t = crv.dropPoint( pt );

Then you can evaluate the tangents of both curves using
var tangent = crv.evaluateTangent( t );

If the angle between the tangents is close to 0 or close to 180 degrees then it's one of the grazing intersections so skip it.

Otherwise keep it as a cutting parameter value, sort those cut parameters and then go through them generating pieces using:
var piece = crv.trim( paramA, paramB );

If it's a closed curve and you don't have the start/end of the curve as a cutting parameter then you probably want to call
var reseamed_crv = crv.changeClosedCurveSeam( t );

- Michael