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