From e188bcdaaffee075adf5fa4371453d91bcb71225 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 11 Mar 2015 14:43:49 +0100 Subject: Add another utility function --- cuda/3d/astra3d.cu | 99 +++++++++++++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 46 deletions(-) (limited to 'cuda') diff --git a/cuda/3d/astra3d.cu b/cuda/3d/astra3d.cu index 0e94fb8..eff928d 100644 --- a/cuda/3d/astra3d.cu +++ b/cuda/3d/astra3d.cu @@ -305,6 +305,37 @@ bool convertAstraGeometry(const CVolumeGeometry3D* pVolGeom, } +bool convertAstraGeometry(const CVolumeGeometry3D* pVolGeom, + const CConeVecProjectionGeometry3D* pProjGeom, + SPar3DProjection*& pParProjs, + SConeProjection*& pConeProjs, + float& fOutputScale) +{ + const CConeProjectionGeometry3D* conegeom = dynamic_cast(pProjGeom); + const CParallelProjectionGeometry3D* par3dgeom = dynamic_cast(pProjGeom); + const CParallelVecProjectionGeometry3D* parvec3dgeom = dynamic_cast(pProjGeom); + const CConeVecProjectionGeometry3D* conevec3dgeom = dynamic_cast(pProjGeom); + + pConeProjs = 0; + pParProjs = 0; + + bool ok; + + if (conegeom) { + ok = convertAstraGeometry(pVolGeom, conegeom, pConeProjs, outputScale); + } else if (conevec3dgeom) { + ok = convertAstraGeometry(pVolGeom, conevec3dgeom, pConeProjs, outputScale); + } else if (par3dgeom) { + ok = convertAstraGeometry(pVolGeom, par3dgeom, pParProjs, outputScale); + } else if (parvec3dgeom) { + ok = convertAstraGeometry(pVolGeom, parvec3dgeom, pParProjs, outputScale); + } else { + ok = false; + } + + return ok; +} + @@ -402,35 +433,23 @@ bool AstraSIRT3d::setGeometry(const CVolumeGeometry3D* pVolGeom, if (!ok) return false; - const CConeProjectionGeometry3D* conegeom = dynamic_cast(pProjGeom); - const CParallelProjectionGeometry3D* par3dgeom = dynamic_cast(pProjGeom); - const CParallelVecProjectionGeometry3D* parvec3dgeom = dynamic_cast(pProjGeom); - const CConeVecProjectionGeometry3D* conevec3dgeom = dynamic_cast(pProjGeom); - - float outputScale; - pData->projs = 0; pData->parprojs = 0; + float outputScale; - if (conegeom) { - ok = convertAstraGeometry(pVolGeom, conegeom, pData->projs, outputScale); - pData->projType = PROJ_PARALLEL; - } else if (conevec3dgeom) { - ok = convertAstraGeometry(pVolGeom, conevec3dgeom, pData->projs, outputScale); - pData->projType = PROJ_PARALLEL; - } else if (par3dgeom) { - ok = convertAstraGeometry(pVolGeom, par3dgeom, pData->parprojs, outputScale); - pData->projType = PROJ_CONE; - } else if (parvec3dgeom) { - ok = convertAstraGeometry(pVolGeom, parvec3dgeom, pData->parprojs, outputScale); - pData->projType = PROJ_CONE; - } else { - ok = false; - } - + ok = convertAstraGeometry(pVolGeom, pProjGeom, + pData->parprojs, pData->projs, + outputScale); if (!ok) return false; + if (pData->projs) { + assert(pData->parprojs == 0); + pData->projType = PROJ_CONE; + } else { + assert(pData->parprojs != 0); + pData->projType = PROJ_PARALLEL; + } // TODO: Handle outputScale @@ -794,35 +813,23 @@ bool AstraCGLS3d::setGeometry(const CVolumeGeometry3D* pVolGeom, if (!ok) return false; - const CConeProjectionGeometry3D* conegeom = dynamic_cast(pProjGeom); - const CParallelProjectionGeometry3D* par3dgeom = dynamic_cast(pProjGeom); - const CParallelVecProjectionGeometry3D* parvec3dgeom = dynamic_cast(pProjGeom); - const CConeVecProjectionGeometry3D* conevec3dgeom = dynamic_cast(pProjGeom); - - float outputScale; - pData->projs = 0; pData->parprojs = 0; + float outputScale; - if (conegeom) { - ok = convertAstraGeometry(pVolGeom, conegeom, pData->projs, outputScale); - pData->projType = PROJ_PARALLEL; - } else if (conevec3dgeom) { - ok = convertAstraGeometry(pVolGeom, conevec3dgeom, pData->projs, outputScale); - pData->projType = PROJ_PARALLEL; - } else if (par3dgeom) { - ok = convertAstraGeometry(pVolGeom, par3dgeom, pData->parprojs, outputScale); - pData->projType = PROJ_CONE; - } else if (parvec3dgeom) { - ok = convertAstraGeometry(pVolGeom, parvec3dgeom, pData->parprojs, outputScale); - pData->projType = PROJ_CONE; - } else { - ok = false; - } - + ok = convertAstraGeometry(pVolGeom, pProjGeom, + pData->parprojs, pData->projs, + outputScale); if (!ok) return false; + if (pData->projs) { + assert(pData->parprojs == 0); + pData->projType = PROJ_CONE; + } else { + assert(pData->parprojs != 0); + pData->projType = PROJ_PARALLEL; + } // TODO: Handle outputScale -- cgit v1.2.3