]> git.mxchange.org Git - flightgear.git/blob - Triangulate/trisegs.hxx
First mostly successful tile triangulation works. There's plenty of tweaking
[flightgear.git] / Triangulate / trisegs.hxx
1 // trisegs.hxx -- "Triangle" segment 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 _TRISEGS_HXX
26 #define _TRISEGS_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 FG_USING_STD(vector);
39
40
41 // a segment is two integer pointers into the node list
42 class FGTriSeg {
43     int n1, n2;
44
45 public:
46
47     // Constructor and destructor
48     inline FGTriSeg( void ) { };
49     inline FGTriSeg( int i1, int i2 ) { n1 = i1; n2 = i2; }
50
51     inline ~FGTriSeg( void ) { };
52
53     inline int get_n1() const { return n1; }
54     inline void set_n1( int i ) { n1 = i; }
55     inline int get_n2() const { return n2; }
56     inline void set_n2( int i ) { n2 = i; }
57
58     friend bool operator == (const FGTriSeg& a, const FGTriSeg& b);
59
60 };
61
62 inline bool operator == (const FGTriSeg& a, const FGTriSeg& b)
63 {
64     return ((a.n1 == b.n1) && (a.n2 == b.n2)) 
65         || ((a.n1 == b.n2) && (a.n2 == b.n1));
66 }
67
68
69 typedef vector < FGTriSeg > triseg_list;
70 typedef triseg_list::iterator triseg_list_iterator;
71 typedef triseg_list::const_iterator const_triseg_list_iterator;
72
73
74 class FGTriSegments {
75
76 private:
77
78     triseg_list seg_list;
79
80 public:
81
82     // Constructor and destructor
83     FGTriSegments( void );
84     ~FGTriSegments( void );
85
86     // Add a point to the point list if it doesn't already exist.
87     // Returns the index (starting at zero) of the point in the list.
88     int unique_add( const FGTriSeg& s );
89
90     // return the master node list
91     inline triseg_list get_seg_list() const { return seg_list; }
92
93     // return the ith segment
94     inline FGTriSeg get_seg( int i ) const { return seg_list[i]; }
95 };
96
97
98 #endif // _TRISEGS_HXX
99
100
101 // $Log$
102 // Revision 1.2  1999/03/20 20:33:00  curt
103 // First mostly successful tile triangulation works.  There's plenty of tweaking
104 // to do, but we are marching in the right direction.
105 //
106 // Revision 1.1  1999/03/20 13:21:36  curt
107 // Initial revision.
108 //