2
* $Id: BSP_Triangulate.h,v 1.7 2005/10/28 20:18:56 intrr Exp $
3
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version. The Blender
9
* Foundation also sells licenses for use in proprietary software under
10
* the Blender License. See http://www.blender.org/BL/ for information
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software Foundation,
20
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
23
* All rights reserved.
25
* The Original Code is: all of this file.
27
* Contributor(s): none yet.
29
* ***** END GPL/BL DUAL LICENSE BLOCK *****
37
/*****************************************************************/
38
/** Static class to triangulate any contour/polygon efficiently **/
39
/** You should replace Vector2d with whatever your own Vector **/
40
/** class might be. Does not support polygons with holes. **/
41
/** Uses STL vectors to represent a dynamic array of vertices. **/
42
/** This code snippet was submitted to FlipCode.com by **/
43
/** John W. Ratcliff (jratcliff@verant.com) on July 22, 2000 **/
44
/** I did not write the original code/algorithm for this **/
45
/** this triangulator, in fact, I can't even remember where I **/
46
/** found it in the first place. However, I did rework it into **/
47
/** the following black-box static class so you can make easy **/
48
/** use of it in your own code. Simply replace Vector2d with **/
49
/** whatever your own Vector implementation might be. **/
50
/*****************************************************************/
52
#include <vector> // Include STL vector class.
53
#include "MT_Point3.h"
54
#include "BSP_MeshPrimitives.h"
65
// triangulate a contour/polygon, places results in STL vector
66
// as series of triangles. IT uses the major axis of the normal
67
// to turn it into a 2d problem.
69
// Should chaange this to accept a point array and a list of
70
// indices into that point array. Result should be indices of those
73
// MT_Point3 global_array
74
// vector<BSP_VertexInd> polygon
75
// result is vector<int> into polygon.
79
const std::vector<BSP_MVertex> &verts,
80
const BSP_VertexList &contour,
81
const MT_Plane3 &normal,
82
std::vector<int> &result
85
// compute area of a contour/polygon
88
const std::vector<BSP_MVertex> &verts,
89
const BSP_VertexList &contour
92
// decide if point Px/Py is inside triangle defined by
93
// (Ax,Ay) (Bx,By) (Cx,Cy)
97
MT_Scalar Ax, MT_Scalar Ay,
98
MT_Scalar Bx, MT_Scalar By,
99
MT_Scalar Cx, MT_Scalar Cy,
100
MT_Scalar Px, MT_Scalar Py
110
const std::vector<BSP_MVertex> &verts,
111
const BSP_VertexList &contour,
124
std::vector<int> m_V;