~ubuntu-branches/ubuntu/intrepid/blender/intrepid-updates

« back to all changes in this revision

Viewing changes to intern/bsp/intern/BSP_Triangulate.h

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-08-08 02:45:40 UTC
  • mfrom: (12.1.14 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080808024540-kkjp7ekfivzhuw3l
Tags: 2.46+dfsg-4
* Fix python syntax warning in import_dxf.py, which led to nasty output
  in installation/upgrade logs during byte-compilation, using a patch
  provided by the script author (Closes: #492280):
   - debian/patches/45_fix_python_syntax_warning

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * $Id: BSP_Triangulate.h,v 1.7 2005/10/28 20:18:56 intrr Exp $
3
 
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
4
 
 *
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
11
 
 * about this.
12
 
 *
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.
17
 
 *
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.
21
 
 *
22
 
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
23
 
 * All rights reserved.
24
 
 *
25
 
 * The Original Code is: all of this file.
26
 
 *
27
 
 * Contributor(s): none yet.
28
 
 *
29
 
 * ***** END GPL/BL DUAL LICENSE BLOCK *****
30
 
 */
31
 
 
32
 
#ifndef TRIANGULATE_H
33
 
 
34
 
 
35
 
#define TRIANGULATE_H
36
 
 
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
 
/*****************************************************************/
51
 
 
52
 
#include <vector>  // Include STL vector class.
53
 
#include "MT_Point3.h"
54
 
#include "BSP_MeshPrimitives.h"
55
 
 
56
 
class MT_Plane3;
57
 
 
58
 
class BSP_Triangulate
59
 
{
60
 
public:
61
 
 
62
 
        BSP_Triangulate(
63
 
        );
64
 
 
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.
68
 
 
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
71
 
        // indices.
72
 
        //
73
 
        // MT_Point3 global_array
74
 
        // vector<BSP_VertexInd> polygon
75
 
        // result is vector<int> into polygon.
76
 
 
77
 
                bool
78
 
        Process(
79
 
                const std::vector<BSP_MVertex> &verts,
80
 
                const BSP_VertexList &contour,
81
 
                const MT_Plane3 &normal,
82
 
                std::vector<int> &result
83
 
        );
84
 
        
85
 
        // compute area of a contour/polygon
86
 
                MT_Scalar 
87
 
        Area(
88
 
                const std::vector<BSP_MVertex> &verts,
89
 
                const BSP_VertexList &contour
90
 
        );
91
 
 
92
 
        // decide if point Px/Py is inside triangle defined by
93
 
        // (Ax,Ay) (Bx,By) (Cx,Cy)
94
 
 
95
 
                bool 
96
 
        InsideTriangle(
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
101
 
        );
102
 
 
103
 
        ~BSP_Triangulate(
104
 
        );
105
 
 
106
 
private:
107
 
 
108
 
                bool 
109
 
        Snip(
110
 
                const std::vector<BSP_MVertex> &verts,
111
 
                const BSP_VertexList &contour,
112
 
                int u,
113
 
                int v,
114
 
                int w,
115
 
                int n,
116
 
                int *V
117
 
        );
118
 
 
119
 
        int m_xi;
120
 
        int m_yi;
121
 
 
122
 
        // Temporary storage
123
 
 
124
 
        std::vector<int> m_V;
125
 
 
126
 
};
127
 
 
128
 
 
129
 
#endif
130