| 581 | } // findIntersection |
| 582 | |
| 583 | static bool |
| 584 | splitAt(const BezierCPs &cps, |
| 585 | double time, |
| 586 | double t, |
| 587 | std::list<BezierCPs>* ret) |
| 588 | { |
| 589 | Point dir = dirVect(cps, time, t); |
| 590 | |
| 591 | if ( (dir.x != 0.) || (dir.y != 0.) ) { |
| 592 | Point z = getPointAt(cps, time, t); |
| 593 | Point zLeft = getLeftPointAt(cps, time, t); |
| 594 | Point zRight = getRightPointAt(cps, time, t); |
| 595 | Point q; |
| 596 | q.x = z.x; |
| 597 | q.y = z.y + dir.y; |
| 598 | boost::shared_ptr<BezierCP> newPoint; |
| 599 | int pointIdx = -1; |
| 600 | findIntersection(cps, time, z, q, &newPoint, &pointIdx); |
| 601 | assert( pointIdx >= 0 && pointIdx < (int)cps.size() ); |
| 602 | |
| 603 | //Separate the original patch in 2 parts and call regularize again on each of them |
| 604 | BezierCPs firstPart, secondPart; |
| 605 | BezierCPs::const_iterator it = cps.begin(); |
| 606 | std::advance( it, std::ceil(t) ); |
| 607 | /* |
| 608 | "it" is now pointing to the next control point after the split point |
| 609 | */ |
| 610 | BezierCPs::const_iterator start = it; |
| 611 | BezierCPs::const_iterator end = cps.begin(); |
| 612 | /* |
| 613 | "end" is the control point before the intersection point |
| 614 | */ |
| 615 | if (pointIdx > 0) { |
| 616 | std::advance(end, pointIdx); |
| 617 | } |
| 618 | |
| 619 | |
| 620 | boost::shared_ptr<BezierCP> startingPoint = makeBezierCPFromPoint(z, zLeft, zRight); |
| 621 | |
| 622 | //Start by adding the split point (if it is not a control point) |
| 623 | if (std::ceil(t) != t) { |
| 624 | firstPart.push_back(startingPoint); |
| 625 | } |
| 626 | |
| 627 | |
| 628 | //Add all control points until we reach the point before the intersection point |
| 629 | for (; it != end; ) { |
| 630 | firstPart.push_back(*it); |
| 631 | |
| 632 | ++it; |
| 633 | if ( it == cps.end() ) { |
| 634 | it = cps.begin(); |
| 635 | } |
| 636 | } |
| 637 | firstPart.push_back(*end); |
| 638 | //Add the intersection point |
| 639 | firstPart.push_back(newPoint); |
| 640 |
no test coverage detected