MCPcopy Create free account
hub / github.com/MrKepzie/Natron / splitAt

Function splitAt

Engine/CoonsRegularization.cpp:583–672  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

581} // findIntersection
582
583static bool
584splitAt(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

Callers 2

regularizeMethod · 0.85

Calls 12

dirVectFunction · 0.85
getPointAtFunction · 0.85
getLeftPointAtFunction · 0.85
getRightPointAtFunction · 0.85
findIntersectionFunction · 0.85
ceilFunction · 0.85
makeBezierCPFromPointFunction · 0.85
sizeMethod · 0.45
beginMethod · 0.45
push_backMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected