/*
* This file is part of rasdaman community.
*
* Rasdaman community is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Rasdaman community is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with rasdaman community. If not, see .
*
* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
rasdaman GmbH.
*
* For more information please see
* or contact Peter Baumann via .
/
/**
* SOURCE: miterf.icc
*
* MODULE: raslib
* CLASS: r_MiterFloat
*
*/
#include "raslib/miterf.hh"
#include "raslib/minterval.hh"
#include "raslib/rmdebug.hh"
#include
const int r_FixedPointNumber::FIXPREC = 30;
const r_Range r_FixedPointNumber::carryPos = 1<getType()->getSize();
firstCell = sourceTile->getContents();
iter_desc *id = 0;
const r_Minterval& tileDomain = sourceTile->getDomain();
int i = 0;
r_Bytes step = cellSize;
id = iterDesc + dim-1;
for(i=dim-1; i>=0; i--, id-- )
{
id->min = (double)sourceDomain[i].low();
id->step = (double)(sourceDomain[i].high()-sourceDomain[i].low() +1) / ( destDomain[i].high() - destDomain[i].low()+1);
id->maxSteps = destDomain[i].high() - destDomain[i].low()+1;
id->dimStep = step;
id->scaleStep = step * id->step.getIntPart();
firstCell += step* (sourceDomain[i].low() - tileDomain[i].low());
step *= (tileDomain[i].high() - tileDomain[i].low() + 1);
}
reset();
}
inline
r_MiterFloat::~r_MiterFloat()
{
if(iterDesc) delete[] iterDesc;
}
inline
void r_MiterFloat::reset()
{
for(r_Dimension i=0;i0 )
{
id->countSteps--;
if(id->countSteps)
{// one more step in this dimension
if(id->pos.stepForwardFlag(id->step))
id->cell += id->dimStep;
id->cell += id->scaleStep;
break;
}
else
{ // we are finished with this dimension
id->pos = id->min;
id->countSteps = id-> maxSteps;
id--;
i--;
}
}
if(i