IB-0.2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
IBVoxCollection.h
Go to the documentation of this file.
1 /*////////////////////////////////////////////////////////////////////////////
2  Copyright 2018 Istituto Nazionale di Fisica Nucleare
3 
4  Licensed under the EUPL, Version 1.2 or - as soon they will be approved by
5  the European Commission - subsequent versions of the EUPL (the "Licence").
6  You may not use this work except in compliance with the Licence.
7 
8  You may obtain a copy of the Licence at:
9 
10  https://joinup.ec.europa.eu/software/page/eupl
11 
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
14  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15  Licence for the specific language governing permissions and limitations under
16  the Licence.
18 
19 
20 /*
21  * File: IBVoxCollection.h
22  * Author: andrea
23  *
24  * Created on June 14, 2011, 11:43 AM
25  */
26 
27 
28 #ifndef IBVOXCOLLECTION_H
29 #define IBVOXCOLLECTION_H
30 
31 #include <Math/Dense.h>
32 #include <Math/ContainerBox.h>
33 #include <Math/VoxImage.h>
34 
35 #include "IBVoxel.h"
36 
37 class IBVoxCollection;
38 
39 namespace IBInterface {
40 
42  template <class Self> void check_structural() {
43  //uLibCheckStaticFunction(Self, UpdateDensity , void ,IBVoxCollection *, unsigned int);
44  }
45 };
46 
47 }
48 
49 namespace IBAbstract {
50 
52  virtual void operator()(IBVoxCollection*,unsigned int) = 0;
53 };
54 
56  virtual void UpdateDensity(IBVoxCollection *voxels, unsigned int threshold) = 0;
57 };
58 
59 }
60 
61 
62 class IBVoxCollection : public uLib::VoxImage<IBVoxel> {
63  typedef uLib::VoxImage<IBVoxel> BaseClass;
65 public:
66 
68 
69  IBVoxCollection(const uLib::Vector3i size);
70 
71  IBVoxCollection(const IBVoxCollection &copy);
72 
73  IBVoxCollection(const BaseClass &copy);
74 
75  // templated update for analyzer specific customizations //
76  template < typename StaticUpdateAlgT >
77  void UpdateDensity(unsigned int threshold);
78 
79  // templated update for analyzer specific customizations //
80  template < typename UpdateAlgT >
81  void UpdateDensity(UpdateAlgT &algorithm, unsigned int threshold);
82 
84 
85  inline void InitLambda(const IBVoxel &value);
86 
87  inline void InitCount(unsigned int count);
88 
89  inline void resetSijCap();
90 
91  int CountLambdaOverThreshold(float threshold);
92 
93  int CountLambdaOverThreshold(float threshold,uLib::Vector3i boxp1, uLib::Vector3i boxp2);
94 
95  int CountLambdaOverThreshold(float threshold,uLib::HPoint3f center, uLib::HVector3f size);
96 
97  inline IBVoxCollection LambdaToInvLrad(float p0) { IBVoxCollection out = *this;
98  out*=((p0/15)*(p0/15)); // 1/cm
99  out*=100.; // 1/m
100  return out;
101  }
102 
103  inline IBVoxCollection InvLradToLambda(float p0) { IBVoxCollection out = *this;
104  out/=((p0/15)*(p0/15)); // 1/cm
105  //out/=100.; // if in 1/m
106  return out;
107  }
108  IBVoxCollection getMCImage(const char* file, int nsamples);
109  float getVoxelMCDensity(const char* file, uLib::HPoint3f c1, uLib::HPoint3f c2, int nrandom=1000);
110 
111 private:
113 };
114 
115 
116 // --- inlines -------------------------------------------------------------- //
117 
118 inline void IBVoxCollection::InitLambda(const IBVoxel &value)
119 {
120  BaseClass::InitVoxels(value);
121  InitCount(0);
122  resetSijCap();
123 }
124 
125 
126 inline void IBVoxCollection::InitCount(unsigned int count)
127 {
128  for(unsigned int i=0; i<this->Data().size(); ++i) {
129  this->Data().operator [](i).Count = count;
130  }
131 }
132 
134 {
135  for(unsigned int i=0; i<this->Data().size(); ++i) {
136  this->Data().operator [](i).SijCap = 0;
137  }
138 }
139 
140 
141 // --- Update --------------------------------------------------------------- //
142 
143 template < class UpdateAlgT >
144 void IBVoxCollection::UpdateDensity(UpdateAlgT &algorithm,
145  unsigned int threshold) {
146 
147  // Analyzer Update //
148  algorithm(this, threshold);
149 
150  // MAP update //
151  if(m_MAPAlgorithm) m_MAPAlgorithm->UpdateDensity(this, threshold);
152 
153  // Reinitialize voxels //
154  this->InitCount(0);
155 }
156 
157 template < class StaticUpdateAlgT >
158 void IBVoxCollection::UpdateDensity(unsigned int threshold) {
159 
160  // Analyzer Update //
161  StaticUpdateAlgT::UpdateDensity(this,threshold);
162 
163  // MAP update //
164  if(m_MAPAlgorithm) m_MAPAlgorithm->UpdateDensity(this, threshold);
165 
166  // Reinitialize voxels //
167  this->InitCount(0);
168 }
169 
170 
171 #endif /* IBVOXCOLLECTION_H */
172 
Definition: IBVoxCollection.h:51
void InitLambda(const IBVoxel &value)
Definition: IBVoxCollection.h:118
float getVoxelMCDensity(const char *file, uLib::HPoint3f c1, uLib::HPoint3f c2, int nrandom=1000)
virtual void operator()(IBVoxCollection *, unsigned int)=0
Definition: IBVoxel.h:28
IBVoxCollection InvLradToLambda(float p0)
Definition: IBVoxCollection.h:103
void UpdateDensity(unsigned int threshold)
Definition: IBVoxCollection.h:158
int CountLambdaOverThreshold(float threshold)
void check_structural()
Definition: IBVoxCollection.h:42
virtual void UpdateDensity(IBVoxCollection *voxels, unsigned int threshold)=0
void SetMAPAlgorithm(IBAbstract::IBVoxCollectionMAPAlgorithm *algorithm)
IBVoxCollection LambdaToInvLrad(float p0)
Definition: IBVoxCollection.h:97
IBVoxCollection getMCImage(const char *file, int nsamples)
Definition: IBVoxCollection.h:62
Definition: IBVoxCollection.h:55
void InitCount(unsigned int count)
Definition: IBVoxCollection.h:126
void resetSijCap()
Definition: IBVoxCollection.h:133