From bf5aa06406162656752f031edf3ca90f00ff76dd Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Mon, 2 Mar 2015 13:42:08 +0100 Subject: Untangle cuda and astra includes --- astra_vc08.vcproj | 12 ++++ astra_vc11.vcxproj | 6 +- build/linux/Makefile.in | 2 +- cuda/2d/dims.h | 12 +--- cuda/3d/dims3d.cu | 74 ------------------------ cuda/3d/dims3d.h | 41 +------------- include/astra/ConeVecProjectionGeometry3D.h | 2 +- include/astra/FanFlatVecProjectionGeometry2D.h | 5 +- include/astra/GeometryUtil2D.h | 47 ++++++++++++++++ include/astra/GeometryUtil3D.h | 73 ++++++++++++++++++++++++ include/astra/ParallelVecProjectionGeometry3D.h | 2 +- src/GeometryUtil3D.cpp | 75 +++++++++++++++++++++++++ 12 files changed, 219 insertions(+), 132 deletions(-) delete mode 100644 cuda/3d/dims3d.cu create mode 100644 include/astra/GeometryUtil2D.h create mode 100644 include/astra/GeometryUtil3D.h create mode 100644 src/GeometryUtil3D.cpp diff --git a/astra_vc08.vcproj b/astra_vc08.vcproj index 750a9eb..957586a 100644 --- a/astra_vc08.vcproj +++ b/astra_vc08.vcproj @@ -966,6 +966,10 @@ RelativePath=".\src\Globals.cpp" > + + @@ -1006,6 +1010,14 @@ RelativePath=".\include\astra\Globals.h" > + + + + diff --git a/astra_vc11.vcxproj b/astra_vc11.vcxproj index 482bb1b..6596a05 100644 --- a/astra_vc11.vcxproj +++ b/astra_vc11.vcxproj @@ -255,6 +255,7 @@ + @@ -364,6 +365,8 @@ + + @@ -415,7 +418,6 @@ - @@ -436,4 +438,4 @@ - \ No newline at end of file + diff --git a/build/linux/Makefile.in b/build/linux/Makefile.in index 6620446..cd5e74b 100644 --- a/build/linux/Makefile.in +++ b/build/linux/Makefile.in @@ -116,6 +116,7 @@ BASE_OBJECTS=\ src/Float32VolumeData3DMemory.lo \ src/ForwardProjectionAlgorithm.lo \ src/Fourier.lo \ + src/GeometryUtil3D.lo \ src/Globals.lo \ src/Logger.lo \ src/ParallelBeamBlobKernelProjector2D.lo \ @@ -185,7 +186,6 @@ CUDA_OBJECTS=\ cuda/3d/cgls3d.lo \ cuda/3d/cone_fp.lo \ cuda/3d/cone_bp.lo \ - cuda/3d/dims3d.lo \ cuda/3d/fdk.lo \ cuda/3d/par3d_fp.lo \ cuda/3d/par3d_bp.lo \ diff --git a/cuda/2d/dims.h b/cuda/2d/dims.h index 37bfa66..e870da5 100644 --- a/cuda/2d/dims.h +++ b/cuda/2d/dims.h @@ -29,18 +29,12 @@ $Id$ #ifndef _CUDA_DIMS_H #define _CUDA_DIMS_H -namespace astraCUDA { +#include "astra/GeometryUtil2D.h" -struct SFanProjection { - // the source - float fSrcX, fSrcY; - // the start of the (linear) detector - float fDetSX, fDetSY; +namespace astraCUDA { - // the length of a single detector pixel - float fDetUX, fDetUY; -}; +using astra::SFanProjection; struct SDimensions { diff --git a/cuda/3d/dims3d.cu b/cuda/3d/dims3d.cu deleted file mode 100644 index 83a8eba..0000000 --- a/cuda/3d/dims3d.cu +++ /dev/null @@ -1,74 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright 2012 iMinds-Vision Lab, University of Antwerp - -Contact: astra@ua.ac.be -Website: http://astra.ua.ac.be - - -This file is part of the -All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). - -The ASTRA Toolbox 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. - -The ASTRA Toolbox 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 the ASTRA Toolbox. If not, see . - ------------------------------------------------------------------------ -$Id$ -*/ - -#include "dims3d.h" - -namespace astra { - -// (See declaration in header for (mathematical) description of these functions) - - -void computeBP_UV_Coeffs(const SPar3DProjection& proj, double &fUX, double &fUY, double &fUZ, double &fUC, - double &fVX, double &fVY, double &fVZ, double &fVC) -{ - double denom = (proj.fRayX*proj.fDetUY*proj.fDetVZ - proj.fRayX*proj.fDetUZ*proj.fDetVY - proj.fRayY*proj.fDetUX*proj.fDetVZ + proj.fRayY*proj.fDetUZ*proj.fDetVX + proj.fRayZ*proj.fDetUX*proj.fDetVY - proj.fRayZ*proj.fDetUY*proj.fDetVX); - - fUX = ( - (proj.fRayY*proj.fDetVZ - proj.fRayZ*proj.fDetVY)) / denom; - fUY = ( (proj.fRayX*proj.fDetVZ - proj.fRayZ*proj.fDetVX)) / denom; - fUZ = (- (proj.fRayX*proj.fDetVY - proj.fRayY*proj.fDetVX) ) / denom; - fUC = (-(proj.fDetSY*proj.fDetVZ - proj.fDetSZ*proj.fDetVY)*proj.fRayX + (proj.fRayY*proj.fDetVZ - proj.fRayZ*proj.fDetVY)*proj.fDetSX - (proj.fRayY*proj.fDetSZ - proj.fRayZ*proj.fDetSY)*proj.fDetVX) / denom; - - fVX = ((proj.fRayY*proj.fDetUZ - proj.fRayZ*proj.fDetUY) ) / denom; - fVY = (- (proj.fRayX*proj.fDetUZ - proj.fRayZ*proj.fDetUX) ) / denom; - fVZ = ((proj.fRayX*proj.fDetUY - proj.fRayY*proj.fDetUX) ) / denom; - fVC = ((proj.fDetSY*proj.fDetUZ - proj.fDetSZ*proj.fDetUY)*proj.fRayX - (proj.fRayY*proj.fDetUZ - proj.fRayZ*proj.fDetUY)*proj.fDetSX + (proj.fRayY*proj.fDetSZ - proj.fRayZ*proj.fDetSY)*proj.fDetUX ) / denom; -} - - - -void computeBP_UV_Coeffs(const SConeProjection& proj, double &fUX, double &fUY, double &fUZ, double &fUC, - double &fVX, double &fVY, double &fVZ, double &fVC, - double &fDX, double &fDY, double &fDZ, double &fDC) -{ - fUX = (proj.fDetSZ - proj.fSrcZ)*proj.fDetVY - (proj.fDetSY - proj.fSrcY)*proj.fDetVZ; - fUY = (proj.fDetSX - proj.fSrcX)*proj.fDetVZ -(proj.fDetSZ - proj.fSrcZ)*proj.fDetVX; - fUZ = (proj.fDetSY - proj.fSrcY)*proj.fDetVX - (proj.fDetSX - proj.fSrcX)*proj.fDetVY; - fUC = (proj.fDetSY*proj.fDetVZ - proj.fDetSZ*proj.fDetVY)*proj.fSrcX - (proj.fDetSX*proj.fDetVZ - proj.fDetSZ*proj.fDetVX)*proj.fSrcY + (proj.fDetSX*proj.fDetVY - proj.fDetSY*proj.fDetVX)*proj.fSrcZ; - - fVX = (proj.fDetSY - proj.fSrcY)*proj.fDetUZ-(proj.fDetSZ - proj.fSrcZ)*proj.fDetUY; - fVY = (proj.fDetSZ - proj.fSrcZ)*proj.fDetUX - (proj.fDetSX - proj.fSrcX)*proj.fDetUZ; - fVZ = (proj.fDetSX - proj.fSrcX)*proj.fDetUY-(proj.fDetSY - proj.fSrcY)*proj.fDetUX; - fVC = -(proj.fDetSY*proj.fDetUZ - proj.fDetSZ*proj.fDetUY)*proj.fSrcX + (proj.fDetSX*proj.fDetUZ - proj.fDetSZ*proj.fDetUX)*proj.fSrcY - (proj.fDetSX*proj.fDetUY - proj.fDetSY*proj.fDetUX)*proj.fSrcZ; - - fDX = proj.fDetUY*proj.fDetVZ - proj.fDetUZ*proj.fDetVY; - fDY = proj.fDetUZ*proj.fDetVX - proj.fDetUX*proj.fDetVZ; - fDZ = proj.fDetUX*proj.fDetVY - proj.fDetUY*proj.fDetVX; - fDC = -proj.fSrcX * (proj.fDetUY*proj.fDetVZ - proj.fDetUZ*proj.fDetVY) - proj.fSrcY * (proj.fDetUZ*proj.fDetVX - proj.fDetUX*proj.fDetVZ) - proj.fSrcZ * (proj.fDetUX*proj.fDetVY - proj.fDetUY*proj.fDetVX); -} - -} diff --git a/cuda/3d/dims3d.h b/cuda/3d/dims3d.h index 9bf0b68..5437a85 100644 --- a/cuda/3d/dims3d.h +++ b/cuda/3d/dims3d.h @@ -29,46 +29,7 @@ $Id$ #ifndef _CUDA_CONE_DIMS_H #define _CUDA_CONE_DIMS_H -namespace astra { - -struct SConeProjection { - // the source - double fSrcX, fSrcY, fSrcZ; - - // the origin ("bottom left") of the (flat-panel) detector - double fDetSX, fDetSY, fDetSZ; - - // the U-edge of a detector pixel - double fDetUX, fDetUY, fDetUZ; - - // the V-edge of a detector pixel - double fDetVX, fDetVY, fDetVZ; -}; - -struct SPar3DProjection { - // the ray direction - double fRayX, fRayY, fRayZ; - - // the origin ("bottom left") of the (flat-panel) detector - double fDetSX, fDetSY, fDetSZ; - - // the U-edge of a detector pixel - double fDetUX, fDetUY, fDetUZ; - - // the V-edge of a detector pixel - double fDetVX, fDetVY, fDetVZ; -}; - -void computeBP_UV_Coeffs(const SPar3DProjection& proj, double &fUX, double &fUY, double &fUZ, double &fUC, - double &fVX, double &fVY, double &fVZ, double &fVC); - -void computeBP_UV_Coeffs(const SConeProjection& proj, double &fUX, double &fUY, double &fUZ, double &fUC, - double &fVX, double &fVY, double &fVZ, double &fVC, - double &fDX, double &fDY, double &fDZ, double &fDC); - -} - - +#include "astra/GeometryUtil3D.h" namespace astraCUDA3d { diff --git a/include/astra/ConeVecProjectionGeometry3D.h b/include/astra/ConeVecProjectionGeometry3D.h index e82a411..71e8010 100644 --- a/include/astra/ConeVecProjectionGeometry3D.h +++ b/include/astra/ConeVecProjectionGeometry3D.h @@ -30,7 +30,7 @@ $Id$ #define _INC_ASTRA_CONEVECPROJECTIONGEOMETRY3D #include "ProjectionGeometry3D.h" -#include "../cuda/3d/dims3d.h" +#include "GeometryUtil3D.h" namespace astra { diff --git a/include/astra/FanFlatVecProjectionGeometry2D.h b/include/astra/FanFlatVecProjectionGeometry2D.h index ee85408..d93de79 100644 --- a/include/astra/FanFlatVecProjectionGeometry2D.h +++ b/include/astra/FanFlatVecProjectionGeometry2D.h @@ -30,13 +30,10 @@ $Id$ #define _INC_ASTRA_FANFLATVECPROJECTIONGEOMETRY2D #include "ProjectionGeometry2D.h" -#include "../cuda/2d/dims.h" +#include "GeometryUtil2D.h" #include -// FIXME: Avoid using -using astraCUDA::SFanProjection; - namespace astra { diff --git a/include/astra/GeometryUtil2D.h b/include/astra/GeometryUtil2D.h new file mode 100644 index 0000000..d4ee92e --- /dev/null +++ b/include/astra/GeometryUtil2D.h @@ -0,0 +1,47 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2015, iMinds-Vision Lab, University of Antwerp + 2014-2015, CWI, Amsterdam + +Contact: astra@uantwerpen.be +Website: http://sf.net/projects/astra-toolbox + +This file is part of the ASTRA Toolbox. + + +The ASTRA Toolbox 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. + +The ASTRA Toolbox 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 the ASTRA Toolbox. If not, see . + +----------------------------------------------------------------------- +$Id$ +*/ + +#ifndef _INC_ASTRA_GEOMETRYUTIL2D +#define _INC_ASTRA_GEOMETRYUTIL2D + +namespace astra { + +struct SFanProjection { + // the source + float fSrcX, fSrcY; + + // the start of the (linear) detector + float fDetSX, fDetSY; + + // the length of a single detector pixel + float fDetUX, fDetUY; +}; + +} + +#endif diff --git a/include/astra/GeometryUtil3D.h b/include/astra/GeometryUtil3D.h new file mode 100644 index 0000000..698372e --- /dev/null +++ b/include/astra/GeometryUtil3D.h @@ -0,0 +1,73 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2015, iMinds-Vision Lab, University of Antwerp + 2014-2015, CWI, Amsterdam + +Contact: astra@uantwerpen.be +Website: http://sf.net/projects/astra-toolbox + +This file is part of the ASTRA Toolbox. + + +The ASTRA Toolbox 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. + +The ASTRA Toolbox 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 the ASTRA Toolbox. If not, see . + +----------------------------------------------------------------------- +$Id$ +*/ + +#ifndef _INC_ASTRA_GEOMETRYUTIL3D +#define _INC_ASTRA_GEOMETRYUTIL3D + +namespace astra { + +struct SConeProjection { + // the source + double fSrcX, fSrcY, fSrcZ; + + // the origin ("bottom left") of the (flat-panel) detector + double fDetSX, fDetSY, fDetSZ; + + // the U-edge of a detector pixel + double fDetUX, fDetUY, fDetUZ; + + // the V-edge of a detector pixel + double fDetVX, fDetVY, fDetVZ; +}; + +struct SPar3DProjection { + // the ray direction + double fRayX, fRayY, fRayZ; + + // the origin ("bottom left") of the (flat-panel) detector + double fDetSX, fDetSY, fDetSZ; + + // the U-edge of a detector pixel + double fDetUX, fDetUY, fDetUZ; + + // the V-edge of a detector pixel + double fDetVX, fDetVY, fDetVZ; +}; + +void computeBP_UV_Coeffs(const SPar3DProjection& proj, + double &fUX, double &fUY, double &fUZ, double &fUC, + double &fVX, double &fVY, double &fVZ, double &fVC); + +void computeBP_UV_Coeffs(const SConeProjection& proj, + double &fUX, double &fUY, double &fUZ, double &fUC, + double &fVX, double &fVY, double &fVZ, double &fVC, + double &fDX, double &fDY, double &fDZ, double &fDC); + +} + +#endif diff --git a/include/astra/ParallelVecProjectionGeometry3D.h b/include/astra/ParallelVecProjectionGeometry3D.h index 5a63249..59238c8 100644 --- a/include/astra/ParallelVecProjectionGeometry3D.h +++ b/include/astra/ParallelVecProjectionGeometry3D.h @@ -30,7 +30,7 @@ $Id$ #define _INC_ASTRA_PARALLELVECPROJECTIONGEOMETRY3D #include "ProjectionGeometry3D.h" -#include "../cuda/3d/dims3d.h" +#include "GeometryUtil3D.h" namespace astra { diff --git a/src/GeometryUtil3D.cpp b/src/GeometryUtil3D.cpp new file mode 100644 index 0000000..52dd5a9 --- /dev/null +++ b/src/GeometryUtil3D.cpp @@ -0,0 +1,75 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2015, iMinds-Vision Lab, University of Antwerp + 2014-2015, CWI, Amsterdam + +Contact: astra@uantwerpen.be +Website: http://sf.net/projects/astra-toolbox + +This file is part of the ASTRA Toolbox. + + +The ASTRA Toolbox 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. + +The ASTRA Toolbox 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 the ASTRA Toolbox. If not, see . + +----------------------------------------------------------------------- +$Id$ +*/ + +#include "astra/GeometryUtil3D.h" + +namespace astra { + +// (See declaration in header for (mathematical) description of these functions) + + +void computeBP_UV_Coeffs(const SPar3DProjection& proj, double &fUX, double &fUY, double &fUZ, double &fUC, + double &fVX, double &fVY, double &fVZ, double &fVC) +{ + double denom = (proj.fRayX*proj.fDetUY*proj.fDetVZ - proj.fRayX*proj.fDetUZ*proj.fDetVY - proj.fRayY*proj.fDetUX*proj.fDetVZ + proj.fRayY*proj.fDetUZ*proj.fDetVX + proj.fRayZ*proj.fDetUX*proj.fDetVY - proj.fRayZ*proj.fDetUY*proj.fDetVX); + + fUX = ( - (proj.fRayY*proj.fDetVZ - proj.fRayZ*proj.fDetVY)) / denom; + fUY = ( (proj.fRayX*proj.fDetVZ - proj.fRayZ*proj.fDetVX)) / denom; + fUZ = (- (proj.fRayX*proj.fDetVY - proj.fRayY*proj.fDetVX) ) / denom; + fUC = (-(proj.fDetSY*proj.fDetVZ - proj.fDetSZ*proj.fDetVY)*proj.fRayX + (proj.fRayY*proj.fDetVZ - proj.fRayZ*proj.fDetVY)*proj.fDetSX - (proj.fRayY*proj.fDetSZ - proj.fRayZ*proj.fDetSY)*proj.fDetVX) / denom; + + fVX = ((proj.fRayY*proj.fDetUZ - proj.fRayZ*proj.fDetUY) ) / denom; + fVY = (- (proj.fRayX*proj.fDetUZ - proj.fRayZ*proj.fDetUX) ) / denom; + fVZ = ((proj.fRayX*proj.fDetUY - proj.fRayY*proj.fDetUX) ) / denom; + fVC = ((proj.fDetSY*proj.fDetUZ - proj.fDetSZ*proj.fDetUY)*proj.fRayX - (proj.fRayY*proj.fDetUZ - proj.fRayZ*proj.fDetUY)*proj.fDetSX + (proj.fRayY*proj.fDetSZ - proj.fRayZ*proj.fDetSY)*proj.fDetUX ) / denom; +} + + + +void computeBP_UV_Coeffs(const SConeProjection& proj, double &fUX, double &fUY, double &fUZ, double &fUC, + double &fVX, double &fVY, double &fVZ, double &fVC, + double &fDX, double &fDY, double &fDZ, double &fDC) +{ + fUX = (proj.fDetSZ - proj.fSrcZ)*proj.fDetVY - (proj.fDetSY - proj.fSrcY)*proj.fDetVZ; + fUY = (proj.fDetSX - proj.fSrcX)*proj.fDetVZ -(proj.fDetSZ - proj.fSrcZ)*proj.fDetVX; + fUZ = (proj.fDetSY - proj.fSrcY)*proj.fDetVX - (proj.fDetSX - proj.fSrcX)*proj.fDetVY; + fUC = (proj.fDetSY*proj.fDetVZ - proj.fDetSZ*proj.fDetVY)*proj.fSrcX - (proj.fDetSX*proj.fDetVZ - proj.fDetSZ*proj.fDetVX)*proj.fSrcY + (proj.fDetSX*proj.fDetVY - proj.fDetSY*proj.fDetVX)*proj.fSrcZ; + + fVX = (proj.fDetSY - proj.fSrcY)*proj.fDetUZ-(proj.fDetSZ - proj.fSrcZ)*proj.fDetUY; + fVY = (proj.fDetSZ - proj.fSrcZ)*proj.fDetUX - (proj.fDetSX - proj.fSrcX)*proj.fDetUZ; + fVZ = (proj.fDetSX - proj.fSrcX)*proj.fDetUY-(proj.fDetSY - proj.fSrcY)*proj.fDetUX; + fVC = -(proj.fDetSY*proj.fDetUZ - proj.fDetSZ*proj.fDetUY)*proj.fSrcX + (proj.fDetSX*proj.fDetUZ - proj.fDetSZ*proj.fDetUX)*proj.fSrcY - (proj.fDetSX*proj.fDetUY - proj.fDetSY*proj.fDetUX)*proj.fSrcZ; + + fDX = proj.fDetUY*proj.fDetVZ - proj.fDetUZ*proj.fDetVY; + fDY = proj.fDetUZ*proj.fDetVX - proj.fDetUX*proj.fDetVZ; + fDZ = proj.fDetUX*proj.fDetVY - proj.fDetUY*proj.fDetVX; + fDC = -proj.fSrcX * (proj.fDetUY*proj.fDetVZ - proj.fDetUZ*proj.fDetVY) - proj.fSrcY * (proj.fDetUZ*proj.fDetVX - proj.fDetUX*proj.fDetVZ) - proj.fSrcZ * (proj.fDetUX*proj.fDetVY - proj.fDetUY*proj.fDetVX); +} + + +} -- cgit v1.2.3