xc
Array3dBoxRefBase.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 //Array3dBoxRefBase.h
22 
23 #ifndef ARRAY3DBOXREFBASE_H
24 #define ARRAY3DBOXREFBASE_H
25 
26 #include <ostream>
27 
28 class RangoIndice;
29 class Array3dRange;
30 
32 //
35  {
36  protected:
37  size_t n_layers;
38  size_t n_rows;
39  size_t n_columns;
40  size_t offset_cp;
41  size_t offset_f;
42  size_t offset_c;
43  public:
44  Array3dBoxRefBase(const size_t &,const size_t &,const size_t &,const size_t &,const size_t &,const size_t &);
45  Array3dBoxRefBase(const Array3dRange &rango);
46  Array3dBoxRefBase(const size_t &iLayer,const RangoIndice &row_range,const RangoIndice &column_range);
47  Array3dBoxRefBase(const RangoIndice &layer_range,const size_t &iRow,const RangoIndice &column_range);
48  Array3dBoxRefBase(const RangoIndice &layer_range,const RangoIndice &row_range,const size_t &col);
49  Array3dBoxRefBase(const size_t &iLayer,const size_t &iRow,const RangoIndice &column_range);
50  Array3dBoxRefBase(const size_t iLayer,const RangoIndice &row_range,const size_t &col);
51  Array3dBoxRefBase(const RangoIndice &layer_range,const size_t &iRow,const size_t &col);
52  inline const size_t &getNumberOfLayers(void) const
53  { return n_layers; }
54  inline const size_t &getNumberOfRows(void) const
55  { return n_rows; }
56  inline const size_t &getNumberOfColumns(void) const
57  { return n_columns; }
58  inline const size_t Size(void) const
59  { return n_layers*n_rows*n_columns; }
60  bool Empty(void) const;
61  RangoIndice LayerRange(void) const;
62  RangoIndice RowRange(void) const;
63  RangoIndice RangoCols(void) const;
64  };
65 
66 template <class ARRAY_3D>
67 inline void PrintArray3d(const ARRAY_3D &t,std::ostream &os)
68  {
69  os << '[';
70  const size_t n_layers= t.getNumberOfLayers();
71  for(size_t i=1;i<=n_layers;i++)
72  {
73  os << '[';
74  const size_t n_rows= t.getNumberOfRows();
75  for(size_t j= 1;j<=n_rows;j++)
76  {
77  os << '[';
78  const size_t n_columns= t.getNumberOfColumns();
79  if(n_columns > 0) os << t(i,j,1);
80  for(size_t k= 2;k<=n_columns;k++)
81  os << ',' << t(i,j,k);
82  os << ']';
83  }
84  os << ']';
85  }
86  os << ']';
87  }
88 
89 #endif
RangoIndice RowRange(void) const
Return the row range.
Definition: Array3dBoxRefBase.cc:89
size_t offset_cp
Offset layer.
Definition: Array3dBoxRefBase.h:40
RangoIndice RangoCols(void) const
Return el column range.
Definition: Array3dBoxRefBase.cc:93
size_t n_layers
number of layers.
Definition: Array3dBoxRefBase.h:37
size_t offset_c
Offset column.
Definition: Array3dBoxRefBase.h:42
bool Empty(void) const
Return verdadero si está vacía.
Definition: Array3dBoxRefBase.cc:97
size_t offset_f
Offset row.
Definition: Array3dBoxRefBase.h:41
RangoIndice LayerRange(void) const
Return el rango de iLayers.
Definition: Array3dBoxRefBase.cc:85
Indices that define a block of an array.
Definition: Array3dBoxRefBase.h:34
size_t n_columns
number of columns.
Definition: Array3dBoxRefBase.h:39
size_t n_rows
number of rows.
Definition: Array3dBoxRefBase.h:38
Rangos de variación de tres índices, se emplea en BoxConstRef.
Definition: Array3dRange.h:32
Rango de variación de un índice, se emplea en BoxConstRef.
Definition: RangoIndice.h:30