X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Fprofile.cpp;fp=source%2Flibmarklin%2Fprofile.cpp;h=0000000000000000000000000000000000000000;hb=1ff06c5bc46a677fa389ef86c6b26664368f1653;hp=7b9dce52073075de8cb9473ae1fa3dda35ceedde;hpb=9b05c573a38639827697fe393d55b7c76f5bde45;p=r2c2.git diff --git a/source/libmarklin/profile.cpp b/source/libmarklin/profile.cpp deleted file mode 100644 index 7b9dce5..0000000 --- a/source/libmarklin/profile.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* $Id$ - -This file is part of the MSP Märklin suite -Copyright © 2010 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - -#include -#include "profile.h" - -using namespace std; -using namespace Msp; - -namespace Marklin { - -void Profile::append_point(const Point &p) -{ - points.push_back(p); - if(points.size()==1) - { - min_coords = p; - max_coords = p; - } - else - { - min_coords.x = min(min_coords.x, p.x); - min_coords.y = min(min_coords.y, p.y); - max_coords.x = max(max_coords.x, p.x); - max_coords.y = max(max_coords.y, p.y); - } -} - -const Point &Profile::get_point(unsigned i) const -{ - if(i>=points.size()) - throw InvalidParameterValue("Index out of range"); - return points[i]; -} - -Point Profile::get_edge_normal(unsigned i) const -{ - if(i+1>=points.size()) - throw InvalidParameterValue("Index out of range"); - float dx = points[i+1].x-points[i].x; - float dy = points[i+1].y-points[i].y; - float len = sqrt(dx*dx+dy*dy); - return Point(dy/len, -dx/len); -} - - -Profile::Loader::Loader(Profile &p): - DataFile::ObjectLoader(p) -{ - add("point", &Loader::point); -} - -void Profile::Loader::point(float x, float y) -{ - obj.append_point(Point(x/1000, y/1000)); -} - -} // namespace Marklin