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

using namespace v8;

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

VtkFocalPlaneContourRepresentationWrap::VtkFocalPlaneContourRepresentationWrap()
{ }

VtkFocalPlaneContourRepresentationWrap::VtkFocalPlaneContourRepresentationWrap(vtkSmartPointer<vtkFocalPlaneContourRepresentation> _native)
{ native = _native; }

VtkFocalPlaneContourRepresentationWrap::~VtkFocalPlaneContourRepresentationWrap()
{ }

void VtkFocalPlaneContourRepresentationWrap::Init(v8::Local<v8::Object> exports)
{
	Nan::SetAccessor(exports, Nan::New("vtkFocalPlaneContourRepresentation").ToLocalChecked(), ConstructorGetter);
	Nan::SetAccessor(exports, Nan::New("FocalPlaneContourRepresentation").ToLocalChecked(), ConstructorGetter);
}

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

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

	Nan::SetPrototypeMethod(tpl, "GetIntermediatePointDisplayPosition", GetIntermediatePointDisplayPosition);
	Nan::SetPrototypeMethod(tpl, "getIntermediatePointDisplayPosition", GetIntermediatePointDisplayPosition);

	Nan::SetPrototypeMethod(tpl, "GetIntermediatePointWorldPosition", GetIntermediatePointWorldPosition);
	Nan::SetPrototypeMethod(tpl, "getIntermediatePointWorldPosition", GetIntermediatePointWorldPosition);

	Nan::SetPrototypeMethod(tpl, "GetNthNodeDisplayPosition", GetNthNodeDisplayPosition);
	Nan::SetPrototypeMethod(tpl, "getNthNodeDisplayPosition", GetNthNodeDisplayPosition);

	Nan::SetPrototypeMethod(tpl, "GetNthNodeWorldPosition", GetNthNodeWorldPosition);
	Nan::SetPrototypeMethod(tpl, "getNthNodeWorldPosition", GetNthNodeWorldPosition);

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

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

	Nan::SetPrototypeMethod(tpl, "UpdateContour", UpdateContour);
	Nan::SetPrototypeMethod(tpl, "updateContour", UpdateContour);

	Nan::SetPrototypeMethod(tpl, "UpdateContourWorldPositionsBasedOnDisplayPositions", UpdateContourWorldPositionsBasedOnDisplayPositions);
	Nan::SetPrototypeMethod(tpl, "updateContourWorldPositionsBasedOnDisplayPositions", UpdateContourWorldPositionsBasedOnDisplayPositions);

	Nan::SetPrototypeMethod(tpl, "UpdateLines", UpdateLines);
	Nan::SetPrototypeMethod(tpl, "updateLines", UpdateLines);

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

