X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftracktype.cpp;h=7a1f27ad5adcc69ee282a028d10755dabf68d37a;hb=d405b9943c888e3945c7ea4e496f9d300b114fe0;hp=fe3a54cd824d7471cb78c95b47b8ba9ceb33e8df;hpb=bde934f7d5ba07a9442a305192e10024820d13ed;p=r2c2.git diff --git a/source/libr2c2/tracktype.cpp b/source/libr2c2/tracktype.cpp index fe3a54c..7a1f27a 100644 --- a/source/libr2c2/tracktype.cpp +++ b/source/libr2c2/tracktype.cpp @@ -7,8 +7,9 @@ using namespace Msp; namespace R2C2 { -TrackType::TrackType(const ArticleNumber &an): +TrackType::TrackType(const ArticleNumber &an, const TrackAppearance &ta): ObjectType(an), + appearance(ta), state_bits(0), autofit_preference(1) { } @@ -61,7 +62,7 @@ const TrackType::Endpoint &TrackType::get_endpoint(unsigned i) const return endpoints[i]; } -TrackPoint TrackType::get_point(unsigned epi, unsigned path, float d) const +OrientedPoint TrackType::get_point(unsigned epi, unsigned path, float d) const { if(epi>=endpoints.size()) throw out_of_range("TrackType::get_point"); @@ -76,8 +77,8 @@ TrackPoint TrackType::get_point(unsigned epi, unsigned path, float d) const unsigned n_part_eps = (i->is_dead_end() ? 1 : 2); for(unsigned j=0; jget_point(j ? i->get_length() : 0); - Vector span = p.pos-endpoints[epi].pos; + OrientedPoint p = i->get_point(j ? i->get_length() : 0); + Vector span = p.position-endpoints[epi].pos; if(dot(span, span)<1e-6) { part = &*i; @@ -96,9 +97,9 @@ TrackPoint TrackType::get_point(unsigned epi, unsigned path, float d) const { if(part_ep==1) d = plen-d; - TrackPoint p = part->get_point(d); + OrientedPoint p = part->get_point(d); if(part_ep==1) - p.dir += Angle::half_turn(); + p.rotation += Angle::half_turn(); return p; } else @@ -113,15 +114,15 @@ TrackPoint TrackType::get_point(unsigned epi, unsigned path, float d) const } } -TrackPoint TrackType::get_nearest_point(const Vector &p) const +OrientedPoint TrackType::get_nearest_point(const Vector &p) const { - TrackPoint result; + OrientedPoint 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); + OrientedPoint n = i->get_nearest_point(p); + float d = distance(n.position, p); if(dget_link(j)) { - TrackPoint p = i->get_point(j ? i->get_length() : 0); + OrientedPoint p = i->get_point(j ? i->get_length() : 0); if(j==0) - p.dir += Angle::half_turn(); + p.rotation += Angle::half_turn(); bool found = false; for(vector::iterator k=endpoints.begin(); k!=endpoints.end(); ++k) { - Vector d = k->pos-p.pos; + Vector d = k->pos-p.position; - Angle da = wrap_balanced(k->dir-p.dir); + Angle da = wrap_balanced(k->dir-p.rotation); if(dot(d, d)<1e-6 && abs(da).radians()<0.01) { @@ -165,7 +166,7 @@ void TrackType::collect_endpoints() } if(!found) - endpoints.push_back(Endpoint(p.pos.x, p.pos.y, p.dir, 1<get_path())); + endpoints.push_back(Endpoint(p.position.x, p.position.y, p.rotation, 1<get_path())); } } }