FEDRA emulsion software from the OPERA Collaboration
TBitMatrix Class Reference

#include <bitmatrix.h>

Inheritance diagram for TBitMatrix:
Collaboration diagram for TBitMatrix:

Public Member Functions

void ClearBit (long i, long j)
 
void ClearBit (long i, long j, int area)
 
int GetBit (int type, long i, long j)
 
int GetElement (int type, long i, long j)
 
float GetZ (void)
 
void SetBit (long i, long j)
 
void SetBit (long i, long j, int area)
 
void SetZ (float z)
 
 TBitMatrix ()
 
 TBitMatrix (long x_size, long y_size)
 
 TBitMatrix (long x_size, long y_size, float z)
 
 TBitMatrix (TBaseMatrix &T)
 
virtual ~TBitMatrix ()
 
- Public Member Functions inherited from TBaseMatrix
void Adopt (unsigned char *mas, long rows, long columns)
 
long GetSize (long *ix_size=NULL, long *iy_size=NULL)
 
void Init (long ix_size, long iy_size)
 
void MoveMatrix (long ud, long lr)
 
TBaseMatrixoperator= (TBaseMatrix &T)
 
void Print (int type)
 
void ResetShift (void)
 
 TBaseMatrix ()
 
 TBaseMatrix (long ix_size, long iy_size)
 
 TBaseMatrix (TBaseMatrix &iT)
 
virtual ~TBaseMatrix ()
 

Protected Attributes

float Z
 
- Protected Attributes inherited from TBaseMatrix
long byteSize
 
unsigned char * mas
 
long shiftX
 
long shiftY
 
long xSize
 
long ySize
 

Additional Inherited Members

- Protected Member Functions inherited from TBaseMatrix
const unsigned char * GetPointer (void)
 

Constructor & Destructor Documentation

◆ TBitMatrix() [1/4]

TBitMatrix::TBitMatrix ( )
14  :TBaseMatrix() {
15 // TBaseMatrix();
16 /* xSize=0;
17  ySize=0;
18  byteSize=0;
19  mas = NULL;
20 
21  xSize=0;
22  ySize=0;
23  byteSize=0;
24  mas = NULL;
25  shiftX=0;
26  position = 0;
27  NonZeroPoints = new TObjArray();
28 
29  shiftY=0;
30 */
31 }
TBaseMatrix()
Definition: basematrix.cxx:25

◆ TBitMatrix() [2/4]

TBitMatrix::TBitMatrix ( long  x_size,
long  y_size 
)
34  :TBaseMatrix(x,y) {
35 // TBitMatrix();
36 /* xSize = x;
37  ySize = y;
38  long bitSize = xSize*ySize;
39  byteSize = (long)(bitSize/8) + (bitSize%8)?1:0;
40  mas = (unsigned char *)calloc(byteSize,sizeof(unsigned char));
41 
42  Init(x,y);
43 */}

◆ TBitMatrix() [3/4]

TBitMatrix::TBitMatrix ( long  x_size,
long  y_size,
float  z 
)
46  :TBaseMatrix(x_size,y_size)
47 {
48 // Init(x_size, y_size);
49  Z=z;
50 }
float Z
Definition: bitmatrix.h:21

◆ TBitMatrix() [4/4]

TBitMatrix::TBitMatrix ( TBaseMatrix T)
52  :TBaseMatrix(T)
53 {
54 /* long xs,ys;
55  T.GetSize(&xs,&ys);
56  Init(xs,ys);
57  */
58 }

◆ ~TBitMatrix()

TBitMatrix::~TBitMatrix ( )
virtual
62  {
63 /* if (imas) {
64  free(imas);
65  imas = NULL;
66  }
67  if (cmas) {
68  free(cmas);
69  cmas = NULL;
70  }
71  ixSize=0;
72  iySize=0;
73  ibyteSize=0;
74 
75  cxSize=0;
76  cySize=0;
77  cbyteSize=0;
78 */}

Member Function Documentation

◆ ClearBit() [1/2]

void TBitMatrix::ClearBit ( long  i,
long  j 
)
158  {
159  long bit = xSize * j + i;
160 // int byte = (int)(xSize/8)*j + (int)(i/8);
161 // int bit_byte = i%8;
162  mas[bit] =0 ;
163 /* MyPoint *point = 0;
164  int n = NonZeroPoints->GetEntries();
165  for (int k=0; k<n; k++) {
166  point = (MyPoint *)(NonZeroPoints->At(k));
167  if ((point->x == i)&&(point->y == j)) {
168  delete NonZeroPoints->RemoveAt(k);
169  NonZeroPoints->Compress();
170  break;
171  }
172  }
173 */
174 }
long xSize
Definition: basematrix.h:22
unsigned char * mas
Definition: basematrix.h:30

