/* 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 "vtkImageAlgorithmWrap.h"
#include "vtkThreadedImageAlgorithmWrap.h"
#include "vtkObjectBaseWrap.h"
#include "vtkImageDataWrap.h"
#include "../../plus/plus.h"

using namespace v8;

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

VtkThreadedImageAlgorithmWrap::VtkThreadedImageAlgorithmWrap()
{ }

VtkThreadedImageAlgorithmWrap::VtkThreadedImageAlgorithmWrap(vtkSmartPointer<vtkThreadedImageAlgorithm> _native)
{ native = _native; }

VtkThreadedImageAlgorithmWrap::~VtkThreadedImageAlgorithmWrap()
{ }

void VtkThreadedImageAlgorithmWrap::Init(v8::Local<v8::Object> exports)
{
	Nan::SetAccessor(exports, Nan::New("vtkThreadedImageAlgorithm").ToLocalChecked(), ConstructorGetter);
	Nan::SetAccessor(exports, Nan::New("ThreadedImageAlgorithm").ToLocalChecked(), ConstructorGetter);
}

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

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

	Nan::SetPrototypeMethod(tpl, "GetEnableSMP", GetEnableSMP);
	Nan::SetPrototypeMethod(tpl, "getEnableSMP", GetEnableSMP);

	Nan::SetPrototypeMethod(tpl, "GetGlobalDefaultEnableSMP", GetGlobalDefaultEnableSMP);
	Nan::SetPrototypeMethod(tpl, "getGlobalDefaultEnableSMP", GetGlobalDefaultEnableSMP);

	Nan::SetPrototypeMethod(tpl, "GetMinimumPieceSize", GetMinimumPieceSize);
	Nan::SetPrototypeMethod(tpl, "getMinimumPieceSize", GetMinimumPieceSize);

	Nan::SetPrototypeMethod(tpl, "GetNumberOfThreads", GetNumberOfThreads);
	Nan::SetPrototypeMethod(tpl, "getNumberOfThreads", GetNumberOfThreads);

	Nan::SetPrototypeMethod(tpl, "GetNumberOfThreadsMaxValue", GetNumberOfThreadsMaxValue);
	Nan::SetPrototypeMethod(tpl, "getNumberOfThreadsMaxValue", GetNumberOfThreadsMaxValue);

	Nan::SetPrototypeMethod(tpl, "GetNumberOfThreadsMinValue", GetNumberOfThreadsMinValue);
	Nan::SetPrototypeMethod(tpl, "getNumberOfThreadsMinValue", GetNumberOfThreadsMinValue);

	Nan::SetPrototypeMethod(tpl, "GetSplitMode", GetSplitMode);
	Nan::SetPrototypeMethod(tpl, "getSplitMode", GetSplitMode);

	Nan::SetPrototypeMethod(tpl, "GetSplitModeMaxValue", GetSplitModeMaxValue);
	Nan::SetPrototypeMethod(tpl, "getSplitModeMaxValue", GetSplitModeMaxValue);

	Nan::SetPrototypeMethod(tpl, "GetSplitModeMinValue", GetSplitModeMinValue);
	Nan::SetPrototypeMethod(tpl, "getSplitModeMinValue", GetSplitModeMinValue);

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

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

	Nan::SetPrototypeMethod(tpl, "SetEnableSMP", SetEnableSMP);
	Nan::SetPrototypeMethod(tpl, "setEnableSMP", SetEnableSMP);

	Nan::SetPrototypeMethod(tpl, "SetGlobalDefaultEnableSMP", SetGlobalDefaultEnableSMP);
	Nan::SetPrototypeMethod(tpl, "setGlobalDefaultEnableSMP", SetGlobalDefaultEnableSMP);

	Nan::SetPrototypeMethod(tpl, "SetMinimumPieceSize", SetMinimumPieceSize);
	Nan::SetPrototypeMethod(tpl, "setMinimumPieceSize", SetMinimumPieceSize);

	Nan::SetPrototypeMethod(tpl, "SetNumberOfThreads", SetNumberOfThreads);
	Nan::SetPrototypeMethod(tpl, "setNumberOfThreads", SetNumberOfThreads);

	Nan::SetPrototypeMethod(tpl, "SetSplitMode", SetSplitMode);
	Nan::SetPrototypeMethod(tpl, "setSplitMode", SetSplitMode);

	Nan::SetPrototypeMethod(tpl, "SetSplitModeToBeam", SetSplitModeToBeam);
	Nan::SetPrototypeMethod(tpl, "setSplitModeToBeam", SetSplitModeToBeam);

	Nan::SetPrototypeMethod(tpl, "SetSplitModeToBlock", SetSplitModeToBlock);
	Nan::SetPrototypeMethod(tpl, "setSplitModeToBlock", SetSplitModeToBlock);

	Nan::SetPrototypeMethod(tpl, "SetSplitModeToSlab", SetSplitModeToSlab);
	Nan::SetPrototypeMethod(tpl, "setSplitModeToSlab", SetSplitModeToSlab);

	Nan::SetPrototypeMethod(tpl, "SplitExtent", SplitExtent);
	Nan::SetPrototypeMethod(tpl, "splitExtent", SplitExtent);

	Nan::SetPrototypeMethod(tpl, "ThreadedExecute", ThreadedExecute);
	Nan::SetPrototypeMethod(tpl, "threadedExecute", ThreadedExecute);

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

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

	if(info.Length() == 0)
	{
		Nan::ThrowError("Cannot create instance of abstract class.");
		return;
	}
	else
	{
		if(info[0]->ToObject() != vtkNodeJsNoWrap )
		{
			Nan::ThrowError("Parameter Error");
			return;
		}
	}

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

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

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

void VtkThreadedImageAlgorithmWrap::GetMinimumPieceSize(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkThreadedImageAlgorithmWrap *wrapper = ObjectWrap::Unwrap<VtkThreadedImageAlgorithmWrap>(info.Holder());
	vtkThreadedImageAlgorithm *native = (vtkThreadedImageAlgorithm *)wrapper->native.GetPointer();
	int const * r;
	if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	r = native->GetMinimumPieceSize();
	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 VtkThreadedImageAlgorithmWrap::GetNumberOfThreads(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkThreadedImageAlgorithmWrap *wrapper = ObjectWrap::Unwrap<VtkThreadedImageAlgorithmWrap>(info.Holder());
	vtkThreadedImageAlgorithm *native = (vtkThreadedImageAlgorithm *)wrapper->native.GetPointer();
	int r;
	if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	r = native->GetNumberOfThreads();
	info.GetReturnValue().Set(Nan::New(r));
}

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

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

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

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

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

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

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

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

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

void VtkThreadedImageAlgorithmWrap::SetMinimumPieceSize(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkThreadedImageAlgorithmWrap *wrapper = ObjectWrap::Unwrap<VtkThreadedImageAlgorithmWrap>(info.Holder());
	vtkThreadedImageAlgorithm *native = (vtkThreadedImageAlgorithm *)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->SetMinimumPieceSize(
			(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->SetMinimumPieceSize(
			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->SetMinimumPieceSize(
					info[0]->Int32Value(),
					info[1]->Int32Value(),
					info[2]->Int32Value()
				);
				return;
			}
		}
	}
	Nan::ThrowError("Parameter mismatch");
}

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

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

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

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

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

void VtkThreadedImageAlgorithmWrap::SplitExtent(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkThreadedImageAlgorithmWrap *wrapper = ObjectWrap::Unwrap<VtkThreadedImageAlgorithmWrap>(info.Holder());
	vtkThreadedImageAlgorithm *native = (vtkThreadedImageAlgorithm *)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() < 6 )
		{
			Nan::ThrowError("Array too short.");
			return;
		}

		if(info.Length() > 1 && info[1]->IsInt32Array())
		{
			v8::Local<v8::Int32Array>a1(v8::Local<v8::Int32Array>::Cast(info[1]->ToObject()));
			if( a1->Length() < 6 )
			{
				Nan::ThrowError("Array too short.");
				return;
			}

			if(info.Length() > 2 && info[2]->IsInt32())
			{
				if(info.Length() > 3 && info[3]->IsInt32())
				{
					int r;
					if(info.Length() != 4)
					{
						Nan::ThrowError("Too many parameters.");
						return;
					}
					r = native->SplitExtent(
						(int *)(a0->Buffer()->GetContents().Data()),
						(int *)(a1->Buffer()->GetContents().Data()),
						info[2]->Int32Value(),
						info[3]->Int32Value()
					);
					info.GetReturnValue().Set(Nan::New(r));
					return;
				}
			}
		}
		else if(info.Length() > 1 && info[1]->IsArray())
		{
			v8::Local<v8::Array>a1(v8::Local<v8::Array>::Cast(info[1]->ToObject()));
			int b1[6];
			if( a1->Length() < 6 )
			{
				Nan::ThrowError("Array too short.");
				return;
			}

			for( i = 0; i < 6; i++ )
			{
				if( !a1->Get(i)->IsInt32() )
				{
					Nan::ThrowError("Array contents invalid.");
					return;
				}
				b1[i] = a1->Get(i)->Int32Value();
			}
			if(info.Length() > 2 && info[2]->IsInt32())
			{
				if(info.Length() > 3 && info[3]->IsInt32())
				{
					int r;
					if(info.Length() != 4)
					{
						Nan::ThrowError("Too many parameters.");
						return;
					}
					r = native->SplitExtent(
						(int *)(a0->Buffer()->GetContents().Data()),
						b1,
						info[2]->Int32Value(),
						info[3]->Int32Value()
					);
					info.GetReturnValue().Set(Nan::New(r));
					return;
				}
			}
		}
	}
	else if(info.Length() > 0 && info[0]->IsArray())
	{
		v8::Local<v8::Array>a0(v8::Local<v8::Array>::Cast(info[0]->ToObject()));
		int b0[6];
		if( a0->Length() < 6 )
		{
			Nan::ThrowError("Array too short.");
			return;
		}

		for( i = 0; i < 6; i++ )
		{
			if( !a0->Get(i)->IsInt32() )
			{
				Nan::ThrowError("Array contents invalid.");
				return;
			}
			b0[i] = a0->Get(i)->Int32Value();
		}
		if(info.Length() > 1 && info[1]->IsArray())
		{
			v8::Local<v8::Array>a1(v8::Local<v8::Array>::Cast(info[1]->ToObject()));
			int b1[6];
			if( a1->Length() < 6 )
			{
				Nan::ThrowError("Array too short.");
				return;
			}

			for( i = 0; i < 6; i++ )
			{
				if( !a1->Get(i)->IsInt32() )
				{
					Nan::ThrowError("Array contents invalid.");
					return;
				}
				b1[i] = a1->Get(i)->Int32Value();
			}
			if(info.Length() > 2 && info[2]->IsInt32())
			{
				if(info.Length() > 3 && info[3]->IsInt32())
				{
					int r;
					if(info.Length() != 4)
					{
						Nan::ThrowError("Too many parameters.");
						return;
					}
					r = native->SplitExtent(
						b0,
						b1,
						info[2]->Int32Value(),
						info[3]->Int32Value()
					);
					info.GetReturnValue().Set(Nan::New(r));
					return;
				}
			}
		}
		else if(info.Length() > 1 && info[1]->IsInt32Array())
		{
			v8::Local<v8::Int32Array>a1(v8::Local<v8::Int32Array>::Cast(info[1]->ToObject()));
			if( a1->Length() < 6 )
			{
				Nan::ThrowError("Array too short.");
				return;
			}

			if(info.Length() > 2 && info[2]->IsInt32())
			{
				if(info.Length() > 3 && info[3]->IsInt32())
				{
					int r;
					if(info.Length() != 4)
					{
						Nan::ThrowError("Too many parameters.");
						return;
					}
					r = native->SplitExtent(
						b0,
						(int *)(a1->Buffer()->GetContents().Data()),
						info[2]->Int32Value(),
						info[3]->Int32Value()
					);
					info.GetReturnValue().Set(Nan::New(r));
					return;
				}
			}
		}
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkThreadedImageAlgorithmWrap::ThreadedExecute(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkThreadedImageAlgorithmWrap *wrapper = ObjectWrap::Unwrap<VtkThreadedImageAlgorithmWrap>(info.Holder());
	vtkThreadedImageAlgorithm *native = (vtkThreadedImageAlgorithm *)wrapper->native.GetPointer();
	size_t i;
	if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkImageDataWrap::ptpl))->HasInstance(info[0]))
	{
		VtkImageDataWrap *a0 = ObjectWrap::Unwrap<VtkImageDataWrap>(info[0]->ToObject());
		if(info.Length() > 1 && info[1]->IsObject() && (Nan::New(VtkImageDataWrap::ptpl))->HasInstance(info[1]))
		{
			VtkImageDataWrap *a1 = ObjectWrap::Unwrap<VtkImageDataWrap>(info[1]->ToObject());
			if(info.Length() > 2 && info[2]->IsInt32Array())
			{
				v8::Local<v8::Int32Array>a2(v8::Local<v8::Int32Array>::Cast(info[2]->ToObject()));
				if( a2->Length() < 6 )
				{
					Nan::ThrowError("Array too short.");
					return;
				}

				if(info.Length() > 3 && info[3]->IsInt32())
				{
										if(info.Length() != 4)
					{
						Nan::ThrowError("Too many parameters.");
						return;
					}
					native->ThreadedExecute(
						(vtkImageData *) a0->native.GetPointer(),
						(vtkImageData *) a1->native.GetPointer(),
						(int *)(a2->Buffer()->GetContents().Data()),
						info[3]->Int32Value()
					);
					return;
				}
			}
			else if(info.Length() > 2 && info[2]->IsArray())
			{
				v8::Local<v8::Array>a2(v8::Local<v8::Array>::Cast(info[2]->ToObject()));
				int b2[6];
				if( a2->Length() < 6 )
				{
					Nan::ThrowError("Array too short.");
					return;
				}

				for( i = 0; i < 6; i++ )
				{
					if( !a2->Get(i)->IsInt32() )
					{
						Nan::ThrowError("Array contents invalid.");
						return;
					}
					b2[i] = a2->Get(i)->Int32Value();
				}
				if(info.Length() > 3 && info[3]->IsInt32())
				{
										if(info.Length() != 4)
					{
						Nan::ThrowError("Too many parameters.");
						return;
					}
					native->ThreadedExecute(
						(vtkImageData *) a0->native.GetPointer(),
						(vtkImageData *) a1->native.GetPointer(),
						b2,
						info[3]->Int32Value()
					);
					return;
				}
			}
		}
	}
	Nan::ThrowError("Parameter mismatch");
}

