xc
PosArray3d.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 //PosArray3d.h
22 //Array of point matrices.
23 
24 #ifndef POSARRAY3D_H
25 #define POSARRAY3D_H
26 
27 #include "PosArray.h"
28 #include "utility/matrices/3d_arrays/Array3dBase.h"
29 
30 
32 //
34 template <class POS>
35 class PosArray3d: public Array3dBase<PosArray<POS> >
36  {
37  public:
38  typedef PosArray<POS> m_pos;
39  PosArray3d(const size_t iLayers= 1): Array3dBase<m_pos >(iLayers) {}
40  PosArray3d(const size_t iLayers,const m_pos &m): Array3dBase<m_pos >(iLayers,m) {}
41  PosArray3d(const m_pos &,const m_pos &,const m_pos &,const m_pos &,const size_t &,const size_t &);
42  size_t NumPos(void) const;
43 
44  POS getCenter(void) const;
45  };
46 
48 template <class POS>
49 PosArray3d<POS>::PosArray3d( const m_pos &l1_points,const m_pos &l2_points,
50  const m_pos &l3_points,const m_pos &l4_points,
51  const size_t &ndiv_12,const size_t &ndiv_14)
52  : Array3dBase<PosArray<POS> >(l1_points.size())
53  {
54  const size_t n_layers= this->size();
55  for(size_t i=1;i<=n_layers;i++) //Iteration on the point "layers".
56  {
57  const POS &p1= l1_points(i); //1st. point of the quadrangle.
58  const POS &p2= l2_points(i); //2nd. point of the quadrangle.
59  const POS &p3= l3_points(i); //3rd. point of the quadrangle.
60  const POS &p4= l4_points(i); //4th. point of the quadrangle.
61  const m_pos lado1= m_pos(p1,p2,ndiv_12);
62  const m_pos lado2= m_pos(p2,p3,ndiv_14);
63  const m_pos lado3= m_pos(p4,p3,ndiv_12);
64  const m_pos lado4= m_pos(p1,p4,ndiv_14);
65  m_pos i_layer(lado1,lado2,lado3,lado4);
66  (*this)(i)= i_layer;
67  }
68  }
69 
71 template <class POS>
72 size_t PosArray3d<POS>::NumPos(void) const
73  { return this->getNumberOfComponents(); }
74 
75 template <class POS,class SEG>
76 POS get_centro(const PosArray3d<POS> t,const SEG &sg)
77  {
78  POS retval;
79  const typename PosArray3d<POS>::m_pos &base= t(1);
80  const typename PosArray3d<POS>::m_pos &tapa= t(t.getNumberOfLayers());
81  SEG s(get_centro(base,SEG()),get_centro(tapa,SEG()));
82  retval= s.getCenterOfMass();
83  return retval;
84  }
85 
86 #endif
size_t NumPos(void) const
Return the number of points in the container.
Definition: PosArray3d.h:72
size_t getNumberOfComponents(void) const
Return the number of components in the container.
Definition: Array3dBase.h:235
Base class for position matrices used to represent grids of points.
Definition: PosArray.h:37
arrays3d
Definition: Array3dBase.h:51
Base class for grids of positions in 3D.
Definition: PosArray3d.h:35