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

using namespace v8;

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

VtkImplicitSelectionLoopWrap::VtkImplicitSelectionLoopWrap()
{ }

VtkImplicitSelectionLoopWrap::VtkImplicitSelectionLoopWrap(vtkSmartPointer<vtkImplicitSelectionLoop> _native)
{ native = _native; }

VtkImplicitSelectionLoopWrap::~VtkImplicitSelectionLoopWrap()
{ }

void VtkImplicitSelectionLoopWrap::Init(v8::Local<v8::Object> exports)
{
	Nan::SetAccessor(exports, Nan::New("vtkImplicitSelectionLoop").ToLocalChecked(), ConstructorGetter);
	Nan::SetAccessor(exports, Nan::New("ImplicitSelectionLoop").ToLocalChecked(), ConstructorGetter);
}

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

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

	Nan::SetPrototypeMethod(tpl, "AutomaticNormalGenerationOff", AutomaticNormalGenerationOff);
	Nan::SetPrototypeMethod(tpl, "automaticNormalGenerationOff", AutomaticNormalGenerationOff);

	Nan::SetPrototypeMethod(tpl, "AutomaticNormalGenerationOn", AutomaticNormalGenerationOn);
	Nan::SetPrototypeMethod(tpl, "automaticNormalGenerationOn", AutomaticNormalGenerationOn);

	Nan::SetPrototypeMethod(tpl, "EvaluateFunction", EvaluateFunction);
	Nan::SetPrototypeMethod(tpl, "evaluateFunction", EvaluateFunction);

	Nan::SetPrototypeMethod(tpl, "EvaluateGradient", EvaluateGradient);
	Nan::SetPrototypeMethod(tpl, "evaluateGradient", EvaluateGradient);

	Nan::SetPrototypeMethod(tpl, "GetAutomaticNormalGeneration", GetAutomaticNormalGeneration);
	Nan::SetPrototypeMethod(tpl, "getAutomaticNormalGeneration", GetAutomaticNormalGeneration);

	Nan::SetPrototypeMethod(tpl, "GetLoop", GetLoop);
	Nan::SetPrototypeMethod(tpl, "getLoop", GetLoop);

	Nan::SetPrototypeMethod(tpl, "GetNormal", GetNormal);
	Nan::SetPrototypeMethod(tpl, "getNormal", GetNormal);

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

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

	Nan::SetPrototypeMethod(tpl, "SetAutomaticNormalGeneration", SetAutomaticNormalGeneration);
	Nan::SetPrototypeMethod(tpl, "setAutomaticNormalGeneration", SetAutomaticNormalGeneration);

	Nan::SetPrototypeMethod(tpl, "SetLoop", SetLoop);
	Nan::SetPrototypeMethod(tpl, "setLoop", SetLoop);

	Nan::SetPrototypeMethod(tpl, "SetNormal", SetNormal);
	Nan::SetPrototypeMethod(tpl, "setNormal", SetNormal);

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

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

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

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

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

void VtkImplicitSelectionLoopWrap::EvaluateFunction(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkImplicitSelectionLoopWrap *wrapper = ObjectWrap::Unwrap<VtkImplicitSelectionLoopWrap>(info.Holder());
	vtkImplicitSelectionLoop *native = (vtkImplicitSelectionLoop *)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;
		}

		double r;
		if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		r = native->EvaluateFunction(
			(double *)(a0->Buffer()->GetContents().Data())
		);
		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()));
		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();
		}
		double r;
		if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		r = native->EvaluateFunction(
			b0
		);
		info.GetReturnValue().Set(Nan::New(r));
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkImplicitSelectionLoopWrap::EvaluateGradient(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkImplicitSelectionLoopWrap *wrapper = ObjectWrap::Unwrap<VtkImplicitSelectionLoopWrap>(info.Holder());
	vtkImplicitSelectionLoop *native = (vtkImplicitSelectionLoop *)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 && info[1]->IsFloat64Array())
		{
			v8::Local<v8::Float64Array>a1(v8::Local<v8::Float64Array>::Cast(info[1]->ToObject()));
			if( a1->Length() < 3 )
			{
				Nan::ThrowError("Array too short.");
				return;
			}

						if(info.Length() != 2)
			{
				Nan::ThrowError("Too many parameters.");
				return;
			}
			native->EvaluateGradient(
				(double *)(a0->Buffer()->GetContents().Data()),
				(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[3];
			if( a1->Length() < 3 )
			{
				Nan::ThrowError("Array too short.");
				return;
			}

			for( i = 0; i < 3; 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->EvaluateGradient(
				(double *)(a0->Buffer()->GetContents().Data()),
				b1
			);
			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 && info[1]->IsArray())
		{
			v8::Local<v8::Array>a1(v8::Local<v8::Array>::Cast(info[1]->ToObject()));
			double b1[3];
			if( a1->Length() < 3 )
			{
				Nan::ThrowError("Array too short.");
				return;
			}

			for( i = 0; i < 3; 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->EvaluateGradient(
				b0,
				b1
			);
			return;
		}
		else if(info.Length() > 1 && info[1]->IsFloat64Array())
		{
			v8::Local<v8::Float64Array>a1(v8::Local<v8::Float64Array>::Cast(info[1]->ToObject()));
			if( a1->Length() < 3 )
			{
				Nan::ThrowError("Array too short.");
				return;
			}

						if(info.Length() != 2)
			{
				Nan::ThrowError("Too many parameters.");
				return;
			}
			native->EvaluateGradient(
				b0,
				(double *)(a1->Buffer()->GetContents().Data())
			);
			return;
		}
	}
	Nan::ThrowError("Parameter mismatch");
}

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

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

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

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

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

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

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

