| 534 | |
| 535 | |
| 536 | float CurvesPrimitiveEvaluator::integrateCurve( unsigned curveIndex, float vStart, float vEnd, int samples, Result& typedResult ) const |
| 537 | { |
| 538 | // get first curve point: |
| 539 | (typedResult.*typedResult.m_init)( curveIndex, vStart, this ); |
| 540 | Imath::V3f current; |
| 541 | Imath::V3f previous = typedResult.point(); |
| 542 | |
| 543 | // take ten samples along the curve, and measure the length of the resulting polyline: |
| 544 | const float vStep = ( vEnd - vStart ) / samples; |
| 545 | float length = 0; |
| 546 | float v; |
| 547 | for( int i=1; i <= samples; ++i ) |
| 548 | { |
| 549 | v = vStart + vStep * i; |
| 550 | (typedResult.*typedResult.m_init)( curveIndex, v, this ); |
| 551 | current = typedResult.point(); |
| 552 | |
| 553 | length += ( current - previous ).length(); |
| 554 | |
| 555 | previous = current; |
| 556 | } |
| 557 | |
| 558 | return length; |
| 559 | } |
| 560 | |
| 561 | |
| 562 | float CurvesPrimitiveEvaluator::curveLength( unsigned curveIndex, float vStart, float vEnd ) const |