/* this file has been autogenerated by vtkNodeJsWrap */
/* editing this might proof futile */

#define VTK_WRAPPING_CXX
#define VTK_STREAMS_FWD_ONLY
#include <nan.h>

#include "vtkAlgorithmWrap.h"
#include "vtkResampleToImageWrap.h"
#include "vtkObjectBaseWrap.h"
#include "vtkImageDataWrap.h"
#include "../../plus/plus.h"

using namespace v8;

extern Nan::Persistent<v8::Object> vtkNodeJsNoWrap;
Nan::Persistent<v8::FunctionTemplate> VtkResampleToImageWrap::ptpl;

VtkResampleToImageWrap::VtkResampleToImageWrap()
{ }

VtkResampleToImageWrap::VtkResampleToImageWrap(vtkSmartPointer<vtkResampleToImage> _native)
{ native = _native; }

VtkResampleToImageWrap::~VtkResampleToImageWrap()
{ }

void VtkResampleToImageWrap::Init(v8::Local<v8::Object> exports)
{
	Nan::SetAccessor(exports, Nan::New("vtkResampleToImage").ToLocalChecked(), ConstructorGetter);
	Nan::SetAccessor(exports, Nan::New("ResampleToImage").ToLocalChecked(), ConstructorGetter);
}

void VtkResampleToImageWrap::ConstructorGetter(
	v8::Local<v8::String> property,
	const Nan::PropertyCallbackInfo<v8::Value>& info)
{
	InitPtpl();
	info.GetReturnValue().Set(Nan::New(ptpl)->GetFunction());
}

void VtkResampleToImageWrap::InitPtpl()
{
	if (!ptpl.IsEmpty()) return;
	v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
	VtkAlgorithmWrap::InitPtpl( );
	tpl->Inherit(Nan::New<FunctionTemplate>(VtkAlgorithmWrap::ptpl));
	tpl->SetClassName(Nan::New("VtkResampleToImageWrap").ToLocalChecked());
	tpl->InstanceTemplate()->SetInternalFieldCount(1);

	Nan::SetPrototypeMethod(tpl, "GetOutput", GetOutput);
	Nan::SetPrototypeMethod(tpl, "getOutput", GetOutput);

	Nan::SetPrototypeMethod(tpl, "GetSamplingBounds", GetSamplingBounds);
	Nan::SetPrototypeMethod(tpl, "getSamplingBounds", GetSamplingBounds);

	Nan::SetPrototypeMethod(tpl, "GetSamplingDimensions", GetSamplingDimensions);
	Nan::SetPrototypeMethod(tpl, "getSamplingDimensions", GetSamplingDimensions);

	Nan::SetPrototypeMethod(tpl, "GetUseInputBounds", GetUseInputBounds);
	Nan::SetPrototypeMethod(tpl, "getUseInputBounds", GetUseInputBounds);

	Nan::SetPrototypeMethod(tpl, "NewInstance", NewInstance);
	Nan::SetPrototypeMethod(tpl, "newInstance", NewInstance);

	Nan::SetPrototypeMethod(tpl, "SafeDownCast", SafeDownCast);
	Nan::SetPrototypeMethod(tpl, "safeDownCast", SafeDownCast);

	Nan::SetPrototypeMethod(tpl, "SetSamplingBounds", SetSamplingBounds);
	Nan::SetPrototypeMethod(tpl, "setSamplingBounds", SetSamplingBounds);

	Nan::SetPrototypeMethod(tpl, "SetSamplingDimensions", SetSamplingDimensions);
	Nan::SetPrototypeMethod(tpl, "setSamplingDimensions", SetSamplingDimensions);

	Nan::SetPrototypeMethod(tpl, "SetUseInputBounds", SetUseInputBounds);
	Nan::SetPrototypeMethod(tpl, "setUseInputBounds", SetUseInputBounds);

	Nan::SetPrototypeMethod(tpl, "UseInputBoundsOff", UseInputBoundsOff);
	Nan::SetPrototypeMethod(tpl, "useInputBoundsOff", UseInputBoundsOff);

	Nan::SetPrototypeMethod(tpl, "UseInputBoundsOn", UseInputBoundsOn);
	Nan::SetPrototypeMethod(tpl, "useInputBoundsOn", UseInputBoundsOn);

#ifdef VTK_NODE_PLUS_VTKRESAMPLETOIMAGEWRAP_INITPTPL
	VTK_NODE_PLUS_VTKRESAMPLETOIMAGEWRAP_INITPTPL
#endif
	ptpl.Reset( tpl );
}

void VtkResampleToImageWrap::New(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	if(!info.IsConstructCall())
	{
		Nan::ThrowError("Constructor not called in a construct call.");
		return;
	}

	if(info.Length() == 0)
	{
		vtkSmartPointer<vtkResampleToImage> native = vtkSmartPointer<vtkResampleToImage>::New();
		VtkResampleToImageWrap* obj = new VtkResampleToImageWrap(native);
		obj->Wrap(info.This());
	}
	else
	{
		if(info[0]->ToObject() != vtkNodeJsNoWrap )
		{
			Nan::ThrowError("Parameter Error");
			return;
		}
	}

	info.GetReturnValue().Set(info.This());
}

