Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
GMocrenDataPrimitive< T > Class Template Reference

#include <G4GMocrenIO.hh>

Public Member Functions

 GMocrenDataPrimitive ()
 
 ~GMocrenDataPrimitive ()
 
GMocrenDataPrimitive< T > & operator= (const GMocrenDataPrimitive< T > &_right)
 
GMocrenDataPrimitive< T > & operator+ (const GMocrenDataPrimitive< T > &_right)
 
GMocrenDataPrimitive< T > & operator+= (const GMocrenDataPrimitive< T > &_right)
 
void clear ()
 
void clearImage ()
 
void setSize (int _size[3])
 
void getSize (int _size[3])
 
void setScale (double &_scale)
 
double getScale ()
 
void setMinMax (T _minmax[2])
 
void getMinMax (T _minmax[2])
 
void setImage (std::vector< T * > &_image)
 
void addImage (T *_image)
 
std::vector< T * > & getImage ()
 
T * getImage (int _z)
 
void setCenterPosition (float _center[3])
 
void getCenterPosition (float _center[3])
 
void setName (std::string &_name)
 
std::string getName ()
 

Protected Attributes

int kSize [3]
 
double kScale
 
kMinmax [2]
 
float kCenter [3]
 
std::vector< T * > kImage
 
std::string kDataName
 

Detailed Description

template<typename T>
class GMocrenDataPrimitive< T >

Definition at line 50 of file G4GMocrenIO.hh.

Constructor & Destructor Documentation

◆ GMocrenDataPrimitive()

template<typename T >
GMocrenDataPrimitive< T >::GMocrenDataPrimitive ( )

Definition at line 59 of file G4GMocrenIO.cc.

59 {
60 clear();
61}

◆ ~GMocrenDataPrimitive()

template<typename T >
GMocrenDataPrimitive< T >::~GMocrenDataPrimitive ( )

Definition at line 63 of file G4GMocrenIO.cc.

63 {
64 /*
65 std::vector<short *>::iterator itr = image.begin();
66 for(; itr != image.end(); itr++) {
67 delete [] *itr;
68 }
69 */
70}

Member Function Documentation

◆ addImage()

template<typename T >
void GMocrenDataPrimitive< T >::addImage ( T * _image)

◆ clear()

template<typename T >
void GMocrenDataPrimitive< T >::clear ( )

Definition at line 167 of file G4GMocrenIO.cc.

167 {
168 for(int i = 0; i < 3; i++) {
169 kSize[i] = 0;
170 kCenter[i] = 0.;
171 }
172 kScale = 1.;
173 kMinmax[0] = (T)32109;
174 kMinmax[1] = (T)-32109;
175
176 clearImage();
177}

Referenced by G4GMocrenIO::initialize().

◆ clearImage()

template<typename T >
void GMocrenDataPrimitive< T >::clearImage ( )

Definition at line 179 of file G4GMocrenIO.cc.

179 {
180 typename std::vector<T *>::iterator itr;
181 for(itr = kImage.begin(); itr != kImage.end(); itr++) {
182 delete [] *itr;
183 }
184 kImage.clear();
185}

Referenced by G4GMocrenIO::clearModalityImage().

◆ getCenterPosition()

template<typename T >
void GMocrenDataPrimitive< T >::getCenterPosition ( float _center[3])

Definition at line 233 of file G4GMocrenIO.cc.

233 {
234 for(int i = 0; i < 3; i++) _center[i] = kCenter[i];
235}

Referenced by G4GMocrenIO::getModalityCenterPosition().

◆ getImage() [1/2]

template<typename T >
std::vector< T * > & GMocrenDataPrimitive< T >::getImage ( )

◆ getImage() [2/2]

template<typename T >
T * GMocrenDataPrimitive< T >::getImage ( int _z)

Definition at line 224 of file G4GMocrenIO.cc.

224 {
225 if(_z >= (int)kImage.size()) return 0;
226 return kImage[_z];
227}

◆ getMinMax()

template<typename T >
void GMocrenDataPrimitive< T >::getMinMax ( T _minmax[2])

◆ getName()

template<typename T >
std::string GMocrenDataPrimitive< T >::getName ( )

Definition at line 241 of file G4GMocrenIO.cc.

241 {
242 return kDataName;
243}
std::string kDataName

◆ getScale()

template<typename T >
double GMocrenDataPrimitive< T >::getScale ( )

◆ getSize()

template<typename T >
void GMocrenDataPrimitive< T >::getSize ( int _size[3])

Definition at line 191 of file G4GMocrenIO.cc.

191 {
192 for(int i = 0; i < 3; i++) _size[i] = kSize[i];
193}

Referenced by G4GMocrenIO::getModalityImageSize(), G4GMocrenIO::storeData2(), G4GMocrenIO::storeData3(), and G4GMocrenIO::storeData4().

◆ operator+()

template<typename T >
GMocrenDataPrimitive< T > & GMocrenDataPrimitive< T >::operator+ ( const GMocrenDataPrimitive< T > & _right)

Definition at line 92 of file G4GMocrenIO.cc.

