/* 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 "vtkImageHistogramWrap.h"
#include "vtkImageHistogramStatisticsWrap.h"
#include "vtkObjectWrap.h"
#include "../../plus/plus.h"

using namespace v8;

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

VtkImageHistogramStatisticsWrap::VtkImageHistogramStatisticsWrap()
{ }

VtkImageHistogramStatisticsWrap::VtkImageHistogramStatisticsWrap(vtkSmartPointer<vtkImageHistogramStatistics> _native)
{ native = _native; }

VtkImageHistogramStatisticsWrap::~VtkImageHistogramStatisticsWrap()
{ }

void VtkImageHistogramStatisticsWrap::Init(v8::Local<v8::Object> exports)
{
	Nan::SetAccessor(exports, Nan::New("vtkImageHistogramStatistics").ToLocalChecked(), ConstructorGetter);
	Nan::SetAccessor(exports, Nan::New("ImageHistogramStatistics").ToLocalChecked(), ConstructorGetter);
}

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

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

	Nan::SetPrototypeMethod(tpl, "GetAutoRange", GetAutoRange);
	Nan::SetPrototypeMethod(tpl, "getAutoRange", GetAutoRange);

	Nan::SetPrototypeMethod(tpl, "GetAutoRangeExpansionFactors", GetAutoRangeExpansionFactors);
	Nan::SetPrototypeMethod(tpl, "getAutoRangeExpansionFactors", GetAutoRangeExpansionFactors);

	Nan::SetPrototypeMethod(tpl, "GetAutoRangePercentiles", GetAutoRangePercentiles);
	Nan::SetPrototypeMethod(tpl, "getAutoRangePercentiles", GetAutoRangePercentiles);

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

	Nan::SetPrototypeMethod(tpl, "GetMaximum", GetMaximum);
	Nan::SetPrototypeMethod(tpl, "getMaximum", GetMaximum);

	Nan::SetPrototypeMethod(tpl, "GetMean", GetMean);
	Nan::SetPrototypeMethod(tpl, "getMean", GetMean);

	Nan::SetPrototypeMethod(tpl, "GetMedian", GetMedian);
	Nan::SetPrototypeMethod(tpl, "getMedian", GetMedian);

	Nan::SetPrototypeMethod(tpl, "GetMinimum", GetMinimum);
	Nan::SetPrototypeMethod(tpl, "getMinimum", GetMinimum);

	Nan::SetPrototypeMethod(tpl, "GetStandardDeviation", GetStandardDeviation);
	Nan::SetPrototypeMethod(tpl, "getStandardDeviation", GetStandardDeviation);

	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, "SetAutoRangeExpansionFactors", SetAutoRangeExpansionFactors);
	Nan::SetPrototypeMethod(tpl, "setAutoRangeExpansionFactors", SetAutoRangeExpansionFactors);

	Nan::SetPrototypeMethod(tpl, "SetAutoRangePercentiles", SetAutoRangePercentiles);
	Nan::SetPrototypeMethod(tpl, "setAutoRangePercentiles", SetAutoRangePercentiles);

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

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

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

void VtkImageHistogramStatisticsWrap::GetAutoRange(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkImageHistogramStatisticsWrap *wrapper = ObjectWrap::Unwrap<VtkImageHistogramStatisticsWrap>(info.Holder());
	vtkImageHistogramStatistics *native = (vtkImageHistogramStatistics *)wrapper->native.GetPointer();
	double const * r;
	if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	r = native->GetAutoRange();
	Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(v8::Isolate::GetCurrent(), 2 * sizeof(double));
	Local<v8::Float64Array> at = v8::Float64Array::New(ab, 0, 2);
	memcpy(ab->GetContents().Data(), r, 2 * sizeof(double));
	info.GetReturnValue().Set(at);
}

void VtkImageHistogramStatisticsWrap::GetAutoRangeExpansionFactors(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkImageHistogramStatisticsWrap *wrapper = ObjectWrap::Unwrap<VtkImageHistogramStatisticsWrap>(info.Holder());
	vtkImageHistogramStatistics *native = (vtkImageHistogramStatistics *)wrapper->native.GetPointer();
	double const * r;
	if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	r = native->GetAutoRangeExpansionFactors();
	Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(v8::Isolate::GetCurrent(), 2 * sizeof(double));
	Local<v8::Float64Array> at = v8::Float64Array::New(ab, 0, 2);
	memcpy(ab->GetContents().Data(), r, 2 * sizeof(double));
	info.GetReturnValue().Set(at);
}

void VtkImageHistogramStatisticsWrap::GetAutoRangePercentiles(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkImageHistogramStatisticsWrap *wrapper = ObjectWrap::Unwrap<VtkImageHistogramStatisticsWrap>(info.Holder());
	vtkImageHistogramStatistics *native = (vtkImageHistogramStatistics *)wrapper->native.GetPointer();
	double const * r;
	if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	r = native->GetAutoRangePercentiles();
	Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(v8::Isolate::GetCurrent(), 2 * sizeof(double));
	Local<v8::Float64Array> at = v8::Float64Array::New(ab, 0, 2);
	memcpy(ab->GetContents().Data(), r, 2 * sizeof(double));
	info.GetReturnValue().Set(at);
}

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

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

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

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

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

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

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

void VtkImageHistogramStatisticsWrap::SetAutoRangeExpansionFactors(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkImageHistogramStatisticsWrap *wrapper = ObjectWrap::Unwrap<VtkImageHistogramStatisticsWrap>(info.Holder());
	vtkImageHistogramStatistics *native = (vtkImageHistogramStatistics *)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() < 2 )
		{
			Nan::ThrowError("Array too short.");
			return;
		}

				if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		native->SetAutoRangeExpansionFactors(
			(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[2];
		if( a0->Length() < 2 )
		{
			Nan::ThrowError("Array too short.");
			return;
		}

		for( i = 0; i < 2; 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->SetAutoRangeExpansionFactors(
			b0
		);
		return;
	}
	else if(info.Length() > 0 && info[0]->IsNumber())
	{
		if(info.Length() > 1 && info[1]->IsNumber())
		{
						if(info.Length() != 2)
			{
				Nan::ThrowError("Too many parameters.");
				return;
			}
			native->SetAutoRangeExpansionFactors(
				info[0]->NumberValue(),
				info[1]->NumberValue()
			);
			return;
		}
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkImageHistogramStatisticsWrap::SetAutoRangePercentiles(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkImageHistogramStatisticsWrap *wrapper = ObjectWrap::Unwrap<VtkImageHistogramStatisticsWrap>(info.Holder());
	vtkImageHistogramStatistics *native = (vtkImageHistogramStatistics *)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() < 2 )
		{
			Nan::ThrowError("Array too short.");
			return;
		}

				if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		native->SetAutoRangePercentiles(
			(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[2];
		if( a0->Length() < 2 )
		{
			Nan::ThrowError("Array too short.");
			return;
		}

		for( i = 0; i < 2; 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->SetAutoRangePercentiles(
			b0
		);
		return;
	}
	else if(info.Length() > 0 && info[0]->IsNumber())
	{
		if(info.Length() > 1 && info[1]->IsNumber())
		{
						if(info.Length() != 2)
			{
				Nan::ThrowError("Too many parameters.");
				return;
			}
			native->SetAutoRangePercentiles(
				info[0]->NumberValue(),
				info[1]->NumberValue()
			);
			return;
		}
	}
	Nan::ThrowError("Parameter mismatch");
}

