From 679c37910ab4d8030b3c09f6591381789b14a5f0 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 14 May 2013 00:03:42 +0300 Subject: [PATCH] Use Objects in Manipulator::neighbors --- source/designer/manipulator.cpp | 23 ++++++++++------------- source/designer/manipulator.h | 2 +- 2 files changed, 11 insertions(+), 14 deletions(-) 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: -- 2.45.2