92 {
93
95 bool stat = true;
96 for(int i = 0; i < 3; i++) {
97 if(kSize[i] != _right.kSize[i]) stat = false;
98 if(kCenter[i] != _right.kCenter[i]) stat = false;
99 }
100 if(!stat) {
102 G4cout << "Warning: operator + "
103 << " Cannot do the operator +"
104 << G4endl;
105 return *this;
106 }
107
108 rprim.setSize(kSize);
110
111 T mms[2] = {9e100,-9e100};
112 //if(mms[0] > _right.minmax[0]) mms[0] = _right.minmax[0];
113 //if(mms[1] < _right.minmax[1]) mms[1] = _right.minmax[1];
114
115 int num = kSize[0]*kSize[1];
116 for(int z = 0; z < kSize[2]; z++) {
117 T * img = new T[num];
118 for(int xy = 0; xy < num; xy++) {
119 img[xy] = kImage[z][xy] + _right.kImage[z][xy];
120 if(mms[0] > img[xy]) mms[0] = img[xy];
121 if(mms[1] < img[xy]) mms[1] = img[xy];
122 }
123 rprim.addImage(img);
124 }
125 rprim.setMinMax(mms);
126
127 T scl = mms[1]/DOSERANGE;
128 rprim.setScale(scl);
129
130 return rprim;
131}
const int DOSERANGE
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
static Verbosity GetVerbosity()
void setSize(int _size[3])
void setMinMax(T _minmax[2])
void setCenterPosition(float _center[3])
void setScale(double &_scale)
void addImage(T *_image)

◆ operator+=()

template<typename T >
GMocrenDataPrimitive< T > & GMocrenDataPrimitive< T >::operator+= ( const GMocrenDataPrimitive< T > & _right)

Definition at line 134 of file G4GMocrenIO.cc.

134 {
135
136 bool stat = true;
137 for(int i = 0; i < 3; i++) {
138 if(kSize[i] != _right.kSize[i]) stat = false;
139 if(kCenter[i] != _right.kCenter[i]) stat = false;
140 }
141 if(!stat) {
143 G4cout << "Warning: operator += " << G4endl
144 << " Cannot do the operator +="
145 << G4endl;
146 return *this;
147 }
148
149 if(kMinmax[0] > _right.kMinmax[0]) kMinmax[0] = _right.kMinmax[0];
150 if(kMinmax[1] < _right.kMinmax[1]) kMinmax[1] = _right.kMinmax[1];
151
152 int num = kSize[0]*kSize[1];
153 for(int z = 0; z < kSize[2]; z++) {
154 for(int xy = 0; xy < num; xy++) {
155 kImage[z][xy] += _right.kImage[z][xy];
156 if(kMinmax[0] > kImage[z][xy]) kMinmax[0] = kImage[z][xy];
157 if(kMinmax[1] < kImage[z][xy]) kMinmax[1] = kImage[z][xy];
158 }
159 }
160
162
163 return *this;
164}

◆ operator=()

template<typename T >
GMocrenDataPrimitive< T > & GMocrenDataPrimitive< T >::operator= ( const GMocrenDataPrimitive< T > & _right)

Definition at line 73 of file G4GMocrenIO.cc.

73 {
74 if (this == &_right) return *this;
75 for(int i = 0; i < 3; i++) {
76 kSize[i] = _right.kSize[i];
77 kCenter[i] = _right.kCenter[i];
78 }
79 kScale = _right.kScale;
80 for(int i = 0; i < 2; i++) kMinmax[i] = _right.kMinmax[i];
81 int num = kSize[0]*kSize[1];
82 kImage.clear();
83 for(int z = 0; z < kSize[2]; z++) {
84 T * img = new T[num];
85 for(int i = 0; i < num; i++) img[i] =_right.kImage[z][i];
86 kImage.push_back(img);
87 }
88 return *this;
89}

◆ setCenterPosition()

template<typename T >
void GMocrenDataPrimitive< T >::setCenterPosition ( float _center[3])

Definition at line 229 of file G4GMocrenIO.cc.

229 {
230 for(int i = 0; i < 3; i++) kCenter[i] = _center[i];
231}

Referenced by GMocrenDataPrimitive< T >::operator+(), and G4GMocrenIO::setModalityCenterPosition().

◆ setImage()

template<typename T >
void GMocrenDataPrimitive< T >::setImage ( std::vector< T * > & _image)

Definition at line 212 of file G4GMocrenIO.cc.

212 {
213 kImage = _image;
214}

◆ setMinMax()

template<typename T >
void GMocrenDataPrimitive< T >::setMinMax ( T _minmax[2])

◆ setName()

template<typename T >
void GMocrenDataPrimitive< T >::setName ( std::string & _name)

Definition at line 237 of file G4GMocrenIO.cc.

237 {
238 kDataName = _name;
239}

◆ setScale()

◆ setSize()

template<typename T >
void GMocrenDataPrimitive< T >::setSize ( int _size[3])

Member Data Documentation

◆ kCenter

template<typename T >
float GMocrenDataPrimitive< T >::kCenter[3]
protected

◆ kDataName

template<typename T >
std::string GMocrenDataPrimitive< T >::kDataName
protected

Definition at line 57 of file G4GMocrenIO.hh.

◆ kImage

template<typename T >
std::vector<T *> GMocrenDataPrimitive< T >::kImage
protected

◆ kMinmax

template<typename T >
T GMocrenDataPrimitive< T >::kMinmax[2]
protected

Definition at line 54 of file G4GMocrenIO.hh.

Referenced by GMocrenDataPrimitive< T >::operator+=().

◆ kScale

template<typename T >
double GMocrenDataPrimitive< T >::kScale
protected

Definition at line 53 of file G4GMocrenIO.hh.

◆ kSize

template<typename T >
int GMocrenDataPrimitive< T >::kSize[3]
protected

The documentation for this class was generated from the following files: