9 void Profile::append_vertex(const Vector &p, bool smooth)
11 if(vertices.size()>1 && !vertices.back().smooth)
12 vertices.push_back(vertices.back());
16 v.smooth = (!vertices.empty() && smooth);
20 Vector span = p-vertices.back().pos;
25 if(vertices.back().smooth)
27 Vector &n = vertices.back().normal;
32 vertices.back().normal = v.normal;
35 vertices.push_back(v);
37 if(vertices.size()==1)
44 min_coords.x = min(min_coords.x, p.x);
45 min_coords.y = min(min_coords.y, p.y);
46 max_coords.x = max(max_coords.x, p.x);
47 max_coords.y = max(max_coords.y, p.y);
51 const Profile::Vertex &Profile::get_vertex(unsigned i) const
53 if(i>=vertices.size())
54 throw out_of_range("Profile::get_vertex");
59 Profile::Loader::Loader(Profile &p):
60 DataFile::ObjectLoader<Profile>(p)
62 add("point", &Loader::point);
63 add("smooth_point", &Loader::smooth_point);
66 void Profile::Loader::point(float x, float y)
68 obj.append_vertex(Vector(x/1000, y/1000, 0), false);
71 void Profile::Loader::smooth_point(float x, float y)
73 obj.append_vertex(Vector(x/1000, y/1000, 0), true);