/* 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 "vtkStatisticsAlgorithmWrap.h"
#include "vtkKMeansStatisticsWrap.h"
#include "vtkObjectWrap.h"
#include "vtkKMeansDistanceFunctorWrap.h"
#include "vtkDataObjectCollectionWrap.h"
#include "vtkMultiBlockDataSetWrap.h"
#include "../../plus/plus.h"

using namespace v8;

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

VtkKMeansStatisticsWrap::VtkKMeansStatisticsWrap()
{ }

VtkKMeansStatisticsWrap::VtkKMeansStatisticsWrap(vtkSmartPointer<vtkKMeansStatistics> _native)
{ native = _native; }

VtkKMeansStatisticsWrap::~VtkKMeansStatisticsWrap()
{ }

void VtkKMeansStatisticsWrap::Init(v8::Local<v8::Object> exports)
{
	Nan::SetAccessor(exports, Nan::New("vtkKMeansStatistics").ToLocalChecked(), ConstructorGetter);
	Nan::SetAccessor(exports, Nan::New("KMeansStatistics").ToLocalChecked(), ConstructorGetter);
}

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

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

	Nan::SetPrototypeMethod(tpl, "Aggregate", Aggregate);
	Nan::SetPrototypeMethod(tpl, "aggregate", Aggregate);

	Nan::SetPrototypeMethod(tpl, "GetClassName", GetClassName);
	Nan::SetPrototypeMethod(tpl, "getClassName", GetClassName);

	Nan::SetPrototypeMethod(tpl, "GetDefaultNumberOfClusters", GetDefaultNumberOfClusters);
	Nan::SetPrototypeMethod(tpl, "getDefaultNumberOfClusters", GetDefaultNumberOfClusters);

	Nan::SetPrototypeMethod(tpl, "GetDistanceFunctor", GetDistanceFunctor);
	Nan::SetPrototypeMethod(tpl, "getDistanceFunctor", GetDistanceFunctor);

	Nan::SetPrototypeMethod(tpl, "GetKValuesArrayName", GetKValuesArrayName);
	Nan::SetPrototypeMethod(tpl, "getKValuesArrayName", GetKValuesArrayName);

	Nan::SetPrototypeMethod(tpl, "GetMaxNumIterations", GetMaxNumIterations);
	Nan::SetPrototypeMethod(tpl, "getMaxNumIterations", GetMaxNumIterations);

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

	Nan::SetPrototypeMethod(tpl, "IsA", IsA);
	Nan::SetPrototypeMethod(tpl, "isA", IsA);

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

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

	Nan::SetPrototypeMethod(tpl, "SetDefaultNumberOfClusters", SetDefaultNumberOfClusters);
	Nan::SetPrototypeMethod(tpl, "setDefaultNumberOfClusters", SetDefaultNumberOfClusters);

	Nan::SetPrototypeMethod(tpl, "SetDistanceFunctor", SetDistanceFunctor);
	Nan::SetPrototypeMethod(tpl, "setDistanceFunctor", SetDistanceFunctor);

	Nan::SetPrototypeMethod(tpl, "SetKValuesArrayName", SetKValuesArrayName);
	Nan::SetPrototypeMethod(tpl, "setKValuesArrayName", SetKValuesArrayName);

	Nan::SetPrototypeMethod(tpl, "SetMaxNumIterations", SetMaxNumIterations);
	Nan::SetPrototypeMethod(tpl, "setMaxNumIterations", SetMaxNumIterations);

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

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

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

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

void VtkKMeansStatisticsWrap::Aggregate(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkKMeansStatisticsWrap *wrapper = ObjectWrap::Unwrap<VtkKMeansStatisticsWrap>(info.Holder());
	vtkKMeansStatistics *native = (vtkKMeansStatistics *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkDataObjectCollectionWrap::ptpl))->HasInstance(info[0]))
	{
		VtkDataObjectCollectionWrap *a0 = ObjectWrap::Unwrap<VtkDataObjectCollectionWrap>(info[0]->ToObject());
		if(info.Length() > 1 && info[1]->IsObject() && (Nan::New(VtkMultiBlockDataSetWrap::ptpl))->HasInstance(info[1]))
		{
			VtkMultiBlockDataSetWrap *a1 = ObjectWrap::Unwrap<VtkMultiBlockDataSetWrap>(info[1]->ToObject());
						if(info.Length() != 2)
			{
				Nan::ThrowError("Too many parameters.");
				return;
			}
			native->Aggregate(
				(vtkDataObjectCollection *) a0->native.GetPointer(),
				(vtkMultiBlockDataSet *) a1->native.GetPointer()
			);
			return;
		}
	}
	Nan::ThrowError("Parameter mismatch");
}

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

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

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

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

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

void VtkKMeansStatisticsWrap::GetTolerance(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkKMeansStatisticsWrap *wrapper = ObjectWrap::Unwrap<VtkKMeansStatisticsWrap>(info.Holder());
	vtkKMeansStatistics *native = (vtkKMeansStatistics *)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 VtkKMeansStatisticsWrap::IsA(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkKMeansStatisticsWrap *wrapper = ObjectWrap::Unwrap<VtkKMeansStatisticsWrap>(info.Holder());
	vtkKMeansStatistics *native = (vtkKMeansStatistics *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsString())
	{
		Nan::Utf8String a0(info[0]);
		int r;
		if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		r = native->IsA(
			*a0
		);
		info.GetReturnValue().Set(Nan::New(r));
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

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

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

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

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

void VtkKMeansStatisticsWrap::SetKValuesArrayName(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkKMeansStatisticsWrap *wrapper = ObjectWrap::Unwrap<VtkKMeansStatisticsWrap>(info.Holder());
	vtkKMeansStatistics *native = (vtkKMeansStatistics *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsString())
	{
		Nan::Utf8String a0(info[0]);
				if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		native->SetKValuesArrayName(
			*a0
		);
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

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

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