◆ ClearBit() [2/2]

void TBitMatrix::ClearBit ( long  i,
long  j,
int  area 
)
178 {
179  if (area<=1) ClearBit(i,j);
180  else {
181  int sarea = (int)(sqrt((double)area));
182  long lbx = i - sarea/2;
183  lbx = (lbx>=0)?lbx:0;
184  long rbx = i + sarea/2;
185 // long xSize = (type==0)?cxSize:ixSize;
186  rbx = (rbx<xSize)?rbx:(xSize-1);
187  long uby = j - sarea/2;
188  uby = (uby>=0)?uby:0;
189 // long ySize = (type==0)?cySize:iySize;
190  long dby = j + sarea/2;
191  dby = (dby<ySize)?dby:(ySize-1);
192  for (long jj=uby; jj<=dby; jj++) {
193  for (long ii=lbx; ii<=rbx; ii++) {
194  ClearBit(ii,jj);
195  }
196  }
197  }
198 
199 }
long ySize
Definition: basematrix.h:23
void ClearBit(long i, long j)
Definition: bitmatrix.cxx:158

◆ GetBit()

int TBitMatrix::GetBit ( int  type,
long  i,
long  j 
)
94  {
95  long shi, shj, shx, shy;
96  if (type==0) {
97  shx = 0;
98  shy = 0;
99  }
100  else if (type==1) {
101  shx = shiftX;
102  shy = shiftY;
103  }
104  else {
105  cout<<"UNKNOWN GETBIT TYPE"<<endl;
106  return 0;
107  }
108  shi = i - shx;
109  shj = j - shy;
110  if ((shi>=xSize)||(shj>=ySize)||(shi<0)||(shj<0)) return 0;
111  long bit = xSize * shj + shi;
112 // int byte = (int)(xSize/8)*j + (int)(i/8);
113 // int bit_byte = i%8;
114 // return (((mas[bit/8])&(0x80>>(bit%8)))>0);
115  return mas[bit]>0;
116 }
long shiftX
Definition: basematrix.h:36
long shiftY
Definition: basematrix.h:37
Int_t type
Definition: testBGReduction_By_ANN.C:15

◆ GetElement()

int TBitMatrix::GetElement ( int  type,
long  i,
long  j 
)
inlinevirtual

Implements TBaseMatrix.

35 {return GetBit(type,i,j);}
int GetBit(int type, long i, long j)
Definition: bitmatrix.cxx:94

◆ GetZ()

float TBitMatrix::GetZ ( void  )
inline
37 {return Z;}

◆ SetBit() [1/2]

void TBitMatrix::SetBit ( long  i,
long  j 
)
120  {
121  long bit = xSize * j + i;
122  mas[bit] =1;
123 /* MyPoint *point = 0;
124  int n = NonZeroPoints->GetEntries();
125  for (int k=0; k<n; k++) {
126  point = (MyPoint *)(NonZeroPoints->At(k));
127  if ((point->x == i)&&(point->y == j)) return;
128  }
129  NonZeroPoints->Add(new MyPoint(i,j,0));
130 */
131 }

◆ SetBit() [2/2]

void TBitMatrix::SetBit ( long  i,
long  j,
int  area 
)
135 {
136  if (area<=1) SetBit(i,j);
137  else {
138  int sarea = (int)(sqrt((double)area));
139  long lbx = i - sarea/2;
140  lbx = (lbx>=0)?lbx:0;
141  long rbx = i + sarea/2;
142 // long _xSize = (type==0)?xSize:xSize;
143  rbx = (rbx<xSize)?rbx:(xSize-1);
144  long uby = j - sarea/2;
145  uby = (uby>=0)?uby:0;
146 // long ySize = (type==0)?cySize:iySize;
147  long dby = j + sarea/2;
148  dby = (dby<ySize)?dby:(ySize-1);
149  for (long jj=uby; jj<=dby; jj++) {
150  for (long ii=lbx; ii<=rbx; ii++) {
151  SetBit(ii,jj);
152  }
153  }
154  }
155 }
void SetBit(long i, long j)
Definition: bitmatrix.cxx:120

◆ SetZ()

void TBitMatrix::SetZ ( float  z)
inline
36 {Z=z;}

Member Data Documentation

◆ Z

float TBitMatrix::Z
protected

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