2 # ifndef TPL_EUCLIDIAN_GRAPH_H
3 # define TPL_EUCLIDIAN_GRAPH_H
5 # include <tpl_graph.H>
15 template <
typename Node_Info>
20 typedef Node_Info Item_Type;
24 typedef Node_Info Node_Type;
62 Point & get_position() {
return position; }
64 const Point & get_position()
const {
return position; }
68 template <
typename Arc_Info>
73 typedef Arc_Info Arc_Item;
77 typedef Arc_Info Arc_Type;
104 template <
class __Eucl
idian_Node,
class __Eucl
idian_Arc>
109 typedef __Euclidian_Node Node;
111 typedef __Euclidian_Arc Arc;
115 typedef typename Node::Node_Type Node_Type;
117 typedef typename Arc::Arc_Type Arc_Type;
150 Geom_Number get_distance(Arc * arc)
152 const Point & src_point = get_src_node(arc)->get_position();
153 const Point & tgt_point = get_tgt_node(arc)->get_position();
170 Node * search_node(
const Point &);
173 template <
class __Eucl
idian_Node,
class __Eucl
idian_Arc>
197 template <
class Node,
class Arc>
202 Euclidian_Graph<Node, Arc>::Node * curr = it.get_current();
203 if (curr->get_position() == point)
209 template <
class __Eucl
idian_Graph>
212 Point * ptr_east_point;
213 Point * ptr_north_point;
214 Point * ptr_west_point;
215 Point * ptr_south_point;
219 Geom_Number x_node_ratio;
220 Geom_Number y_node_ratio;
227 : x_node_ratio(0), y_node_ratio(0), x_scale(1), y_scale(1),
228 ptr_east_point(NULL), ptr_north_point(NULL), ptr_west_point(NULL), ptr_south_point(NULL)
234 : x_node_ratio(0), y_node_ratio(0), x_scale(1), y_scale(1),
235 ptr_east_point(NULL), ptr_north_point(NULL), ptr_west_point(NULL), ptr_south_point(NULL)
237 if (graph.get_num_nodes() < 1)
240 typename __Euclidian_Graph::Node_Iterator itor(graph);
241 points.
append(itor.get_current()->get_position());
242 ptr_west_point = ptr_north_point = ptr_east_point = ptr_south_point = &points.
access(0);
244 for (
int i = 1 ; itor.has_current(); itor.next(), ++i)
246 const Point & p = itor.get_current()->get_position();
249 ptr_west_point = &points.
access(i);
251 ptr_north_point = &points.
access(i);
253 ptr_east_point = &points.
access(i);
255 ptr_south_point = &points.
access(i);
264 Point & add_point(
typename __Euclidian_Graph::Node * node)
267 throw std::domain_error(
"node is NULL");
268 points.
append(node->get_position());
270 if (points.
size() == 1)
271 ptr_west_point = ptr_north_point = ptr_east_point = ptr_south_point = &points.
access(0);
277 ptr_north_point = &p;
281 ptr_south_point = &p;
286 const Point & get_west_point()
const
288 if (points.
size() < 1)
289 throw std::logic_error(
"There are no points on plane");
290 return *ptr_west_point;
293 const Point & get_north_point()
const
295 if (points.
size() < 1)
296 throw std::logic_error(
"There are no points on plane");
297 return *ptr_north_point;
300 const Point & get_east_point()
const
302 if (points.
size() < 1)
303 throw std::logic_error(
"There are no points on plane");
304 return *ptr_east_point;
307 const Point & get_south_point()
const
309 if (points.
size() < 1)
310 throw std::logic_error(
"There are no points on plane");
311 return *ptr_south_point;
314 const Geom_Number get_width()
const
316 if (points.
size() < 1)
317 return Geom_Number(0);
318 return ptr_east_point->
get_x() - ptr_west_point->
get_x();
321 const Geom_Number get_height()
const
323 if (points.
size() < 1)
324 return Geom_Number(0);
325 return ptr_north_point->
get_y() - ptr_south_point->
get_y();
328 const Geom_Number & get_x_node_ratio()
const {
return x_node_ratio; }
330 void set_x_node_ratio(
const Geom_Number & _x_node_ratio) { x_node_ratio = _x_node_ratio; }
332 const Geom_Number & get_y_node_ratio()
const {
return y_node_ratio; }
334 void set_y_node_ratio(
const Geom_Number & _y_node_ratio) { y_node_ratio = _y_node_ratio; }
336 const Geom_Number & get_x_scale()
const {
return x_scale; }
338 void set_x_scale(
const Geom_Number & _x_scale) { x_scale = _x_scale; }
340 const Geom_Number & get_y_scale()
const {
return y_scale; }
342 void set_y_scale(
const Geom_Number & _y_scale) { y_scale = _y_scale; }
348 # endif // TPL_EUCLIDIAN_GRAPH_H
Definition: tpl_euclidian_graph.H:69
Definition: tpl_graph.H:29
Definition: tpl_euclidian_graph.H:16
Definition: tpl_graph.H:21
virtual Node * insert_node(Node *node)
Definition: tpl_euclidian_graph.H:130
size_t size() const
Retorna dimensión actual (más lejano índice escrito)
Definition: tpl_dynArray.H:523
T & top()
Retorna el último elemento del arreglo como si fuese una pila.
Definition: tpl_dynArray.H:1154
const Geom_Number & get_y() const
retorna el valor de la coordenada y
Definition: point.H:166
Definition: tpl_euclidian_graph.H:174
const Geom_Number & get_x() const
retorna el valor de la coordenada x
Definition: point.H:161
void clear_graph(GT &g)
Definition: tpl_graph.H:2486
T & append()
Definition: tpl_dynArray.H:1115
Definition: tpl_graph.H:19
void copy_graph(GT >gt, GT &gsrc, const bool cookie_map=false)
Definition: tpl_graph.H:2505
Geom_Number distance_with(const Point &p) const
retorna la distancia euclidiana entre this y el punto p
Definition: point.H:853
T & access(const size_t i)
Definition: tpl_dynArray.H:793
Definition: tpl_euclidian_graph.H:105
virtual Node * insert_node(const Node_Type &info)
Definition: tpl_euclidian_graph.H:135
virtual Node * insert_node(Node *node)
Definition: tpl_graph.H:2215
Definition: tpl_euclidian_graph.H:210