]> git.mxchange.org Git - flightgear.git/blob - Triangulate/tripoly.hxx
Added a mechanism to dump out the triangle structures for viewing.
[flightgear.git] / Triangulate / tripoly.hxx
1 // tripoly.hxx -- "Triangle" polygon management class
2 //
3 // Written by Curtis Olson, started March 1999.
4 //
5 // Copyright (C) 1999  Curtis L. Olson  - curt@flightgear.org
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22 // (Log is kept at end of this file)
23
24
25 #ifndef _TRIPOLY_HXX
26 #define _TRIPOLY_HXX
27
28
29 #ifndef __cplusplus                                                          
30 # error This library requires C++
31 #endif                                   
32
33
34 #include <Include/compiler.h>
35
36 #include <vector>
37
38 #include "trinodes.hxx"
39
40 FG_USING_STD(vector);
41
42
43 typedef vector < int > tripoly;
44 typedef tripoly::iterator tripoly_iterator;
45 typedef tripoly::const_iterator const_tripoly_iterator;
46
47
48 class FGTriPoly {
49
50 private:
51
52     tripoly poly;
53     Point3D inside;
54
55 public:
56
57     // Constructor and destructor
58     FGTriPoly( void );
59     ~FGTriPoly( void );
60
61     // Add the specified node (index) to the polygon
62     inline void add_node( int index ) { poly.push_back( index ); }
63
64     // return size
65     inline int size() const { return poly.size(); }
66
67     // return the ith polygon point index
68     inline int get_pt_index( int i ) const { return poly[i]; }
69
70     // calculate an "arbitrary" point inside this polygon for
71     // assigning attribute areas
72     void calc_point_inside( const FGTriNodes& trinodes );
73     inline Point3D get_point_inside() const { return inside; }
74
75     inline void erase() { poly.erase( poly.begin(), poly.end() ); }
76 };
77
78
79 #endif // _TRIPOLY_HXX
80
81
82 // $Log$
83 // Revision 1.3  1999/03/21 14:02:07  curt
84 // Added a mechanism to dump out the triangle structures for viewing.
85 // Fixed a couple bugs in first pass at triangulation.
86 // - needed to explicitely initialize the polygon accumulator in triangle.cxx
87 //   before each polygon rather than depending on the default behavior.
88 // - Fixed a problem with region attribute propagation where I wasn't generating
89 //   the hole points correctly.
90 //
91 // Revision 1.2  1999/03/20 20:32:58  curt
92 // First mostly successful tile triangulation works.  There's plenty of tweaking
93 // to do, but we are marching in the right direction.
94 //
95 // Revision 1.1  1999/03/20 13:21:36  curt
96 // Initial revision.
97 //