Blame c++/contourgl/triangulator.h

Ivan Mahonin 8cd87e
/*
Ivan Mahonin 8cd87e
    ......... 2015 Ivan Mahonin
Ivan Mahonin 8cd87e
Ivan Mahonin 8cd87e
    This program is free software: you can redistribute it and/or modify
Ivan Mahonin 8cd87e
    it under the terms of the GNU General Public License as published by
Ivan Mahonin 8cd87e
    the Free Software Foundation, either version 3 of the License, or
Ivan Mahonin 8cd87e
    (at your option) any later version.
Ivan Mahonin 8cd87e
Ivan Mahonin 8cd87e
    This program is distributed in the hope that it will be useful,
Ivan Mahonin 8cd87e
    but WITHOUT ANY WARRANTY; without even the implied warranty of
Ivan Mahonin 8cd87e
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Ivan Mahonin 8cd87e
    GNU General Public License for more details.
Ivan Mahonin 8cd87e
Ivan Mahonin 8cd87e
    You should have received a copy of the GNU General Public License
Ivan Mahonin 8cd87e
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
Ivan Mahonin 8cd87e
*/
Ivan Mahonin 8cd87e
Ivan Mahonin 8cd87e
#ifndef _TRIANGULATOR_H_
Ivan Mahonin 8cd87e
#define _TRIANGULATOR_H_
Ivan Mahonin 8cd87e
Ivan Mahonin 8cd87e
#include <vector>
Ivan Mahonin 8cd87e
Ivan Mahonin 8cd87e
#include "geometry.h"
Ivan Mahonin 8cd87e
#include "contour.h"
Ivan Mahonin 8cd87e
Ivan Mahonin 8cd87e
class Triangulator {
Ivan Mahonin 8cd87e
public:
Ivan Mahonin 8cd87e
	class Vertex {
Ivan Mahonin 8cd87e
	public:
Ivan Mahonin 8cd87e
		int index;
Ivan Mahonin 8cd87e
		Vector p;
Ivan Mahonin 8cd87e
		Vertex *next;
Ivan Mahonin 8cd87e
		Vertex(): index(), next() { }
Ivan Mahonin 8cd87e
	};
Ivan Mahonin 8cd87e
Ivan Mahonin 8cd87e
	typedef std::vector<Vertex> Path;
Ivan Mahonin 8cd87e
	typedef std::vector<int> TriangleList;
Ivan Mahonin 8cd87e
Ivan Mahonin 8cd87e
	static bool intersect_lines(Vector a0, Vector a1, Vector b0, Vector b1);
Ivan Mahonin 8cd87e
	static void build_path(const Contour &contour, Path &path, int index_offset);
Ivan Mahonin 8cd87e
	static bool check_triangle(Vertex *first, TriangleList &triangles);
Ivan Mahonin 8cd87e
	static void split_path(Vertex *first, TriangleList &triangles);
Ivan Mahonin 8cd87e
	static void triangulate(const Contour &contour, TriangleList &triangles, int index_offset);
Ivan Mahonin 8cd87e
};
Ivan Mahonin 8cd87e
Ivan Mahonin 8cd87e
#endif