/* 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 "vtkPCANormalEstimationWrap.h"
#include "vtkObjectBaseWrap.h"
#include "vtkAbstractPointLocatorWrap.h"
#include "../../plus/plus.h"

using namespace v8;

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

VtkPCANormalEstimationWrap::VtkPCANormalEstimationWrap()
{ }

VtkPCANormalEstimationWrap::VtkPCANormalEstimationWrap(vtkSmartPointer<vtkPCANormalEstimation> _native)
{ native = _native; }

VtkPCANormalEstimationWrap::~VtkPCANormalEstimationWrap()
{ }

void VtkPCANormalEstimationWrap::Init(v8::Local<v8::Object> exports)
{
	Nan::SetAccessor(exports, Nan::New("vtkPCANormalEstimation").ToLocalChecked(), ConstructorGetter);
	Nan::SetAccessor(exports, Nan::New("PCANormalEstimation").ToLocalChecked(), ConstructorGetter);
}

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

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

	Nan::SetPrototypeMethod(tpl, "FlipNormalsOff", FlipNormalsOff);
	Nan::SetPrototypeMethod(tpl, "flipNormalsOff", FlipNormalsOff);

	Nan::SetPrototypeMethod(tpl, "FlipNormalsOn", FlipNormalsOn);
	Nan::SetPrototypeMethod(tpl, "flipNormalsOn", FlipNormalsOn);

	Nan::SetPrototypeMethod(tpl, "GetFlipNormals", GetFlipNormals);
	Nan::SetPrototypeMethod(tpl, "getFlipNormals", GetFlipNormals);

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

	Nan::SetPrototypeMethod(tpl, "GetNormalOrientation", GetNormalOrientation);
	Nan::SetPrototypeMethod(tpl, "getNormalOrientation", GetNormalOrientation);

	Nan::SetPrototypeMethod(tpl, "GetOrientationPoint", GetOrientationPoint);
	Nan::SetPrototypeMethod(tpl, "getOrientationPoint", GetOrientationPoint);

	Nan::SetPrototypeMethod(tpl, "GetSampleSize", GetSampleSize);
	Nan::SetPrototypeMethod(tpl, "getSampleSize", GetSampleSize);

	Nan::SetPrototypeMethod(tpl, "GetSampleSizeMaxValue", GetSampleSizeMaxValue);
	Nan::SetPrototypeMethod(tpl, "getSampleSizeMaxValue", GetSampleSizeMaxValue);

	Nan::SetPrototypeMethod(tpl, "GetSampleSizeMinValue", GetSampleSizeMinValue);
	Nan::SetPrototypeMethod(tpl, "getSampleSizeMinValue", GetSampleSizeMinValue);

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

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

	Nan::SetPrototypeMethod(tpl, "SetFlipNormals", SetFlipNormals);
	Nan::SetPrototypeMethod(tpl, "setFlipNormals", SetFlipNormals);

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

	Nan::SetPrototypeMethod(tpl, "SetNormalOrientation", SetNormalOrientation);
	Nan::SetPrototypeMethod(tpl, "setNormalOrientation", SetNormalOrientation);

	Nan::SetPrototypeMethod(tpl, "SetNormalOrientationToAsComputed", SetNormalOrientationToAsComputed);
	Nan::SetPrototypeMethod(tpl, "setNormalOrientationToAsComputed", SetNormalOrientationToAsComputed);

	Nan::SetPrototypeMethod(tpl, "SetNormalOrientationToGraphTraversal", SetNormalOrientationToGraphTraversal);
	Nan::SetPrototypeMethod(tpl, "setNormalOrientationToGraphTraversal", SetNormalOrientationToGraphTraversal);

	Nan::SetPrototypeMethod(tpl, "SetNormalOrientationToPoint", SetNormalOrientationToPoint);
	Nan::SetPrototypeMethod(tpl, "setNormalOrientationToPoint", SetNormalOrientationToPoint);

	Nan::SetPrototypeMethod(tpl, "SetOrientationPoint", SetOrientationPoint);
	Nan::SetPrototypeMethod(tpl, "setOrientationPoint", SetOrientationPoint);

	Nan::SetPrototypeMethod(tpl, "SetSampleSize", SetSampleSize);
	Nan::SetPrototypeMethod(tpl, "setSampleSize", SetSampleSize);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

