X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Flibmarklin%2Ftrackpart.cpp;h=37c5f97a90b0fc81cae5eb150bb2cbd8a654e8d5;hb=9b05c573a38639827697fe393d55b7c76f5bde45;hp=f2b61be1f37f2050105d94f020d4347aeb1dd2dc;hpb=6dc18b0e518407bd2a86602bae1e9bbae05da7c8;p=r2c2.git diff --git a/source/libmarklin/trackpart.cpp b/source/libmarklin/trackpart.cpp index f2b61be..37c5f97 100644 --- a/source/libmarklin/trackpart.cpp +++ b/source/libmarklin/trackpart.cpp @@ -1,7 +1,7 @@ /* $Id$ This file is part of the MSP Märklin suite -Copyright © 2006-2009 Mikkosoft Productions, Mikko Rasa +Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa Distributed under the GPL */ @@ -9,6 +9,7 @@ Distributed under the GPL #include "trackpart.h" using namespace std; +using namespace Msp; namespace Marklin { @@ -18,26 +19,23 @@ TrackPart::TrackPart(): radius(0), path(0), dead_end(false) -{ } - -void TrackPart::collect_endpoints(vector &eps) const { - eps.push_back(Endpoint(pos.x, pos.y, dir+M_PI, 1<M_PI) + da -= M_PI*2; + while(da<-M_PI) + da += M_PI*2; + + if(dx*dx+dy*dy<1e-6 && da>=-0.01 && da<=0.01) + { + links[i] = &other; + other.links[j] = this; + return; + } + } + } +} + +TrackPart *TrackPart::get_link(unsigned i) const +{ + if(i>=2) + throw InvalidParameterValue("Index out of range"); + return links[i]; }