+++ /dev/null
-/* $Id$
-
-This file is part of the MSP Märklin suite
-Copyright © 2010 Mikkosoft Productions, Mikko Rasa
-Distributed under the GPL
-*/
-
-#include <cmath>
-#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<Profile>(p)
-{
- add("point", &Loader::point);
-}
-
-void Profile::Loader::point(float x, float y)
-{
- obj.append_point(Point(x/1000, y/1000));
-}
-
-} // namespace Marklin