------------------------------------------------------------------------------
| 2426 | |
| 2427 | //------------------------------------------------------------------------------ |
| 2428 | void vtkReebGraph::Implementation::Collapse(vtkIdType startingNode, vtkIdType endingNode, |
| 2429 | vtkReebLabelTag startingLabel, vtkReebLabelTag endingLabel) |
| 2430 | { |
| 2431 | |
| 2432 | int L0, L0n, L1, L1n; |
| 2433 | int cont[3] = { 0, 0, 0 }, Case; |
| 2434 | |
| 2435 | if (startingNode == endingNode) |
| 2436 | return; |
| 2437 | |
| 2438 | vtkReebNode* nstart = this->GetNode(startingNode); |
| 2439 | vtkReebNode* nend = this->GetNode(endingNode); |
| 2440 | |
| 2441 | if (!vtkReebGraphIsSmaller(this, startingNode, endingNode, nstart, nend)) |
| 2442 | { |
| 2443 | vtkReebGraphSwapVars(int, startingNode, endingNode); |
| 2444 | vtkReebGraphSwapVars(vtkReebNode*, nstart, nend); |
| 2445 | } |
| 2446 | |
| 2447 | L0 = FindUpLabel(startingNode, startingLabel); |
| 2448 | L1 = FindUpLabel(startingNode, endingLabel); |
| 2449 | |
| 2450 | while (true) |
| 2451 | { |
| 2452 | int A0 = this->GetLabel(L0)->ArcId; |
| 2453 | vtkReebArc* a0 = this->GetArc(A0); |
| 2454 | int A1 = this->GetLabel(L1)->ArcId; |
| 2455 | vtkReebArc* a1 = this->GetArc(A1); |
| 2456 | |
| 2457 | vtkReebNode* down0 = this->GetNode(a0->NodeId0); |
| 2458 | vtkReebNode* up0 = this->GetNode(a0->NodeId1); |
| 2459 | vtkReebNode* up1 = this->GetNode(a1->NodeId1); |
| 2460 | |
| 2461 | /* it is the same arc, no semplification is done */ |
| 2462 | if (A0 == A1) |
| 2463 | { |
| 2464 | Case = 0; |
| 2465 | L0n = this->GetLabel(L0)->VNext; |
| 2466 | L1n = this->GetLabel(L1)->VNext; |
| 2467 | } |
| 2468 | /* there are two arcs connecting the same start-end node */ |
| 2469 | else if (A0 != A1 && a0->NodeId1 == a1->NodeId1) |
| 2470 | { |
| 2471 | Case = 1; |
| 2472 | vtkReebGraphRemoveUpArc(this, a0->NodeId0, A1); |
| 2473 | vtkReebGraphRemoveDownArc(this, a0->NodeId1, A1); |
| 2474 | |
| 2475 | for (int Lcur = this->GetArc(A1)->LabelId0; Lcur; Lcur = this->GetLabel(Lcur)->HNext) |
| 2476 | { |
| 2477 | this->GetLabel(Lcur)->ArcId = A0; |
| 2478 | } |
| 2479 | |
| 2480 | this->GetLabel(this->GetArc(A1)->LabelId0)->HPrev = this->GetArc(A0)->LabelId1; |
| 2481 | this->GetLabel(this->GetArc(A0)->LabelId1)->HNext = this->GetArc(A1)->LabelId0; |
| 2482 | this->GetArc(A0)->LabelId1 = this->GetArc(A1)->LabelId1; |
| 2483 | |
| 2484 | this->GetArc(A1)->LabelId0 = 0; |
| 2485 | this->GetArc(A1)->LabelId1 = 0; |
no test coverage detected