Initial revision.
This commit is contained in:
parent
24597f6854
commit
7e237e7572
5 changed files with 320 additions and 0 deletions
10
Triangulate/Makefile.am
Normal file
10
Triangulate/Makefile.am
Normal file
|
@ -0,0 +1,10 @@
|
|||
noinst_LIBRARIES = libTriangulate.a
|
||||
|
||||
libTriangulate_a_SOURCES = \
|
||||
triangle.cxx triangle.hxx \
|
||||
trinodes.cxx trinodes.hxx
|
||||
|
||||
INCLUDES += \
|
||||
-I$(top_builddir) \
|
||||
-I$(top_builddir)/Lib \
|
||||
-I$(top_builddir)/Tools/Construct
|
73
Triangulate/triangle.cxx
Normal file
73
Triangulate/triangle.cxx
Normal file
|
@ -0,0 +1,73 @@
|
|||
// triangle.cxx -- "Triangle" interface class
|
||||
//
|
||||
// Written by Curtis Olson, started March 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
// (Log is kept at end of this file)
|
||||
|
||||
|
||||
#include "triangle.hxx"
|
||||
|
||||
|
||||
// Constructor
|
||||
FGTriangle::FGTriangle( void ) {
|
||||
}
|
||||
|
||||
|
||||
// Destructor
|
||||
FGTriangle::~FGTriangle( void ) {
|
||||
}
|
||||
|
||||
|
||||
// populate this class based on the specified gpc_polys list
|
||||
int FGTriangle::build( FGgpcPolyList gpc_polys ) {
|
||||
// traverse the gpc_polys and build a unified node list and a set
|
||||
// of Triangle PSLG that reference the node list by index
|
||||
// (starting at zero)
|
||||
|
||||
gpc_polygon *gpc_poly;
|
||||
gpcpoly_iterator current, last;
|
||||
|
||||
// process polygons in priority order
|
||||
cout << "prepairing node list and polygons" << endl;
|
||||
|
||||
for ( int i = 0; i < FG_MAX_AREAS; ++i ) {
|
||||
cout << "area type = " << i << endl;
|
||||
current = gpc_polys.polys[i].begin();
|
||||
last = gpc_polys.polys[i].end();
|
||||
for ( ; current != last; ++current ) {
|
||||
gpc_poly = *current;
|
||||
|
||||
for ( int j = 0; j < gpc_poly->num_contours; j++ ) {
|
||||
for ( int k = 0; k < gpc_poly->contour[j].num_vertices; k++ ) {
|
||||
Point3D p( gpc_poly->contour[j].vertex[k].x,
|
||||
gpc_poly->contour[j].vertex[k].y,
|
||||
0 );
|
||||
cout << trinodes.unique_add( p ) << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.1 1999/03/17 23:51:59 curt
|
||||
// Initial revision.
|
||||
//
|
79
Triangulate/triangle.hxx
Normal file
79
Triangulate/triangle.hxx
Normal file
|
@ -0,0 +1,79 @@
|
|||
// triandgle.hxx -- "Triangle" interface class
|
||||
//
|
||||
// Written by Curtis Olson, started March 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
// (Log is kept at end of this file)
|
||||
|
||||
|
||||
#ifndef _TRIANGLE_HXX
|
||||
#define _TRIANGLE_HXX
|
||||
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
|
||||
#include <Include/compiler.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <Clipper/clipper.hxx>
|
||||
#include <Math/point3d.hxx>
|
||||
|
||||
#include "trinodes.hxx"
|
||||
|
||||
FG_USING_STD(vector);
|
||||
|
||||
|
||||
typedef vector < int > tripoly;
|
||||
typedef tripoly::iterator tripoly_iterator;
|
||||
typedef tripoly::const_iterator const_tripoly_iterator;
|
||||
|
||||
typedef vector < int > tripoly_list;
|
||||
typedef tripoly_list::iterator tripoly_list_iterator;
|
||||
typedef tripoly_list::const_iterator const_tripoly_list_iterator;
|
||||
|
||||
|
||||
class FGTriangle {
|
||||
|
||||
private:
|
||||
|
||||
FGTriNodes trinodes;
|
||||
tripoly_list polylist;
|
||||
|
||||
public:
|
||||
|
||||
// Constructor and destructor
|
||||
FGTriangle( void );
|
||||
~FGTriangle( void );
|
||||
|
||||
// populate this class based on the specified gpc_polys list
|
||||
int build( FGgpcPolyList gpc_polys );
|
||||
};
|
||||
|
||||
|
||||
#endif // _TRIANGLE_HXX
|
||||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.1 1999/03/17 23:51:59 curt
|
||||
// Initial revision.
|
||||
//
|
79
Triangulate/trinodes.cxx
Normal file
79
Triangulate/trinodes.cxx
Normal file
|
@ -0,0 +1,79 @@
|
|||
// trinodes.cxx -- "Triangle" nodes management class
|
||||
//
|
||||
// Written by Curtis Olson, started March 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
// (Log is kept at end of this file)
|
||||
|
||||
|
||||
#include "trinodes.hxx"
|
||||
|
||||
|
||||
// Constructor
|
||||
FGTriNodes::FGTriNodes( void ) {
|
||||
}
|
||||
|
||||
|
||||
// Destructor
|
||||
FGTriNodes::~FGTriNodes( void ) {
|
||||
}
|
||||
|
||||
|
||||
// return true of the two points are "close enough" as defined by
|
||||
// FG_PROXIMITY_EPSILON
|
||||
inline bool FGTriNodes::close_enough( const Point3D& p1, const Point3D& p2 ) {
|
||||
if ( ( fabs(p1.x() - p2.x()) < FG_PROXIMITY_EPSILON ) &&
|
||||
( fabs(p1.y() - p2.y()) < FG_PROXIMITY_EPSILON ) ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add a point to the point list if it doesn't already exist. Returns
|
||||
// the index (starting at zero) of the point in the list.
|
||||
int FGTriNodes::unique_add( const Point3D& p ) {
|
||||
point_iterator current, last;
|
||||
int counter = 0;
|
||||
|
||||
// see if point already exists
|
||||
current = point_list.begin();
|
||||
last = point_list.end();
|
||||
for ( ; current != last; ++current ) {
|
||||
if ( close_enough(p, *current) ) {
|
||||
return counter;
|
||||
}
|
||||
|
||||
++counter;
|
||||
}
|
||||
|
||||
// add to list
|
||||
point_list.push_back( p );
|
||||
|
||||
return counter;
|
||||
}
|
||||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.1 1999/03/17 23:52:00 curt
|
||||
// Initial revision.
|
||||
//
|
||||
|
||||
|
79
Triangulate/trinodes.hxx
Normal file
79
Triangulate/trinodes.hxx
Normal file
|
@ -0,0 +1,79 @@
|
|||
// trinodes.hxx -- "Triangle" nodes management class
|
||||
//
|
||||
// Written by Curtis Olson, started March 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
// (Log is kept at end of this file)
|
||||
|
||||
|
||||
#ifndef _TRINODES_HXX
|
||||
#define _TRINODES_HXX
|
||||
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
|
||||
#include <Include/compiler.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <Math/point3d.hxx>
|
||||
|
||||
FG_USING_STD(vector);
|
||||
|
||||
|
||||
#define FG_PROXIMITY_EPSILON 0.000001
|
||||
|
||||
|
||||
typedef vector < Point3D > point_container;
|
||||
typedef point_container::iterator point_iterator;
|
||||
typedef point_container::const_iterator const_point_iterator;
|
||||
|
||||
|
||||
class FGTriNodes {
|
||||
|
||||
private:
|
||||
|
||||
point_container point_list;
|
||||
|
||||
// return true of the two points are "close enough" as defined by
|
||||
// FG_PROXIMITY_EPSILON
|
||||
bool close_enough( const Point3D& p, const Point3D& p );
|
||||
|
||||
public:
|
||||
|
||||
// Constructor and destructor
|
||||
FGTriNodes( void );
|
||||
~FGTriNodes( void );
|
||||
|
||||
// Add a point to the point list if it doesn't already exist.
|
||||
// Returns the index (starting at zero) of the point in the list.
|
||||
int unique_add( const Point3D& p );
|
||||
};
|
||||
|
||||
|
||||
#endif // _TRINODES_HXX
|
||||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.1 1999/03/17 23:52:00 curt
|
||||
// Initial revision.
|
||||
//
|
Loading…
Reference in a new issue