/* ImLib3D
 * Copyright (c) 2001, ULP-IPB Strasbourg.
 *
 * This program 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 2 of the License, or (at
 * your option) any later version.
 * 
 * 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 the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
/*! \file Interpolator3D.hxx */

#ifndef _Interpolator3D_hxx
#define _Interpolator3D_hxx

#include<ImLib3D/Image3Dlinear.hpp>
#include<ImLib3D/Interpolator3D.hpp>
#include<ImLib3D/SplineInterpolation.hpp>

template<class Im3DValue>
Interpolator3D<Im3DValue> *
Interpolator3D<Im3DValue>::Create(const string &name0)
{
	vector<string> names;
	Split(name0,names);
	string name=names[0];
	int arg=0;
	if(names.size()>1){arg=LongInt(names[1]);}

	if(name=="Spline")
	{
		if(arg<2 || arg>5){mprintf("WARNING: using spline interpolation default degree 5\n");arg=5;}
		return new SplineInterpolator3D<Im3DValue>(arg);
	}
	else
	if(name=="Linear" || name=="TriLinear")
	{
		return new TriLinearInterpolator<Im3DValue>();
	}
	else
	if(name=="NearestNeighbor" || name=="Nearest")
	{
		return new NNInterpolator<Im3DValue>();
	}
	else
	if(name=="TruncatedSinC")
	{
		if(arg<1){mprintf("WARNING: using sinc interpolation default radius 5\n");arg=5;}
		return new TruncatedSinCInterpolator<Im3DValue>(arg);
	}
	else
	{
		ThrowError("Unknown interpolator name:%s",name);
		return NULL;
	}
}
#endif// _Interpolator3D_hxx
