C++ casting ON_Curve to ON_Polyline

How can I cast ON_Curve to ON_Polyline?

This way it would not work, as ON_Polyline has no function cast:

const ON_Polyline* GetPolyline(const ON_Curve* crv)
	const ON_Polyline* p = 0;
	if (crv != 0)
		p = ON_Polyline::Cast(crv);
	return p;

ON_Polyline is not derived from ON_Curve which is why the cast will always fail. You need to try and cast to an ON_PolylineCurve.

In see that checking IsPolyline can return array of points:

ON_SimpleArray< ON_3dPoint > points;
int n = curve->IsPolyline(points);

But this gives error:
C2664 ‘int ON_Curve::IsPolyline(ON_SimpleArray<ON_3dPoint> *,ON_SimpleArray *) const’: cannot convert argument 1 from ‘ON_SimpleArray<ON_3dPoint>’ to ‘ON_SimpleArray<ON_3dPoint> *’

What is a correct way to retrieve collection of points from ON_Curve?

Found it, it has be passed by reference:

	ON_SimpleArray< ON_3dPoint > points;
    int n = curve->IsPolyline(&points);

Does it mean that I always need to cast PolylineCurve and then to Polyline?
Or there is a direction way?

You can either call the IsPolyline function that you found which will also handle curves that are polylines but may not necessarily derive from ON_PolylineCurve, or you try to cast to an ON_PolylineCurve and then look at the m_pline member on that class.

Thank you