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.
| 1345 | // relative to the point z, or the largest odd integer if the point lies on |
| 1346 | // the path. |
| 1347 | static int |
| 1348 | computeWindingNumber(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 | |
| 1379 | void |
| 1380 | CoonsRegularization::regularize(const BezierCPs &patch, |
no test coverage detected