]> git.mxchange.org Git - flightgear.git/commitdiff
Continue shaping the code towards triangulation bliss. Added code to
authorcurt <curt>
Sat, 20 Mar 1999 02:21:51 +0000 (02:21 +0000)
committercurt <curt>
Sat, 20 Mar 1999 02:21:51 +0000 (02:21 +0000)
calculate some point guaranteed to be inside a polygon.

Triangulate/Makefile.am
Triangulate/triangle.cxx
Triangulate/triangle.hxx
Triangulate/trinodes.cxx
Triangulate/trinodes.hxx

index f28601c0d71c0c251d7c1bb32ce98e6ff3a33cca..8beeb47bfe18b4c89290c54eb5d6f36e0cd5fee1 100644 (file)
@@ -2,7 +2,8 @@ noinst_LIBRARIES = libTriangulate.a
 
 libTriangulate_a_SOURCES = \
        triangle.cxx triangle.hxx \
-       trinodes.cxx trinodes.hxx
+       trinodes.cxx trinodes.hxx \
+       tripoly.cxx tripoly.hxx
 
 INCLUDES += \
        -I$(top_builddir) \
index 854b5b508188588e4c00493844e520c742cc6ef7..74b5d2fa2f729ae9e1a25ba3dce9d7c208bca316 100644 (file)
@@ -23,6 +23,7 @@
 
 
 #include "triangle.hxx"
+#include "tripoly.hxx"
 
 
 // Constructor
