/* 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 "vtkTensorProbeRepresentationWrap.h"
#include "vtkEllipsoidTensorProbeRepresentationWrap.h"
#include "vtkObjectWrap.h"
#include "vtkViewportWrap.h"
#include "vtkPropCollectionWrap.h"
#include "vtkWindowWrap.h"
#include "../../plus/plus.h"

using namespace v8;

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

VtkEllipsoidTensorProbeRepresentationWrap::VtkEllipsoidTensorProbeRepresentationWrap()
{ }

VtkEllipsoidTensorProbeRepresentationWrap::VtkEllipsoidTensorProbeRepresentationWrap(vtkSmartPointer<vtkEllipsoidTensorProbeRepresentation> _native)
{ native = _native; }

VtkEllipsoidTensorProbeRepresentationWrap::~VtkEllipsoidTensorProbeRepresentationWrap()
{ }

void VtkEllipsoidTensorProbeRepresentationWrap::Init(v8::Local<v8::Object> exports)
{
	Nan::SetAccessor(exports, Nan::New("vtkEllipsoidTensorProbeRepresentation").ToLocalChecked(), ConstructorGetter);
	Nan::SetAccessor(exports, Nan::New("EllipsoidTensorProbeRepresentation").ToLocalChecked(), ConstructorGetter);
}

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

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

	Nan::SetPrototypeMethod(tpl, "BuildRepresentation", BuildRepresentation);
	Nan::SetPrototypeMethod(tpl, "buildRepresentation", BuildRepresentation);

	Nan::SetPrototypeMethod(tpl, "GetActors", GetActors);
	Nan::SetPrototypeMethod(tpl, "getActors", GetActors);

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

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

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

	Nan::SetPrototypeMethod(tpl, "ReleaseGraphicsResources", ReleaseGraphicsResources);
	Nan::SetPrototypeMethod(tpl, "releaseGraphicsResources", ReleaseGraphicsResources);

	Nan::SetPrototypeMethod(tpl, "RenderOpaqueGeometry", RenderOpaqueGeometry);
	Nan::SetPrototypeMethod(tpl, "renderOpaqueGeometry", RenderOpaqueGeometry);

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

	Nan::SetPrototypeMethod(tpl, "SelectProbe", SelectProbe);
	Nan::SetPrototypeMethod(tpl, "selectProbe", SelectProbe);

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

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

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

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

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

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

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

void VtkEllipsoidTensorProbeRepresentationWrap::RenderOpaqueGeometry(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkEllipsoidTensorProbeRepresentationWrap *wrapper = ObjectWrap::Unwrap<VtkEllipsoidTensorProbeRepresentationWrap>(info.Holder());
	vtkEllipsoidTensorProbeRepresentation *native = (vtkEllipsoidTensorProbeRepresentation *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkViewportWrap::ptpl))->HasInstance(info[0]))
	{
		VtkViewportWrap *a0 = ObjectWrap::Unwrap<VtkViewportWrap>(info[0]->ToObject());
		int r;
		if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		r = native->RenderOpaqueGeometry(
			(vtkViewport *) a0->native.GetPointer()
		);
		info.GetReturnValue().Set(Nan::New(r));
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

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

void VtkEllipsoidTensorProbeRepresentationWrap::SelectProbe(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkEllipsoidTensorProbeRepresentationWrap *wrapper = ObjectWrap::Unwrap<VtkEllipsoidTensorProbeRepresentationWrap>(info.Holder());
	vtkEllipsoidTensorProbeRepresentation *native = (vtkEllipsoidTensorProbeRepresentation *)wrapper->native.GetPointer();
	size_t i;
	if(info.Length() > 0 && info[0]->IsInt32Array())
	{
		v8::Local<v8::Int32Array>a0(v8::Local<v8::Int32Array>::Cast(info[0]->ToObject()));
		if( a0->Length() < 2 )
		{
			Nan::ThrowError("Array too short.");
			return;
		}

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

		for( i = 0; i < 2; i++ )
		{
			if( !a0->Get(i)->IsInt32() )
			{
				Nan::ThrowError("Array contents invalid.");
				return;
			}
			b0[i] = a0->Get(i)->Int32Value();
		}
		int r;
		if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		r = native->SelectProbe(
			b0
		);
		info.GetReturnValue().Set(Nan::New(r));
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

