Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QRSequenceGenerator Class Reference

#include <qrsequence.h>

List of all members.

Public Member Functions

 QRSequenceGenerator (int N)
int GetVal ()

Protected Member Functions

int GetBinaryReversedInteger (int in_val) const

Protected Attributes

int N_
int next_num_
int num_bits_

Detailed Description

Definition at line 32 of file qrsequence.h.


Constructor & Destructor Documentation

QRSequenceGenerator::QRSequenceGenerator ( int  N)
inlineexplicit

Definition at line 35 of file qrsequence.h.

: N_(N), next_num_(0) {
num_bits_ = static_cast<int>(ceil(log(static_cast<double>(N)) / log(2.0)));
}

Member Function Documentation

int QRSequenceGenerator::GetBinaryReversedInteger ( int  in_val) const
inlineprotected

Definition at line 58 of file qrsequence.h.

{
int bit_pos = num_bits_;
int out_val = 0;
while(bit_pos--) {
// Set the value of the last bit.
out_val |= (in_val & 0x1);
if (bit_pos > 0) {
// Left-shift output value to prepare for storing the next bit.
out_val <<= 1;
}
// Right-shift input value to prepare for retrieving the next bit.
in_val >>= 1;
}
return out_val;
}
int QRSequenceGenerator::GetVal ( )
inline

Definition at line 41 of file qrsequence.h.

{
const int kInvalidVal = -1;
const int kMaxNaturalNumberValue = 1 << num_bits_;
if (next_num_ >= kMaxNaturalNumberValue)
return kInvalidVal;
int n = next_num_;
while (next_num_ < kMaxNaturalNumberValue) {
if (n < N_) break;
}
return (next_num_ > kMaxNaturalNumberValue) ? kInvalidVal : n;
}

Member Data Documentation

int QRSequenceGenerator::N_
protected

Definition at line 73 of file qrsequence.h.

int QRSequenceGenerator::next_num_
protected

Definition at line 75 of file qrsequence.h.

int QRSequenceGenerator::num_bits_
protected

Definition at line 77 of file qrsequence.h.


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