/* 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 "vtkPolyDataAlgorithmWrap.h"
#include "vtkVoxelGridWrap.h"
#include "vtkObjectBaseWrap.h"
#include "vtkInterpolationKernelWrap.h"
#include "../../plus/plus.h"

using namespace v8;

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

VtkVoxelGridWrap::VtkVoxelGridWrap()
{ }

VtkVoxelGridWrap::VtkVoxelGridWrap(vtkSmartPointer<vtkVoxelGrid> _native)
{ native = _native; }

VtkVoxelGridWrap::~VtkVoxelGridWrap()
{ }

void VtkVoxelGridWrap::Init(v8::Local<v8::Object> exports)
{
	Nan::SetAccessor(exports, Nan::New("vtkVoxelGrid").ToLocalChecked(), ConstructorGetter);
	Nan::SetAccessor(exports, Nan::New("VoxelGrid").ToLocalChecked(), ConstructorGetter);
}

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

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

	Nan::SetPrototypeMethod(tpl, "GetConfigurationStyle", GetConfigurationStyle);
	Nan::SetPrototypeMethod(tpl, "getConfigurationStyle", GetConfigurationStyle);

	Nan::SetPrototypeMethod(tpl, "GetDivisions", GetDivisions);
	Nan::SetPrototypeMethod(tpl, "getDivisions", GetDivisions);

	Nan::SetPrototypeMethod(tpl, "GetKernel", GetKernel);
	Nan::SetPrototypeMethod(tpl, "getKernel", GetKernel);

	Nan::SetPrototypeMethod(tpl, "GetLeafSize", GetLeafSize);
	Nan::SetPrototypeMethod(tpl, "getLeafSize", GetLeafSize);

	Nan::SetPrototypeMethod(tpl, "GetNumberOfPointsPerBin", GetNumberOfPointsPerBin);
	Nan::SetPrototypeMethod(tpl, "getNumberOfPointsPerBin", GetNumberOfPointsPerBin);

	Nan::SetPrototypeMethod(tpl, "GetNumberOfPointsPerBinMaxValue", GetNumberOfPointsPerBinMaxValue);
	Nan::SetPrototypeMethod(tpl, "getNumberOfPointsPerBinMaxValue", GetNumberOfPointsPerBinMaxValue);

	Nan::SetPrototypeMethod(tpl, "GetNumberOfPointsPerBinMinValue", GetNumberOfPointsPerBinMinValue);
	Nan::SetPrototypeMethod(tpl, "getNumberOfPointsPerBinMinValue", GetNumberOfPointsPerBinMinValue);

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

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

	Nan::SetPrototypeMethod(tpl, "SetConfigurationStyle", SetConfigurationStyle);
	Nan::SetPrototypeMethod(tpl, "setConfigurationStyle", SetConfigurationStyle);

	Nan::SetPrototypeMethod(tpl, "SetConfigurationStyleToAutomatic", SetConfigurationStyleToAutomatic);
	Nan::SetPrototypeMethod(tpl, "setConfigurationStyleToAutomatic", SetConfigurationStyleToAutomatic);

	Nan::SetPrototypeMethod(tpl, "SetConfigurationStyleToLeafSize", SetConfigurationStyleToLeafSize);
	Nan::SetPrototypeMethod(tpl, "setConfigurationStyleToLeafSize", SetConfigurationStyleToLeafSize);

	Nan::SetPrototypeMethod(tpl, "SetConfigurationStyleToManual", SetConfigurationStyleToManual);
	Nan::SetPrototypeMethod(tpl, "setConfigurationStyleToManual", SetConfigurationStyleToManual);

	Nan::SetPrototypeMethod(tpl, "SetDivisions", SetDivisions);
	Nan::SetPrototypeMethod(tpl, "setDivisions", SetDivisions);

	Nan::SetPrototypeMethod(tpl, "SetKernel", SetKernel);
	Nan::SetPrototypeMethod(tpl, "setKernel", SetKernel);

	Nan::SetPrototypeMethod(tpl, "SetLeafSize", SetLeafSize);
	Nan::SetPrototypeMethod(tpl, "setLeafSize", SetLeafSize);

	Nan::SetPrototypeMethod(tpl, "SetNumberOfPointsPerBin", SetNumberOfPointsPerBin);
	Nan::SetPrototypeMethod(tpl, "setNumberOfPointsPerBin", SetNumberOfPointsPerBin);

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

void VtkVoxelGridWrap::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<vtkVoxelGrid> native = vtkSmartPointer<vtkVoxelGrid>::New();
		VtkVoxelGridWrap* obj = new VtkVoxelGridWrap(native);
		obj->Wrap(info.This());
	}
	else
	{
		if(info[0]->ToObject() != vtkNodeJsNoWrap )
		{
			Nan::ThrowError("Parameter Error");
			return;
		}
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

void VtkVoxelGridWrap::SetKernel(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkVoxelGridWrap *wrapper = ObjectWrap::Unwrap<VtkVoxelGridWrap>(info.Holder());
	vtkVoxelGrid *native = (vtkVoxelGrid *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkInterpolationKernelWrap::ptpl))->HasInstance(info[0]))
	{
		VtkInterpolationKernelWrap *a0 = ObjectWrap::Unwrap<VtkInterpolationKernelWrap>(info[0]->ToObject());
				if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		native->SetKernel(
			(vtkInterpolationKernel *) a0->native.GetPointer()
		);
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

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

				if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		native->SetLeafSize(
			(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[3];
		if( a0->Length() < 3 )
		{
			Nan::ThrowError("Array too short.");
			return;
		}

		for( i = 0; i < 3; 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->SetLeafSize(
			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)
				{
					Nan::ThrowError("Too many parameters.");
					return;
				}
				native->SetLeafSize(
					info[0]->NumberValue(),
					info[1]->NumberValue(),
					info[2]->NumberValue()
				);
				return;
			}
		}
	}
	Nan::ThrowError("Parameter mismatch");
}

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

