MCPcopy Create free account
hub / github.com/AngusJohnson/Clipper2 / BuildIntersectList

Method BuildIntersectList

CPP/Clipper2Lib/src/clipper.engine.cpp:2390–2446  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2388 }
2389
2390 bool ClipperBase::BuildIntersectList(const int64_t top_y)
2391 {
2392 if (!actives_ || !actives_->next_in_ael) return false;
2393
2394 //Calculate edge positions at the top of the current scanbeam, and from this
2395 //we will determine the intersections required to reach these new positions.
2396 AdjustCurrXAndCopyToSEL(top_y);
2397 //Find all edge intersections in the current scanbeam using a stable merge
2398 //sort that ensures only adjacent edges are intersecting. Intersect info is
2399 //stored in FIntersectList ready to be processed in ProcessIntersectList.
2400 //Re merge sorts see https://stackoverflow.com/a/46319131/359538
2401
2402 Active* left = sel_, * right, * l_end, * r_end, * curr_base, * tmp;
2403
2404 while (left && left->jump)
2405 {
2406 Active* prev_base = nullptr;
2407 while (left && left->jump)
2408 {
2409 curr_base = left;
2410 right = left->jump;
2411 l_end = right;
2412 r_end = right->jump;
2413 left->jump = r_end;
2414 while (left != l_end && right != r_end)
2415 {
2416 if (right->curr_x < left->curr_x)
2417 {
2418 tmp = right->prev_in_sel;
2419 for (; ; )
2420 {
2421 AddNewIntersectNode(*tmp, *right, top_y);
2422 if (tmp == left) break;
2423 tmp = tmp->prev_in_sel;
2424 }
2425
2426 tmp = right;
2427 right = ExtractFromSEL(tmp);
2428 l_end = right;
2429 Insert1Before2InSEL(tmp, left);
2430 if (left == curr_base)
2431 {
2432 curr_base = tmp;
2433 curr_base->jump = r_end;
2434 if (!prev_base) sel_ = curr_base;
2435 else prev_base->jump = curr_base;
2436 }
2437 }
2438 else left = left->next_in_sel;
2439 }
2440 prev_base = curr_base;
2441 left = r_end;
2442 }
2443 left = sel_;
2444 }
2445 return intersect_nodes_.size() > 0;
2446 }
2447

Callers

nothing calls this directly

Calls 2

ExtractFromSELFunction · 0.85
Insert1Before2InSELFunction · 0.85

Tested by

no test coverage detected