Problem in divide segments for multi curves

Dear All:

I encounter a problem in divide multi curve object. I make a minor change based on the sample. I want to divide two curves but only one curve is divided as shown below. The code is as follows:

CRhinoGetObject go;
go.SetCommandPrompt(L"Select curves to divide");
go.SetGeometryFilter(CRhinoGetObject::curve_object);
go.GetObjects(1, 0);

if (go.Result() == CRhinoGet::cancel)
return CRhinoCommand::cancel;

if (go.Result() != CRhinoGet::object | go.ObjectCount() <= 0)
return CRhinoCommand::failure;


CRhinoGetInteger gi;
gi.SetCommandPrompt(L"Number of segments");
gi.SetDefaultInteger(2);
gi.SetLowerLimit(2);
gi.SetUpperLimit(100);
gi.GetInteger();

if (gi.Result() == CRhinoGet::cancel)
return CRhinoCommand::cancel;

if (gi.Result() != CRhinoGet::number)
return CRhinoCommand::failure;

int count = gi.Number();
count++;
ON_SimpleArray<double> t(count);
t.SetCount(count);

int i;
for (i = 0; i < count; i++)
{
    double param = (double)i / ((double)count - 1);
    t[i] = param;
}

int id, id_count = go.ObjectCount();
for (id = 0; id < id_count; id++)
{
    CRhinoObjRef& objref = go.Object(id);
    const ON_Curve* crv = objref.Curve();
    if (!crv)
    return CRhinoCommand::failure;
    if (crv->GetNormalizedArcLengthPoints(count, (double*)&t[0], (double*)&t[0]))
    {
        for (i = 0; i < count; i++)
        {
            ON_3dPoint pt = crv->PointAt(t[i]);
            context.m_doc.AddPointObject(pt);
        }
        
    }
}
context.m_doc.Redraw();
return CRhinoCommand::success;

problem

Many thanks!

I have already solved the problem. The ON_SimpleArray t(count) should be initilizaed for every object.




int id, id_count = go.ObjectCount();
for (id = 0; id < id_count; id++)
{
    CRhinoObjRef& objref = go.Object(id);
    const ON_Curve* crv = objref.Curve();
    if (!crv)
    return CRhinoCommand::failure;
    for (int i = 0; i < count; i++)
    {
        double param = (double)i / ((double)count - 1);
        t[i] = param;
    }
    if (crv->GetNormalizedArcLengthPoints(count, (double*)&t[0], (double*)&t[0]))
    {
        for (i = 0; i < count; i++)
        {
            ON_3dPoint pt = crv->PointAt(t[i]);
            context.m_doc.AddPointObject(pt);
        }
        
    }
}