void VtkResampleToImageWrap::GetOutput(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkResampleToImageWrap *wrapper = ObjectWrap::Unwrap<VtkResampleToImageWrap>(info.Holder());
	vtkResampleToImage *native = (vtkResampleToImage *)wrapper->native.GetPointer();
	vtkImageData * r;
	if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	r = native->GetOutput();
	VtkImageDataWrap::InitPtpl();
	v8::Local<v8::Value> argv[1] =
		{ Nan::New(vtkNodeJsNoWrap) };
	v8::Local<v8::Function> cons =
		Nan::New<v8::FunctionTemplate>(VtkImageDataWrap::ptpl)->GetFunction();
	v8::Local<v8::Object> wo = cons->NewInstance(1, argv);
	VtkImageDataWrap *w = new VtkImageDataWrap();
	w->native = r;
	w->Wrap(wo);
	info.GetReturnValue().Set(wo);
}

void VtkResampleToImageWrap::GetSamplingBounds(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkResampleToImageWrap *wrapper = ObjectWrap::Unwrap<VtkResampleToImageWrap>(info.Holder());
	vtkResampleToImage *native = (vtkResampleToImage *)wrapper->native.GetPointer();
	double const * r;
	if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	r = native->GetSamplingBounds();
	Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(v8::Isolate::GetCurrent(), 6 * sizeof(double));
	Local<v8::Float64Array> at = v8::Float64Array::New(ab, 0, 6);
	memcpy(ab->GetContents().Data(), r, 6 * sizeof(double));
	info.GetReturnValue().Set(at);
}

void VtkResampleToImageWrap::GetSamplingDimensions(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkResampleToImageWrap *wrapper = ObjectWrap::Unwrap<VtkResampleToImageWrap>(info.Holder());
	vtkResampleToImage *native = (vtkResampleToImage *)wrapper->native.GetPointer();
	int const * r;
	if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	r = native->GetSamplingDimensions();
	Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(v8::Isolate::GetCurrent(), 3 * sizeof(int));
	Local<v8::Int32Array> at = v8::Int32Array::New(ab, 0, 3);
	memcpy(ab->GetContents().Data(), r, 3 * sizeof(int));
	info.GetReturnValue().Set(at);
}

void VtkResampleToImageWrap::GetUseInputBounds(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkResampleToImageWrap *wrapper = ObjectWrap::Unwrap<VtkResampleToImageWrap>(info.Holder());
	vtkResampleToImage *native = (vtkResampleToImage *)wrapper->native.GetPointer();
	bool r;
	if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	r = native->GetUseInputBounds();
	info.GetReturnValue().Set(Nan::New(r));
}

void VtkResampleToImageWrap::NewInstance(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkResampleToImageWrap *wrapper = ObjectWrap::Unwrap<VtkResampleToImageWrap>(info.Holder());
	vtkResampleToImage *native = (vtkResampleToImage *)wrapper->native.GetPointer();
	vtkResampleToImage * r;
	if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	r = native->NewInstance();
	VtkResampleToImageWrap::InitPtpl();
	v8::Local<v8::Value> argv[1] =
		{ Nan::New(vtkNodeJsNoWrap) };
	v8::Local<v8::Function> cons =
		Nan::New<v8::FunctionTemplate>(VtkResampleToImageWrap::ptpl)->GetFunction();
	v8::Local<v8::Object> wo = cons->NewInstance(1, argv);
	VtkResampleToImageWrap *w = new VtkResampleToImageWrap();
	w->native = r;
	w->Wrap(wo);
	info.GetReturnValue().Set(wo);
}

