示例#1
0
文件: b_0_38.cpp 项目: jakexie/micmac
void BenchcDbleGrid
     (
         Pt2dr aP0In,Pt2dr aP1In,
         REAL               aStepDir,
         ElDistortion22_Gen & aDist
     )
{
     //cDbleGrid aDGr(aP0In,aP1In,aStepDir,aDist);
     Pt2dr stepDir2(aStepDir,aStepDir);                // __NEW
     cDbleGrid aDGr(false,aP0In,aP1In,stepDir2,aDist); // __NEW

     for (REAL aX = aP0In.x ; aX<aP1In.x ; aX += aStepDir)
         for (REAL aY = aP0In.y ; aY<aP1In.y ; aY += aStepDir)
         {
             REAL x = aX + NRrandom3() * aStepDir;
             SetInRange(aP0In.x,x,aP1In.x);
             REAL y = aY + NRrandom3() * aStepDir;
             SetInRange(aP0In.y,y,aP1In.y);

	     Pt2dr aP(x,y);
	     Pt2dr aQ0 = aDist.Direct(aP);
	     Pt2dr aQ1 = aDGr.Direct(aP);
	     Pt2dr aR0 = aDist.Inverse(aQ0);
	     Pt2dr aR1 = aDist.Inverse(aQ1);

	     REAL aDQ = euclid(aQ0,aQ1);
	     REAL aDR = euclid(aR0,aP) +  euclid(aR1,aP);
	     aDQ /= ElSquare(aStepDir);
	     aDR /= ElSquare(aStepDir);
	     BENCH_ASSERT(aDQ<0.1);
	     BENCH_ASSERT(aDR<0.1);
         }
}
cDbleGrid::cDbleGrid
(
    bool  AdaptStep,
    Pt2dr aP0In,Pt2dr aP1In,
    Pt2dr               aStepDir,
    ElDistortion22_Gen & aDist,
    const std::string &  aName,
    bool                 doDir,
    bool                 doInv
)   :
    mName (aName)
{
    pGrDir = new PtImGrid(AdaptStep,aP0In,aP1In,aStepDir,mName+"_Directe");
    Pt2di aSzGr = pGrDir->SzGrid();

    bool First = true;
    Pt2dr aP0Dist(1e9,1e9);
    Pt2dr aP1Dist(-1e9,-1e9);

    for (INT aI=0; aI<aSzGr.x ; aI++)
    {
        for (INT aJ=0; aJ<aSzGr.y ; aJ++)
        {
            Pt2di aPIJ(aI,aJ);
            Pt2dr aPR = pGrDir->ToReal(Pt2dr(aPIJ));
            Pt2dr  aPDR = aDist.Direct(aPR);
            pGrDir->SetValueGrid(aPIJ,aPDR);
            if (First)
            {
                aP0Dist = aPDR;
                aP1Dist = aPDR;
                First = false;
            }
            else
            {
                aP0Dist.SetInf(aPDR);
                aP1Dist.SetSup(aPDR);
            }
        }
    }
    if (!doDir)
    {
        delete pGrDir;
        pGrDir = 0;
    }
    
    if (doInv)
    {

       Pt2dr aStepInv = (aP1Dist-aP0Dist).dcbyc(Pt2dr(aSzGr));
    /*
    REAL aStepInv = sqrt
                    (
                         ((aP1Dist.x-aP0Dist.x)*(aP1Dist.y-aP0Dist.y) )
                       / (aSzGr.x*aSzGr.y)
                    );
    */
       pGrInv = new PtImGrid(AdaptStep,aP0Dist,aP1Dist,aStepInv,aName+"_Inverse");
       aSzGr = pGrInv->SzGrid();

       for (INT aI=0; aI<aSzGr.x ; aI++)
       {
           for (INT aJ=0; aJ<aSzGr.y ; aJ++)
	   {
               Pt2di aPIJ(aI,aJ);
               Pt2dr aPR = pGrInv->ToReal(Pt2dr(aPIJ));
               Pt2dr  aPDR = aDist.Inverse(aPR);
               pGrInv->SetValueGrid(aPIJ,aPDR);
	   }
       }
    }
    else
    {
       pGrInv = 0;
    }
}