xc
Pos2dList.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 //Pos2dList.
22 
23 #ifndef LISTAPOS2D_H
24 #define LISTAPOS2D_H
25 
26 #include "../d2/GeomObj2d.h"
27 
28 class Polygon2d;
29 
31 //
33 class Pos2dList: public GeomObj2d
34  {
35  public:
37  typedef GeomObj::list_Pos2d::iterator point_iterator;
38  typedef GeomObj::list_Pos2d::const_iterator point_const_iterator;
39  protected:
40  list_Pos2d lista_ptos;
41  Pos2d &operator[](const size_t &i);
42  public:
43  Pos2dList(void);
44  explicit Pos2dList(const GeomObj::list_Pos2d &l);
45  explicit Pos2dList(const boost::python::list &);
46  virtual GeomObj *getCopy(void) const
47  { return new Pos2dList(*this); }
48  inline size_t getNumberOfPoints(void) const
49  { return lista_ptos.size(); }
50  inline point_const_iterator points_begin(void) const
51  { return lista_ptos.begin(); }
52  const point_const_iterator points_end(void) const
53  { return lista_ptos.end(); }
54  inline short unsigned int Dimension(void) const
55  { return 0; }
56 
57  const GeomObj::list_Pos2d &getPoints(void) const
58  { return lista_ptos; }
59  const Pos2d &operator[](const size_t &i) const;
60 
61  const Pos2d *appendPoint(const Pos2d &p);
62  void appendPointPy(const Pos2d &p);
63  template <class InputIterator>
65  inline void assign(InputIterator first, InputIterator last)
66  { lista_ptos.assign(first,last); }
67  virtual bool In(const Pos2d &p, const double &tol= 0.0) const;
68 
69  virtual GEOM_FT Ix(void) const;
70  virtual GEOM_FT Iy(void) const;
71  virtual GEOM_FT Iz(void) const;
72 
74  inline virtual GEOM_FT Pxy(void) const
75  { return NAN; }
77  virtual GEOM_FT getLength(void) const
78  { return 0.0; }
80  virtual GEOM_FT getArea(void) const
81  { return 0.0; }
82  virtual GEOM_FT GetMax(unsigned short int i) const;
83  virtual GEOM_FT GetMin(unsigned short int i) const;
84  Pos2dList GetMayores(unsigned short int i,const GEOM_FT &d) const;
85  Pos2dList GetMenores(unsigned short int i,const GEOM_FT &d) const;
86  const Pos2d &Point(const size_t &i) const;
87  Pos2d getCenterOfMass(void) const
88  { return lista_ptos.getCenterOfMass(); }
89 
90  void Transform(const Trf2d &trf2d);
91  Pos2dList offset(const GEOM_FT &d) const;
92 
93  std::deque<GEOM_FT> &GetSeparaciones(void) const;
94  std::deque<GEOM_FT> &getCovers(const Polygon2d &) const;
95  double GetSeparacionMedia(void) const;
96 
97  void Print(std::ostream &stream) const;
98  void Plot(Plotter &) const;
99  };
100 
101 #endif
102 
103 
104 
105 
106 
107 
Pos2dList offset(const GEOM_FT &d) const
Return the vertex list of a polyline parallel to the polyline builded with the vertex of this line at...
Definition: Pos2dList.cc:70
void assign(InputIterator first, InputIterator last)
Insert the vertices between [first,last).
Definition: Pos2dList.h:65
virtual GEOM_FT getLength(void) const
Return the length of the object.
Definition: Pos2dList.h:77
Base class for position lists.
Definition: PolyPos.h:35
const Pos2d * appendPoint(const Pos2d &p)
Appends the point to the list.
Definition: Pos2dList.cc:51
pos getCenterOfMass(void) const
Return the center of mass del polígono.
Definition: PolyPos.h:353
Posición en dos dimensiones.
Definition: Pos2d.h:41
Base class for two-dimensional transformations.
Definition: Trf2d.h:40
void Transform(const Trf2d &trf2d)
Applies the transformation to the points.
Definition: Pos2dList.cc:63
Base class for the two-dimensional geometric objects.
Definition: GeomObj2d.h:37
Polígono en dos dimensiones.
Definition: Polygon2d.h:38
const Pos2d & Point(const size_t &i) const
Return el vértice i-ésimo (el primero es el 1).
Definition: Pos2dList.cc:177
Pos2dList GetMayores(unsigned short int i, const GEOM_FT &d) const
Return a Pos2dList with the points which i coordinate is greater than d.
Definition: Pos2dList.cc:159
virtual GEOM_FT Iz(void) const
Moment of inertia polar with respect to the center of mass en local axis.
Definition: Pos2dList.cc:191
virtual GEOM_FT Ix(void) const
Moment of inertia with respect to the center of mass en local axis.
Definition: Pos2dList.cc:181
Pos2dList GetMenores(unsigned short int i, const GEOM_FT &d) const
Return a Pos2dList with the points which i coordinate is less than d.
Definition: Pos2dList.cc:168
virtual bool In(const Pos2d &p, const double &tol=0.0) const
Return true if the point belongs to the set.
Definition: Pos2dList.cc:143
virtual GEOM_FT GetMin(unsigned short int i) const
Return the minimum value of the i coordinate.
Definition: Pos2dList.cc:154
virtual GEOM_FT Iy(void) const
Moment of inertia with respect to the center of mass en local axis.
Definition: Pos2dList.cc:186
short unsigned int Dimension(void) const
Return the dimension of the object 0, 1, 2 or 3.
Definition: Pos2dList.h:54
virtual GEOM_FT GetMax(unsigned short int i) const
Return the maximum value of the i coordinate.
Definition: Pos2dList.cc:150
Pos2d & operator[](const size_t &i)
Return a reference al objeto cuyo índice se pasa como parámetro.
Definition: Pos2dList.cc:116
Clase base para las entidades geométricas.
Definition: GeomObj.h:40
virtual GEOM_FT getArea(void) const
Return the area of the object.
Definition: Pos2dList.h:80
void appendPointPy(const Pos2d &p)
Appends the point to the list.
Definition: Pos2dList.cc:59
virtual GEOM_FT Pxy(void) const
Product of inertia.
Definition: Pos2dList.h:74
List of 2D positions.
Definition: Pos2dList.h:33