Curve extrusion along curve differences between gui and api

Dear all,

I have developed a c++ Rhino plug-in and now I need to write a command to enlarge planar curves of a specific offset value, on a 2D plane.
The expected result is a 2D surface.

I’m able to reach exactly the target using the Rhino user interface, in particular the command “_ExtrudeCrvAlongCrv”.
I simply create a circle with radius equal to the required offset at an end of the curve to be offset, then I use the circle as shape and the curve as drive curve.
The result i simply perfect, as show in figure “Input.png”

and “UI_brep.png”

The problems occur when I try to reach the same result using Rhino SDK API:
In particular I use “Rhino1RailSweep” function, expecting the same results, but instead the output is the one shown in figure “API_brep.png”.

Top-left and top-right example are completely wrong but there are moreover less evident errors:
A) Some corners are not rounded:

B) In one case, the surface does not end with the circle center at the end of the line, but just before

C) In general the algorithm seems to be less precise

The code I wrote is the following:

const double in_offset;
const ON_Curve& in_drive_curve;
const ON_Circle shape(ON_xy_plane, in_drive_curve.PointAtStart(), in_offset);
ON_NurbsCurve shape_nurb;
const int is_nurb_correct =
shape.GetNurbForm(shape_nurb);
if (!is_nurb_correct)
{
	return;
}

ON_SimpleArray<const ON_Curve*> shapes;
shapes.Append(&shape_nurb);

ON_SimpleArray<ON_Brep*> breps;
Rhino1RailSweep(
	breps,
	&in_drive_curve,
	shapes);

Can you please supply to me help for my purpose?
@Dale usually is great with this problems.

Thank you,

Ciao Alberto,

scusa la schiettezza ma non mi pare una grande idea estrudere una curva piana e creare una superficie del genere… vien fuori una roba che si autointerseca…

Non è meglio utilizzare un pipe lungo il percorso e poi intersecarlo con un piano per ottenere la curva piana sulla quale fare la superficie?

Il comando Offset con opzione Both Side e Cap=Round non riesci a richiamarlo da SDK ?
Ti verrebbe una cosa come da immagine sotto

Ci sono veramente tanti modi per creare quello che ti serve, ma fare un extrudecrv lungo lo stesso piano dove giace la curva piana mi sembra l’inizio di un incubo…

Edit
Vedendo le tue immagini presumo che le curve siano dei percorsi utensile… fresatura magari?
Quindi stai facendo una simulazione del percorso utensile?
O stai facendo un aggiornamento pezzo lavorato per vedere dove ci sono sovrametalli da togliere?
Se si tratta solo di una simulazione, allora potresti dividere il percorso (tipo estrapolare un punto ogni 0.01mm) e su quel punto copiare la forma utensile.
Alla fine sommando tutte le circonferenze (con un curve boolean) ottieni l’area lavorata.
Questo approccio può essere più efficace se siamo in presenza di percorsi sovrapposti o autointersecanti dove comandi tipo offset, extrude e compagnia bella tendono a crashare (perchè cercano di risolvere situazioni anomale).

5 Mi Piace