X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftracktype.cpp;h=3be1ecb364e8631a84ac216960bc154a82277510;hb=8b7d4054b05002d82338775ac9b4ee764a8560e4;hp=c7a6aef7ba70fa85bac12a2ac2c1ff1738cc6a6e;hpb=621c5c938d70ba0d155e0eda91a708db0a52c0dc;p=r2c2.git diff --git a/source/libr2c2/tracktype.cpp b/source/libr2c2/tracktype.cpp index c7a6aef..3be1ecb 100644 --- a/source/libr2c2/tracktype.cpp +++ b/source/libr2c2/tracktype.cpp @@ -7,7 +7,7 @@ using namespace Msp; namespace R2C2 { TrackType::TrackType(const ArticleNumber &an): - art_nr(an), + ObjectType(an), state_bits(0), autofit_preference(1) { } @@ -69,7 +69,7 @@ TrackPoint TrackType::get_point(unsigned epi, unsigned path, float d) const unsigned part_ep = 0; for(vector::const_iterator i=parts.begin(); i!=parts.end(); ++i) { - if((endpoints[epi].paths&(1<get_path()!=path) + if(endpoints[epi].has_path(path) && i->get_path()!=path) continue; unsigned n_part_eps = (i->is_dead_end() ? 1 : 2); @@ -113,6 +113,25 @@ TrackPoint TrackType::get_point(unsigned epi, unsigned path, float d) const } } +TrackPoint TrackType::get_nearest_point(const Vector &p) const +{ + TrackPoint result; + float dist = -1; + + for(vector::const_iterator i=parts.begin(); i!=parts.end(); ++i) + { + TrackPoint n = i->get_nearest_point(p); + float d = distance(n.pos, p); + if(d::const_iterator i=parts.begin(); i!=parts.end(); ++i) @@ -173,11 +192,10 @@ TrackType::Endpoint::Endpoint(float x, float y, float d, unsigned p): TrackType::Loader::Loader(TrackType &t): - Msp::DataFile::BasicLoader(t), + DataFile::DerivedObjectLoader(t), state_bits_set(false) { add("autofit_preference", &TrackType::autofit_preference); - add("description", &TrackType::description); add("object", &TrackType::object); add("state_bits", &Loader::state_bits); add("part", &Loader::part);