Changeset 1212 for applications/robust

Show
Ignore:
Timestamp:
10/06/10 18:13:42 (14 years ago)
Author:
sindj
Message:

Pokracovani split - nedokonceno. JS

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • applications/robust/robustlib.h

    r1211 r1212  
    264264 
    265265 
    266         void send_state_message(polyhedron* sender, bool shouldsplit, bool shouldmerge, int level) 
     266        void send_state_message(polyhedron* sender, vec toadd, vec toremove, int level) 
    267267        {                        
    268268 
     269                bool should_remove = (toremove.size() != 0); 
     270                bool should_add    = (toadd.size() != 0); 
     271                 
    269272                if(shouldsplit||shouldmerge) 
    270273                { 
     
    384387                                                                { 
    385388                                                                        current_parent->set_state(-1, SPLIT); 
     389 
     390                                                                        ((toprow*)current_parent)->condition-=toadd; 
    386391                                                                } 
    387392                                                                else if(current_parent->positivechildren.size()>0) 
    388393                                                                { 
    389                                                                 current_parent->set_state(1, SPLIT); 
     394                                                                        current_parent->set_state(1, SPLIT); 
     395 
     396                                                                        ((toprow*)current_parent)->condition+=toadd; 
    390397                                                                } 
    391398                                                                else 
     
    422429                create_statistic(number_of_parameters); 
    423430 
    424                 for(int i = 0;i<statistic.size();i++) 
     431                for(vector<vector<polyhedron*>::iterator local_iter = statistic.begin();local_iter<statistic.end();local_iter++) 
    425432                { 
    426433                        vector<polyhedron*> empty_split; 
     
    519526                        { 
    520527                                vec appended_vec = current_vertex->get_coordinates(); 
    521                                 appended_vec.ins(0,1.0); 
     528                                appended_vec.ins(0,-1.0); 
    522529 
    523530                                if(should_add) 
     
    548555                        } 
    549556 
    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                                } 
    562625                        } 
    563626                }