KSquare Utilities
KKB::MorphOpStretcher::CellFactor Class Reference

Public Member Functions

 CellFactor ()
 
 ~CellFactor ()
 
void UpdateForSourceCellIdx (kkuint32 cellIdx, float factor)
 

Public Attributes

kkuint16 destCellCount
 
float * destCellFracts
 
kkuint32destCellIdxs
 

Detailed Description

Definition at line 22 of file MorphOpStretcher.cpp.

Constructor & Destructor Documentation

KKB::MorphOpStretcher::CellFactor::~CellFactor ( )
inline

Member Function Documentation

void KKB::MorphOpStretcher::CellFactor::UpdateForSourceCellIdx ( kkuint32  cellIdx,
float  factor 
)
inline

Definition at line 39 of file MorphOpStretcher.cpp.

References KKB::MorphOpStretcher::CellFactor::destCellCount, KKB::MorphOpStretcher::CellFactor::destCellFracts, and KKB::MorphOpStretcher::CellFactor::destCellIdxs.

42  {
43  float cellStart = (float)cellIdx * factor;
44  float cellEnd = (float)(cellIdx + 1) * factor;
45 
46  kkuint32 cellStartIdx = (kkuint32)floor (cellStart);
47  kkuint32 cellEndIdx = (kkuint32)floor (cellEnd);
48  destCellCount = cellEndIdx - cellStartIdx;
49  if (cellEnd > floor(cellEnd))
50  ++destCellCount;
51 
52  delete destCellIdxs;
54 
55  delete destCellFracts;
56  destCellFracts = new float[destCellCount];
57 
58  float cellValue = cellStart;
59  float nextCellValue = cellStart;
60  for (kkuint32 idx = 0; idx < destCellCount; ++idx)
61  {
62  if (cellValue < ceil (cellValue))
63  nextCellValue = Min (cellEnd, ceilf (cellValue));
64  else
65  nextCellValue = Min (cellEnd, ceilf (cellValue + 1.0f));
66 
67  float fract = nextCellValue - cellValue;
68  destCellIdxs[idx] = cellStartIdx + idx;
69  destCellFracts[idx] = fract;
70  cellValue = nextCellValue;
71  }
72  }
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
kkint32 Min(kkint32 x1, kkint32 x2)
Definition: Raster.cpp:229

Member Data Documentation


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