/*  $Id: delauney_triangulator.cpp,v 1.2 2004/04/07 21:43:51 mbn Exp $
**
**  ClanLib Game SDK
**  Copyright (C) 2003  The ClanLib Team
**  For a total list of contributers see the file CREDITS.
**
**  This library is free software; you can redistribute it and/or
**  modify it under the terms of the GNU Lesser General Public
**  License as published by the Free Software Foundation; either
**  version 2.1 of the License, or (at your option) any later version.
**
**  This library is distributed in the hope that it will be useful,
**  but WITHOUT ANY WARRANTY; without even the implied warranty of
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
**  Lesser General Public License for more details.
**
**  You should have received a copy of the GNU Lesser General Public
**  License along with this library; if not, write to the Free Software
**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
**
*/

#include "Core/precomp.h"
#include "API/Core/Math/delauney_triangulator.h"
#include "delauney_triangulator_generic.h"

/////////////////////////////////////////////////////////////////////////////
// CL_Delauney_Triangulator construction:

CL_DelauneyTriangulator::CL_DelauneyTriangulator() : impl(new CL_DelauneyTriangulator_Generic)
{
}

CL_DelauneyTriangulator::~CL_DelauneyTriangulator()
{
}

/////////////////////////////////////////////////////////////////////////////
// CL_DelauneyTriangulator attributes:

const std::vector<CL_DelauneyTriangulator_Vertex> &CL_DelauneyTriangulator::get_vertices() const
{
	return impl->input_vertices;
}

const std::vector<CL_DelauneyTriangulator_Triangle> &CL_DelauneyTriangulator::get_triangles() const
{
	return impl->triangles;
}

/////////////////////////////////////////////////////////////////////////////
// CL_DelauneyTriangulator operations:

void CL_DelauneyTriangulator::add_vertex(double x, double y, void *data)
{
	CL_DelauneyTriangulator_Vertex vertex;
	vertex.x = x;
	vertex.y = y;
	vertex.data = data;
	impl->input_vertices.push_back(vertex);
}

void CL_DelauneyTriangulator::generate()
{
	if (impl->input_vertices.empty()) return;
	impl->triangulate();
}

/////////////////////////////////////////////////////////////////////////////
// CL_DelauneyTriangulator implementation:
