550 | | send_state_message(current_vertex, should_add, should_remove, 0); |
551 | | } |
552 | | |
553 | | for(vector<vector<polyhedron*>>::iterator vert_ref = for_splitting.begin();vert_ref<for_splitting.end();vert_ref++) |
554 | | { |
555 | | int original_size = (*vert_ref).size(); |
556 | | |
557 | | for(int split_counter = 0;split_counter<original_size;split_counter++) |
558 | | { |
559 | | polyhedron* current_polyhedron = (*vert_ref)[original_size-1-split_counter]; |
560 | | |
561 | | |
| 557 | send_state_message(current_vertex, toadd, toremove, 0); |
| 558 | } |
| 559 | |
| 560 | if(should_add) |
| 561 | { |
| 562 | for(vector<vector<polyhedron*>>::iterator vert_ref = for_splitting.begin();vert_ref<for_splitting.end();vert_ref++) |
| 563 | { |
| 564 | int original_size = (*vert_ref).size(); |
| 565 | |
| 566 | for(int split_counter = 0;split_counter<original_size;split_counter++) |
| 567 | { |
| 568 | polyhedron* current_polyhedron = (*vert_ref)[original_size-1-split_counter]; |
| 569 | |
| 570 | polyhedron* new_totally_neutral_child; |
| 571 | |
| 572 | if(vert_ref == for_splitting.begin()) |
| 573 | { |
| 574 | vec coordinates1 = ((vertex*)current_polyhedron->children[0])->get_coordinates(); |
| 575 | vec coordinates2 = ((vertex*)current_polyhedron->children[1])->get_coordinates(); |
| 576 | coordinates2.ins(0,-1.0); |
| 577 | |
| 578 | double t = (-toadd*coordinates2)/(toadd(1,toadd.size()-1)*coordinates1)+1; |
| 579 | |
| 580 | vec new_coordinates = coordinates1*t+(coordinates2(1,coordinates2.size()-1)-coordinates1); |
| 581 | |
| 582 | vertex* neutral_vertex = new vertex(new_coordinates); |
| 583 | |
| 584 | new_totally_neutral_child = neutral_vertex; |
| 585 | } |
| 586 | else |
| 587 | { |
| 588 | toprow* neutral_toprow = new toprow(); |
| 589 | |
| 590 | new_totally_neutral_child = neutral_toprow; |
| 591 | } |
| 592 | |
| 593 | new_totally_neutral_child->children.insert(new_totally_neutral_child->children.end(), |
| 594 | current_polyhedron->totallyneutralgrandchildren.begin(), |
| 595 | current_polyhedron->totallyneutralgrandchildren.end()); |
| 596 | |
| 597 | toprow* positive_poly = new toprow(((toprow*)current_polyhedron)->condition+toadd); |
| 598 | toprow* negative_poly = new toprow(((toprow*)current_polyhedron)->condition-toadd); |
| 599 | |
| 600 | positive_poly->children.push_back(new_totally_neutral_child); |
| 601 | negative_poly->children.push_back(new_totally_neutral_child); |
| 602 | |
| 603 | positive_poly->parents.insert(positive_poly->parents.end(), |
| 604 | current_polyhedron->parents.begin(), |
| 605 | current_polyhedron->parents.end()); |
| 606 | |
| 607 | negative_poly->parents.insert(negative_poly->parents.end(), |
| 608 | current_polyhedron->parents.begin(), |
| 609 | current_polyhedron->parents.end()); |
| 610 | |
| 611 | positive_poly->children.insert(positive_poly->children.end(), |
| 612 | current_polyhedron->positivechildren.begin(), |
| 613 | current_polyhedron->positivechildren.end()); |
| 614 | |
| 615 | negative_poly->children.insert(negative_poly->children.end(), |
| 616 | current_polyhedron->negativechildren.begin(), |
| 617 | current_polyhedron->negativechildren.end()); |
| 618 | |
| 619 | |
| 620 | |
| 621 | |
| 622 | |
| 623 | |
| 624 | } |