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

	Program:		Range Imaging Toolkit (RITK)
	Module:			ritkRImageVTKData.h
	Version:		$Revision: 1821 $
	Date:			$Date: 2011-10-02 15:41:17 +0200 (So, 02 Okt 2011) $

	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 RIMAGEVTKDATA_H__
#define RIMAGEVTKDATA_H__

#include "ritkVTK.h"

#include "ritkRImage.h"
#include <itkImageToVTKImageFilter.h>
#include <vtkSmartPointer.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkDelaunay2D.h>
#include <vtkCellArray.h>

namespace ritk
{

/**	@ingroup	ritkVTK
 *	@class		RImageVTKData
 *	@author		Sebastian Bauer
 *	@brief		Class that generates VTK data out of 3D point cloud
 *
 *	@details
 *	...
 *	@todo	Really needs a detailed documentation as this class is used VERY often.
 */
class RITKVTK_EXPORT RImageVTKData : public vtkObject
{
public:
	/// Object creation
	static RImageVTKData *New();

	/**	@name	Typedefs for the range image */
	//@{
	typedef RImageF2 RImageType;
	typedef RImageType::Pointer RImagePointer;
	typedef RImageType::ConstPointer RImageConstPointer;
	//@}

	
	/**	@name	The polydata types */
	//@{
	typedef enum PolyDataType
	{
		POINTCLOUD,
		TRIANGLESTRIPS,
		DELAUNAYTRIANGLES
	} PolyDataType;
	//@}

	/// Generate the polydata. @todo Documentation of the GeneratePolyData() method
	void GeneratePolyData(const RImageType *Image, bool UseRImageMask=true);
	/// Set the poly data @todo Documentation of the SetPolyData() method
	void SetPolyDataType(PolyDataType Type);

	/// Get the previously generated poly data. 
	vtkSmartPointer<vtkPolyData> GetPolyData();

protected:
	/// Constructor
	RImageVTKData();
	/// Destructor
	~RImageVTKData();

	/**	@name VTK elements for the world coord visualization */
	//@{
	bool m_MeshInitialized;
	PolyDataType m_PolyDataType;
	vtkSmartPointer<vtkPolyData> m_WorldCoordPolyData;
	//@}

	/// Will hold the point cloud
	vtkSmartPointer<vtkPoints> m_Points;
};

} // end namespace ritk


#endif // RIMAGEVTKDATA_H__