/*======================================================================================

	Program:		Range Imaging Toolkit (RITK)
	Module:			ritkCudaRayCasterInterfaces.h
	Version:		$Revision: 2739 $
	Date:			$Date: 2012-03-07 17:44:03 +0100 (Mi, 07 Mrz 2012) $

	Copyright (c) 2010-2011
	Pattern Recognition Lab, 
    University Erlangen-Nuremberg, Germany
    All rights reserved.

	This program 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 RITKCopyright.txt for more information.

	http://www5.informatik.uni-erlangen.de/research/software/ritk

========================================================================================*/


#ifndef RITKCUDARAYCASTERINTERFACES_H__
#define RITKCUDARAYCASTERINTERFACES_H__

#include "cuda_runtime.h"

/// A struct wrapping volume paramters used for ray casting
//---------------------------------------------------------
struct ritkCudaRayCasterVolumeParameters
{
public:
	/**	@name	Volume information */
	//@{
	int3 Size; // in pixel
	float3 Origin;
	float3 Spacing;
	float3 Center;
	//@}

	/**	@name	Volume data and channels description */
	//@{
	const cudaChannelFormatDesc *ChannelDesc;
	const cudaArray *DataArray;
	//@}
};


/// A struct wrapping projection image parameters used for ray casting
//--------------------------------------------------------------------
template<class TType>
struct ritkCudaRayCasterProjectionImageParameters
{
public:
	/**	@name	Image information */
	//@{
	float2 Size; // in pixel
	float2 Origin;
	float2 Spacing;
	//@}

	/**	@name	Image data */
	//@{
	TType *DataPtr;
	size_t Pitch;
	//@}
};

/// A struct wrapping projection parameters used for ray casting
//--------------------------------------------------------------
struct ritkCudaRayCasterProjectionParameters
{
public:
	/// The "inverse" projection matrix
	float InverseProjectionMatrix[9];

	/// The optical center
	float3 OpticalCenter;
};


/// Helper function to resolve the template argument via template spezializations
//--------------------------------------------------------------
template<class TInputVolumePixel, class TOutputImagePixel>
bool KernelInvocationHelper(const ritkCudaRayCasterVolumeParameters &VP, const ritkCudaRayCasterProjectionImageParameters<TOutputImagePixel> &IP, const ritkCudaRayCasterProjectionParameters &PP);


/// Cuda ray casting. Will eventually invoke the kernel
//-----------------------------------------------------
extern "C" 
bool 
ritkFloatVolumeCudaRayCaster(const ritkCudaRayCasterVolumeParameters &VP, const ritkCudaRayCasterProjectionImageParameters<float> &IP, const ritkCudaRayCasterProjectionParameters &PP);


/// Cuda ray casting. Will eventually invoke the kernel
//-----------------------------------------------------
extern "C" 
bool 
ritkRGBAVolumeCudaRayCaster_uchar(const ritkCudaRayCasterVolumeParameters &VP, const ritkCudaRayCasterProjectionImageParameters<uchar4> &IP, const ritkCudaRayCasterProjectionParameters &PP);

/// Cuda ray casting. Will eventually invoke the kernel
//-----------------------------------------------------
extern "C" 
bool 
ritkRGBAVolumeCudaRayCaster_float(const ritkCudaRayCasterVolumeParameters &VP, const ritkCudaRayCasterProjectionImageParameters<float4> &IP, const ritkCudaRayCasterProjectionParameters &PP);



#endif // RITKCUDARAYCASTERINTERFACES_H__