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

using namespace v8;

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

VtkLinearSelectorWrap::VtkLinearSelectorWrap()
{ }

VtkLinearSelectorWrap::VtkLinearSelectorWrap(vtkSmartPointer<vtkLinearSelector> _native)
{ native = _native; }

VtkLinearSelectorWrap::~VtkLinearSelectorWrap()
{ }

void VtkLinearSelectorWrap::Init(v8::Local<v8::Object> exports)
{
	Nan::SetAccessor(exports, Nan::New("vtkLinearSelector").ToLocalChecked(), ConstructorGetter);
	Nan::SetAccessor(exports, Nan::New("LinearSelector").ToLocalChecked(), ConstructorGetter);
}

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

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

	Nan::SetPrototypeMethod(tpl, "GetEndPoint", GetEndPoint);
	Nan::SetPrototypeMethod(tpl, "getEndPoint", GetEndPoint);

	Nan::SetPrototypeMethod(tpl, "GetIncludeVertices", GetIncludeVertices);
	Nan::SetPrototypeMethod(tpl, "getIncludeVertices", GetIncludeVertices);

	Nan::SetPrototypeMethod(tpl, "GetPoints", GetPoints);
	Nan::SetPrototypeMethod(tpl, "getPoints", GetPoints);

	Nan::SetPrototypeMethod(tpl, "GetStartPoint", GetStartPoint);
	Nan::SetPrototypeMethod(tpl, "getStartPoint", GetStartPoint);

	Nan::SetPrototypeMethod(tpl, "GetTolerance", GetTolerance);
	Nan::SetPrototypeMethod(tpl, "getTolerance", GetTolerance);

	Nan::SetPrototypeMethod(tpl, "GetVertexEliminationTolerance", GetVertexEliminationTolerance);
	Nan::SetPrototypeMethod(tpl, "getVertexEliminationTolerance", GetVertexEliminationTolerance);

	Nan::SetPrototypeMethod(tpl, "GetVertexEliminationToleranceMaxValue", GetVertexEliminationToleranceMaxValue);
	Nan::SetPrototypeMethod(tpl, "getVertexEliminationToleranceMaxValue", GetVertexEliminationToleranceMaxValue);

	Nan::SetPrototypeMethod(tpl, "GetVertexEliminationToleranceMinValue", GetVertexEliminationToleranceMinValue);
	Nan::SetPrototypeMethod(tpl, "getVertexEliminationToleranceMinValue", GetVertexEliminationToleranceMinValue);

	Nan::SetPrototypeMethod(tpl, "IncludeVerticesOff", IncludeVerticesOff);
	Nan::SetPrototypeMethod(tpl, "includeVerticesOff", IncludeVerticesOff);

	Nan::SetPrototypeMethod(tpl, "IncludeVerticesOn", IncludeVerticesOn);
	Nan::SetPrototypeMethod(tpl, "includeVerticesOn", IncludeVerticesOn);

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

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

	Nan::SetPrototypeMethod(tpl, "SetEndPoint", SetEndPoint);
	Nan::SetPrototypeMethod(tpl, "setEndPoint", SetEndPoint);

	Nan::SetPrototypeMethod(tpl, "SetIncludeVertices", SetIncludeVertices);
	Nan::SetPrototypeMethod(tpl, "setIncludeVertices", SetIncludeVertices);

	Nan::SetPrototypeMethod(tpl, "SetPoints", SetPoints);
	Nan::SetPrototypeMethod(tpl, "setPoints", SetPoints);

	Nan::SetPrototypeMethod(tpl, "SetStartPoint", SetStartPoint);
	Nan::SetPrototypeMethod(tpl, "setStartPoint", SetStartPoint);

	Nan::SetPrototypeMethod(tpl, "SetTolerance", SetTolerance);
	Nan::SetPrototypeMethod(tpl, "setTolerance", SetTolerance);

	Nan::SetPrototypeMethod(tpl, "SetVertexEliminationTolerance", SetVertexEliminationTolerance);
	Nan::SetPrototypeMethod(tpl, "setVertexEliminationTolerance", SetVertexEliminationTolerance);

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

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

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

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

void VtkLinearSelectorWrap::GetPoints(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkLinearSelectorWrap *wrapper = ObjectWrap::Unwrap<VtkLinearSelectorWrap>(info.Holder());
	vtkLinearSelector *native = (vtkLinearSelector *)wrapper->native.GetPointer();
	vtkPoints * r;
	if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	r = native->GetPoints();
	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 VtkLinearSelectorWrap::GetStartPoint(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkLinearSelectorWrap *wrapper = ObjectWrap::Unwrap<VtkLinearSelectorWrap>(info.Holder());
	vtkLinearSelector *native = (vtkLinearSelector *)wrapper->native.GetPointer();
	double const * r;
	if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	r = native->GetStartPoint();
	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 VtkLinearSelectorWrap::GetTolerance(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkLinearSelectorWrap *wrapper = ObjectWrap::Unwrap<VtkLinearSelectorWrap>(info.Holder());
	vtkLinearSelector *native = (vtkLinearSelector *)wrapper->native.GetPointer();
	double r;
	if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	r = native->GetTolerance();
	info.GetReturnValue().Set(Nan::New(r));
}

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

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

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

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

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

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

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

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

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

void VtkLinearSelectorWrap::SetPoints(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkLinearSelectorWrap *wrapper = ObjectWrap::Unwrap<VtkLinearSelectorWrap>(info.Holder());
	vtkLinearSelector *native = (vtkLinearSelector *)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->SetPoints(
			(vtkPoints *) a0->native.GetPointer()
		);
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

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

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

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

