xc
Pos3dList.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 //Pos3dList.
22 
23 #ifndef LISTAPOS3D_H
24 #define LISTAPOS3D_H
25 
26 #include "Pos3d.h"
27 #include "Vector3d.h"
28 #include "../d3/GeomObj3d.h"
29 
30 class Trf3d;
31 
32 
34 //
36 class Pos3dList: public GeomObj3d
37  {
38  public:
40  typedef GeomObj::list_Pos3d::iterator point_iterator;
41  typedef GeomObj::list_Pos3d::const_iterator point_const_iterator;
42  protected:
43  list_Pos3d point_lst;
44  Pos3d &operator[](const size_t &i);
45  public:
46  Pos3dList(void);
47  explicit Pos3dList(const GeomObj::list_Pos3d &l);
48  explicit Pos3dList(const boost::python::list &);
49  template <typename InputIterator>
50  explicit Pos3dList(InputIterator first,InputIterator last);
51  virtual GeomObj *getCopy(void) const
52  { return new Pos3dList(*this); }
53  inline size_t getNumberOfPoints(void) const
54  { return point_lst.size(); }
55  inline point_const_iterator points_begin(void) const
56  { return point_lst.begin(); }
57  const point_const_iterator points_end(void) const
58  { return point_lst.end(); }
59  inline short unsigned int Dimension(void) const
60  { return 0; }
61 
62  const GeomObj::list_Pos3d &getPoints(void) const
63  { return point_lst; }
64  const Pos3d &operator[](const size_t &i) const;
65 
66  const Pos3d *appendPoint(const Pos3d &p);
68  template <class InputIterator>
69  inline void assign(InputIterator first, InputIterator last)
70  { point_lst.assign(first,last); }
71  virtual bool In(const Pos3d &p, const double &tol= 0.0) const;
72 
73  virtual GEOM_FT Ix(void) const;
74  virtual GEOM_FT Iy(void) const;
75  virtual GEOM_FT Iz(void) const;
76 
78  inline virtual GEOM_FT Pxy(void) const
79  { return NAN; }
81  virtual GEOM_FT getLength(void) const
82  { return 0.0; }
84  virtual GEOM_FT getArea(void) const
85  { return 0.0; }
87  virtual GEOM_FT getVolume(void) const
88  { return 0.0; }
89  virtual GEOM_FT GetMax(unsigned short int i) const;
90  virtual GEOM_FT GetMin(unsigned short int i) const;
91  Pos3dList GetMayores(unsigned short int i,const GEOM_FT &d) const;
92  Pos3dList GetMenores(unsigned short int i,const GEOM_FT &d) const;
93  const Pos3d &Point(const size_t &i) const;
94  Pos3d getCenterOfMass(void) const
95  { return point_lst.getCenterOfMass(); }
96  Vector3d getAvgKVector(void) const;
97  bool clockwise(const Pos3d &) const;
98  bool counterclockwise(const Pos3d &) const;
99  std::string orientation(const Pos3d &) const;
100 
101  void Transform(const Trf3d &trf3d);
102 
103  std::deque<GEOM_FT> &GetSeparaciones(void) const;
104  double GetSeparacionMedia(void) const;
105 
106  CGPlane_3 linearLeastSquaresFittingPlane(GEOM_FT &quality);
107  void Print(std::ostream &stream) const;
108  void Plot(Plotter &) const;
109  };
110 
111 template <typename InputIterator>
112 Pos3dList::Pos3dList(InputIterator begin,InputIterator end)
113  : GeomObj3d()
114  {
115  for(InputIterator i= begin; i!= end; i++)
116  point_lst.push_back(*i);
117  }
118 
119 #endif
120 
121 
122 
123 
124 
125 
Pos3dList GetMenores(unsigned short int i, const GEOM_FT &d) const
Return a Pos2dList with the points which i coordinate is less than d.
Definition: Pos3dList.cc:114
Base class for position lists.
Definition: PolyPos.h:35
virtual GEOM_FT getVolume(void) const
Return the volume of the object.
Definition: Pos3dList.h:87
pos getCenterOfMass(void) const
Return the center of mass del polígono.
Definition: PolyPos.h:353
Pos3d & operator[](const size_t &i)
Return a reference al objeto cuyo índice se pasa como parámetro.
Definition: Pos3dList.cc:62
virtual GEOM_FT getArea(void) const
Return the area of the Pos3dList.
Definition: Pos3dList.h:84
const Pos3d & Point(const size_t &i) const
Return el vértice i-ésimo (el primero es el 1).
Definition: Pos3dList.cc:123
short unsigned int Dimension(void) const
Return the dimension of the object 0, 1, 2 or 3.
Definition: Pos3dList.h:59
void Transform(const Trf3d &trf3d)
Applies the transformation to the points.
Definition: Pos3dList.cc:56
bool clockwise(const Pos3d &) const
Return true if the point list is oriented clockwise.
Definition: Pos3dList.cc:197
bool counterclockwise(const Pos3d &) const
Return true if the point list is oriented counterclockwise.
Definition: Pos3dList.cc:202
std::string orientation(const Pos3d &) const
Return the orientation of the point list (clockwise or counterclockwise).
Definition: Pos3dList.cc:226
virtual GEOM_FT GetMax(unsigned short int i) const
Return the maximum value of the i coordinate.
Definition: Pos3dList.cc:96
List of 3D positions.
Definition: Pos3dList.h:36
Pos3dList GetMayores(unsigned short int i, const GEOM_FT &d) const
Return a Pos2dList with the points which i coordinate is greater than d.
Definition: Pos3dList.cc:105
void Print(std::ostream &stream) const
Print stuff.
Definition: Pos3dList.cc:234
virtual GEOM_FT getLength(void) const
Return the length of the Pos3dList.
Definition: Pos3dList.h:81
virtual GEOM_FT GetMin(unsigned short int i) const
Return the minimum value of the i coordinate.
Definition: Pos3dList.cc:100
virtual bool In(const Pos3d &p, const double &tol=0.0) const
Returns true if the points belongs to the list.
Definition: Pos3dList.cc:89
void assign(InputIterator first, InputIterator last)
Insert the vertices between [first,last).
Definition: Pos3dList.h:69
Posición en tres dimensiones.
Definition: Pos3d.h:44
Vector3d getAvgKVector(void) const
Return an average k vector by computing the average of of the cross products of the vectors joining t...
Definition: Pos3dList.cc:162
Three-dimensional transformation.
Definition: Trf3d.h:39
Clase base para las entidades geométricas.
Definition: GeomObj.h:40
Vector en tres dimensiones.
Definition: Vector3d.h:39
Pos3dList(void)
Default constructor.
Definition: Pos3dList.cc:33
virtual GEOM_FT Pxy(void) const
Product of inertia.
Definition: Pos3dList.h:78
Clase base para los objetos en tres dimensiones.
Definition: GeomObj3d.h:43