Current Origin C support for range based calculation is quite tricky. Best would be to make a copy of the curve to do analysis, the following code will do,
// nFrom and nTo are inclusive index (0 offset) to integrate, nTo = -1 to integrate to the end
bool integrate(curvebase& cuv, IntegrationResult& result, int nFrom = 0, int nTo = -1)
{
if(0 == nFrom && -1 == nTo)
return Curve_integrate(&cuv, &result);
// if range specified, must make local copy
// to ensure that the original range is not modified
int nNumMissingInCopy, nSrcOffset;
Curve cc(cuv, nNumMissingInCopy, nSrcOffset,
CURVECOPY_SCAN_OVER_MISSING_FROM_LEFT | CURVECOPY_SCAN_OVER_MISSING_FROM_RIGHT | CURVECOPY_SKIP_MISSING_INSIDE,
nFrom, nTo);
return Curve_integrate(&cc, &result);
}
void test(int i1, int i2)
{
IntegrationResult aa;
if(integrate(Project.ActiveCurveBase(), aa, i1, i2))
{
printf("From %f to %f, area = %f\n", aa.x1, aa.x2, aa.Area);
}
}
CP