/* 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 "vtkGenericCutterWrap.h"
#include "vtkObjectBaseWrap.h"
#include "vtkImplicitFunctionWrap.h"
#include "vtkIncrementalPointLocatorWrap.h"
#include "../../plus/plus.h"

using namespace v8;

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

VtkGenericCutterWrap::VtkGenericCutterWrap()
{ }

VtkGenericCutterWrap::VtkGenericCutterWrap(vtkSmartPointer<vtkGenericCutter> _native)
{ native = _native; }

VtkGenericCutterWrap::~VtkGenericCutterWrap()
{ }

void VtkGenericCutterWrap::Init(v8::Local<v8::Object> exports)
{
	Nan::SetAccessor(exports, Nan::New("vtkGenericCutter").ToLocalChecked(), ConstructorGetter);
	Nan::SetAccessor(exports, Nan::New("GenericCutter").ToLocalChecked(), ConstructorGetter);
}

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

void VtkGenericCutterWrap::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("VtkGenericCutterWrap").ToLocalChecked());
	tpl->InstanceTemplate()->SetInternalFieldCount(1);

	Nan::SetPrototypeMethod(tpl, "CreateDefaultLocator", CreateDefaultLocator);
	Nan::SetPrototypeMethod(tpl, "createDefaultLocator", CreateDefaultLocator);

	Nan::SetPrototypeMethod(tpl, "GenerateCutScalarsOff", GenerateCutScalarsOff);
	Nan::SetPrototypeMethod(tpl, "generateCutScalarsOff", GenerateCutScalarsOff);

	Nan::SetPrototypeMethod(tpl, "GenerateCutScalarsOn", GenerateCutScalarsOn);
	Nan::SetPrototypeMethod(tpl, "generateCutScalarsOn", GenerateCutScalarsOn);

	Nan::SetPrototypeMethod(tpl, "GenerateValues", GenerateValues);
	Nan::SetPrototypeMethod(tpl, "generateValues", GenerateValues);

	Nan::SetPrototypeMethod(tpl, "GetCutFunction", GetCutFunction);
	Nan::SetPrototypeMethod(tpl, "getCutFunction", GetCutFunction);

	Nan::SetPrototypeMethod(tpl, "GetGenerateCutScalars", GetGenerateCutScalars);
	Nan::SetPrototypeMethod(tpl, "getGenerateCutScalars", GetGenerateCutScalars);

	Nan::SetPrototypeMethod(tpl, "GetLocator", GetLocator);
	Nan::SetPrototypeMethod(tpl, "getLocator", GetLocator);

	Nan::SetPrototypeMethod(tpl, "GetNumberOfContours", GetNumberOfContours);
	Nan::SetPrototypeMethod(tpl, "getNumberOfContours", GetNumberOfContours);

	Nan::SetPrototypeMethod(tpl, "GetValue", GetValue);
	Nan::SetPrototypeMethod(tpl, "getValue", GetValue);

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

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

	Nan::SetPrototypeMethod(tpl, "SetCutFunction", SetCutFunction);
	Nan::SetPrototypeMethod(tpl, "setCutFunction", SetCutFunction);

	Nan::SetPrototypeMethod(tpl, "SetGenerateCutScalars", SetGenerateCutScalars);
	Nan::SetPrototypeMethod(tpl, "setGenerateCutScalars", SetGenerateCutScalars);

	Nan::SetPrototypeMethod(tpl, "SetLocator", SetLocator);
	Nan::SetPrototypeMethod(tpl, "setLocator", SetLocator);

	Nan::SetPrototypeMethod(tpl, "SetNumberOfContours", SetNumberOfContours);
	Nan::SetPrototypeMethod(tpl, "setNumberOfContours", SetNumberOfContours);

	Nan::SetPrototypeMethod(tpl, "SetValue", SetValue);
	Nan::SetPrototypeMethod(tpl, "setValue", SetValue);

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

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

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

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

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

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

void VtkGenericCutterWrap::GenerateValues(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkGenericCutterWrap *wrapper = ObjectWrap::Unwrap<VtkGenericCutterWrap>(info.Holder());
	vtkGenericCutter *native = (vtkGenericCutter *)wrapper->native.GetPointer();
	size_t i;
	if(info.Length() > 0 && info[0]->IsInt32())
	{
		if(info.Length() > 1 && info[1]->IsFloat64Array())
		{
			v8::Local<v8::Float64Array>a1(v8::Local<v8::Float64Array>::Cast(info[1]->ToObject()));
			if( a1->Length() < 2 )
			{
				Nan::ThrowError("Array too short.");
				return;
			}

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

			for( i = 0; i < 2; i++ )
			{
				if( !a1->Get(i)->IsNumber() )
				{
					Nan::ThrowError("Array contents invalid.");
					return;
				}
				b1[i] = a1->Get(i)->NumberValue();
			}
						if(info.Length() != 2)
			{
				Nan::ThrowError("Too many parameters.");
				return;
			}
			native->GenerateValues(
				info[0]->Int32Value(),
				b1
			);
			return;
		}
		else 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->GenerateValues(
					info[0]->Int32Value(),
					info[1]->NumberValue(),
					info[2]->NumberValue()
				);
				return;
			}
		}
	}
	Nan::ThrowError("Parameter mismatch");
}

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

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

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

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

void VtkGenericCutterWrap::GetValue(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkGenericCutterWrap *wrapper = ObjectWrap::Unwrap<VtkGenericCutterWrap>(info.Holder());
	vtkGenericCutter *native = (vtkGenericCutter *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsInt32())
	{
		double r;
		if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		r = native->GetValue(
			info[0]->Int32Value()
		);
		info.GetReturnValue().Set(Nan::New(r));
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

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

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

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

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

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

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

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

