From 4c1565c869ab4da8b2b34e91b1ea41aa1c9c2a2b Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 22 Mar 1999 23:49:01 +0000 Subject: [PATCH] Modifications to facilitate conversion to output format. --- Triangulate/Makefile.am | 1 + Triangulate/triangle.cxx | 35 ++++++++++++++++++++++++++++++----- Triangulate/triangle.hxx | 16 +++++++++++++++- Triangulate/trinodes.cxx | 11 +++++++++++ Triangulate/trinodes.hxx | 6 ++++++ 5 files changed, 63 insertions(+), 6 deletions(-) diff --git a/Triangulate/Makefile.am b/Triangulate/Makefile.am index 42ba81984..34c320f91 100644 --- a/Triangulate/Makefile.am +++ b/Triangulate/Makefile.am @@ -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 diff --git a/Triangulate/triangle.cxx b/Triangulate/triangle.cxx index 1c2476837..4e5265bb2 100644 --- a/Triangulate/triangle.cxx +++ b/Triangulate/triangle.cxx @@ -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. diff --git a/Triangulate/triangle.hxx b/Triangulate/triangle.hxx index 0a115fd73..de26cd625 100644 --- a/Triangulate/triangle.hxx +++ b/Triangulate/triangle.hxx @@ -45,6 +45,7 @@ extern "C" { #include } +#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. diff --git a/Triangulate/trinodes.cxx b/Triangulate/trinodes.cxx index d29e907b1..3acc7775d 100644 --- a/Triangulate/trinodes.cxx +++ b/Triangulate/trinodes.cxx @@ -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. diff --git a/Triangulate/trinodes.hxx b/Triangulate/trinodes.hxx index 3a3d31beb..cd14e1299 100644 --- a/Triangulate/trinodes.hxx +++ b/Triangulate/trinodes.hxx @@ -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.