1 // triangle.cxx -- "Triangle" interface class
3 // Written by Curtis Olson, started March 1999.
5 // Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
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.
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.
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.
22 // (Log is kept at end of this file)
25 #include "triangle.hxx"
29 FGTriangle::FGTriangle( void ) {
34 FGTriangle::~FGTriangle( void ) {
38 // populate this class based on the specified gpc_polys list
39 int FGTriangle::build( const FGgpcPolyList& gpc_polys ) {
43 // traverse the gpc_polys and build a unified node list and a set
44 // of Triangle PSLG that reference the node list by index
47 gpc_polygon *gpc_poly;
48 const_gpcpoly_iterator current, last;
50 // process polygons in priority order
51 cout << "prepairing node list and polygons" << endl;
53 for ( int i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
54 cout << "area type = " << i << endl;
55 current = gpc_polys.polys[i].begin();
56 last = gpc_polys.polys[i].end();
57 for ( ; current != last; ++current ) {
59 cout << "processing a polygon, contours = "
60 << gpc_poly->num_contours << endl;
62 poly.erase(poly.begin(), poly.end());
64 if (gpc_poly->num_contours <= 0 ) {
65 cout << "FATAL ERROR! no contours in this polygon" << endl;
69 if (gpc_poly->num_contours > 1 ) {
70 cout << "FATAL ERROR! no multi-contour support" << endl;
74 for ( int j = 0; j < gpc_poly->num_contours; j++ ) {
75 for ( int k = 0; k < gpc_poly->contour[j].num_vertices; k++ ) {
76 Point3D p( gpc_poly->contour[j].vertex[k].x,
77 gpc_poly->contour[j].vertex[k].y,
79 index = trinodes.unique_add( p );
80 poly.push_back(index);
81 // cout << index << endl;
83 polylist[i].push_back(poly);
88 for ( int i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
89 cout << "polylist[" << i << "] = " << polylist[i].size() << endl;
96 // Revision 1.3 1999/03/19 00:27:10 curt
97 // Continued work on triangulation preparation.
99 // Revision 1.2 1999/03/18 04:31:11 curt
100 // Let's not pass copies of huge structures on the stack ... ye might see a
103 // Revision 1.1 1999/03/17 23:51:59 curt