]> git.tdb.fi Git - r2c2.git/commitdiff
Use Objects in Manipulator::neighbors
authorMikko Rasa <tdb@tdb.fi>
Mon, 13 May 2013 21:03:42 +0000 (00:03 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 13 May 2013 21:03:42 +0000 (00:03 +0300)
source/designer/manipulator.cpp
source/designer/manipulator.h

index 9dbf1cbb8900c7c240caba8f6a9ebe48212a5ad8..802adb16fd45942e95deb2ac7038b347cb909557 100644 (file)
@@ -139,7 +139,7 @@ void Manipulator::even_slope(bool smooth)
        float total_len = 0;
 
        list<TrackOrder> order;
-       Track *cur = *neighbors.begin();
+       Track *cur = dynamic_cast<Track *>(*neighbors.begin());
        while(tracks2.size())
        {
                bool rev = false;
@@ -164,7 +164,7 @@ void Manipulator::even_slope(bool smooth)
                total_len += cur->get_type().get_total_length();
        }
 
-       set<Track *>::iterator nb = neighbors.begin();
+       set<Object *>::iterator nb = neighbors.begin();
        int epi = (*nb)->get_link_slot(*order.front().track);
        float start_z = (*nb)->get_snap_node(epi).position.z;
        ++nb;
@@ -325,7 +325,7 @@ void Manipulator::button_press(unsigned btn)
 
                if(m!=EXTEND)
                {
-                       for(set<Track *>::iterator i=neighbors.begin(); i!=neighbors.end(); ++i)
+                       for(set<Object *>::iterator i=neighbors.begin(); i!=neighbors.end(); ++i)
                                for(vector<MObject>::iterator j=objects.begin(); j!=objects.end(); ++j)
                                        j->object->break_link(**i);
                }
@@ -567,24 +567,21 @@ void Manipulator::update_neighbors()
        neighbors.clear();
        for(vector<MObject>::iterator i=objects.begin(); i!=objects.end(); ++i)
        {
-               Track *track = dynamic_cast<Track *>(i->object);
-               if(!track)
-                       continue;
-
-               const vector<Track *> &links = track->get_links();
-               for(vector<Track *>::const_iterator j=links.begin(); j!=links.end(); ++j)
+               unsigned nls = i->object->get_n_link_slots();
+               for(unsigned j=0; j<nls; ++j)
                {
-                       if(!*j)
+                       Object *linked = i->object->get_link(j);
+                       if(!linked)
                                continue;
-                       if(neighbors.count(*j))
+                       if(neighbors.count(linked))
                                continue;
 
                        bool ok = true;
                        for(vector<MObject>::iterator k=objects.begin(); (k!=objects.end() && ok); ++k)
-                               ok = (k->object!=*j);
+                               ok = (k->object!=linked);
 
                        if(ok)
-                               neighbors.insert(*j);
+                               neighbors.insert(linked);
                }
        }
 }
index cb4759ac7ad1a671e757b598cc67945199ccbba0..12e551bb7a1da125a7c3365f4806271b5d561d2c 100644 (file)
@@ -53,7 +53,7 @@ private:
        float angle;
        float rot_origin;
        float elev_origin;
-       std::set<R2C2::Track *> neighbors;
+       std::set<R2C2::Object *> neighbors;
        std::vector<R2C2::Track *> extend_tracks;
 
 public: