Changeset 1356 for applications
- Timestamp:
- 05/04/11 18:21:26 (14 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/robust/robustlib.h
r1349 r1356 804 804 bool is_first = (current_parent->message_counter == 1); 805 805 806 bool out_of_the_game = true; 807 806 808 if(shouldmerge) 807 809 { … … 826 828 if(parent_state == 1) 827 829 { 828 ((toprow*)current_parent)->condition_sum-=toremove->value; 829 ((toprow*)current_parent)->condition_order--; 830 ((toprow*)current_parent)->condition_sum-=toremove->value; 830 831 } 831 832 832 833 if(parent_state == -1) 833 834 { 834 ((toprow*)current_parent)->condition_sum+=toremove->value; 835 ((toprow*)current_parent)->condition_order--; 835 ((toprow*)current_parent)->condition_sum+=toremove->value; 836 836 } 837 838 ((toprow*)current_parent)->condition_order--; 839 837 840 838 841 if(current_parent->mergechild != NULL) 839 842 { 843 out_of_the_game = false; 844 840 845 if(current_parent->mergechild->get_multiplicity()==1) 841 846 { … … 849 854 current_parent->mergechild->negativeparent = current_parent; 850 855 } 851 } 856 } 857 else 858 { 859 out_of_the_game = true; 860 } 852 861 } 853 else 862 863 if(out_of_the_game) 854 864 { 855 865 //current_parent->set_state(0,MERGE); … … 985 995 } 986 996 987 if( current_parent->mergechild == NULL)997 if(out_of_the_game) 988 998 { 989 999 current_parent->positivechildren.clear(); … … 1076 1086 // cout << "Stepped." << endl; 1077 1087 1088 if(marker==101) 1089 { 1090 if(!(*horiz_ref).negativechildren.empty()||!(*horiz_ref).positivechildren.empty()||!(*horiz_ref).neutralchildren.empty()||!(*horiz_ref).kids_rel_addresses.empty()||!(*horiz_ref).mergechild==NULL||!(*horiz_ref).negativeneutralvertices.empty()) 1091 { 1092 cout << "Cleaning error!" << endl; 1093 } 1094 1095 } 1096 1078 1097 for(set<simplex*>::iterator sim_ref = (*horiz_ref).triangulation.begin();sim_ref!=(*horiz_ref).triangulation.end();sim_ref++) 1079 1098 { … … 1285 1304 local_condition = appended_coords*toadd; 1286 1305 1287 cout << "Vertex multiplicity: "<< current_vertex->get_multiplicity() << endl;1306 // cout << "Vertex multiplicity: "<< current_vertex->get_multiplicity() << endl; 1288 1307 1289 1308 current_vertex->set_state(local_condition,SPLIT); … … 1339 1358 } 1340 1359 1341 // step_me(1);1360 // step_me(1); 1342 1361 1343 1362 if(should_remove) … … 1376 1395 { 1377 1396 (*merge_ref)->lower_multiplicity(); 1397 } 1398 1399 if((*merge_ref)->get_state(SPLIT)!=0||(*merge_ref)->totally_neutral) 1400 { 1401 (*merge_ref)->positivechildren.clear(); 1402 (*merge_ref)->negativechildren.clear(); 1403 (*merge_ref)->neutralchildren.clear(); 1404 (*merge_ref)->totallyneutralgrandchildren.clear(); 1405 (*merge_ref)->positiveneutralvertices.clear(); 1406 (*merge_ref)->negativeneutralvertices.clear(); 1407 (*merge_ref)->totally_neutral = NULL; 1408 (*merge_ref)->kids_rel_addresses.clear(); 1378 1409 } 1379 1410 } … … 1384 1415 toprow* current_positive = (toprow*)(*merge_ref)->positiveparent; 1385 1416 toprow* current_negative = (toprow*)(*merge_ref)->negativeparent; 1417 1418 if(current_positive->totally_neutral!=current_negative->totally_neutral) 1419 { 1420 throw new exception("Both polyhedrons must be totally neutral if they should be merged!"); 1421 } 1386 1422 1387 1423 //current_positive->condition_sum -= toremove; … … 1439 1475 current_positive->set_state(0,SPLIT); 1440 1476 for_splitting[k].push_back(current_positive); 1477 1441 1478 will_be_split = true; 1442 1479 } … … 1477 1514 } 1478 1515 else 1479 { 1480 if(!current_positive->totally_neutral) 1481 { 1482 current_positive->positivechildren.clear(); 1483 current_positive->negativechildren.clear(); 1484 current_positive->neutralchildren.clear(); 1485 // current_positive->totallyneutralchildren.clear(); 1486 current_positive->totallyneutralgrandchildren.clear(); 1487 current_positive->positiveneutralvertices.clear(); 1488 current_positive->negativeneutralvertices.clear(); 1489 current_positive->totally_neutral = NULL; 1490 current_positive->kids_rel_addresses.clear(); 1491 } 1492 1493 } 1494 1495 1516 { 1517 current_positive->positivechildren.clear(); 1518 current_positive->negativechildren.clear(); 1519 current_positive->neutralchildren.clear(); 1520 // current_positive->totallyneutralchildren.clear(); 1521 current_positive->totallyneutralgrandchildren.clear(); 1522 current_positive->positiveneutralvertices.clear(); 1523 current_positive->negativeneutralvertices.clear(); 1524 current_positive->totally_neutral = NULL; 1525 current_positive->kids_rel_addresses.clear(); 1526 } 1496 1527 1497 1528 current_positive->vertices.insert(current_negative->vertices.begin(),current_negative->vertices.end()); … … 1504 1535 current_positive->vertices.erase(*vert_ref); 1505 1536 1506 if( (current_positive->get_state(SPLIT)==0&&!current_positive->totally_neutral)||(current_negative->get_state(SPLIT)==0&&!current_negative->totally_neutral))1537 if(will_be_split) 1507 1538 { 1508 1539 current_positive->negativeneutralvertices.erase(*vert_ref); … … 1517 1548 } 1518 1549 1519 if(current_positive->totally_neutral)1520 {1521 if(!current_negative->totally_neutral)1522 {1523 for(set<polyhedron*>::iterator grand_ref = current_positive->grandparents.begin();grand_ref!=current_positive->grandparents.end();grand_ref++)1524 {1525 (*grand_ref)->totallyneutralgrandchildren.erase(current_positive);1526 }1527 }1528 else1529 {1530 for(set<polyhedron*>::iterator grand_ref = current_negative->grandparents.begin();grand_ref!=current_negative->grandparents.end();grand_ref++)1531 {1532 (*grand_ref)->totallyneutralgrandchildren.erase(current_negative);1533 (*grand_ref)->totallyneutralgrandchildren.insert(current_positive);1534 }1535 }1536 }1537 else1538 {1539 if(current_negative->totally_neutral)1540 {1541 for(set<polyhedron*>::iterator grand_ref = current_negative->grandparents.begin();grand_ref!=current_negative->grandparents.end();grand_ref++)1542 {1543 (*grand_ref)->totallyneutralgrandchildren.erase(current_negative);1544 }1545 }1546 }1547 1548 current_positive->grandparents.clear();1549 1550 1550 1551 1551 1552 current_positive->totally_neutral = (current_positive->totally_neutral && current_negative->totally_neutral); 1553 1552 if(current_positive->totally_neutral) 1553 { 1554 for(set<polyhedron*>::iterator grand_ref = current_negative->grandparents.begin();grand_ref!=current_negative->grandparents.end();grand_ref++) 1555 { 1556 (*grand_ref)->totallyneutralgrandchildren.erase(current_negative); 1557 (*grand_ref)->totallyneutralgrandchildren.insert(current_positive); 1558 } 1559 } 1560 1561 current_positive->grandparents.clear(); 1562 1554 1563 normalization_factor += current_positive->triangulate(k==for_splitting.size()-1 && !will_be_split); 1555 1564 … … 1627 1636 1628 1637 1629 cout << endl; 1630 1631 if(this->statistic.row_size(2)==62) 1632 { 1633 this->step_me(2); 1634 } 1638 cout << endl; 1635 1639 1636 1640 if(should_add) 1637 1641 { 1642 cout << "Splitting." << endl; 1643 1638 1644 int k = 1; 1645 int counter = 0; 1639 1646 1640 1647 vector<list<polyhedron*>>::iterator beginning_ref = ++for_splitting.begin(); … … 1645 1652 for(list<polyhedron*>::reverse_iterator split_ref = vert_ref->rbegin();split_ref != vert_ref->rend();split_ref++) 1646 1653 { 1654 counter++; 1655 1647 1656 polyhedron* new_totally_neutral_child; 1648 1657 … … 1775 1784 normalization_factor += negative_poly->triangulate(k==for_splitting.size()-1); 1776 1785 1777 statistic.append_polyhedron(k-1, new_totally_neutral_child); 1786 statistic.append_polyhedron(k-1, new_totally_neutral_child); 1787 1788 1778 1789 1779 1790 statistic.insert_polyhedron(k, positive_poly, current_polyhedron); … … 1812 1823 */ 1813 1824 1814 // step_me(0);1825 step_me(101); 1815 1826 1816 1827 }