]> git.mxchange.org Git - flightgear.git/blob - Triangulate/trinodes.cxx
Continued work on triangulation preparation.
[flightgear.git] / Triangulate / trinodes.cxx
1 // trinodes.cxx -- "Triangle" nodes 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 #include "trinodes.hxx"
26
27
28 // Constructor 
29 FGTriNodes::FGTriNodes( void ) {
30 }
31
32
33 // Destructor
34 FGTriNodes::~FGTriNodes( void ) {
35 }
36
37
38 // return true of the two points are "close enough" as defined by
39 // FG_PROXIMITY_EPSILON
40 inline bool FGTriNodes::close_enough( const Point3D& p1, const Point3D& p2 ) {
41     if ( ( fabs(p1.x() - p2.x()) < FG_PROXIMITY_EPSILON ) &&
42          ( fabs(p1.y() - p2.y()) < FG_PROXIMITY_EPSILON ) ) {
43         return true;
44     } else {
45         return false;
46     }
47 }
48
49
50 // Add a point to the point list if it doesn't already exist.  Returns
51 // the index (starting at zero) of the point in the list.
52 int FGTriNodes::unique_add( const Point3D& p ) {
53     point_iterator current, last;
54     int counter = 0;
55
56     // cout << p.x() << "," << p.y() << endl;
57
58     // see if point already exists
59     current = point_list.begin();
60     last = point_list.end();
61     for ( ; current != last; ++current ) {
62         if ( close_enough(p, *current) ) {
63             cout << "found an existing match!" << endl;
64             return counter;
65         }
66         
67         ++counter;
68     }
69
70     // add to list
71     point_list.push_back( p );
72
73     return counter;
74 }
75
76
77 // $Log$
78 // Revision 1.2  1999/03/19 00:27:12  curt
79 // Continued work on triangulation preparation.
80 //
81 // Revision 1.1  1999/03/17 23:52:00  curt
82 // Initial revision.
83 //
84
85