MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / computeWindingNumber

Function computeWindingNumber

Engine/CoonsRegularization.cpp:1347–1377  ·  view source on GitHub ↗

Return the winding number of the region bounded by the (cyclic) path relative to the point z, or the largest odd integer if the point lies on the path.

Source from the content-addressed store, hash-verified

1345// relative to the point z, or the largest odd integer if the point lies on
1346// the path.
1347static int
1348computeWindingNumber(const BezierCPs& patch,
1349 double time,
1350 const Point& z)
1351{
1352 assert(patch.size() >= 3);
1353
1354 static const int undefined = std::numeric_limits<int>::max() % 2 ? std::numeric_limits<int>::max() : std::numeric_limits<int>::max() - 1;
1355 const unsigned maxdepth = DBL_MANT_DIG;
1356 int count = 0;
1357 BezierCPs::const_iterator it = patch.begin();
1358 BezierCPs::const_iterator next = it;
1359 ++next;
1360 for (; it != patch.end(); ++it, ++next) {
1361 if ( next == patch.end() ) {
1362 next = patch.begin();
1363 }
1364
1365 Point p0, p1, p2, p3;
1366 (*it)->getPositionAtTime(false, time, ViewIdx(0), &p0.x, &p0.y);
1367 (*it)->getRightBezierPointAtTime(false, time, ViewIdx(0), &p1.x, &p1.y);
1368 (*next)->getLeftBezierPointAtTime(false, time, ViewIdx(0), &p2.x, &p2.y);
1369 (*next)->getPositionAtTime(false, time, ViewIdx(0), &p3.x, &p3.y);
1370
1371 if ( checkCurve(p0, p1, p2, p3, z, &count, maxdepth) ) {
1372 return undefined;
1373 }
1374 }
1375
1376 return count;
1377}
1378
1379void
1380CoonsRegularization::regularize(const BezierCPs &patch,

Callers 1

regularizeMethod · 0.85

Calls 9

maxFunction · 0.85
checkCurveFunction · 0.85
getPositionAtTimeMethod · 0.80
ViewIdxClass · 0.70
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected