⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wmlintpakimauniform3.cpp

📁 3D Game Engine Design Source Code非常棒
💻 CPP
📖 第 1 页 / 共 4 页
字号:
                        aaafFXYZ[iZ0][0][iX0] += fMask*
                            aaafF[iZ0+iZ-1][iY][iX0+iX-1];

                        aaafFXYZ[iZ0][iYBoundM1][iX0] += fMask*
                            aaafF[iZ0+iZ-1][iYBoundM1-iY][iX0+iX-1];
                    }
                }
            }
        }
    }

    // yz-faces
    for (iZ0 = 1; iZ0 < iZBoundM1; iZ0++)
    {
        for (iY0 = 1; iY0 < iYBoundM1; iY0++)
        {
            aaafFXYZ[iZ0][iY0][0] = (Real)0.0;
            aaafFXYZ[iZ0][iY0][iXBoundM1] = (Real)0.0;
            for (iZ = 0; iZ <= 2; iZ++)
            {
                for (iY = 0; iY <= 2; iY++)
                {
                    for (iX = 0; iX <= 2; iX++)
                    {
                        fMask = fInvDXDYDZ*afODer[iX]*afCDer[iY]*afCDer[iZ];

                        aaafFXYZ[iZ0][iY0][0] += fMask*
                            aaafF[iZ0+iZ-1][iY0+iY-1][iX];

                        aaafFXYZ[iZ0][iY0][iXBoundM1] += fMask*
                            aaafF[iZ0+iZ-1][iY0+iY-1][iXBoundM1-iX];
                    }
                }
            }
        }
    }

    // interiors
    for (iZ0 = 1; iZ0 < iZBoundM1; iZ0++)
    {
        for (iY0 = 1; iY0 < iYBoundM1; iY0++)
        {
            for (iX0 = 1; iX0 < iXBoundM1; iX0++)
            {
                aaafFXYZ[iZ0][iY0][iX0] = (Real)0.0;

                for (iZ = 0; iZ <= 2; iZ++)
                {
                    for (iY = 0; iY <= 2; iY++)
                    {
                        for (iX = 0; iX <= 2; iX++)
                        {
                            fMask = fInvDXDYDZ*afCDer[iX]*afCDer[iY]*
                                afCDer[iZ];

                            aaafFXYZ[iZ0][iY0][iX0] += fMask*
                                aaafF[iZ0+iZ-1][iY0+iY-1][iX0+iX-1];
                        }
                    }
                }
            }
        }
    }

    // construct polynomials
    Allocate3D(iXBoundM1,iYBoundM1,iZBoundM1,m_aaakPoly);
    for (iZ = 0; iZ < iZBoundM1; iZ++)
    {
        for (iY = 0; iY < iYBoundM1; iY++)
        {
            for (iX = 0; iX < iXBoundM1; iX++)
            {
                // Note the 'transposing' of the 2x2x2 blocks (to match
                // notation used in the polynomial definition).
                Real aaafG[2][2][2] =
                {
                    {{aaafF[iZ][iY][iX],
                      aaafF[iZ+1][iY][iX]},
                     {aaafF[iZ][iY+1][iX],
                      aaafF[iZ+1][iY+1][iX]}},
                    {{aaafF[iZ][iY][iX+1],
                      aaafF[iZ+1][iY][iX+1]},
                     {aaafF[iZ][iY+1][iX+1],
                      aaafF[iZ+1][iY+1][iX+1]}}
                };

                Real aaafGX[2][2][2] =
                {
                    {{aaafFX[iZ][iY][iX],
                      aaafFX[iZ+1][iY][iX]},
                     {aaafFX[iZ][iY+1][iX],
                      aaafFX[iZ+1][iY+1][iX]}},
                    {{aaafFX[iZ][iY][iX+1],
                      aaafFX[iZ+1][iY][iX+1]},
                     {aaafFX[iZ][iY+1][iX+1],
                      aaafFX[iZ+1][iY+1][iX+1]}}
                };

                Real aaafGY[2][2][2] =
                {
                    {{aaafFY[iZ][iY][iX],
                      aaafFY[iZ+1][iY][iX]},
                     {aaafFY[iZ][iY+1][iX],
                      aaafFY[iZ+1][iY+1][iX]}},
                    {{aaafFY[iZ][iY][iX+1],
                      aaafFY[iZ+1][iY][iX+1]},
                     {aaafFY[iZ][iY+1][iX+1],
                      aaafFY[iZ+1][iY+1][iX+1]}}
                };

                Real aaafGZ[2][2][2] =
                {
                    {{aaafFZ[iZ][iY][iX],
                      aaafFZ[iZ+1][iY][iX]},
                     {aaafFZ[iZ][iY+1][iX],
                      aaafFZ[iZ+1][iY+1][iX]}},
                    {{aaafFZ[iZ][iY][iX+1],
                      aaafFZ[iZ+1][iY][iX+1]},
                     {aaafFZ[iZ][iY+1][iX+1],
                      aaafFZ[iZ+1][iY+1][iX+1]}}
                };

                Real aaafGXY[2][2][2] =
                {
                    {{aaafFXY[iZ][iY][iX],
                      aaafFXY[iZ+1][iY][iX]},
                     {aaafFXY[iZ][iY+1][iX],
                      aaafFXY[iZ+1][iY+1][iX]}},
                    {{aaafFXY[iZ][iY][iX+1],
                      aaafFXY[iZ+1][iY][iX+1]},
                     {aaafFXY[iZ][iY+1][iX+1],
                      aaafFXY[iZ+1][iY+1][iX+1]}}
                };

                Real aaafGXZ[2][2][2] =
                {
                    {{aaafFXZ[iZ][iY][iX],
                      aaafFXZ[iZ+1][iY][iX]},
                     {aaafFXZ[iZ][iY+1][iX],
                      aaafFXZ[iZ+1][iY+1][iX]}},
                    {{aaafFXZ[iZ][iY][iX+1],
                      aaafFXZ[iZ+1][iY][iX+1]},
                     {aaafFXZ[iZ][iY+1][iX+1],
                      aaafFXZ[iZ+1][iY+1][iX+1]}}
                };

                Real aaafGYZ[2][2][2] =
                {
                    {{aaafFYZ[iZ][iY][iX],
                      aaafFYZ[iZ+1][iY][iX]},
                     {aaafFYZ[iZ][iY+1][iX],
                      aaafFYZ[iZ+1][iY+1][iX]}},
                    {{aaafFYZ[iZ][iY][iX+1],
                      aaafFYZ[iZ+1][iY][iX+1]},
                     {aaafFYZ[iZ][iY+1][iX+1],
                      aaafFYZ[iZ+1][iY+1][iX+1]}}
                };

                Real aaafGXYZ[2][2][2] =
                {
                    {{aaafFXYZ[iZ][iY][iX],
                      aaafFXYZ[iZ+1][iY][iX]},
                     {aaafFXYZ[iZ][iY+1][iX],
                      aaafFXYZ[iZ+1][iY+1][iX]}},
                    {{aaafFXYZ[iZ][iY][iX+1],
                      aaafFXYZ[iZ+1][iY][iX+1]},
                     {aaafFXYZ[iZ][iY+1][iX+1],
                      aaafFXYZ[iZ+1][iY+1][iX+1]}}
                };

                Construct(m_aaakPoly[iZ][iY][iX],aaafG,aaafGX,aaafGY,
                    aaafGZ,aaafGXY,aaafGXZ,aaafGYZ,aaafGXYZ);
            }
        }
    }

    Deallocate3D(iYBound,iZBound,aaafXSlope);
    Deallocate3D(iXBound,iZBound,aaafYSlope);
    Deallocate3D(iXBound,iYBound,aaafZSlope);
    Deallocate3D(iYBound,iZBound,aaafFX);
    Deallocate3D(iYBound,iZBound,aaafFY);
    Deallocate3D(iYBound,iZBound,aaafFZ);
    Deallocate3D(iYBound,iZBound,aaafFXY);
    Deallocate3D(iYBound,iZBound,aaafFXZ);
    Deallocate3D(iYBound,iZBound,aaafFYZ);
    Deallocate3D(iYBound,iZBound,aaafFXYZ);
}
//----------------------------------------------------------------------------
template <class Real>
IntpAkimaUniform3<Real>::~IntpAkimaUniform3 ()
{
    Deallocate3D(m_iYBound-1,m_iZBound-1,m_aaakPoly);
}
//----------------------------------------------------------------------------
template <class Real>
int IntpAkimaUniform3<Real>::GetXBound () const
{
    return m_iXBound;
}
//----------------------------------------------------------------------------
template <class Real>
int IntpAkimaUniform3<Real>::GetYBound () const
{
    return m_iYBound;
}
//----------------------------------------------------------------------------
template <class Real>
int IntpAkimaUniform3<Real>::GetZBound () const
{
    return m_iZBound;
}
//----------------------------------------------------------------------------
template <class Real>
int IntpAkimaUniform3<Real>::GetQuantity () const
{
    return m_iQuantity;
}
//----------------------------------------------------------------------------
template <class Real>
Real*** IntpAkimaUniform3<Real>::GetF () const
{
    return m_aaafF;
}
//----------------------------------------------------------------------------
template <class Real>
typename IntpAkimaUniform3<Real>::Polynomial***
IntpAkimaUniform3<Real>::GetPolynomials () const
{
    return m_aaakPoly;
}
//----------------------------------------------------------------------------
template <class Real>
const typename IntpAkimaUniform3<Real>::Polynomial&
IntpAkimaUniform3<Real>::GetPolynomial (int iX, int iY, int iZ) const
{
    assert( iX < m_iXBound-1 && iY < m_iYBound-1 && iZ < m_iZBound-1 );
    return m_aaakPoly[iZ][iY][iX];
}
//----------------------------------------------------------------------------
template <class Real>
Real IntpAkimaUniform3<Real>::GetXMin () const
{
    return m_fXMin;
}
//----------------------------------------------------------------------------
template <class Real>
Real IntpAkimaUniform3<Real>::GetXMax () const
{
    return m_fXMax;
}
//----------------------------------------------------------------------------
template <class Real>
Real IntpAkimaUniform3<Real>::GetXSpacing () const
{
    return m_fXSpacing;
}
//----------------------------------------------------------------------------
template <class Real>
Real IntpAkimaUniform3<Real>::GetYMin () const
{
    return m_fYMin;
}
//----------------------------------------------------------------------------
template <class Real>
Real IntpAkimaUniform3<Real>::GetYMax () const
{
    return m_fYMax;
}
//----------------------------------------------------------------------------
template <class Real>
Real IntpAkimaUniform3<Real>::GetYSpacing () const
{
    return m_fYSpacing;
}
//----------------------------------------------------------------------------
template <class Real>
Real IntpAkimaUniform3<Real>::GetZMin () const
{
    return m_fZMin;
}
//----------------------------------------------------------------------------
template <class Real>
Real IntpAkimaUniform3<Real>::GetZMax () const
{
    return m_fZMax;
}
//----------------------------------------------------------------------------
template <class Real>
Real IntpAkimaUniform3<Real>::GetZSpacing () const
{
    return m_fZSpacing;
}
//----------------------------------------------------------------------------
template <class Real>
Real IntpAkimaUniform3<Real>::ComputeDerivative (Real* afSlope) const
{
    if ( afSlope[1] != afSlope[2] )
    {
        if ( afSlope[0] != afSlope[1] )
        {
            if ( afSlope[2] != afSlope[3] )
            {
                Real fAD0 = Math<Real>::FAbs(afSlope[3] - afSlope[2]);
                Real fAD1 = Math<Real>::FAbs(afSlope[0] - afSlope[1]);
                return (fAD0*afSlope[1]+fAD1*afSlope[2])/(fAD0+fAD1);
            }
            else
            {
                return afSlope[2];
            }
        }
        else
        {
            if ( afSlope[2] != afSlope[3] )
                return afSlope[1];
            else
                return ((Real)0.5)*(afSlope[1]+afSlope[2]);
        }
    }
    else
    {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -