xc
PolyPos.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // xc utils library; general purpose classes and functions.
4 //
5 // Copyright (C) Luis C. Pérez Tato
6 //
7 // XC utils is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // This software is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program.
19 // If not, see <http://www.gnu.org/licenses/>.
20 //----------------------------------------------------------------------------
21 //PolyPos.h
22 
23 #ifndef POLYPOS_H
24 #define POLYPOS_H
25 
26 #include <deque>
27 #include "../cgal_types.h"
28 #include "utility/utils/misc_utils/matem.h"
29 #include "utility/geom/proximity.h"
30 #include <boost/python.hpp>
31 #include "utility/utils/misc_utils/colormod.h"
32 
34 //
36 template<class pos>
37 class PolyPos : public std::deque<pos>
38  {
39  protected:
40  typedef std::deque<pos> deque_pos;
41  //Auxiliary function.
42  static GEOM_FT g(GEOM_FT v1, GEOM_FT v2)
43  { return (sqr(v1) + v1 * v2 + sqr(v2)); }
44  public:
45  typedef typename deque_pos::iterator iterator;
46  typedef typename deque_pos::const_iterator const_iterator;
47  typedef typename pos::vector vector;
48 
49  protected:
50  void simplify_select(GEOM_FT epsilon, iterator it1, iterator it2, std::set<const_iterator> &selected);
51  void remove_selected(std::set<const_iterator> &selected);
52  void select_repeated(std::set<const_iterator> &selected, const GEOM_FT &tol= 0.0);
53  void select_backward_segments(std::set<const_iterator> &selected, const GEOM_FT &tol);
54  public:
55 
56  PolyPos(void)
57  : deque_pos() {}
58 
59  explicit PolyPos(size_t n)
60  : std::deque<pos>(n) {}
61 
62  PolyPos(size_t n, const pos &p)
63  : std::deque<pos>(n, p) {}
64 
65  explicit PolyPos(const std::deque<pos> &dq_pos)
66  : std::deque<pos>(dq_pos) {}
67 
68  pos getFromPoint(void) const
69  { return this->front(); }
70 
71  pos getToPoint(void) const
72  { return this->back(); }
73 
74  bool operator==(const PolyPos<pos> &other) const
75  {
76  return ( (const deque_pos &) (*this) == (const deque_pos &) other );
77  }
78  inline pos *Agrega(const pos &p)
79  {
80  deque_pos::push_back(p);
81  return &(this->back());
82  }
83  inline void Agrega(const PolyPos<pos> &p)
84  { Cat(p); }
85  inline void AgregaSiNuevo(const PolyPos<pos> &p);
88  template <class InputIterator>
89  void extend(InputIterator first, InputIterator last)
90  {
91  for(InputIterator i= first;i!=last; i++)
92  Agrega(*i);
93  }
94  void AgregaSiNuevo(const pos &);
95  const_iterator find(const pos &p) const
96  { return std::find(this->begin(),this->end(),p); }
97  iterator find(const pos &p)
98  { return std::find(this->begin(),this->end(),p); }
99  bool In(const pos &p) const;
100  void close(void);
101  bool isClosed(const GEOM_FT &tol= 1e-6) const;
102  GEOM_FT getLength(void) const;
103  std::vector<GEOM_FT> getLengths(void) const;
104  boost::python::list getLengthsPy(void) const;
105  GEOM_FT getLengthUntilVertex(const_iterator) const;
106  const_iterator getSegmentAtLength(const GEOM_FT &s) const;
107  int getIndexOfSegmentAtLength(const GEOM_FT &s) const;
108  int getIndexOfSegmentAtParam(const GEOM_FT &lambda) const;
109  boost::python::list getIthCoordinates(unsigned short i) const;
110  GEOM_FT GetMax(unsigned short i) const;
111  GEOM_FT GetMin(unsigned short i) const;
112  PolyPos GetMayores(unsigned short int i,const GEOM_FT &d) const;
113  PolyPos GetMenores(unsigned short int i,const GEOM_FT &d) const;
114  pos getCenterOfMass(void) const;
115  pos getWeightedCenterOfMass(const std::deque<GEOM_FT> &) const;
116  PolyPos<pos> getSwap(void) const;
117  void swap(void)
118  { *this= this->getSwap(); }
119  std::deque<GEOM_FT> &GetSeparaciones(void) const;
120  GEOM_FT GetSeparacionMedia(void) const;
121 
122  iterator getNearestPoint(const pos &);
123  const_iterator getNearestPoint(const pos &) const;
124  iterator getFarthestPoint(const pos &);
125  const_iterator getFarthestPoint(const pos &) const;
126  virtual iterator getFarthestPointFromSegment(iterator it1, iterator it2, GEOM_FT &pMaxDist);
127  void simplify(GEOM_FT epsilon, iterator it1, iterator it2);
128  void simplify(GEOM_FT epsilon);
129  PolyPos<pos> getSimplified(GEOM_FT epsilon) const;
130  void removeRepeated(const GEOM_FT &tol= 0.0);
131  void removeBackwardSegments(const GEOM_FT &tol);
132 
133  void Cat(const PolyPos<pos> &l);
134  template <class inputIterator>
135  void Cat(inputIterator begin, inputIterator end);
136  };
137 
138 
140 template <class pos>
141 bool PolyPos<pos>::In(const pos &p) const
142  { return (find(p)!=this->end()); }
143 
145 template <class pos>
146 void PolyPos<pos>::AgregaSiNuevo(const pos &p)
147  {
148  if(!In(p))
149  this->push_back(p);
150  }
151 
153 template <class pos>
155  {
156  if(!isClosed())
157  {
158  const pos &first= this->front();
159  this->push_back(first);
160  }
161  }
162 
164 template <class pos>
165 bool PolyPos<pos>::isClosed(const GEOM_FT &tol) const
166  {
167  bool retval= false;
168  const GEOM_FT treshold= tol*getLength();
169  const pos &first= this->front();
170  const pos &last= this->back();
171  if(dist(first,last)<treshold)
172  retval= true;
173  return retval;
174  }
175 
177 template <class pos>
178 GEOM_FT PolyPos<pos>::getLength(void) const
179  { return getLengthUntilVertex(this->end()); }
180 
183 //
185 template <class pos>
186 GEOM_FT PolyPos<pos>::getLengthUntilVertex(const_iterator nth) const
187  {
188  if(this->size()<2) return 0.0;
189  GEOM_FT temp = 0;
190  const_iterator last= this->end();
191  if(nth<last)
192  last= nth;
193  const_iterator j;
194  for(const_iterator i=this->begin(); i != last; i++)
195  {
196  j= i;j++;
197  if (j!=this->end()) temp += dist(*i,*j);
198  }
199  return temp;
200  }
201 
203 template <class pos>
204 std::vector<GEOM_FT> PolyPos<pos>::getLengths(void) const
205  {
206  const size_t sz= this->size();
207  std::vector<GEOM_FT> retval(sz, 0.0);
208  if(sz>1)
209  {
210  GEOM_FT temp = 0;
211  const_iterator last= this->end();
212  const_iterator j;
213  size_t count= 1;
214  for(const_iterator i=this->begin(); i != std::prev(last); i++, count++)
215  {
216  j= std::next(i);
217  temp+= dist(*i,*j);
218  retval[count]= temp;
219  }
220  }
221  return retval;
222  }
223 
225 template <class pos>
226 boost::python::list PolyPos<pos>::getLengthsPy(void) const
227  {
228  const std::vector<GEOM_FT> lengths= this->getLengths();
229  boost::python::list retval;
230  for(std::vector<GEOM_FT>::const_iterator i= lengths.begin(); i!=lengths.end(); i++)
231  retval.append(*i);
232  return retval;
233  }
234 
237 //
239 template <class pos>
240 typename PolyPos<pos>::const_iterator PolyPos<pos>::getSegmentAtLength(const GEOM_FT &s) const
241  {
242  const_iterator retval= this->end(); // past the end
243  const size_t sz= this->size();
244  if(sz<2)
245  {
246  std::cerr << Color::red << "PolyPos<>::" << __FUNCTION__
247  << ";ERROR: no segments, so no length."
248  << Color::def << std::endl;
249  }
250  else
251  {
252  if(s<=0.0)
253  {
254  retval= this->begin();
255  if(s<0.0)
256  std::clog << Color::yellow << "PolyPos<>::" << __FUNCTION__
257  << ";WARNING: length argument: " << s
258  << " negative. First segment returned."
259  << Color::def << std::endl;
260  }
261  else
262  {
263  GEOM_FT totalLength= this->getLength();
264  if(s<=totalLength)
265  {
266  GEOM_FT temp = 0; //Distance from origin.
267  retval= this->begin();
268  const_iterator j;
269  for(const_iterator i=this->begin(); i != this->end(); i++)
270  {
271  j= i;j++;
272  if(j!=this->end())
273  {
274  temp+= dist(*i,*j); // increment distance.
275  if(temp>=s) //we found it.
276  {
277  retval= i;
278  break;
279  }
280  }
281  }
282  }
283  else
284  {
285  std::clog << Color::yellow << "PolyPos<>::" << __FUNCTION__
286  << ";WARNING: length argument: " << s
287  << " greater than total length: " << totalLength
288  << Color::def << std::endl;
289  retval= this->end()-2; // return last segment.
290  }
291  }
292  }
293  return retval;
294  }
295 
300 template <class pos>
301 int PolyPos<pos>::getIndexOfSegmentAtLength(const GEOM_FT &s) const
302  {
303  const_iterator i= this->getSegmentAtLength(s);
304  return std::distance(this->begin(), i);
305  }
306 
311 template <class pos>
312 int PolyPos<pos>::getIndexOfSegmentAtParam(const GEOM_FT &lambda) const
313  { return this->getIndexOfSegmentAtParam(lambda*this->getLength()); }
314 
316 template <class pos>
317 boost::python::list PolyPos<pos>::getIthCoordinates(unsigned short j) const
318  {
319  boost::python::list retval;
320  if(!this->empty())
321  {
322  for(const_iterator i=this->begin();i!=this->end(); i++)
323  {
324  const GEOM_FT value= (*i)[j];
325  retval.append(value);
326  }
327  }
328  return retval;
329  }
330 
332 template <class pos>
333 GEOM_FT PolyPos<pos>::GetMax(unsigned short j) const
334  {
335  GEOM_FT retval(0.0);
336  if(!this->empty())
337  {
338  const_iterator i=this->begin();
339  retval= (*i)(j);
340  for(; i != this->end(); i++)
341  retval= std::max(retval,(*i)(j));
342  }
343  return retval;
344  }
345 
347 template <class pos>
348 GEOM_FT PolyPos<pos>::GetMin(unsigned short j) const
349  {
350  GEOM_FT retval(0.0);
351  if(!this->empty())
352  {
353  const_iterator i=this->begin();
354  retval= (*i)(j);
355  for(; i != this->end(); i++)
356  retval= std::min(retval,(*i)(j));
357  }
358  return retval;
359  }
360 
361 template <class pos>
364  {
365  const size_t sz= this->size();
366  const pos org= pos();
367  if(sz<1) return org;
368  if(sz<2) return *(this->begin());
369  const_iterator i= this->begin();
370  vector vpos_center_of_mass((*i).VectorPos());
371  i++;
372  for(; i != this->end(); i++)
373  vpos_center_of_mass= vpos_center_of_mass + (*i).VectorPos();
374  vpos_center_of_mass= vpos_center_of_mass * (1.0/sz);
375  return org+ vpos_center_of_mass;
376  }
377 
378 template <class pos>
380 pos PolyPos<pos>::getWeightedCenterOfMass(const std::deque<GEOM_FT> &areas) const
381  {
382  pos retval;
383  const size_t sz= this->size();
384  if(sz>0)
385  {
386  assert(sz==areas.size());
387  if(sz<2)
388  retval= *(this->begin());
389  else
390  {
391  std::deque<GEOM_FT>::const_iterator iArea= areas.begin();
392  GEOM_FT areaTot(0.0);
393  const_iterator i= this->begin();
394  vector vpos_center_of_mass((*i).VectorPos()*(*iArea));
395  areaTot+= *iArea;
396  i++; iArea++;
397  for(; i != this->end(); i++)
398  {
399  vpos_center_of_mass= vpos_center_of_mass + (*i).VectorPos()*(*iArea);
400  areaTot+= *iArea;
401  }
402  if(areaTot!=0.0)
403  {
404  vpos_center_of_mass= vpos_center_of_mass * (1.0/areaTot);
405  retval= pos()+vpos_center_of_mass;
406  }
407  }
408  }
409  return retval;
410  }
411 
413 template <class pos>
415  {
416  PolyPos<pos> retval(*this);
417  const size_t sz= this->size();
418  if (sz<2) return retval;
419  for(size_t i=0; i<sz; i++)
420  retval[sz-i-1]= (*this)[i];
421  return retval;
422  }
423 
425 template <class pos>
426 std::deque<GEOM_FT> &PolyPos<pos>::GetSeparaciones(void) const
427  {
428  const size_t sz= this->size();
429  static std::deque<GEOM_FT> retval;
430  retval.resize(sz);
431  const GEOM_FT grande= 10.0*getBnd((*this)).Diagonal().GetModulus();
432  for(size_t i= 0;i<sz;i++)
433  retval[i]= grande;
434  if(sz>1)
435  {
436  GEOM_FT d;
437  for(size_t i= 0;i<sz;i++)
438  {
439  const pos &pi= (*this)[i];
440  for(size_t j= 0;j<sz;j++)
441  if(i!=j)
442  {
443  const pos &pj= (*this)[j];
444  d= dist(pi,pj);
445  if(d<retval[i] && d>0.0)
446  retval[i]= d;
447  }
448  }
449  }
450  return retval;
451  }
452 
454 template <class pos>
456  {
457  GEOM_FT retval(0);
458  const size_t sz= this->size();
459  if(sz>0)
460  {
461  const std::deque<GEOM_FT> &seps= this->GetSeparaciones();
462  for(size_t i= 0;i<sz;i++)
463  retval+= seps[i];
464  retval/=sz;
465  }
466  return retval;
467  }
468 
469 template <class pos>
470 PolyPos<pos> PolyPos<pos>::GetMayores(unsigned short int i,const GEOM_FT &d) const
471  {
472  PolyPos<pos> retval;
473  for(const_iterator j=this->begin();j != this->end();j++)
474  if ((*j)(i) > d) retval.push_back(*j);
475  return retval;
476  }
477 
478 template <class pos>
479 PolyPos<pos> PolyPos<pos>::GetMenores(unsigned short int i,const GEOM_FT &d) const
480  {
481  PolyPos<pos> retval;
482  for(const_iterator j=this->begin();j != this->end();j++)
483  if ((*j)(i) < d) retval.push_back(*j);
484  return retval;
485  }
486 
488 template <class pos>
489 typename PolyPos<pos>::iterator PolyPos<pos>::getNearestPoint(const pos &p)
490  { return nearest(this->begin(), this->end(),p); }
491 
493 template <class pos>
494 typename PolyPos<pos>::const_iterator PolyPos<pos>::getNearestPoint(const pos &p) const
495  { return nearest(this->begin(), this->end(),p); }
496 
498 template <class pos>
499 typename PolyPos<pos>::iterator PolyPos<pos>::getFarthestPoint(const pos &p)
500  {
501  iterator i= this->begin();
502  iterator retval= i; i++;
503  GEOM_FT maxDist= dist(p,*retval);
504  GEOM_FT d= 0.0;
505  for(;i!= this->end();i++)
506  {
507  d= dist(p,*i);
508  if(d>maxDist)
509  {
510  maxDist= d;
511  retval= i;
512  }
513  }
514  return retval;
515  }
516 
518 template <class pos>
519 typename PolyPos<pos>::const_iterator PolyPos<pos>::getFarthestPoint(const pos &p) const
520  {
521  PolyPos<pos> *this_no_const= const_cast<PolyPos<pos> *>(this);
522  return this_no_const->getFarthestPoint(p);
523  }
524 
531 template <class pos>
532 typename PolyPos<pos>::iterator PolyPos<pos>::getFarthestPointFromSegment(iterator , iterator , GEOM_FT &)
533  {
534  std::cerr << Color::red << "PolyPos<>::" << __FUNCTION__
535  << ";must be redefined in derived classes."
536  << Color::def << std::endl;
537  return this->begin();
538  }
539 
545 template <class pos>
546 void PolyPos<pos>::select_repeated(std::set<const_iterator> &selected, const GEOM_FT &tol)
547  {
548  GEOM_FT localTol= 10*DBL_EPSILON; // default tolerance.
549  if(tol>0.0)
550  localTol= tol;
551  const size_t sz= this->size();
552  if(sz>1) // if more than one vertex.
553  {
554  iterator i= this->begin();
555  pos p0= *i; i++;
556  for(; i!= this->end(); i++)
557  {
558  const pos &p1= *i;
559  const GEOM_FT d= dist(p1, p0);
560  if(d<localTol)
561  selected.insert(i);
562  p0= p1;
563  }
564  }
565  }
566 
572 template <class pos>
573 void PolyPos<pos>::select_backward_segments(std::set<const_iterator> &selected, const GEOM_FT &tol)
574  {
575  const size_t sz= this->size();
576  if(sz>2) // if more than one segment.
577  {
578  iterator i= this->begin();
579  pos p0= *i; i++;
580  pos p1= *i; i++;
581  vector iVector0= (p1-p0).getNormalized();
582  GEOM_FT dot= 0.0;
583  for(; i!= this->end(); i++)
584  {
585  if(dot>=tol) // don't update p0 if the vertex will be removed.
586  p0= p1;
587  p1= *i;
588  vector iVector1= (p1-p0).getNormalized();
589  dot= iVector1.GetDot(iVector0);
590  if(dot<tol)
591  selected.insert(i);
592  else // don't update iVector0 if the vertex will be removed.
593  iVector0= iVector1;
594  }
595  }
596  if(10*selected.size()>2*sz)
597  std::clog << Color::yellow << "PolyPos<>::" << __FUNCTION__
598  << ";WARNING: many backwards segments (" << selected.size()
599  << "/" << sz << "), check input data."
600  << Color::def << std::endl;
601  }
602 
607 template <class pos>
608 void PolyPos<pos>::removeRepeated(const GEOM_FT &tol)
609  {
610  std::set<const_iterator> repeated;
611  select_repeated(repeated, tol);
612  remove_selected(repeated);
613  }
614 
619 template <class pos>
620 void PolyPos<pos>::removeBackwardSegments(const GEOM_FT &tol)
621  {
622  std::set<const_iterator> backwards;
623  select_backward_segments(backwards, tol);
624  remove_selected(backwards);
625  }
626 
635 template <class pos>
636 void PolyPos<pos>::simplify_select(GEOM_FT epsilon, iterator it1, iterator it2, std::set<const_iterator> &selected)
637  {
638  if (distance(it1, it2) <= 1) return;
639 
640  // Acquire the farthest point from the segment it1, it2
641  GEOM_FT dist= -1.0;
642  iterator index= getFarthestPointFromSegment(it1, it2, dist);
643 
644  // If the farthest point exceeds epsilon, recurse, with index as pivot.
645  if(dist > epsilon)
646  {
647  simplify_select(epsilon, it1, index, selected);
648  simplify_select(epsilon, index, it2, selected);
649  }
650  else
651  {
652  // Mark to delete everything except it1 and it2.
653  auto it = it1;
654  it++;
655  for(; it < it2; it++)
656  {
657  selected.insert(it); // add it to the deletion list.
658  }
659  }
660  }
661 
664 template <class pos>
665 void PolyPos<pos>::remove_selected(std::set<const_iterator> &selected)
666  {
667  static std::deque<pos> tmp;
668  tmp.clear();
669  for(const_iterator i= this->begin(); i!= this->end(); i++)
670  if(selected.find(i)==selected.end()) // not selected to remove.
671  tmp.push_back(*i);
672  this->clear();
673  this->assign(tmp.begin(), tmp.end());
674  }
675 
683 template <class pos>
684 void PolyPos<pos>::simplify(GEOM_FT epsilon, iterator it1, iterator it2)
685  {
686  if (distance(it1, it2) <= 1) return;
687 
688  std::set<const_iterator> selected;
689  simplify_select(epsilon, it1, it2, selected);
690  remove_selected(selected);
691  }
692 
699 template <class pos>
700 void PolyPos<pos>::simplify(GEOM_FT epsilon)
701  {
702  const bool closed= this->isClosed();
703  if(closed)
704  {
705  std::set<const_iterator> selected;
706  iterator i= this->begin();
707  iterator j= this->getFarthestPoint(*i);
708  simplify_select(epsilon,i,j, selected);
709  i= j;
710  j= this->end(); --j; //Last point.
711  simplify_select(epsilon,i,j, selected);
712  // Erase the simplified vertexes.
713  remove_selected(selected);
714  }
715  else
716  {
717  iterator i= this->begin();
718  iterator j= this->end(); --j; //Last point.
719  simplify(epsilon,i,j);
720  }
721  }
722 
728 template <class pos>
730  {
731  PolyPos<pos> retval(*this);
732  retval->simplify(epsilon);
733  return retval;
734  }
735 
736 template <class pos>
738  {
739  for(typename PolyPos<pos>::const_iterator k= l.begin();k!=l.end();k++)
740  this->AgregaSiNuevo(*k);
741  }
742 
743 template <class pos>
744 void PolyPos<pos>::Cat(const PolyPos<pos> &l)
745  {
746  for(typename PolyPos<pos>::const_iterator k= l.begin();k!=l.end();k++)
747  this->push_back(*k);
748  }
749 
751 template <class pos> template<class inputIterator>
752 void PolyPos<pos>::Cat(inputIterator begin, inputIterator end)
753  {
754  for(inputIterator i= begin;i!=end;i++)
755  this->push_back(*i);
756  }
757 
758 template <class pos>
759 std::ostream &operator<<(std::ostream &os,const PolyPos<pos> &l)
760  {
761  if(l.size()<1) return os;
762  typedef typename PolyPos<pos>::const_iterator c_iterator;
763  c_iterator i= l.begin();
764  os << *i; i++;
765  for(;i!= l.end();i++)
766  os << " , " << *i;
767  return os;
768  }
769 
770 
771 #endif
772 
773 
774 
775 
776 
777 
bool In(const pos &p) const
Return true if the points is on en la lista.
Definition: PolyPos.h:141
bool isClosed(const GEOM_FT &tol=1e-6) const
True if dist(lastPoint,firstPoint)< tol*length.
Definition: PolyPos.h:165
void simplify_select(GEOM_FT epsilon, iterator it1, iterator it2, std::set< const_iterator > &selected)
Douglas Peucker algorithm implementation.
Definition: PolyPos.h:636
std::vector< GEOM_FT > getLengths(void) const
Return the lengths corresponding to each vertex.
Definition: PolyPos.h:204
PolyPos< pos > getSwap(void) const
Return a list with the elements in reverse order.
Definition: PolyPos.h:414
Base class for position lists.
Definition: PolyPos.h:37
void remove_selected(std::set< const_iterator > &selected)
Removes the selected items.
Definition: PolyPos.h:665
virtual GEOM_FT GetModulus(void) const
Return el módulo del vector.
Definition: Vector2d.cc:248
GEOM_FT GetSeparacionMedia(void) const
Return the average distance between points.
Definition: PolyPos.h:455
void close(void)
Close the point list (insert the first point as its last one)
Definition: PolyPos.h:154
pos getCenterOfMass(void) const
Return the center of mass del polígono.
Definition: PolyPos.h:363
iterator getNearestPoint(const pos &)
Returns the nearest point from those of the list.
Definition: PolyPos.h:489
virtual iterator getFarthestPointFromSegment(iterator it1, iterator it2, GEOM_FT &pMaxDist)
Definition: PolyPos.h:532
void select_backward_segments(std::set< const_iterator > &selected, const GEOM_FT &tol)
Select backward segments.
Definition: PolyPos.h:573
const_iterator getSegmentAtLength(const GEOM_FT &s) const
Return an iterator pointing to the vertex that is just before the point at a distance "s" measured al...
Definition: PolyPos.h:240
void removeBackwardSegments(const GEOM_FT &tol)
remove backward segments.
Definition: PolyPos.h:620
int getIndexOfSegmentAtLength(const GEOM_FT &s) const
Return the index of the segment that lies at the point at a distance "s" measured along the polyline ...
Definition: PolyPos.h:301
iterator getFarthestPoint(const pos &)
Returns the farthest point from those of the list.
Definition: PolyPos.h:499
std::deque< GEOM_FT > & GetSeparaciones(void) const
Compute the distance from each point to the nearest one.
Definition: PolyPos.h:426
boost::python::list getIthCoordinates(unsigned short i) const
Return the list of values for j-th coordinate.
Definition: PolyPos.h:317
GEOM_FT GetMin(unsigned short i) const
Return the minimum value of j-th coordinate.
Definition: PolyPos.h:348
PolyPos< pos > getSimplified(GEOM_FT epsilon) const
!
Definition: PolyPos.h:729
int getIndexOfSegmentAtParam(const GEOM_FT &lambda) const
Return the index of the segment that lies at the point at a distance "lambda*L" measured along the po...
Definition: PolyPos.h:312
GEOM_FT getLengthUntilVertex(const_iterator) const
Return the length of the PolyPos until the vertex pointed by the iterator.
Definition: PolyPos.h:186
pos getWeightedCenterOfMass(const std::deque< GEOM_FT > &) const
Return the center of mass del polígono.
Definition: PolyPos.h:380
GEOM_FT getLength(void) const
Return the length of the PolyPos.
Definition: PolyPos.h:178
GEOM_FT GetMax(unsigned short i) const
Return the maximum value of j-th coordinate.
Definition: PolyPos.h:333
void removeRepeated(const GEOM_FT &tol=0.0)
remove repeated vertexes.
Definition: PolyPos.h:608
boost::python::list getLengthsPy(void) const
Return the lengths corresponding to each vertex in a Python list.
Definition: PolyPos.h:226
void simplify(GEOM_FT epsilon, iterator it1, iterator it2)
Douglas Peucker algorithm implementation.
Definition: PolyPos.h:684
void select_repeated(std::set< const_iterator > &selected, const GEOM_FT &tol=0.0)
Select repeated vertexes.
Definition: PolyPos.h:546
void extend(InputIterator first, InputIterator last)
Append the vertices between [first,last) to thebefore end of the list.
Definition: PolyPos.h:89