]> git.mxchange.org Git - flightgear.git/commitdiff
Modifications to facilitate conversion to output format.
authorcurt <curt>
Mon, 22 Mar 1999 23:49:01 +0000 (23:49 +0000)
committercurt <curt>
Mon, 22 Mar 1999 23:49:01 +0000 (23:49 +0000)
Triangulate/Makefile.am
Triangulate/triangle.cxx
Triangulate/triangle.hxx
Triangulate/trinodes.cxx
Triangulate/trinodes.hxx

index 42ba8198415d95a43ab1e8990c96ee6eba18fdae..34c320f91e6e520ad424e36017f69faac973a838 100644 (file)
@@ -2,6 +2,7 @@ noinst_LIBRARIES = libTriangulate.a
 
 libTriangulate_a_SOURCES = \
        triangle.cxx triangle.hxx \
+       trieles.cxx trieles.hxx \
        trinodes.cxx trinodes.hxx \
        tripoly.cxx tripoly.hxx \
        trisegs.cxx trisegs.hxx
index 1c24768374a588b9dace3b2f4f812928e895733d..4e5265bb27da11bc987efce0fdc2f6a16ef73d17 100644 (file)
@@ -57,7 +57,7 @@ FGTriangle::build( const fitnode_list& fit_list,
     f_current = fit_list.begin();
     f_last = fit_list.end();
     for ( ; f_current != f_last; ++f_current ) {
-       index = trinodes.unique_add( *f_current );
+       index = in_nodes.unique_add( *f_current );
     }
 
     gpc_polygon *gpc_poly;
@@ -97,8 +97,8 @@ FGTriangle::build( const fitnode_list& fit_list,
                    Point3D p( gpc_poly->contour[j].vertex[k].x,
                               gpc_poly->contour[j].vertex[k].y,
                               0 );
-                   index = trinodes.unique_add( p );
-                   // junkp = trinodes.get_node( index );
+                   index = in_nodes.unique_add( p );
+                   // junkp = in_nodes.get_node( index );
                    // fprintf(junkfp, "%.4f %.4f\n", junkp.x(), junkp.y());
                    poly.add_node(index);
                    // cout << index << endl;
@@ -108,7 +108,7 @@ FGTriangle::build( const fitnode_list& fit_list,
                //    gpc_poly->contour[j].vertex[0].y);
                // fclose(junkfp);
 
-               poly.calc_point_inside( trinodes );
+               poly.calc_point_inside( in_nodes );
 
                polylist[i].push_back(poly);
            }
@@ -208,7 +208,7 @@ int FGTriangle::run_triangulate() {
     int counter;
 
     // point list
-    trinode_list node_list = trinodes.get_node_list();
+    trinode_list node_list = in_nodes.get_node_list();
     in.numberofpoints = node_list.size();
     in.pointlist = (REAL *) malloc(in.numberofpoints * 2 * sizeof(REAL));
 
@@ -241,6 +241,7 @@ int FGTriangle::run_triangulate() {
     triseg_list seg_list = trisegs.get_seg_list();
     in.numberofsegments = seg_list.size();
     in.segmentlist = (int *) malloc(in.numberofsegments * 2 * sizeof(int));
+    in.segmentmarkerlist = (int *) NULL;
 
     triseg_list_iterator s_current, s_last;
     s_current = seg_list.begin();
@@ -323,6 +324,27 @@ int FGTriangle::run_triangulate() {
     // TEMPORARY
     write_out_data(&out);
 
+    // now copy the results back into the corresponding FGTriangle
+    // structures
+
+    // nodes
+    for ( int i = 0; i < out.numberofpoints; i++ ) {
+       Point3D p( out.pointlist[2*i], out.pointlist[2*i + 1], 0.0 );
+       // cout << "point = " << p << endl;
+       out_nodes.simple_add( p );
+    }
+
+    // triangles
+    int n1, n2, n3;
+    for ( int i = 0; i < out.numberoftriangles; i++ ) {
+       n1 = out.trianglelist[i * 3];
+       n2 = out.trianglelist[i * 3 + 1];
+       n3 = out.trianglelist[i * 3 + 2];
+       // cout << "triangle = " << n1 << " " << n2 << " " << n3 << endl;
+
+       elelist.push_back( FGTriEle( n1, n2, n3 ) );
+    }
+
     // free mem allocated to the "Triangle" structures
     free(in.pointlist);
     free(in.pointattributelist);
@@ -349,6 +371,9 @@ int FGTriangle::run_triangulate() {
 
 
 // $Log$
+// Revision 1.10  1999/03/22 23:49:02  curt
+// Modifications to facilitate conversion to output format.
+//
 // Revision 1.9  1999/03/21 15:48:02  curt
 // Removed Dem2node from the Tools fold.
 // Tweaked the triangulator options to add quality mesh refinement.
index 0a115fd7342f4e60629a4aa9675576c968a0b485..de26cd62515e9d5f9f26fc4ce9d20af2160138b2 100644 (file)
@@ -45,6 +45,7 @@ extern "C" {
 #include <Triangle/triangle.h>
 }
 
+#include "trieles.hxx"
 #include "trinodes.hxx"
 #include "tripoly.hxx"
 #include "trisegs.hxx"
@@ -56,13 +57,18 @@ typedef vector < FGTriPoly > tripoly_list;
 typedef tripoly_list::iterator tripoly_list_iterator;
 typedef tripoly_list::const_iterator const_tripoly_list_iterator;
 
+typedef vector < FGTriEle > triele_list;
+typedef triele_list::iterator triele_list_iterator;
+typedef triele_list::const_iterator const_triele_list_iterator;
+
 
 class FGTriangle {
 
 private:
 
     // list of nodes
-    FGTriNodes trinodes;
+    FGTriNodes in_nodes;
+    FGTriNodes out_nodes;
 
     // list of segments
     FGTriSegments trisegs;
@@ -70,6 +76,9 @@ private:
     // polygon list
     tripoly_list polylist[FG_MAX_AREA_TYPES];
     
+    // triangle list
+    triele_list elelist;
+
 public:
 
     // Constructor and destructor
@@ -84,6 +93,8 @@ public:
 
     // front end triangulator for polygon list
     int run_triangulate();
+
+    inline FGTriNodes get_out_nodes() const { return out_nodes; }
 };
 
 
@@ -91,6 +102,9 @@ public:
 
 
 // $Log$
+// Revision 1.7  1999/03/22 23:49:03  curt
+// Modifications to facilitate conversion to output format.
+//
 // Revision 1.6  1999/03/20 20:32:56  curt
 // First mostly successful tile triangulation works.  There's plenty of tweaking
 // to do, but we are marching in the right direction.
index d29e907b1a9e7bd170eb6e67deb8589cecb61c93..3acc7775d753c68b20e1b9b57d0632a5154fd475 100644 (file)
@@ -74,7 +74,18 @@ int FGTriNodes::unique_add( const Point3D& p ) {
 }
 
 
+// Add the point with no uniqueness checking
+int FGTriNodes::simple_add( const Point3D& p ) {
+    node_list.push_back( p );
+
+    return node_list.size() - 1;
+}
+
+
 // $Log$
+// Revision 1.4  1999/03/22 23:49:04  curt
+// Modifications to facilitate conversion to output format.
+//
 // 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.
index 3a3d31beb32a4400591256d48a17533cad144b23..cd14e12995912103a39c82f238ebd90a9c088cef 100644 (file)
@@ -68,6 +68,9 @@ public:
     // Returns the index (starting at zero) of the point in the list.
     int unique_add( const Point3D& p );
 
+    // Add the point with no uniqueness checking
+    int simple_add( const Point3D& p );
+
     // return the master node list
     inline trinode_list get_node_list() const { return node_list; }
 
@@ -80,6 +83,9 @@ public:
 
 
 // $Log$
+// Revision 1.4  1999/03/22 23:49:05  curt
+// Modifications to facilitate conversion to output format.
+//
 // 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.