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;
Many thanks!