From: Mikko Rasa Date: Mon, 13 May 2013 21:03:42 +0000 (+0300) Subject: Use Objects in Manipulator::neighbors X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=679c37910ab4d8030b3c09f6591381789b14a5f0;p=r2c2.git Use Objects in Manipulator::neighbors --- diff --git a/source/designer/manipulator.cpp b/source/designer/manipulator.cpp index 9dbf1cb..802adb1 100644 --- a/source/designer/manipulator.cpp +++ b/source/designer/manipulator.cpp @@ -139,7 +139,7 @@ void Manipulator::even_slope(bool smooth) float total_len = 0; list order; - Track *cur = *neighbors.begin(); + Track *cur = dynamic_cast(*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::iterator nb = neighbors.begin(); + set::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::iterator i=neighbors.begin(); i!=neighbors.end(); ++i) + for(set::iterator i=neighbors.begin(); i!=neighbors.end(); ++i) for(vector::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::iterator i=objects.begin(); i!=objects.end(); ++i) { - Track *track = dynamic_cast(i->object); - if(!track) - continue; - - const vector &links = track->get_links(); - for(vector::const_iterator j=links.begin(); j!=links.end(); ++j) + unsigned nls = i->object->get_n_link_slots(); + for(unsigned j=0; jobject->get_link(j); + if(!linked) continue; - if(neighbors.count(*j)) + if(neighbors.count(linked)) continue; bool ok = true; for(vector::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); } } } diff --git a/source/designer/manipulator.h b/source/designer/manipulator.h index cb4759a..12e551b 100644 --- a/source/designer/manipulator.h +++ b/source/designer/manipulator.h @@ -53,7 +53,7 @@ private: float angle; float rot_origin; float elev_origin; - std::set neighbors; + std::set neighbors; std::vector extend_tracks; public: