uLib-0.2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
StructuredData.h
Go to the documentation of this file.
1 /*//////////////////////////////////////////////////////////////////////////////
2 // CMT Cosmic Muon Tomography project //////////////////////////////////////////
4 
5  Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
6  All rights reserved
7 
8  Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
9 
10  ------------------------------------------------------------------
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Lesser General Public
13  License as published by the Free Software Foundation; either
14  version 3.0 of the License, or (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Lesser General Public License for more details.
20 
21  You should have received a copy of the GNU Lesser General Public
22  License along with this library.
23 
25 
26 
27 
28 #ifndef STRUCTUREDDATA_H
29 #define STRUCTUREDDATA_H
30 
31 #include "Math/Dense.h"
32 
33 namespace uLib {
34 
35 class StructuredData {
36 public:
37  enum _Order
38  {
39  CustomOrder = 0,
40  XYZ = 0 | 1 << 2 | 2 << 4,
41  XZY = 0 | 2 << 2 | 1 << 4,
42  YXZ = 1 | 0 << 2 | 2 << 4,
43  YZX = 2 | 0 << 2 | 1 << 4,
44  ZXY = 1 | 2 << 2 | 0 << 4,
45  ZYX = 2 | 1 << 2 | 0 << 4
46  };
47 
48  typedef enum _Order Order;
49 
50  StructuredData(const Vector3i &size);
51 
52  StructuredData(const StructuredData &copy) :
53  m_DataOrder(copy.m_DataOrder),
54  m_Dims(copy.m_Dims),
55  m_Increments(copy.m_Increments)
56  {}
57 
58 
59  inline Vector3i GetDims() const { return this->m_Dims; }
60 
61  void SetDims(const Vector3i &size);
62 
63  inline Vector3i GetIncrements() const { return this->m_Increments; }
64 
65  inline void SetIncrements(Vector3i name) { this->m_Increments = name; }
66 
67  void SetDataOrder(Order order = YXZ);
68 
69  inline Order GetDataOrder() const { return this->m_DataOrder; }
70 
71  bool IsInsideGrid(const Vector3i &v) const;
72 
73  inline int Map(Vector3i index) const;
74 
75  Vector3i UnMap(int index) const;
76 
77 private:
78  Order m_DataOrder;
79  Vector3i m_Dims;
80  Vector3i m_Increments; //TODO: make this line matrix //
81 };
82 
83 
84 
85 // --- INLINES -------------------------------------------------------------- //
86 
87 
88 inline int StructuredData::Map(Vector3i index) const
89 {
90  return (m_Increments.transpose() * index);
91 }
92 
93 
94 
95 
96 
97 }
98 
99 #endif // STRUCTUREDDATA_H