/* 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 "vtkPlanesWrap.h"
#include "vtkPlanesIntersectionWrap.h"
#include "vtkObjectBaseWrap.h"
#include "vtkPointsWrap.h"
#include "vtkCellWrap.h"
#include "../../plus/plus.h"

using namespace v8;

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

VtkPlanesIntersectionWrap::VtkPlanesIntersectionWrap()
{ }

VtkPlanesIntersectionWrap::VtkPlanesIntersectionWrap(vtkSmartPointer<vtkPlanesIntersection> _native)
{ native = _native; }

VtkPlanesIntersectionWrap::~VtkPlanesIntersectionWrap()
{ }

void VtkPlanesIntersectionWrap::Init(v8::Local<v8::Object> exports)
{
	Nan::SetAccessor(exports, Nan::New("vtkPlanesIntersection").ToLocalChecked(), ConstructorGetter);
	Nan::SetAccessor(exports, Nan::New("PlanesIntersection").ToLocalChecked(), ConstructorGetter);
}

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

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

	Nan::SetPrototypeMethod(tpl, "Convert3DCell", Convert3DCell);
	Nan::SetPrototypeMethod(tpl, "convert3DCell", Convert3DCell);

	Nan::SetPrototypeMethod(tpl, "GetNumRegionVertices", GetNumRegionVertices);
	Nan::SetPrototypeMethod(tpl, "getNumRegionVertices", GetNumRegionVertices);

	Nan::SetPrototypeMethod(tpl, "GetNumberOfRegionVertices", GetNumberOfRegionVertices);
	Nan::SetPrototypeMethod(tpl, "getNumberOfRegionVertices", GetNumberOfRegionVertices);

	Nan::SetPrototypeMethod(tpl, "IntersectsRegion", IntersectsRegion);
	Nan::SetPrototypeMethod(tpl, "intersectsRegion", IntersectsRegion);

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

	Nan::SetPrototypeMethod(tpl, "PolygonIntersectsBBox", PolygonIntersectsBBox);
	Nan::SetPrototypeMethod(tpl, "polygonIntersectsBBox", PolygonIntersectsBBox);

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

	Nan::SetPrototypeMethod(tpl, "SetRegionVertices", SetRegionVertices);
	Nan::SetPrototypeMethod(tpl, "setRegionVertices", SetRegionVertices);

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

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

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

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

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

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

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

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

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

		if(info.Length() > 1 && info[1]->IsObject() && (Nan::New(VtkPointsWrap::ptpl))->HasInstance(info[1]))
		{
			VtkPointsWrap *a1 = ObjectWrap::Unwrap<VtkPointsWrap>(info[1]->ToObject());
			int r;
			if(info.Length() != 2)
			{
				Nan::ThrowError("Too many parameters.");
				return;
			}
			r = native->PolygonIntersectsBBox(
				(double *)(a0->Buffer()->GetContents().Data()),
				(vtkPoints *) a1->native.GetPointer()
			);
			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()));
		double b0[6];
		if( a0->Length() < 6 )
		{
			Nan::ThrowError("Array too short.");
			return;
		}

		for( i = 0; i < 6; i++ )
		{
			if( !a0->Get(i)->IsNumber() )
			{
				Nan::ThrowError("Array contents invalid.");
				return;
			}
			b0[i] = a0->Get(i)->NumberValue();
		}
		if(info.Length() > 1 && info[1]->IsObject() && (Nan::New(VtkPointsWrap::ptpl))->HasInstance(info[1]))
		{
			VtkPointsWrap *a1 = ObjectWrap::Unwrap<VtkPointsWrap>(info[1]->ToObject());
			int r;
			if(info.Length() != 2)
			{
				Nan::ThrowError("Too many parameters.");
				return;
			}
			r = native->PolygonIntersectsBBox(
				b0,
				(vtkPoints *) a1->native.GetPointer()
			);
			info.GetReturnValue().Set(Nan::New(r));
			return;
		}
	}
	Nan::ThrowError("Parameter mismatch");
}

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

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

