Hi @dale,
Here I attach an example reproducing it. I have the points A, ab, B, bc, C, cd, D (sorry if the notation is confusing) forming the segments [A,B], [B, C], [C, D] and I want a PolylineCurve joining them, regardless the order in which I append the segments.
This piece of code does it well:
ON_3dPoint A(0.0, 0.0, 0.0);
ON_3dPoint ab(0.25, 0.1, 0.0);
ON_3dPoint B(0.5, 0.5, 0.0);
ON_3dPoint bc(0.75, 0.9, 0.0);
ON_3dPoint C(1.0, 1.0, 0.0);
ON_3dPoint cd(1.5, 0.5, 0.0);
ON_3dPoint D(2.0, 0.0, 0.0);
ON_3dPointArray segmentAB; segmentAB.Append(A); segmentAB.Append(ab); segmentAB.Append(B);
ON_3dPointArray segmentBC; segmentBC.Append(B); segmentBC.Append(bc); segmentBC.Append(C);
ON_3dPointArray segmentCD; segmentCD.Append(C); segmentCD.Append(cd); segmentCD.Append(D);
ON_SimpleArray<ON_PolylineCurve*> curves(3);
ON_PolylineCurve* joinedCurve = new ON_PolylineCurve();
curves[0] = new ON_PolylineCurve(segmentAB);
curves[1] = new ON_PolylineCurve(segmentBC);
curves[2] = new ON_PolylineCurve(segmentCD);
joinedCurve->Append( *curves[0] );
joinedCurve->Append( *curves[1] );
joinedCurve->Append( *curves[2] );
CRhinoCurveObject* curveObject = new CRhinoCurveObject();
curveObject->SetCurve( joinedCurve );
context.m_doc.AddObject( curveObject );
context.m_doc.Redraw();
as it gives the right polyline curve:
However, in my plugin most usually the segments are not sorted. So, I usually have, for example, this change in the code, appending first [C, D] and then [A, B], [B, C]:
joinedCurve->Append( *curves[2] );
joinedCurve->Append( *curves[0] );
joinedCurve->Append( *curves[1] );
then the polyline does this weird change:
Do you know what could be happening? Maybe I’m obliged to put the segments in the right order of parameterization?
Many thanks,
Pablo
DemoPolylineCurve.zip (12.0 MB)