35 template <
typename Po
intT>
42 return static_cast<Vertex *
>(v);
45 static Vertex * to_vertex(PointT & p)
50 return (
Vertex *) (point_address - off_set);
63 : num_vertices(0), vertex_list()
68 GenPolygon(
const std::initializer_list<PointT> &);
106 std::swap(num_vertices, p.num_vertices);
107 vertex_list.
swap(p.vertex_list);
126 if (num_vertices == 0)
127 throw std::length_error(
"Polygon has not vertices");
129 return dl_to_vertex(vertex_list.
get_next())->get_item();
134 if (num_vertices == 0)
135 throw std::length_error(
"Polygon has not vertices");
142 if (num_vertices == 0)
143 throw std::length_error(
"Polygon has not vertices");
145 return dl_to_vertex(vertex_list.
get_prev())->get_item();
150 if (num_vertices == 0)
151 throw std::length_error(
"Polygon has not vertices");
158 if (num_vertices < 2)
159 throw std::length_error(
"Polygon has not segments");
171 if (num_vertices < 2)
172 throw std::length_error(
"Polygon has not segments");
175 dl_to_vertex(const_cast<DL *>(vertex_list.
get_prev())->get_prev())
185 return num_vertices == 0;
203 void locate_position();
207 : Base(), p_ptr(nullptr)
213 : Base(const_cast<
DL *>(&p.vertex_list)),
220 : Base(const_cast<
DL *>(&p.vertex_list), curr),
227 : Base(it), p_ptr(it.p_ptr)
257 std::swap(p_ptr, it.p_ptr);
273 throw std::overflow_error(
"There is not current element");
277 --p_ptr->num_vertices;
310 void locate_position();
320 : head(nullptr), curr(nullptr)
326 : head(dl_to_vertex(const_cast<
DL *>(&p.vertex_list))),
327 curr(head->get_next()), pos(0)
330 throw std::length_error(
"There are no segments in polygon");
334 : head(dl_to_vertex(const_cast<
DL *>(&p.vertex_list))),
335 curr(dl_to_vertex(c)), pos(0)
338 throw std::length_error(
"There are no segments in polygon");
344 : head(it.head), curr(it.curr)
357 std::swap(head, it.head);
358 std::swap(curr, it.curr);
369 throw std::overflow_error(
"There is not current element");
380 throw std::overflow_error(
"There is not current element");
391 throw std::out_of_range(
"There is not next element");
400 throw std::out_of_range(
"There is not previous element");
409 throw std::overflow_error(
"There is not current element");
426 p_ptr->num_vertices -= 2;
469 return SegmentIterator(*
this);
474 return SegmentIterator(*
this);
479 return SegmentIterator(*
this, &vertex_list);
484 return SegmentIterator(*
this, const_cast<DL *>(&vertex_list));
499 template <
class Pred>
505 template <
class Pred>
511 template <
class Pred>
517 template <
class Pred>
521 std::forward<Pred>(pred));
524 template <
class Pred>
530 template <
class Pred>
534 std::forward<Pred>(pred));
549 template <
class Pred>
555 template <
class Pred>
561 template <
class Pred>
567 template <
class Pred>
571 std::forward<Pred>(pred));
574 template <
class Pred>
580 template <
class Pred>
584 std::forward<Pred>(pred));
588 template <
class Po
intT>
591 Vertex * v = dl_to_vertex(const_cast<DL *>(p.vertex_list.
get_next()));
593 while (v != &p.vertex_list)
601 template <
class Po
intT>
605 for (
const PointT & p : l)
609 template <
class Po
intT>
618 template <
class Po
intT>
623 while (ptr != Base::get_location())
630 template <
class Po
intT>
656 # endif // DSGPOLYGON_H void prev()
Definition: polygon.H:288
nat_t get_position() const
Definition: polygon.H:294
bool none_segment(Pred &&pred=Pred()) const
Definition: polygon.H:581
void next()
Definition: polygon.H:388
VertexIterator(const VertexIterator &it)
Definition: polygon.H:226
bool all_vertex(Pred &&pred=Pred()) const
Definition: polygon.H:506
bool all_vertex(Pred &pred) const
Definition: polygon.H:500
SegmentIterator(const GenPolygon &p)
Definition: polygon.H:325
~GenPolygon()
Definition: polygon.H:82
SegmentIterator segments_begin()
Definition: polygon.H:467
DLNode *& get_prev()
Definition: nodesdef.H:474
VertexIterator vertices_begin() const
Definition: polygon.H:452
Definition: polygon.H:193
const PointT & get_first_vertex() const
Definition: polygon.H:132
bool none_it(const It &, const It &, Pred &)
Definition: italgorithms.H:325
void add_vertex(PointT &&p)
Definition: polygon.H:118
bool is_empty() const
Definition: nodesdef.H:153
SegmentIterator(const GenPolygon &p, DL *c)
Definition: polygon.H:333
VertexIterator vertices_begin()
Definition: polygon.H:447
bool has_current() const
Definition: polygon.H:361
Definition: nodesdef.H:113
VertexIterator vertices_end()
Definition: polygon.H:457
void swap(GenPolygon &p)
Definition: polygon.H:104
PointT & get_current()
Definition: polygon.H:260
T & get_item()
Definition: nodesdef.H:454
void next()
Definition: polygon.H:282
void next()
Definition: nodesdef.H:383
void swap(SegmentIterator &it)
Definition: polygon.H:355
void swap(VertexIterator &it)
Definition: polygon.H:254
SegmentType get_last_segment() const
Definition: polygon.H:169
void prev()
Definition: nodesdef.H:391
Definition: iterator.H:36
SegmentIterator(const SegmentIterator &it)
Definition: polygon.H:343
VertexIterator(const GenPolygon &p)
Definition: polygon.H:212
void for_each_vertex(Op &&op=Op()) const
Definition: polygon.H:494
bool none_vertex(Pred &&pred=Pred()) const
Definition: polygon.H:531
void add_vertex(const PointT &p)
Definition: polygon.H:112
GenPolygon(const GenPolygon &p)
Definition: polygon.H:70
Definition: polygon.H:300
Vertex * get_location() const
Definition: polygon.H:313
VertexIterator(const GenPolygon &p, DL *curr)
Definition: polygon.H:219
bool none_vertex(Pred &pred) const
Definition: polygon.H:525
DL *& get_prev()
Definition: nodesdef.H:178
void del()
Definition: nodesdef.H:208
GenPolygon(GenPolygon &&p)
Definition: polygon.H:76
bool exists_it(const It &, const It &, Pred &)
Definition: italgorithms.H:310
SegmentIterator segments_begin() const
Definition: polygon.H:472
SegmentIterator segments_end() const
Definition: polygon.H:482
Definition: point2D.H:241
bool has_current() const
Definition: nodesdef.H:362
bool none_segment(Pred &pred) const
Definition: polygon.H:575
void for_each_it(const It &, const It &, Op &)
Definition: italgorithms.H:183
Definition: nodesdef.H:415
Definition: polygon.H:642
SegmentType get_current()
Definition: polygon.H:366
void swap(Iterator &it)
Definition: nodesdef.H:356
void del()
Definition: polygon.H:406
bool all_segment(Pred &pred) const
Definition: polygon.H:550
SegmentIterator(SegmentIterator &&it)
Definition: polygon.H:349
bool exists_segment(Pred &pred) const
Definition: polygon.H:562
const PointT & get_last_vertex() const
Definition: polygon.H:148
GenPolygon()
Definition: polygon.H:62
void for_each_segment(Op &&op=Op()) const
Definition: polygon.H:544
GenSegment< PointT > SegmentType
Definition: polygon.H:60
SegmentType get_current() const
Definition: polygon.H:377
VertexIterator & operator=(const VertexIterator &it)
Definition: polygon.H:238
SegmentIterator segments_end()
Definition: polygon.H:477
nat_t get_position() const
Definition: polygon.H:441
DL * remove_next()
Definition: nodesdef.H:215
bool exists_vertex(Pred &pred) const
Definition: polygon.H:512
DLNode *& get_next()
Definition: nodesdef.H:464
PointT & get_first_vertex()
Definition: polygon.H:124
GenPolygon & operator=(const GenPolygon &p)
Definition: polygon.H:87
void reset()
Definition: polygon.H:435
void for_each_segment(Op &op) const
Definition: polygon.H:538
SegmentIterator()
Definition: polygon.H:319
Definition: iterator.H:112
VertexIterator(VertexIterator &&it)
Definition: polygon.H:232
SegmentType get_first_segment() const
Definition: polygon.H:156
unsigned long int nat_t
Definition: types.H:50
void for_each_vertex(Op &op) const
Definition: polygon.H:488
bool exists_vertex(Pred &&pred=Pred()) const
Definition: polygon.H:518
VertexIterator()
Definition: polygon.H:206
VertexIterator vertices_end() const
Definition: polygon.H:462
void prev()
Definition: polygon.H:397
Definition: polygon.H:648
bool exists_segment(Pred &&pred=Pred()) const
Definition: polygon.H:568
bool all_segment(Pred &&pred=Pred()) const
Definition: polygon.H:556
DL * get_current()
Definition: nodesdef.H:367
PointT & get_last_vertex()
Definition: polygon.H:140
nat_t size() const
Definition: polygon.H:188
void clear()
Definition: polygon.H:610
const PointT & get_current() const
Definition: polygon.H:265
bool is_empty() const
Definition: polygon.H:183
void del()
Definition: polygon.H:270
DL *& get_next()
Definition: nodesdef.H:168
void insert_prev(DL *node)
Definition: nodesdef.H:198
Definition: nodesdef.H:293
void swap(DL *node)
Definition: nodesdef.H:229
bool all_it(const It &, const It &, Pred &)
Definition: italgorithms.H:295