1 #ifndef VERTEX_H_INCLUDED
2 #define VERTEX_H_INCLUDED
11 #include "virtualVertex.h"
37 Coordinates(
const float x = 0.,
const float y = 0.) {
41 float squareDistanceTo(
const Coordinates& othr)
const {
42 return (this->_x - othr._x)*(this->_x - othr._x)+(this->_y - othr._y)*(this->_y - othr._y);
46 (this->_x - othr._x)*(this->_x - othr._x)+(this->_y - othr._y)*(this->_y - othr._y)
50 float x()
const {
return this->_x; }
51 float y()
const {
return this->_y; }
52 void setX(
float x) { this->_x = round_float(x, EPSILON*10.); }
53 void setY(
float y) { this->_y = round_float(y, EPSILON*10.); }
54 void setCoord(
float x,
float y) { this->setX(x); this->setY(y); }
57 return (fabs(othr._x - this->_x) < EPSILON) && (fabs(othr._y - this->_y) < EPSILON);
60 return not (*
this == othr);
63 return Coordinates(this->_x + c._x, this->_y + c._y);
66 return Coordinates(this->_x - c._x, this->_y - c._y);
69 return Coordinates(this->_x / value, this->_y / value);
86 Vertex(
const float = 0.,
const float = 0.,
Edge* = NULL);
90 unsigned int neighbourCount()
const;
95 unsigned int getID()
const {
return this->id; }
96 unsigned int getObjectCount()
const {
return this->objects.size(); }
97 std::list<VirtualVertex*>
getObjects(
unsigned int = 0)
const;
109 static unsigned int last_id;
110 std::list<VirtualVertex*> objects;
118 std::ostream& operator<<(std::ostream&,
Coordinates const &);
119 std::ostream& operator<<(std::ostream&,
Vertex const &);
133 bool operator()(
const Vertex* left,
const Vertex* right) {
137 return left->squareDistanceTo(this->reference) > right->squareDistanceTo(this->reference);
149 inline size_t operator()(
const Vertex* o)
const {
return (
size_t)o; }
154 typedef std::priority_queue<const Vertex*, std::vector<Vertex*>,
VertexComparison> vertex_comparator;