@@ -38,8 +39,6 @@ FGTriangle::~FGTriangle( void ) {
 // populate this class based on the specified gpc_polys list
 int FGTriangle::build( const FGgpcPolyList& gpc_polys ) {
     int index;
-    tripoly poly;
-
     // 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)
@@ -59,7 +58,7 @@ int FGTriangle::build( const FGgpcPolyList& gpc_polys ) {
            cout << "processing a polygon, contours = " 
                 << gpc_poly->num_contours << endl;
 
-           poly.erase(poly.begin(), poly.end());
+           FGTriPoly poly;
 
            if (gpc_poly->num_contours <= 0 ) {
                cout << "FATAL ERROR! no contours in this polygon" << endl;
@@ -78,9 +77,11 @@ int FGTriangle::build( const FGgpcPolyList& gpc_polys ) {
                               gpc_poly->contour[j].vertex[k].y,
                               0 );
                    index = trinodes.unique_add( p );
-                   poly.push_back(index);
+                   poly.add_node(index);
                    // cout << index << endl;
                }
+               poly.calc_point_inside( trinodes );
+               cout << endl;
                polylist[i].push_back(poly);
            }
        }
@@ -97,8 +98,8 @@ int FGTriangle::build( const FGgpcPolyList& gpc_polys ) {
 
 
 // do actual triangulation
-int FGTriangle::do_triangulate( const tripoly& poly ) {
-    point_container node_list;
+int FGTriangle::do_triangulate( const FGTriPoly& poly ) {
+    trinode_list node_list;
     struct triangulateio in, mid, out, vorout;
     int counter;
 
@@ -108,7 +109,7 @@ int FGTriangle::do_triangulate( const tripoly& poly ) {
     in.numberofpoints = node_list.size();
     in.pointlist = (REAL *) malloc(in.numberofpoints * 2 * sizeof(REAL));
 
-    point_iterator current, last;
+    trinode_list_iterator current, last;
     current = node_list.begin();
     last = node_list.end();
     counter = 0;
@@ -116,12 +117,14 @@ int FGTriangle::do_triangulate( const tripoly& poly ) {
        in.pointlist[counter++] = current->x();
        in.pointlist[counter++] = current->y();
     }
+
+    return 0;
 }
 
 
 // triangulate each of the polygon areas
 int FGTriangle::triangulate() {
-    tripoly poly;
+    FGTriPoly poly;
 
     tripoly_list_iterator current, last;
 
@@ -142,6 +145,10 @@ int FGTriangle::triangulate() {
 
 
 // $Log$
+// Revision 1.5  1999/03/20 02:21:52  curt
+// Continue shaping the code towards triangulation bliss.  Added code to
+// calculate some point guaranteed to be inside a polygon.
+//
 // Revision 1.4  1999/03/19 22:29:04  curt
 // Working on preparationsn for triangulation.
 //
index 9c9b133cddb89a9a1242fe1c59dee3c37146a631..58fa1bd265725fd9f75c3468c13c1d0dfe30e91a 100644 (file)
@@ -1,4 +1,4 @@
-// triandgle.hxx -- "Triangle" interface class
+// triangle.hxx -- "Triangle" interface class
 //
 // Written by Curtis Olson, started March 1999.
 //
@@ -45,15 +45,12 @@ extern "C" {
 }
 
 #include "trinodes.hxx"
+#include "tripoly.hxx"
 
 FG_USING_STD(vector);
 
 
-typedef vector < int > tripoly;
-typedef tripoly::iterator tripoly_iterator;
-typedef tripoly::const_iterator const_tripoly_iterator;
-
-typedef vector < tripoly > tripoly_list;
+typedef vector < FGTriPoly > tripoly_list;
 typedef tripoly_list::iterator tripoly_list_iterator;
 typedef tripoly_list::const_iterator const_tripoly_list_iterator;
 
@@ -78,7 +75,7 @@ public:
     int build( const FGgpcPolyList& gpc_polys );
 
     // do actual triangulation
-    int do_triangulate( const tripoly& poly );
+    int do_triangulate( const FGTriPoly& poly );
 
     // front end triangulator for polygon list
     int triangulate();
@@ -89,6 +86,10 @@ public:
 
 
 // $Log$
+// Revision 1.5  1999/03/20 02:21:53  curt
+// Continue shaping the code towards triangulation bliss.  Added code to
+// calculate some point guaranteed to be inside a polygon.
+//
 // Revision 1.4  1999/03/19 22:29:05  curt
 // Working on preparationsn for triangulation.
 //
index 82c2b69331c0cb64793db67746164c23dcc68aca..d29e907b1a9e7bd170eb6e67deb8589cecb61c93 100644 (file)
@@ -50,17 +50,17 @@ inline bool FGTriNodes::close_enough( const Point3D& p1, const Point3D& p2 ) {
 // 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;
+    trinode_list_iterator current, last;
     int counter = 0;
 
     // cout << p.x() << "," << p.y() << endl;
 
     // see if point already exists
-    current = point_list.begin();
-    last = point_list.end();
+    current = node_list.begin();
+    last = node_list.end();
     for ( ; current != last; ++current ) {
        if ( close_enough(p, *current) ) {
-           cout << "found an existing match!" << endl;
+           // cout << "found an existing match!" << endl;
            return counter;
        }
        
@@ -68,13 +68,17 @@ int FGTriNodes::unique_add( const Point3D& p ) {
     }
 
     // add to list
-    point_list.push_back( p );
+    node_list.push_back( p );
 
     return counter;
 }
 
 
 // $Log$
+// Revision 1.3  1999/03/20 02:21:54  curt
+// Continue shaping the code towards triangulation bliss.  Added code to
+// calculate some point guaranteed to be inside a polygon.
+//
 // Revision 1.2  1999/03/19 00:27:12  curt
 // Continued work on triangulation preparation.
 //
index 1a540f981a660ad9a9992042d2f3281ce55f6da4..3a3d31beb32a4400591256d48a17533cad144b23 100644 (file)
@@ -43,16 +43,16 @@ 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;
+typedef vector < Point3D > trinode_list;
+typedef trinode_list::iterator trinode_list_iterator;
+typedef trinode_list::const_iterator const_trinode_list_iterator;
 
 
 class FGTriNodes {
 
 private:
 
-    point_container point_list;
+    trinode_list node_list;
 
     // return true of the two points are "close enough" as defined by
     // FG_PROXIMITY_EPSILON
@@ -69,7 +69,10 @@ public:
     int unique_add( const Point3D& p );
 
     // return the master node list
-    inline point_container get_node_list() const { return point_list; }
+    inline trinode_list get_node_list() const { return node_list; }
+
+    // return the ith point
+    inline Point3D get_node( int i ) const { return node_list[i]; }
 };
 
 
@@ -77,6 +80,10 @@ public:
 
 
 // $Log$
+// Revision 1.3  1999/03/20 02:21:55  curt
+// Continue shaping the code towards triangulation bliss.  Added code to
+// calculate some point guaranteed to be inside a polygon.
+//
 // Revision 1.2  1999/03/19 22:29:06  curt
 // Working on preparationsn for triangulation.
 //