void VtkFocalPlaneContourRepresentationWrap::New(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	if(!info.IsConstructCall())
	{
		Nan::ThrowError("Constructor not called in a construct call.");
		return;
	}

	if(info.Length() == 0)
	{
		Nan::ThrowError("Cannot create instance of abstract class.");
		return;
	}
	else
	{
		if(info[0]->ToObject() != vtkNodeJsNoWrap )
		{
			Nan::ThrowError("Parameter Error");
			return;
		}
	}

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

void VtkFocalPlaneContourRepresentationWrap::GetIntermediatePointDisplayPosition(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkFocalPlaneContourRepresentationWrap *wrapper = ObjectWrap::Unwrap<VtkFocalPlaneContourRepresentationWrap>(info.Holder());
	vtkFocalPlaneContourRepresentation *native = (vtkFocalPlaneContourRepresentation *)wrapper->native.GetPointer();
	size_t i;
	if(info.Length() > 0 && info[0]->IsInt32())
	{
		if(info.Length() > 1 && info[1]->IsInt32())
		{
			if(info.Length() > 2 && info[2]->IsFloat64Array())
			{
				v8::Local<v8::Float64Array>a2(v8::Local<v8::Float64Array>::Cast(info[2]->ToObject()));
				if( a2->Length() < 3 )
				{
					Nan::ThrowError("Array too short.");
					return;
				}

				int r;
				if(info.Length() != 3)
				{
					Nan::ThrowError("Too many parameters.");
					return;
				}
				r = native->GetIntermediatePointDisplayPosition(
					info[0]->Int32Value(),
					info[1]->Int32Value(),
					(double *)(a2->Buffer()->GetContents().Data())
				);
				info.GetReturnValue().Set(Nan::New(r));
				return;
			}
			else if(info.Length() > 2 && info[2]->IsArray())
			{
				v8::Local<v8::Array>a2(v8::Local<v8::Array>::Cast(info[2]->ToObject()));
				double b2[3];
				if( a2->Length() < 3 )
				{
					Nan::ThrowError("Array too short.");
					return;
				}

				for( i = 0; i < 3; i++ )
				{
					if( !a2->Get(i)->IsNumber() )
					{
						Nan::ThrowError("Array contents invalid.");
						return;
					}
					b2[i] = a2->Get(i)->NumberValue();
				}
				int r;
				if(info.Length() != 3)
				{
					Nan::ThrowError("Too many parameters.");
					return;
				}
				r = native->GetIntermediatePointDisplayPosition(
					info[0]->Int32Value(),
					info[1]->Int32Value(),
					b2
				);
				info.GetReturnValue().Set(Nan::New(r));
				return;
			}
		}
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkFocalPlaneContourRepresentationWrap::GetIntermediatePointWorldPosition(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkFocalPlaneContourRepresentationWrap *wrapper = ObjectWrap::Unwrap<VtkFocalPlaneContourRepresentationWrap>(info.Holder());
	vtkFocalPlaneContourRepresentation *native = (vtkFocalPlaneContourRepresentation *)wrapper->native.GetPointer();
	size_t i;
	if(info.Length() > 0 && info[0]->IsInt32())
	{
		if(info.Length() > 1 && info[1]->IsInt32())
		{
			if(info.Length() > 2 && info[2]->IsFloat64Array())
			{
				v8::Local<v8::Float64Array>a2(v8::Local<v8::Float64Array>::Cast(info[2]->ToObject()));
				if( a2->Length() < 3 )
				{
					Nan::ThrowError("Array too short.");
					return;
				}

				int r;
				if(info.Length() != 3)
				{
					Nan::ThrowError("Too many parameters.");
					return;
				}
				r = native->GetIntermediatePointWorldPosition(
					info[0]->Int32Value(),
					info[1]->Int32Value(),
					(double *)(a2->Buffer()->GetContents().Data())
				);
				info.GetReturnValue().Set(Nan::New(r));
				return;
			}
			else if(info.Length() > 2 && info[2]->IsArray())
			{
				v8::Local<v8::Array>a2(v8::Local<v8::Array>::Cast(info[2]->ToObject()));
				double b2[3];
				if( a2->Length() < 3 )
				{
					Nan::ThrowError("Array too short.");
					return;
				}

				for( i = 0; i < 3; i++ )
				{
					if( !a2->Get(i)->IsNumber() )
					{
						Nan::ThrowError("Array contents invalid.");
						return;
					}
					b2[i] = a2->Get(i)->NumberValue();
				}
				int r;
				if(info.Length() != 3)
				{
					Nan::ThrowError("Too many parameters.");
					return;
				}
				r = native->GetIntermediatePointWorldPosition(
					info[0]->Int32Value(),
					info[1]->Int32Value(),
					b2
				);
				info.GetReturnValue().Set(Nan::New(r));
				return;
			}
		}
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkFocalPlaneContourRepresentationWrap::GetNthNodeDisplayPosition(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkFocalPlaneContourRepresentationWrap *wrapper = ObjectWrap::Unwrap<VtkFocalPlaneContourRepresentationWrap>(info.Holder());
	vtkFocalPlaneContourRepresentation *native = (vtkFocalPlaneContourRepresentation *)wrapper->native.GetPointer();
	size_t i;
	if(info.Length() > 0 && info[0]->IsInt32())
	{
		if(info.Length() > 1 && info[1]->IsFloat64Array())
		{
			v8::Local<v8::Float64Array>a1(v8::Local<v8::Float64Array>::Cast(info[1]->ToObject()));
			if( a1->Length() < 2 )
			{
				Nan::ThrowError("Array too short.");
				return;
			}

			int r;
			if(info.Length() != 2)
			{
				Nan::ThrowError("Too many parameters.");
				return;
			}
			r = native->GetNthNodeDisplayPosition(
				info[0]->Int32Value(),
				(double *)(a1->Buffer()->GetContents().Data())
			);
			info.GetReturnValue().Set(Nan::New(r));
			return;
		}
		else if(info.Length() > 1 && info[1]->IsArray())
		{
			v8::Local<v8::Array>a1(v8::Local<v8::Array>::Cast(info[1]->ToObject()));
			double b1[2];
			if( a1->Length() < 2 )
			{
				Nan::ThrowError("Array too short.");
				return;
			}

			for( i = 0; i < 2; i++ )
			{
				if( !a1->Get(i)->IsNumber() )
				{
					Nan::ThrowError("Array contents invalid.");
					return;
				}
				b1[i] = a1->Get(i)->NumberValue();
			}
			int r;
			if(info.Length() != 2)
			{
				Nan::ThrowError("Too many parameters.");
				return;
			}
			r = native->GetNthNodeDisplayPosition(
				info[0]->Int32Value(),
				b1
			);
			info.GetReturnValue().Set(Nan::New(r));
			return;
		}
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkFocalPlaneContourRepresentationWrap::GetNthNodeWorldPosition(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkFocalPlaneContourRepresentationWrap *wrapper = ObjectWrap::Unwrap<VtkFocalPlaneContourRepresentationWrap>(info.Holder());
	vtkFocalPlaneContourRepresentation *native = (vtkFocalPlaneContourRepresentation *)wrapper->native.GetPointer();
	size_t i;
	if(info.Length() > 0 && info[0]->IsInt32())
	{
		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;
			}

			int r;
			if(info.Length() != 2)
			{
				Nan::ThrowError("Too many parameters.");
				return;
			}
			r = native->GetNthNodeWorldPosition(
				info[0]->Int32Value(),
				(double *)(a1->Buffer()->GetContents().Data())
			);
			info.GetReturnValue().Set(Nan::New(r));
			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();
			}
			int r;
			if(info.Length() != 2)
			{
				Nan::ThrowError("Too many parameters.");
				return;
			}
			r = native->GetNthNodeWorldPosition(
				info[0]->Int32Value(),
				b1
			);
			info.GetReturnValue().Set(Nan::New(r));
			return;
		}
	}
	Nan::ThrowError("Parameter mismatch");
}

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

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

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

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

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