void VtkResampleToImageWrap::SafeDownCast(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkResampleToImageWrap *wrapper = ObjectWrap::Unwrap<VtkResampleToImageWrap>(info.Holder());
	vtkResampleToImage *native = (vtkResampleToImage *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkObjectBaseWrap::ptpl))->HasInstance(info[0]))
	{
		VtkObjectBaseWrap *a0 = ObjectWrap::Unwrap<VtkObjectBaseWrap>(info[0]->ToObject());
		vtkResampleToImage * r;
		if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		r = native->SafeDownCast(
			(vtkObjectBase *) a0->native.GetPointer()
		);
		VtkResampleToImageWrap::InitPtpl();
		v8::Local<v8::Value> argv[1] =
			{ Nan::New(vtkNodeJsNoWrap) };
		v8::Local<v8::Function> cons =
			Nan::New<v8::FunctionTemplate>(VtkResampleToImageWrap::ptpl)->GetFunction();
		v8::Local<v8::Object> wo = cons->NewInstance(1, argv);
		VtkResampleToImageWrap *w = new VtkResampleToImageWrap();
		w->native = r;
		w->Wrap(wo);
		info.GetReturnValue().Set(wo);
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkResampleToImageWrap::SetSamplingBounds(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkResampleToImageWrap *wrapper = ObjectWrap::Unwrap<VtkResampleToImageWrap>(info.Holder());
	vtkResampleToImage *native = (vtkResampleToImage *)wrapper->native.GetPointer();
	size_t i;
	if(info.Length() > 0 && info[0]->IsFloat64Array())
	{
		v8::Local<v8::Float64Array>a0(v8::Local<v8::Float64Array>::Cast(info[0]->ToObject()));
		if( a0->Length() < 6 )
		{
			Nan::ThrowError("Array too short.");
			return;
		}

				if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		native->SetSamplingBounds(
			(double *)(a0->Buffer()->GetContents().Data())
		);
		return;
	}
	else if(info.Length() > 0 && info[0]->IsArray())
	{
		v8::Local<v8::Array>a0(v8::Local<v8::Array>::Cast(info[0]->ToObject()));
		double b0[6];
		if( a0->Length() < 6 )
		{
			Nan::ThrowError("Array too short.");
			return;
		}

		for( i = 0; i < 6; i++ )
		{
			if( !a0->Get(i)->IsNumber() )
			{
				Nan::ThrowError("Array contents invalid.");
				return;
			}
			b0[i] = a0->Get(i)->NumberValue();
		}
				if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		native->SetSamplingBounds(
			b0
		);
		return;
	}
	else if(info.Length() > 0 && info[0]->IsNumber())
	{
		if(info.Length() > 1 && info[1]->IsNumber())
		{
			if(info.Length() > 2 && info[2]->IsNumber())
			{
				if(info.Length() > 3 && info[3]->IsNumber())
				{
					if(info.Length() > 4 && info[4]->IsNumber())
					{
						if(info.Length() > 5 && info[5]->IsNumber())
						{
														if(info.Length() != 6)
							{
								Nan::ThrowError("Too many parameters.");
								return;
							}
							native->SetSamplingBounds(
								info[0]->NumberValue(),
								info[1]->NumberValue(),
								info[2]->NumberValue(),
								info[3]->NumberValue(),
								info[4]->NumberValue(),
								info[5]->NumberValue()
							);
							return;
						}
					}
				}
			}
		}
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkResampleToImageWrap::SetSamplingDimensions(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkResampleToImageWrap *wrapper = ObjectWrap::Unwrap<VtkResampleToImageWrap>(info.Holder());
	vtkResampleToImage *native = (vtkResampleToImage *)wrapper->native.GetPointer();
	size_t i;
	if(info.Length() > 0 && info[0]->IsInt32Array())
	{
		v8::Local<v8::Int32Array>a0(v8::Local<v8::Int32Array>::Cast(info[0]->ToObject()));
		if( a0->Length() < 3 )
		{
			Nan::ThrowError("Array too short.");
			return;
		}

				if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		native->SetSamplingDimensions(
			(int *)(a0->Buffer()->GetContents().Data())
		);
		return;
	}
	else if(info.Length() > 0 && info[0]->IsArray())
	{
		v8::Local<v8::Array>a0(v8::Local<v8::Array>::Cast(info[0]->ToObject()));
		int b0[3];
		if( a0->Length() < 3 )
		{
			Nan::ThrowError("Array too short.");
			return;
		}

		for( i = 0; i < 3; i++ )
		{
			if( !a0->Get(i)->IsInt32() )
			{
				Nan::ThrowError("Array contents invalid.");
				return;
			}
			b0[i] = a0->Get(i)->Int32Value();
		}
				if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		native->SetSamplingDimensions(
			b0
		);
		return;
	}
	else if(info.Length() > 0 && info[0]->IsInt32())
	{
		if(info.Length() > 1 && info[1]->IsInt32())
		{
			if(info.Length() > 2 && info[2]->IsInt32())
			{
								if(info.Length() != 3)
				{
					Nan::ThrowError("Too many parameters.");
					return;
				}
				native->SetSamplingDimensions(
					info[0]->Int32Value(),
					info[1]->Int32Value(),
					info[2]->Int32Value()
				);
				return;
			}
		}
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkResampleToImageWrap::SetUseInputBounds(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkResampleToImageWrap *wrapper = ObjectWrap::Unwrap<VtkResampleToImageWrap>(info.Holder());
	vtkResampleToImage *native = (vtkResampleToImage *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsBoolean())
	{
				if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		native->SetUseInputBounds(
			info[0]->BooleanValue()
		);
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkResampleToImageWrap::UseInputBoundsOff(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkResampleToImageWrap *wrapper = ObjectWrap::Unwrap<VtkResampleToImageWrap>(info.Holder());
	vtkResampleToImage *native = (vtkResampleToImage *)wrapper->native.GetPointer();
		if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	native->UseInputBoundsOff();
}

void VtkResampleToImageWrap::UseInputBoundsOn(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkResampleToImageWrap *wrapper = ObjectWrap::Unwrap<VtkResampleToImageWrap>(info.Holder());
	vtkResampleToImage *native = (vtkResampleToImage *)wrapper->native.GetPointer();
		if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	native->UseInputBoundsOn();
}

